4
0

email-templates.prisma 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. /// A template for one kind of mail the workshop sends, saved under a name.
  2. ///
  3. /// The same idea as DocumentDesign: a workshop keeps several templates for a
  4. /// kind, and the one that sends is named by the AppSetting
  5. /// `email.template.<kind>` as `design:<id>`, the way `invoice.activeDesign`
  6. /// names the sheet. No setting means the built-in preset. Blocks and a theme
  7. /// rather than a body of HTML, because the renderer turns them into markup a
  8. /// mail client will honour and a workshop should never have to think about
  9. /// tables and inline styles.
  10. ///
  11. /// Nothing is snapshotted. An issued invoice has to reprint identically for
  12. /// years, which is why its design is frozen; a sent email is already in
  13. /// somebody's inbox and is never rendered again.
  14. model EmailTemplate {
  15. id String @id @default(cuid())
  16. organizationId String
  17. organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
  18. /// One of EMAIL_KINDS in src/features/email/Lib/emailKinds.ts.
  19. kind String
  20. name String
  21. /// The subject line, tags and all.
  22. subject String
  23. /// EmailBlock[] as edited.
  24. blocks Json
  25. /// EmailTheme: colours, typeface, button shape, logo on or off.
  26. theme Json
  27. createdAt DateTime @default(now())
  28. updatedAt DateTime @updatedAt
  29. @@index([organizationId, kind])
  30. @@map("email_templates")
  31. }