EmailTemplates.utils.ts14 lines · main
| 1 | import { type AuthTemplateType, type KebabCase } from './EmailTemplates.types' |
| 2 | |
| 3 | /** |
| 4 | * Convert template title to URL-friendly slug |
| 5 | * Shared function to ensure slug matching works correctly across multiple files |
| 6 | * Necessary because TEMPLATES_SCHEMAS does not provide a slug for each template |
| 7 | */ |
| 8 | export const slugifyTitle = (title: string) => { |
| 9 | return title.trim().replace(/\s+/g, '-').toLowerCase() |
| 10 | } |
| 11 | |
| 12 | /* Convert upper camel case to lower kebab case */ |
| 13 | export const getAuthTemplateType = <T extends AuthTemplateType>(id: T) => |
| 14 | id.toLowerCase().replace(/_/g, '-') as KebabCase<T> |