sms-templates.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. import { SETTING_KEYS } from "@/features/settings/Schema/settingsSchema";
  2. export const SMS_TEMPLATE_DEFAULTS: Record<string, string> = {
  3. [SETTING_KEYS.SMS_TEMPLATE_INVOICE_READY]:
  4. "Your invoice is ready. View it here: {share_link}",
  5. [SETTING_KEYS.SMS_TEMPLATE_QUOTE_READY]:
  6. "Your quote is ready for review. View it here: {share_link}",
  7. [SETTING_KEYS.SMS_TEMPLATE_INSPECTION_READY]:
  8. "Your vehicle inspection report is ready. View it here: {share_link}",
  9. [SETTING_KEYS.SMS_TEMPLATE_STATUS_IN_PROGRESS]:
  10. "Work has started on your vehicle. We'll keep you updated.",
  11. [SETTING_KEYS.SMS_TEMPLATE_STATUS_WAITING_PARTS]:
  12. "Your vehicle is waiting for parts. We'll notify you when work resumes.",
  13. [SETTING_KEYS.SMS_TEMPLATE_STATUS_READY]:
  14. "Your vehicle is ready for pickup!",
  15. [SETTING_KEYS.SMS_TEMPLATE_STATUS_COMPLETED]:
  16. "Your service is complete. Thank you for your business!",
  17. [SETTING_KEYS.SMS_TEMPLATE_PAYMENT_RECEIVED]:
  18. "Payment of {amount} received for invoice {invoice_number}. Thank you!",
  19. };
  20. /**
  21. * Replace `{variable_name}` placeholders in a template string with actual values.
  22. */
  23. export function interpolateSmsTemplate(
  24. template: string,
  25. variables: Record<string, string>,
  26. ): string {
  27. return template.replace(/\{(\w+)\}/g, (match, key) => {
  28. return key in variables ? variables[key] : match;
  29. });
  30. }