Files
picpeak/frontend/src/services/devTools.service.ts
T
Luca 6d302e7998 feat(crm): add event_reminder_* templates to dev email tester
The pre-event reminder feature shipped with 5 seeded templates
(event_reminder_default + wedding/birthday/corporate/other) but the
CRM → Development "Send any CRM email to me" picker only listed the
quote/invoice/contract templates. Maintainer can now eyeball each
reminder category's body without staging a real event.

Backend:
- Extend TEMPLATES_KEYS in adminDev.js with all 5 reminder keys.
- Add event_date (today+2d), days_before (2), business_name (from
  business_profile.legal_name) to the common payload so the
  {{tokens}} in the reminder bodies resolve.

Frontend:
- Extend CrmEmailTemplateKey union.
- Add TEMPLATE_LABEL_KEYS entries.
- EN+DE i18n labels under crmDev.templates.label.event_reminder_*.

No PDF attachment — reminders are body-only emails (matches the
real flow).
2026-05-26 20:44:11 +02:00

56 lines
1.8 KiB
TypeScript

/**
* Admin → Dev tools API client. Gated server-side by the
* `crmDevelopment` feature flag; the frontend additionally hides
* the page when the flag is off, but the API check is what
* actually enforces the gate.
*/
import { api } from '../config/api';
export type CrmEmailTemplateKey =
| 'quote_sent'
| 'quote_accepted_customer'
| 'quote_accepted_admin'
| 'quote_declined_admin'
| 'invoice_sent'
| 'invoice_reminder_first'
| 'invoice_reminder_second'
| 'invoice_payment_check_admin'
// Contracts (migration 130). Backend exposes all three flows via the
// dev tester (admin → customer send, customer-signed ping, dual-party
// fully-signed). Without these in the union, useQuery returns rows
// whose `key` doesn't resolve to a label and they render as raw
// template_key strings.
| 'contract_sent'
| 'contract_signed_admin_notification'
| 'contract_fully_signed'
// Pre-event reminder emails (migration 143). One template per
// event_type with a catch-all default. Backend resolves
// `event_reminder_<event_type>` then falls back to
// `event_reminder_default`.
| 'event_reminder_default'
| 'event_reminder_wedding'
| 'event_reminder_birthday'
| 'event_reminder_corporate'
| 'event_reminder_other';
export interface DevEmailTemplateStatus {
key: CrmEmailTemplateKey;
present: boolean;
}
export const devToolsService = {
async listEmailTemplates(): Promise<DevEmailTemplateStatus[]> {
const { data } = await api.get('/admin/dev/email-templates');
return (data.data || data).templates;
},
async sendTestEmail(templateKey: CrmEmailTemplateKey): Promise<{
sent: true;
to: string;
template: CrmEmailTemplateKey;
}> {
const { data } = await api.post('/admin/dev/send-test-email', { templateKey });
return data.data || data;
},
};