EmailTemplates.utils.ts 586 B

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