Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Added the email template editor to the dashboard

Damian Legawiec4bd1741677b2
diff --git a/.changeset/dashboard-email-templates.md b/.changeset/dashboard-email-templates.md
new file mode 100644
index 0000000000..13fae7e4b0
--- /dev/null
+++ b/.changeset/dashboard-email-templates.md
@@ -0,0 +1,7 @@
+---
+"@spree/dashboard": minor
+"@spree/dashboard-core": minor
+"@spree/dashboard-ui": minor
+---
+
+Added an email template editor under Settings → Emails → Templates. Merchants edit the emails customers receive, the email layout and shared blocks with a code editor that suggests variables and marks problems by line, next to a live preview (desktop and mobile, email and plain text). Edits save as drafts and go live when published; drafts can be discarded, templates reverted to Spree's default, test emails sent to yourself, and earlier versions restored from the history. A banner shows when a Spree upgrade changed a default the store customized, with a side-by-side comparison. The email settings page gains a Branding card for the colors and font of customer emails, with a preview. `@spree/dashboard-ui` adds a `CodeEditor` (deep import `@spree/dashboard-ui/ui/code-editor`) and a `useDebouncedValue` hook; `@spree/dashboard-core` adds the `EmailTemplate` permission subject.
diff --git a/packages/dashboard-core/src/hooks/use-global-search.ts b/packages/dashboard-core/src/hooks/use-global-search.ts
index b3e474f5fb..53d8dbc01d 100644
--- a/packages/dashboard-core/src/hooks/use-global-search.ts
+++ b/packages/dashboard-core/src/hooks/use-global-search.ts
@@ -1,5 +1,5 @@
+import { useDebouncedValue } from '@spree/dashboard-ui'
import { useQueries } from '@tanstack/react-query'
-import { useEffect, useState } from 'react'
import { useAuth } from '../hooks/use-auth'
import { type SearchEntry, useSearchEntries } from '../lib/search-registry'
import { usePermissions } from '../providers/permission-provider'
@@ -66,14 +66,3 @@ export function useGlobalSearch(rawQuery: string) {
hasResults: groups.length > 0,
}
}
-
-function useDebouncedValue<T>(value: T, delayMs: number): T {
- const [debounced, setDebounced] = useState(value)
-
- useEffect(() => {
- const id = setTimeout(() => setDebounced(value), delayMs)
- return () => clearTimeout(id)
- }, [value, delayMs])
-
- return debounced
-}
diff --git a/packages/dashboard-core/src/lib/permissions.ts b/packages/dashboard-core/src/lib/permissions.ts
index 9f5cdca201..281a639557 100644
--- a/packages/dashboard-core/src/lib/permissions.ts
+++ b/packages/dashboard-core/src/lib/permissions.ts
@@ -77,6 +77,7 @@ export const Subject = {
Invitation: 'Spree::Invitation',
Market: 'Spree::Market',
WebhookEndpoint: 'Spree::WebhookEndpoint',
+ EmailTemplate: 'Spree::EmailTemplate',
WebhookDelivery: 'Spree::WebhookDelivery',
Wishlist: 'Spree::Wishlist',
Seller: 'Spree::Seller',
diff --git a/packages/dashboard-starter/src/routeTree.gen.ts b/packages/dashboard-starter/src/routeTree.gen.ts
index 47d18c2c9c..76ae8add27 100644
--- a/packages/dashboard-starter/src/routeTree.gen.ts
+++ b/packages/dashboard-starter/src/routeTree.gen.ts
@@ -54,7 +54,6 @@ import { Route as SettingsPackageTypesRouteImport } from './../node_modules/@spr
import { Route as SettingsMarketsRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/settings/markets'
import { Route as SettingsMarketplaceRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/settings/marketplace'
import { Route as SettingsIntegrationsRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/settings/integrations'
-import { Route as SettingsEmailsRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/settings/emails'
import { Route as SettingsCustomFieldDefinitionsRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/settings/custom-field-definitions'
import { Route as SettingsCommissionRatesRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/settings/commission-rates'
import { Route as SettingsChannelsRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/settings/channels'
@@ -85,6 +84,7 @@ import { Route as BrandsDotbrandIdRouteImport } from './../node_modules/@spree/d
import { Route as TransfersTransferIdIndexRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/transfers/$transferId/index'
import { Route as SettingsWebhooksIndexRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/settings/webhooks/index'
import { Route as SettingsImportsIndexRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/settings/imports/index'
+import { Route as SettingsEmailsIndexRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/settings/emails/index'
import { Route as SettingsDeliveryProfilesIndexRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/settings/delivery-profiles/index'
import { Route as SellersPayoutsIndexRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/sellers/payouts/index'
import { Route as PurchaseOrdersPurchaseOrderIdIndexRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/purchase-orders/$purchaseOrderId/index'
@@ -104,8 +104,10 @@ import { Route as ProductsCategoriesNewRouteImport } from './../node_modules/@sp
import { Route as ProductsCategoriesCategoryIdRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/products/categories/$categoryId'
import { Route as ProductsCatalogsCatalogIdRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/products/catalogs/$catalogId'
import { Route as OrdersOrderIdEditRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/orders/$orderId/edit'
+import { Route as SettingsEmailsTemplatesIndexRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/settings/emails/templates/index'
import { Route as SettingsDeliveryProfilesProfileIdIndexRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/index'
import { Route as ProductsPriceListsPriceListIdIndexRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/products/price-lists/$priceListId/index'
+import { Route as SettingsEmailsTemplatesTemplateIdRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/settings/emails/templates/$templateId'
import { Route as SettingsDeliveryProfilesProfileIdMethodsNewRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new'
import { Route as SettingsDeliveryProfilesProfileIdMethodsMethodIdRouteImport } from './../node_modules/@spree/dashboard/src/routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/$methodId'
@@ -335,11 +337,6 @@ const SettingsIntegrationsRoute = SettingsIntegrationsRouteImport.update({
path: '/integrations',
getParentRoute: () => SettingsRoute,
} as any)
-const SettingsEmailsRoute = SettingsEmailsRouteImport.update({
- id: '/emails',
- path: '/emails',
- getParentRoute: () => SettingsRoute,
-} as any)
const SettingsCustomFieldDefinitionsRoute =
SettingsCustomFieldDefinitionsRouteImport.update({
id: '/custom-field-definitions',
@@ -492,6 +489,11 @@ const SettingsImportsIndexRoute = SettingsImportsIndexRouteImport.update({
path: '/imports/',
getParentRoute: () => SettingsRoute,
} as any)
+const SettingsEmailsIndexRoute = SettingsEmailsIndexRouteImport.update({
+ id: '/emails/',
+ path: '/emails/',
+ getParentRoute: () => SettingsRoute,
+} as any)
const SettingsDeliveryProfilesIndexRoute =
SettingsDeliveryProfilesIndexRouteImport.update({
id: '/delivery-profiles/',
@@ -595,6 +597,12 @@ const OrdersOrderIdEditRoute = OrdersOrderIdEditRouteImport.update({
path: '/orders/$orderId/edit',
getParentRoute: () => authenticatedStoreIdRoute,
} as any)
+const SettingsEmailsTemplatesIndexRoute =
+ SettingsEmailsTemplatesIndexRouteImport.update({
+ id: '/emails/templates/',
+ path: '/emails/templates/',
+ getParentRoute: () => SettingsRoute,
+ } as any)
const SettingsDeliveryProfilesProfileIdIndexRoute =
SettingsDeliveryProfilesProfileIdIndexRouteImport.update({
id: '/delivery-profiles/$profileId/',
@@ -607,6 +615,12 @@ const ProductsPriceListsPriceListIdIndexRoute =
path: '/products/price-lists/$priceListId/',
getParentRoute: () => authenticatedStoreIdRoute,
} as any)
+const SettingsEmailsTemplatesTemplateIdRoute =
+ SettingsEmailsTemplatesTemplateIdRouteImport.update({
+ id: '/emails/templates/$templateId',
+ path: '/emails/templates/$templateId',
+ getParentRoute: () => SettingsRoute,
+ } as any)
const SettingsDeliveryProfilesProfileIdMethodsNewRoute =
SettingsDeliveryProfilesProfileIdMethodsNewRouteImport.update({
id: '/delivery-profiles/$profileId/methods/new',
@@ -663,7 +677,6 @@ export interface FileRoutesByFullPath {
'/$storeId/settings/channels': typeof SettingsChannelsRoute
'/$storeId/settings/commission-rates': typeof SettingsCommissionRatesRoute
'/$storeId/settings/custom-field-definitions': typeof SettingsCustomFieldDefinitionsRoute
- '/$storeId/settings/emails': typeof SettingsEmailsRoute
'/$storeId/settings/integrations': typeof SettingsIntegrationsRoute
'/$storeId/settings/marketplace': typeof SettingsMarketplaceRoute
'/$storeId/settings/markets': typeof SettingsMarketsRoute
@@ -712,11 +725,14 @@ export interface FileRoutesByFullPath {
'/$storeId/purchase-orders/$purchaseOrderId/': typeof PurchaseOrdersPurchaseOrderIdIndexRoute
'/$storeId/sellers/payouts/': typeof SellersPayoutsIndexRoute
'/$storeId/settings/delivery-profiles/': typeof SettingsDeliveryProfilesIndexRoute
+ '/$storeId/settings/emails/': typeof SettingsEmailsIndexRoute
'/$storeId/settings/imports/': typeof SettingsImportsIndexRoute
'/$storeId/settings/webhooks/': typeof SettingsWebhooksIndexRoute
'/$storeId/transfers/$transferId/': typeof TransfersTransferIdIndexRoute
+ '/$storeId/settings/emails/templates/$templateId': typeof SettingsEmailsTemplatesTemplateIdRoute
'/$storeId/products/price-lists/$priceListId/': typeof ProductsPriceListsPriceListIdIndexRoute
'/$storeId/settings/delivery-profiles/$profileId/': typeof SettingsDeliveryProfilesProfileIdIndexRoute
+ '/$storeId/settings/emails/templates/': typeof SettingsEmailsTemplatesIndexRoute
'/$storeId/settings/delivery-profiles/$profileId/methods/$methodId': typeof SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute
'/$storeId/settings/delivery-profiles/$profileId/methods/new': typeof SettingsDeliveryProfilesProfileIdMethodsNewRoute
}
@@ -761,7 +777,6 @@ export interface FileRoutesByTo {
'/$storeId/settings/channels': typeof SettingsChannelsRoute
'/$storeId/settings/commission-rates': typeof SettingsCommissionRatesRoute
'/$storeId/settings/custom-field-definitions': typeof SettingsCustomFieldDefinitionsRoute
- '/$storeId/settings/emails': typeof SettingsEmailsRoute
'/$storeId/settings/integrations': typeof SettingsIntegrationsRoute
'/$storeId/settings/marketplace': typeof SettingsMarketplaceRoute
'/$storeId/settings/markets': typeof SettingsMarketsRoute
@@ -810,11 +825,14 @@ export interface FileRoutesByTo {
'/$storeId/purchase-orders/$purchaseOrderId': typeof PurchaseOrdersPurchaseOrderIdIndexRoute
'/$storeId/sellers/payouts': typeof SellersPayoutsIndexRoute
'/$storeId/settings/delivery-profiles': typeof SettingsDeliveryProfilesIndexRoute
+ '/$storeId/settings/emails': typeof SettingsEmailsIndexRoute
'/$storeId/settings/imports': typeof SettingsImportsIndexRoute
'/$storeId/settings/webhooks': typeof SettingsWebhooksIndexRoute
'/$storeId/transfers/$transferId': typeof TransfersTransferIdIndexRoute
+ '/$storeId/settings/emails/templates/$templateId': typeof SettingsEmailsTemplatesTemplateIdRoute
'/$storeId/products/price-lists/$priceListId': typeof ProductsPriceListsPriceListIdIndexRoute
'/$storeId/settings/delivery-profiles/$profileId': typeof SettingsDeliveryProfilesProfileIdIndexRoute
+ '/$storeId/settings/emails/templates': typeof SettingsEmailsTemplatesIndexRoute
'/$storeId/settings/delivery-profiles/$profileId/methods/$methodId': typeof SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute
'/$storeId/settings/delivery-profiles/$profileId/methods/new': typeof SettingsDeliveryProfilesProfileIdMethodsNewRoute
}
@@ -863,7 +881,6 @@ export interface FileRoutesById {
'/_authenticated/$storeId/settings/channels': typeof SettingsChannelsRoute
'/_authenticated/$storeId/settings/commission-rates': typeof SettingsCommissionRatesRoute
'/_authenticated/$storeId/settings/custom-field-definitions': typeof SettingsCustomFieldDefinitionsRoute
- '/_authenticated/$storeId/settings/emails': typeof SettingsEmailsRoute
'/_authenticated/$storeId/settings/integrations': typeof SettingsIntegrationsRoute
'/_authenticated/$storeId/settings/marketplace': typeof SettingsMarketplaceRoute
'/_authenticated/$storeId/settings/markets': typeof SettingsMarketsRoute
@@ -912,11 +929,14 @@ export interface FileRoutesById {
'/_authenticated/$storeId/purchase-orders/$purchaseOrderId/': typeof PurchaseOrdersPurchaseOrderIdIndexRoute
'/_authenticated/$storeId/sellers/payouts/': typeof SellersPayoutsIndexRoute
'/_authenticated/$storeId/settings/delivery-profiles/': typeof SettingsDeliveryProfilesIndexRoute
+ '/_authenticated/$storeId/settings/emails/': typeof SettingsEmailsIndexRoute
'/_authenticated/$storeId/settings/imports/': typeof SettingsImportsIndexRoute
'/_authenticated/$storeId/settings/webhooks/': typeof SettingsWebhooksIndexRoute
'/_authenticated/$storeId/transfers/$transferId/': typeof TransfersTransferIdIndexRoute
+ '/_authenticated/$storeId/settings/emails/templates/$templateId': typeof SettingsEmailsTemplatesTemplateIdRoute
'/_authenticated/$storeId/products/price-lists/$priceListId/': typeof ProductsPriceListsPriceListIdIndexRoute
'/_authenticated/$storeId/settings/delivery-profiles/$profileId/': typeof SettingsDeliveryProfilesProfileIdIndexRoute
+ '/_authenticated/$storeId/settings/emails/templates/': typeof SettingsEmailsTemplatesIndexRoute
'/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/$methodId': typeof SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute
'/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new': typeof SettingsDeliveryProfilesProfileIdMethodsNewRoute
}
@@ -965,7 +985,6 @@ export interface FileRouteTypes {
| '/$storeId/settings/channels'
| '/$storeId/settings/commission-rates'
| '/$storeId/settings/custom-field-definitions'
- | '/$storeId/settings/emails'
| '/$storeId/settings/integrations'
| '/$storeId/settings/marketplace'
| '/$storeId/settings/markets'
@@ -1014,11 +1033,14 @@ export interface FileRouteTypes {
| '/$storeId/purchase-orders/$purchaseOrderId/'
| '/$storeId/sellers/payouts/'
| '/$storeId/settings/delivery-profiles/'
+ | '/$storeId/settings/emails/'
| '/$storeId/settings/imports/'
| '/$storeId/settings/webhooks/'
| '/$storeId/transfers/$transferId/'
+ | '/$storeId/settings/emails/templates/$templateId'
| '/$storeId/products/price-lists/$priceListId/'
| '/$storeId/settings/delivery-profiles/$profileId/'
+ | '/$storeId/settings/emails/templates/'
| '/$storeId/settings/delivery-profiles/$profileId/methods/$methodId'
| '/$storeId/settings/delivery-profiles/$profileId/methods/new'
fileRoutesByTo: FileRoutesByTo
@@ -1063,7 +1085,6 @@ export interface FileRouteTypes {
| '/$storeId/settings/channels'
| '/$storeId/settings/commission-rates'
| '/$storeId/settings/custom-field-definitions'
- | '/$storeId/settings/emails'
| '/$storeId/settings/integrations'
| '/$storeId/settings/marketplace'
| '/$storeId/settings/markets'
@@ -1112,11 +1133,14 @@ export interface FileRouteTypes {
| '/$storeId/purchase-orders/$purchaseOrderId'
| '/$storeId/sellers/payouts'
| '/$storeId/settings/delivery-profiles'
+ | '/$storeId/settings/emails'
| '/$storeId/settings/imports'
| '/$storeId/settings/webhooks'
| '/$storeId/transfers/$transferId'
+ | '/$storeId/settings/emails/templates/$templateId'
| '/$storeId/products/price-lists/$priceListId'
| '/$storeId/settings/delivery-profiles/$profileId'
+ | '/$storeId/settings/emails/templates'
| '/$storeId/settings/delivery-profiles/$profileId/methods/$methodId'
| '/$storeId/settings/delivery-profiles/$profileId/methods/new'
id:
@@ -1164,7 +1188,6 @@ export interface FileRouteTypes {
| '/_authenticated/$storeId/settings/channels'
| '/_authenticated/$storeId/settings/commission-rates'
| '/_authenticated/$storeId/settings/custom-field-definitions'
- | '/_authenticated/$storeId/settings/emails'
| '/_authenticated/$storeId/settings/integrations'
| '/_authenticated/$storeId/settings/marketplace'
| '/_authenticated/$storeId/settings/markets'
@@ -1213,11 +1236,14 @@ export interface FileRouteTypes {
| '/_authenticated/$storeId/purchase-orders/$purchaseOrderId/'
| '/_authenticated/$storeId/sellers/payouts/'
| '/_authenticated/$storeId/settings/delivery-profiles/'
+ | '/_authenticated/$storeId/settings/emails/'
| '/_authenticated/$storeId/settings/imports/'
| '/_authenticated/$storeId/settings/webhooks/'
| '/_authenticated/$storeId/transfers/$transferId/'
+ | '/_authenticated/$storeId/settings/emails/templates/$templateId'
| '/_authenticated/$storeId/products/price-lists/$priceListId/'
| '/_authenticated/$storeId/settings/delivery-profiles/$profileId/'
+ | '/_authenticated/$storeId/settings/emails/templates/'
| '/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/$methodId'
| '/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new'
fileRoutesById: FileRoutesById
@@ -1548,13 +1574,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof SettingsIntegrationsRouteImport
parentRoute: typeof SettingsRoute
}
- '/_authenticated/$storeId/settings/emails': {
- id: '/_authenticated/$storeId/settings/emails'
- path: '/emails'
- fullPath: '/$storeId/settings/emails'
- preLoaderRoute: typeof SettingsEmailsRouteImport
- parentRoute: typeof SettingsRoute
- }
'/_authenticated/$storeId/settings/custom-field-definitions': {
id: '/_authenticated/$storeId/settings/custom-field-definitions'
path: '/custom-field-definitions'
@@ -1765,6 +1784,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof SettingsImportsIndexRouteImport
parentRoute: typeof SettingsRoute
}
+ '/_authenticated/$storeId/settings/emails/': {
+ id: '/_authenticated/$storeId/settings/emails/'
+ path: '/emails'
+ fullPath: '/$storeId/settings/emails/'
+ preLoaderRoute: typeof SettingsEmailsIndexRouteImport
+ parentRoute: typeof SettingsRoute
+ }
'/_authenticated/$storeId/settings/delivery-profiles/': {
id: '/_authenticated/$storeId/settings/delivery-profiles/'
path: '/delivery-profiles'
@@ -1898,6 +1924,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof OrdersOrderIdEditRouteImport
parentRoute: typeof authenticatedStoreIdRoute
}
+ '/_authenticated/$storeId/settings/emails/templates/': {
+ id: '/_authenticated/$storeId/settings/emails/templates/'
+ path: '/emails/templates'
+ fullPath: '/$storeId/settings/emails/templates/'
+ preLoaderRoute: typeof SettingsEmailsTemplatesIndexRouteImport
+ parentRoute: typeof SettingsRoute
+ }
'/_authenticated/$storeId/settings/delivery-profiles/$profileId/': {
id: '/_authenticated/$storeId/settings/delivery-profiles/$profileId/'
path: '/delivery-profiles/$profileId'
@@ -1912,6 +1945,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ProductsPriceListsPriceListIdIndexRouteImport
parentRoute: typeof authenticatedStoreIdRoute
}
+ '/_authenticated/$storeId/settings/emails/templates/$templateId': {
+ id: '/_authenticated/$storeId/settings/emails/templates/$templateId'
+ path: '/emails/templates/$templateId'
+ fullPath: '/$storeId/settings/emails/templates/$templateId'
+ preLoaderRoute: typeof SettingsEmailsTemplatesTemplateIdRouteImport
+ parentRoute: typeof SettingsRoute
+ }
'/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new': {
id: '/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new'
path: '/delivery-profiles/$profileId/methods/new'
@@ -1935,7 +1975,6 @@ interface SettingsRouteChildren {
SettingsChannelsRoute: typeof SettingsChannelsRoute
SettingsCommissionRatesRoute: typeof SettingsCommissionRatesRoute
SettingsCustomFieldDefinitionsRoute: typeof SettingsCustomFieldDefinitionsRoute
- SettingsEmailsRoute: typeof SettingsEmailsRoute
SettingsIntegrationsRoute: typeof SettingsIntegrationsRoute
SettingsMarketplaceRoute: typeof SettingsMarketplaceRoute
SettingsMarketsRoute: typeof SettingsMarketsRoute
@@ -1955,9 +1994,12 @@ interface SettingsRouteChildren {
SettingsIndexRoute: typeof SettingsIndexRoute
SettingsWebhooksWebhookEndpointIdRoute: typeof SettingsWebhooksWebhookEndpointIdRoute
SettingsDeliveryProfilesIndexRoute: typeof SettingsDeliveryProfilesIndexRoute
+ SettingsEmailsIndexRoute: typeof SettingsEmailsIndexRoute
SettingsImportsIndexRoute: typeof SettingsImportsIndexRoute
SettingsWebhooksIndexRoute: typeof SettingsWebhooksIndexRoute
+ SettingsEmailsTemplatesTemplateIdRoute: typeof SettingsEmailsTemplatesTemplateIdRoute
SettingsDeliveryProfilesProfileIdIndexRoute: typeof SettingsDeliveryProfilesProfileIdIndexRoute
+ SettingsEmailsTemplatesIndexRoute: typeof SettingsEmailsTemplatesIndexRoute
SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute: typeof SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute
SettingsDeliveryProfilesProfileIdMethodsNewRoute: typeof SettingsDeliveryProfilesProfileIdMethodsNewRoute
}
@@ -1968,7 +2010,6 @@ const SettingsRouteChildren: SettingsRouteChildren = {
SettingsChannelsRoute: SettingsChannelsRoute,
SettingsCommissionRatesRoute: SettingsCommissionRatesRoute,
SettingsCustomFieldDefinitionsRoute: SettingsCustomFieldDefinitionsRoute,
- SettingsEmailsRoute: SettingsEmailsRoute,
SettingsIntegrationsRoute: SettingsIntegrationsRoute,
SettingsMarketplaceRoute: SettingsMarketplaceRoute,
SettingsMarketsRoute: SettingsMarketsRoute,
@@ -1989,10 +2030,14 @@ const SettingsRouteChildren: SettingsRouteChildren = {
SettingsWebhooksWebhookEndpointIdRoute:
SettingsWebhooksWebhookEndpointIdRoute,
SettingsDeliveryProfilesIndexRoute: SettingsDeliveryProfilesIndexRoute,
+ SettingsEmailsIndexRoute: SettingsEmailsIndexRoute,
SettingsImportsIndexRoute: SettingsImportsIndexRoute,
SettingsWebhooksIndexRoute: SettingsWebhooksIndexRoute,
+ SettingsEmailsTemplatesTemplateIdRoute:
+ SettingsEmailsTemplatesTemplateIdRoute,
SettingsDeliveryProfilesProfileIdIndexRoute:
SettingsDeliveryProfilesProfileIdIndexRoute,
+ SettingsEmailsTemplatesIndexRoute: SettingsEmailsTemplatesIndexRoute,
SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute:
SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute,
SettingsDeliveryProfilesProfileIdMethodsNewRoute:
diff --git a/packages/dashboard-ui/package.json b/packages/dashboard-ui/package.json
index bf4cfd5d9f..a4c94f0336 100644
--- a/packages/dashboard-ui/package.json
+++ b/packages/dashboard-ui/package.json
@@ -54,6 +54,15 @@
},
"dependencies": {
"@base-ui/react": "1.8.0",
+ "@codemirror/autocomplete": "6.20.3",
+ "@codemirror/commands": "6.11.1",
+ "@codemirror/lang-html": "6.4.12",
+ "@codemirror/lang-liquid": "6.3.3",
+ "@codemirror/language": "6.12.4",
+ "@codemirror/lint": "6.9.7",
+ "@codemirror/search": "6.7.2",
+ "@codemirror/state": "6.7.6",
+ "@codemirror/view": "6.43.13",
"@dnd-kit/core": "6.3.1",
"@dnd-kit/sortable": "10.0.0",
"@dnd-kit/utilities": "3.2.2",
diff --git a/packages/dashboard-ui/src/hooks/use-debounced-value.ts b/packages/dashboard-ui/src/hooks/use-debounced-value.ts
new file mode 100644
index 0000000000..e92544785c
--- /dev/null
+++ b/packages/dashboard-ui/src/hooks/use-debounced-value.ts
@@ -0,0 +1,13 @@
+import { useEffect, useState } from 'react'
+
+/** The value, once it has stopped changing for `delayMs`. */
+export function useDebouncedValue<T>(value: T, delayMs: number): T {
+ const [debounced, setDebounced] = useState(value)
+
+ useEffect(() => {
+ const id = setTimeout(() => setDebounced(value), delayMs)
+ return () => clearTimeout(id)
+ }, [value, delayMs])
+
+ return debounced
+}
diff --git a/packages/dashboard-ui/src/index.ts b/packages/dashboard-ui/src/index.ts
index b10bf9f285..1883c914ca 100644
--- a/packages/dashboard-ui/src/index.ts
+++ b/packages/dashboard-ui/src/index.ts
@@ -12,6 +12,7 @@
// CSS lives at `@spree/dashboard-ui/styles.css` — import once from your Vite app.
export * from './hooks/use-copy-to-clipboard'
+export * from './hooks/use-debounced-value'
export { useIsMobile } from './hooks/use-mobile'
export * from './hooks/use-prefers-reduced-motion'
export * from './hooks/use-scrolled'
@@ -65,6 +66,8 @@ export * from './spree/return-dialogs'
// `@spree/dashboard-ui/spree/json-preview-drawer` and
// `@spree/dashboard-ui/spree/json-value-view`. Types are available the same
// way — `import { type JsonPreviewDrawerProps } from '@spree/dashboard-ui/spree/json-preview-drawer'`.
+// CodeEditor (CodeMirror) is deep-imported for the same reason:
+// `@spree/dashboard-ui/ui/code-editor`.
export * from './spree/external-link'
export * from './spree/language-menu-items'
diff --git a/packages/dashboard-ui/src/spree/icons.ts b/packages/dashboard-ui/src/spree/icons.ts
index d608713ce3..b946e60af7 100644
--- a/packages/dashboard-ui/src/spree/icons.ts
+++ b/packages/dashboard-ui/src/spree/icons.ts
@@ -69,6 +69,7 @@ export {
GlobeLockIcon,
GripVerticalIcon,
HandCoinsIcon,
+ HistoryIcon,
HomeIcon,
ImageIcon,
ImagePlusIcon,
@@ -134,6 +135,7 @@ export {
ShieldIcon,
ShoppingCartIcon,
SlidersHorizontalIcon,
+ SmartphoneIcon,
SparklesIcon,
SplitIcon,
SquareTextIcon,
diff --git a/packages/dashboard-ui/src/ui/code-editor.tsx b/packages/dashboard-ui/src/ui/code-editor.tsx
new file mode 100644
index 0000000000..9fde4feb1d
--- /dev/null
+++ b/packages/dashboard-ui/src/ui/code-editor.tsx
@@ -0,0 +1,225 @@
+import {
+ autocompletion,
+ closeBrackets,
+ closeBracketsKeymap,
+ completionKeymap,
+} from '@codemirror/autocomplete'
+import { defaultKeymap, history, historyKeymap, indentWithTab } from '@codemirror/commands'
+import { html } from '@codemirror/lang-html'
+import { closePercentBrace, liquid } from '@codemirror/lang-liquid'
+import {
+ bracketMatching,
+ defaultHighlightStyle,
+ foldGutter,
+ indentOnInput,
+ syntaxHighlighting,
+} from '@codemirror/language'
+import { type Diagnostic, lintGutter, setDiagnostics } from '@codemirror/lint'
+import { highlightSelectionMatches, searchKeymap } from '@codemirror/search'
+import { Compartment, EditorState } from '@codemirror/state'
+import {
+ drawSelection,
+ EditorView,
+ highlightActiveLine,
+ highlightActiveLineGutter,
+ keymap,
+ lineNumbers,
+} from '@codemirror/view'
+import { useEffect, useRef } from 'react'
+import { cn } from '../lib/utils'
+
+export interface CodeEditorCompletion {
+ /** A variable, or a dotted path to one of its fields (`order.number`). */
+ label: string
+ /** Short type or value shown next to the label. */
+ detail?: string
+ /** Longer description shown beside the list. */
+ info?: string
+}
+
+export interface CodeEditorDiagnostic {
+ /** 1-based line the problem is on; problems without one mark the first line. */
+ line?: number | null
+ message: string
+}
+
+export interface CodeEditorProps {
+ value: string
+ onChange?: (value: string) => void
+ /** Variables offered after `{{` and their fields after a dot. */
+ completions?: CodeEditorCompletion[]
+ /** Filters offered after `|`. */
+ filters?: CodeEditorCompletion[]
+ diagnostics?: CodeEditorDiagnostic[]
+ readOnly?: boolean
+ /** Called on Cmd/Ctrl+S. */
+ onSave?: () => void
+ 'aria-label'?: string
+ className?: string
+}
+
+const theme = EditorView.theme({
+ '&': {
+ backgroundColor: 'var(--card)',
+ color: 'var(--foreground)',
+ fontSize: '13px',
+ height: '100%',
+ },
+ '.cm-scroller': { fontFamily: 'var(--font-mono, ui-monospace, monospace)', lineHeight: '1.6' },
+ '.cm-content': { caretColor: 'var(--foreground)' },
+ '.cm-gutters': {
+ backgroundColor: 'var(--background)',
+ color: 'var(--muted-foreground)',
+ borderRight: '1px solid var(--border)',
+ },
+ '.cm-activeLine, .cm-activeLineGutter': {
+ backgroundColor: 'color-mix(in srgb, var(--accent) 60%, transparent)',
+ },
+ '&.cm-focused': { outline: 'none' },
+ '&.cm-focused .cm-selectionBackground, .cm-selectionBackground': {
+ backgroundColor: 'color-mix(in srgb, var(--ring) 20%, transparent)',
+ },
+ '.cm-tooltip': {
+ backgroundColor: 'var(--popover)',
+ color: 'var(--popover-foreground)',
+ border: '1px solid var(--border)',
+ borderRadius: '8px',
+ },
+})
+
+function toDiagnostics(state: EditorState, problems: CodeEditorDiagnostic[]): Diagnostic[] {
+ return problems.map((problem) => {
+ const lineNumber = Math.min(Math.max(problem.line ?? 1, 1), state.doc.lines)
+ const line = state.doc.line(lineNumber)
+ return { from: line.from, to: line.to, severity: 'error', message: problem.message }
+ })
+}
+
+/**
+ * A code editor for Liquid templates written in HTML or MJML, with variable
+ * and filter completion, inline problems and the usual editing keys.
+ */
+function CodeEditor({
+ value,
+ onChange,
+ completions = [],
+ filters = [],
+ diagnostics = [],
+ readOnly = false,
+ onSave,
+ className,
+ ...props
+}: CodeEditorProps) {
+ const containerRef = useRef<HTMLDivElement>(null)
+ const viewRef = useRef<EditorView | null>(null)
+ const languageCompartment = useRef(new Compartment())
+ const readOnlyCompartment = useRef(new Compartment())
+ const callbacks = useRef({ onChange, onSave })
+ callbacks.current = { onChange, onSave }
+
+ // biome-ignore lint/correctness/useExhaustiveDependencies: the view is created once; later props flow in through the effects below
+ useEffect(() => {
+ if (!containerRef.current) return
+
+ const view = new EditorView({
+ parent: containerRef.current,
+ state: EditorState.create({
+ doc: value,
+ extensions: [
+ lineNumbers(),
+ highlightActiveLineGutter(),
+ foldGutter(),
+ history(),
+ drawSelection(),
+ indentOnInput(),
+ bracketMatching(),
+ closeBrackets(),
+ closePercentBrace,
+ highlightActiveLine(),
+ highlightSelectionMatches(),
+ autocompletion(),
+ lintGutter(),
+ syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
+ EditorView.lineWrapping,
+ theme,
+ languageCompartment.current.of([]),
+ readOnlyCompartment.current.of(EditorState.readOnly.of(readOnly)),
+ keymap.of([
+ {
+ key: 'Mod-s',
+ preventDefault: true,
+ run: () => {
+ callbacks.current.onSave?.()
+ return true
+ },
+ },
+ ...closeBracketsKeymap,
+ ...defaultKeymap,
+ ...searchKeymap,
+ ...historyKeymap,
+ ...completionKeymap,
+ indentWithTab,
+ ]),
+ EditorView.updateListener.of((update) => {
+ if (update.docChanged) callbacks.current.onChange?.(update.state.doc.toString())
+ }),
+ EditorView.contentAttributes.of({ 'aria-label': props['aria-label'] ?? '' }),
+ ],
+ }),
+ })
+ viewRef.current = view
+
+ return () => {
+ view.destroy()
+ viewRef.current = null
+ }
+ }, [])
+
+ useEffect(() => {
+ const view = viewRef.current
+ if (!view || view.state.doc.toString() === value) return
+ view.dispatch({ changes: { from: 0, to: view.state.doc.length, insert: value } })
+ }, [value])
+
+ useEffect(() => {
+ const variables = completions.filter((completion) => !completion.label.includes('.'))
+ const language = liquid({
+ base: html(),
+ variables,
+ filters,
+ properties: (path) => {
+ const prefix = `${path.join('.')}.`
+ return completions
+ .filter((completion) => completion.label.startsWith(prefix))
+ .map((completion) => ({ ...completion, label: completion.label.slice(prefix.length) }))
+ .filter((completion) => !completion.label.includes('.'))
+ },
+ })
+ viewRef.current?.dispatch({ effects: languageCompartment.current.reconfigure(language) })
+ }, [completions, filters])
+
+ useEffect(() => {
+ viewRef.current?.dispatch({
+ effects: readOnlyCompartment.current.reconfigure(EditorState.readOnly.of(readOnly)),
+ })
+ }, [readOnly])
+
+ useEffect(() => {
+ const view = viewRef.current
+ if (!view) return
+ view.dispatch(setDiagnostics(view.state, toDiagnostics(view.state, diagnostics)))
+ }, [diagnostics])
+
+ return (
+ <div
+ ref={containerRef}
+ data-slot="code-editor"
+ className={cn(
+ 'min-h-64 overflow-hidden rounded-md border border-border bg-card shadow-control focus-within:border-blue-500 focus-within:shadow-[0_0_0_3px_color-mix(in_srgb,var(--ring)_15%,transparent)]',
+ className,
+ )}
+ />
+ )
+}
+
+export { CodeEditor }
diff --git a/packages/dashboard/src/components/spree/email-templates/default-diff-dialog.tsx b/packages/dashboard/src/components/spree/email-templates/default-diff-dialog.tsx
new file mode 100644
index 0000000000..b8047b4bb3
--- /dev/null
+++ b/packages/dashboard/src/components/spree/email-templates/default-diff-dialog.tsx
@@ -0,0 +1,104 @@
+import {
+ Button,
+ cn,
+ Dialog,
+ DialogBody,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@spree/dashboard-ui'
+import { useMemo } from 'react'
+import { useTranslation } from 'react-i18next'
+import { type DiffRow, diffLines } from '../../../lib/line-diff'
+
+const CELL_TONE: Record<DiffRow['kind'], { before: string; after: string }> = {
+ same: { before: '', after: '' },
+ removed: { before: 'bg-danger-bg', after: '' },
+ added: { before: '', after: 'bg-success-bg' },
+ changed: { before: 'bg-danger-bg', after: 'bg-success-bg' },
+}
+
+/**
+ * Spree's default as the store's version started from it, next to the default
+ * now, so a merchant can see what an upgrade changed before deciding.
+ */
+export function DefaultDiffDialog({
+ open,
+ onOpenChange,
+ before,
+ after,
+ pending,
+ onKeepMine,
+ onStartOver,
+}: {
+ open: boolean
+ onOpenChange: (open: boolean) => void
+ before: string
+ after: string
+ pending: boolean
+ onKeepMine: () => void
+ onStartOver: () => void
+}) {
+ const { t } = useTranslation()
+ const rows = useMemo(() => (open ? diffLines(before, after) : []), [open, before, after])
+
+ return (
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent className="sm:max-w-[min(1100px,calc(100%-2rem))]">
+ <DialogHeader>
+ <DialogTitle>{t('admin.email_templates.default_update.dialog_title')}</DialogTitle>
+ <DialogDescription>
+ {t('admin.email_templates.default_update.dialog_description')}
+ </DialogDescription>
+ </DialogHeader>
+ <DialogBody className="overflow-auto">
+ <table className="w-full table-fixed border-collapse font-mono text-xs">
+ <thead>
+ <tr className="text-left text-muted-foreground">
+ <th className="px-2 py-1 font-medium">
+ {t('admin.email_templates.default_update.before')}
+ </th>
+ <th className="px-2 py-1 font-medium">
+ {t('admin.email_templates.default_update.after')}
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ {rows.map((row, index) => (
+ // biome-ignore lint/suspicious/noArrayIndexKey: rows have no identity beyond their position
+ <tr key={index}>
+ <td
+ className={cn(
+ 'whitespace-pre-wrap break-all px-2 align-top',
+ CELL_TONE[row.kind].before,
+ )}
+ >
+ {row.before}
+ </td>
+ <td
+ className={cn(
+ 'whitespace-pre-wrap break-all px-2 align-top',
+ CELL_TONE[row.kind].after,
+ )}
+ >
+ {row.after}
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </DialogBody>
+ <DialogFooter>
+ <Button variant="outline" disabled={pending} onClick={onStartOver}>
+ {t('admin.email_templates.default_update.start_over')}
+ </Button>
+ <Button disabled={pending} onClick={onKeepMine}>
+ {t('admin.email_templates.default_update.keep_mine')}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )
+}
diff --git a/packages/dashboard/src/components/spree/email-templates/email-preview-frame.tsx b/packages/dashboard/src/components/spree/email-templates/email-preview-frame.tsx
new file mode 100644
index 0000000000..7e65241f57
--- /dev/null
+++ b/packages/dashboard/src/components/spree/email-templates/email-preview-frame.tsx
@@ -0,0 +1,56 @@
+import { cn } from '@spree/dashboard-ui'
+import { useTranslation } from 'react-i18next'
+
+export type EmailPreviewWidth = 'desktop' | 'mobile'
+
+/**
+ * A rendered email in a sandboxed frame: no scripts, no navigation, nothing
+ * the email's markup can reach in the dashboard.
+ */
+export function EmailPreviewFrame({
+ html,
+ text,
+ view = 'html',
+ width = 'desktop',
+ className,
+}: {
+ html?: string
+ text?: string
+ view?: 'html' | 'text'
+ width?: EmailPreviewWidth
+ className?: string
+}) {
+ const { t } = useTranslation()
+
+ if (view === 'text') {
+ return (
+ <pre
+ className={cn(
+ 'h-full min-h-96 overflow-auto whitespace-pre-wrap rounded-md border border-border bg-card p-4 font-mono text-xs',
+ className,
+ )}
+ >
+ {text}
+ </pre>
+ )
+ }
+
+ return (
+ <div
+ className={cn(
+ 'flex h-full min-h-96 justify-center rounded-md border border-border bg-muted p-2',
+ className,
+ )}
+ >
+ <iframe
+ title={t('admin.email_templates.preview.frame_title')}
+ sandbox=""
+ srcDoc={html ?? ''}
+ className={cn(
+ 'h-full min-h-96 rounded bg-white transition-[width] duration-150',
+ width === 'mobile' ? 'w-[375px]' : 'w-full',
+ )}
+ />
+ </div>
+ )
+}
diff --git a/packages/dashboard/src/components/spree/email-templates/emails-tabs.tsx b/packages/dashboard/src/components/spree/email-templates/emails-tabs.tsx
new file mode 100644
index 0000000000..8865c86853
--- /dev/null
+++ b/packages/dashboard/src/components/spree/email-templates/emails-tabs.tsx
@@ -0,0 +1,34 @@
+import { Subject, usePermissions } from '@spree/dashboard-core'
+import { Tabs, TabsList, TabsTrigger } from '@spree/dashboard-ui'
+import { useNavigate, useParams } from '@tanstack/react-router'
+import { useTranslation } from 'react-i18next'
+
+/** Switches between the email settings and the email templates. */
+export function EmailsTabs({ current }: { current: 'settings' | 'templates' }) {
+ const { t } = useTranslation()
+ const navigate = useNavigate()
+ const { storeId } = useParams({ strict: false }) as { storeId: string }
+ const { permissions } = usePermissions()
+
+ if (!permissions.can('read', Subject.EmailTemplate)) return null
+
+ return (
+ <Tabs
+ value={current}
+ onValueChange={(value) =>
+ navigate({
+ to:
+ value === 'templates'
+ ? '/$storeId/settings/emails/templates'
+ : '/$storeId/settings/emails',
+ params: { storeId },
+ })
+ }
+ >
+ <TabsList>
+ <TabsTrigger value="settings">{t('admin.email_templates.tabs.settings')}</TabsTrigger>
+ <TabsTrigger value="templates">{t('admin.email_templates.tabs.templates')}</TabsTrigger>
+ </TabsList>
+ </Tabs>
+ )
+}
diff --git a/packages/dashboard/src/components/spree/email-templates/history-sheet.tsx b/packages/dashboard/src/components/spree/email-templates/history-sheet.tsx
new file mode 100644
index 0000000000..d419d1b6b0
--- /dev/null
+++ b/packages/dashboard/src/components/spree/email-templates/history-sheet.tsx
@@ -0,0 +1,94 @@
+import type { EmailTemplateRevision } from '@spree/admin-sdk'
+import {
+ Button,
+ RelativeTime,
+ Sheet,
+ SheetContent,
+ SheetDescription,
+ SheetHeader,
+ SheetTitle,
+ Skeleton,
+} from '@spree/dashboard-ui'
+import { useTranslation } from 'react-i18next'
+import { ActorLabel } from '../actor-label'
+
+/** Published versions of a template, newest first, each one restorable into the draft. */
+export function EmailTemplateHistorySheet({
+ open,
+ onOpenChange,
+ revisions,
+ isLoading,
+ canRestore,
+ restoring,
+ onRestore,
+}: {
+ open: boolean
+ onOpenChange: (open: boolean) => void
+ revisions?: EmailTemplateRevision[]
+ isLoading: boolean
+ canRestore: boolean
+ restoring: boolean
+ onRestore: (revision: EmailTemplateRevision) => void
+}) {
+ const { t } = useTranslation()
+
+ return (
+ <Sheet open={open} onOpenChange={onOpenChange}>
+ <SheetContent className="sm:max-w-lg">
+ <SheetHeader>
+ <SheetTitle>{t('admin.email_templates.history.title')}</SheetTitle>
+ <SheetDescription>{t('admin.email_templates.history.description')}</SheetDescription>
+ </SheetHeader>
+ <div className="flex flex-col gap-3 overflow-y-auto px-4 pb-4">
+ {isLoading && <Skeleton className="h-24 w-full" />}
+ {!isLoading && !revisions?.length && (
+ <p className="text-sm text-muted-foreground">
+ {t('admin.email_templates.history.empty')}
+ </p>
+ )}
+ {revisions?.map((revision, index) => (
+ <div
+ key={revision.id}
+ className="flex flex-col gap-2 rounded-md border border-border p-3"
+ >
+ <div className="flex items-center justify-between gap-2 text-sm">
+ <div className="flex flex-col">
+ <span className="font-medium">
+ {index === 0
+ ? t('admin.email_templates.history.latest')
+ : t('admin.email_templates.history.version', {
+ number: revisions.length - index,
+ })}
+ </span>
+ <span className="text-muted-foreground">
+ <RelativeTime iso={revision.created_at} />
+ {revision.published_by && (
+ <>
+ {' · '}
+ <ActorLabel actor={revision.published_by} />
+ </>
+ )}
+ </span>
+ </div>
+ {canRestore && (
+ <Button
+ size="sm"
+ variant="outline"
+ disabled={restoring}
+ onClick={() => onRestore(revision)}
+ >
+ {t('admin.email_templates.history.restore')}
+ </Button>
+ )}
+ </div>
+ {revision.subject && <p className="truncate text-sm">{revision.subject}</p>}
+ <pre className="max-h-40 overflow-auto rounded bg-muted p-2 font-mono text-xs">
+ {revision.body}
+ </pre>
+ </div>
+ ))}
+ </div>
+ </SheetContent>
+ </Sheet>
+ )
+}
diff --git a/packages/dashboard/src/hooks/use-email-templates.ts b/packages/dashboard/src/hooks/use-email-templates.ts
new file mode 100644
index 0000000000..999ca51387
--- /dev/null
+++ b/packages/dashboard/src/hooks/use-email-templates.ts
@@ -0,0 +1,117 @@
+import {
+ type EmailTemplate,
+ type EmailTemplateDraftParams,
+ type EmailTemplatePreview,
+ type EmailTemplatePreviewParams,
+ SpreeError,
+} from '@spree/admin-sdk'
+import { adminClient, useResourceKey, useResourceMutation } from '@spree/dashboard-core'
+import { useMutation, useQuery } from '@tanstack/react-query'
+import i18n from 'i18next'
+
+const RESOURCE = 'email-templates'
+
+export interface EmailTemplateProblem {
+ email: string
+ message: string
+ line?: number | null
+}
+
+/** The problems a 422 lists when a template does not render, else none. */
+export function templateProblems(error: unknown): EmailTemplateProblem[] {
+ if (!(error instanceof SpreeError) || error.code !== 'email_template_invalid') return []
+ const problems = (error.details as unknown as { problems?: EmailTemplateProblem[] } | undefined)
+ ?.problems
+ return problems ?? [{ email: '', message: error.message }]
+}
+
+export function useEmailTemplates(language = 'any') {
+ return useQuery({
+ queryKey: useResourceKey(RESOURCE, 'list', language),
+ queryFn: () => adminClient.emailTemplates.list({ language }),
+ })
+}
+
+export function useEmailTemplate(id: string, language: string) {
+ return useQuery({
+ queryKey: useResourceKey(RESOURCE, id, language),
+ queryFn: () => adminClient.emailTemplates.get(id, { language, expand: ['draft.updated_by'] }),
+ })
+}
+
+export function useEmailTemplateRevisions(id: string, language: string, enabled: boolean) {
+ return useQuery({
+ queryKey: useResourceKey(RESOURCE, id, language, 'revisions'),
+ queryFn: () =>
+ adminClient.emailTemplates.revisions.list(id, {
+ language,
+ expand: ['published_by'],
+ limit: 50,
+ }),
+ enabled,
+ })
+}
+
+/** Saves the draft; conflicts and render problems are left to the editor. */
+export function useSaveEmailTemplateDraft(id: string) {
+ return useResourceMutation<EmailTemplate, Error, EmailTemplateDraftParams>({
+ mutationFn: (params) => adminClient.emailTemplates.draft.update(id, params),
+ invalidate: [[RESOURCE]],
+ successMessage: i18n.t('admin.email_templates.messages.draft_saved'),
+ errorMessage: false,
+ })
+}
+
+export function useDiscardEmailTemplateDraft(id: string) {
+ return useResourceMutation<EmailTemplate, Error, string>({
+ mutationFn: (language) => adminClient.emailTemplates.draft.delete(id, { language }),
+ invalidate: [[RESOURCE]],
+ successMessage: i18n.t('admin.email_templates.messages.draft_discarded'),
+ })
+}
+
+export function usePublishEmailTemplate(id: string) {
+ return useResourceMutation<EmailTemplate, Error, string>({
+ mutationFn: (language) => adminClient.emailTemplates.publish(id, { language }),
+ invalidate: [[RESOURCE]],
+ successMessage: i18n.t('admin.email_templates.messages.published'),
+ errorMessage: false,
+ })
+}
+
+export function useRevertEmailTemplate(id: string) {
+ return useResourceMutation<EmailTemplate, Error, string>({
+ mutationFn: (language) => adminClient.emailTemplates.revert(id, { language }),
+ invalidate: [[RESOURCE]],
+ successMessage: i18n.t('admin.email_templates.messages.reverted'),
+ })
+}
+
+export function useRestoreEmailTemplateRevision(id: string) {
+ return useResourceMutation<
+ EmailTemplate,
+ Error,
+ { revisionId: string; language: string; lock_version?: number }
+ >({
+ mutationFn: ({ revisionId, ...params }) =>
+ adminClient.emailTemplates.revisions.restore(id, revisionId, params),
+ invalidate: [[RESOURCE]],
+ successMessage: i18n.t('admin.email_templates.messages.restored'),
+ errorMessage: false,
+ })
+}
+
+export function useSendTestEmail(id: string) {
+ return useResourceMutation<{ sent_to: string }, Error, EmailTemplatePreviewParams>({
+ mutationFn: (params) => adminClient.emailTemplates.sendTest(id, params),
+ successMessage: false,
+ errorMessage: i18n.t('admin.email_templates.errors.test_email_failed'),
+ })
+}
+
+/** Renders a template, or unsaved changes to it, with sample data. Never cached. */
+export function useEmailTemplatePreview(id: string) {
+ return useMutation<EmailTemplatePreview, Error, EmailTemplatePreviewParams>({
+ mutationFn: (params) => adminClient.emailTemplates.preview(id, params),
+ })
+}
diff --git a/packages/dashboard/src/lib/email-template-name.ts b/packages/dashboard/src/lib/email-template-name.ts
new file mode 100644
index 0000000000..33216b7e99
--- /dev/null
+++ b/packages/dashboard/src/lib/email-template-name.ts
@@ -0,0 +1,8 @@
+import type { TFunction } from 'i18next'
+
+/** The merchant-facing name of a template, from its key. */
+export function emailTemplateName(t: TFunction, key: string): string {
+ const [folder, file] = key.split('/').slice(-2)
+ const fallback = file.replace(/_/g, ' ').replace(/^\w/, (letter) => letter.toUpperCase())
+ return t(`admin.email_templates.names.${folder}_${file}`, { defaultValue: fallback })
+}
diff --git a/packages/dashboard/src/lib/email-template-variables.test.ts b/packages/dashboard/src/lib/email-template-variables.test.ts
new file mode 100644
index 0000000000..53f7939437
--- /dev/null
+++ b/packages/dashboard/src/lib/email-template-variables.test.ts
@@ -0,0 +1,26 @@
+import { describe, expect, it } from 'vitest'
+import { flattenVariables } from './email-template-variables'
+
+describe('flattenVariables', () => {
+ it('lists dotted paths with samples, reading a list through its first item', () => {
+ const paths = flattenVariables({
+ order: { number: 'R123', items: [{ name: 'Shirt' }, { name: 'Hat' }], note: null },
+ resend: false,
+ })
+
+ expect(paths).toEqual([
+ { path: 'order', sample: '{…}' },
+ { path: 'order.number', sample: 'R123' },
+ { path: 'order.items', sample: '[2]' },
+ { path: 'order.items.name', sample: 'Shirt' },
+ { path: 'order.note', sample: 'null' },
+ { path: 'resend', sample: 'false' },
+ ])
+ })
+
+ it('stops descending past a few levels', () => {
+ const deep = { a: { b: { c: { d: { e: { f: 1 } } } } } }
+
+ expect(flattenVariables(deep).map((entry) => entry.path)).not.toContain('a.b.c.d.e.f')
+ })
+})
diff --git a/packages/dashboard/src/lib/email-template-variables.ts b/packages/dashboard/src/lib/email-template-variables.ts
new file mode 100644
index 0000000000..2ce6f2a727
--- /dev/null
+++ b/packages/dashboard/src/lib/email-template-variables.ts
@@ -0,0 +1,149 @@
+import type {
+ Company,
+ Customer,
+ EmailFulfillment,
+ EmailOrder,
+ EmailOrderGroup,
+ EmailReturn,
+ EmailStore,
+} from '@spree/admin-sdk'
+
+type FieldsOf<T> = ReadonlyArray<Extract<keyof T, string>>
+
+/** A variable a template receives, with the fields worth pointing out. */
+export interface EmailTemplateVariable {
+ name: string
+ /** Translation key for one line saying what it is. */
+ descriptionKey: string
+ fields?: readonly string[]
+}
+
+const variable = (name: string, fields?: readonly string[]): EmailTemplateVariable => ({
+ name,
+ descriptionKey: `admin.email_templates.variables.${name}`,
+ fields,
+})
+
+const ORDER_FIELDS = [
+ 'number',
+ 'customer_name',
+ 'email',
+ 'completed_at',
+ 'items',
+ 'display_item_total',
+ 'display_delivery_total',
+ 'display_tax_total',
+ 'display_total',
+ 'shipping_address',
+ 'billing_address',
+ 'payments',
+] as const satisfies FieldsOf<EmailOrder>
+
+const order = variable('order', ORDER_FIELDS)
+const resend = variable('resend')
+
+const STORE_FIELDS = [
+ 'name',
+ 'url',
+ 'support_email',
+ 'logo_url',
+ 'address',
+ 'branding',
+] as const satisfies FieldsOf<EmailStore>
+
+/** Every email receives these. */
+export const SHARED_EMAIL_VARIABLES: EmailTemplateVariable[] = [
+ variable('store', STORE_FIELDS),
+ variable('locale'),
+]
+
+/** The variables each editable email receives, by its key with dots. */
+export const EMAIL_TEMPLATE_VARIABLES: Record<string, EmailTemplateVariable[]> = {
+ 'spree.order_mailer.confirm_email': [order, resend],
+ 'spree.order_mailer.cancel_email': [order, resend],
+ 'spree.order_mailer.payment_link_email': [order, variable('payment_url')],
+ 'spree.order_group_mailer.confirm_email': [
+ variable('order_group', [
+ 'number',
+ 'customer_name',
+ 'order_count',
+ 'items',
+ 'fulfillment_groups',
+ 'display_total',
+ ] as const satisfies FieldsOf<EmailOrderGroup>),
+ resend,
+ ],
+ 'spree.fulfillment_mailer.fulfilled_email': [
+ order,
+ variable('fulfillment', [
+ 'number',
+ 'tracking',
+ 'tracking_url',
+ 'delivery_method_name',
+ 'items',
+ ] as const satisfies FieldsOf<EmailFulfillment>),
+ resend,
+ ],
+ 'spree.return_mailer.refunded_email': [
+ order,
+ variable('return', [
+ 'number',
+ 'returned_items',
+ 'display_refunded_total',
+ ] as const satisfies FieldsOf<EmailReturn>),
+ resend,
+ ],
+ 'spree.digital_asset_mailer.files_ready_email': [order, variable('downloads'), resend],
+ 'spree.customer_mailer.password_reset_email': [
+ variable('customer', [
+ 'first_name',
+ 'last_name',
+ 'email',
+ ] as const satisfies FieldsOf<Customer>),
+ variable('reset_url'),
+ ],
+ 'spree.customer_mailer.data_export_email': [variable('download_url'), variable('expires_at')],
+ 'spree.newsletter_mailer.email_confirmation': [variable('confirmation_url')],
+ 'spree.company_mailer.invitation_email': [
+ variable('company', ['name'] as const satisfies FieldsOf<Company>),
+ variable('accept_url'),
+ ],
+}
+
+/** Spree's own Liquid filters, on top of Liquid's standard ones. */
+export const EMAIL_TEMPLATE_FILTERS = ['money', 'money_with_currency', 'date', 't'] as const
+
+const MAX_DEPTH = 4
+
+/**
+ * Dotted paths to every value in a rendered email's variables, with a sample
+ * of each. A list contributes the fields of its first item, as a loop over it
+ * (`{% for item in order.items %}`) reads them.
+ */
+export function flattenVariables(
+ variables: Record<string, unknown>,
+): Array<{ path: string; sample: string }> {
+ const paths: Array<{ path: string; sample: string }> = []
+
+ const visit = (value: unknown, path: string, depth: number) => {
+ if (Array.isArray(value)) {
+ paths.push({ path, sample: `[${value.length}]` })
+ if (depth < MAX_DEPTH && value.length > 0) visitObject(value[0], path, depth + 1)
+ } else if (value !== null && typeof value === 'object') {
+ paths.push({ path, sample: '{…}' })
+ if (depth < MAX_DEPTH) visitObject(value, path, depth + 1)
+ } else {
+ paths.push({ path, sample: value === null || value === undefined ? 'null' : String(value) })
+ }
+ }
+
+ const visitObject = (value: unknown, prefix: string, depth: number) => {
+ if (value === null || typeof value !== 'object' || Array.isArray(value)) return
+ for (const [key, child] of Object.entries(value as Record<string, unknown>)) {
+ visit(child, prefix ? `${prefix}.${key}` : key, depth)
+ }
+ }
+
+ visitObject(variables, '', 0)
+ return paths
+}
diff --git a/packages/dashboard/src/lib/line-diff.test.ts b/packages/dashboard/src/lib/line-diff.test.ts
new file mode 100644
index 0000000000..9210312959
--- /dev/null
+++ b/packages/dashboard/src/lib/line-diff.test.ts
@@ -0,0 +1,24 @@
+import { describe, expect, it } from 'vitest'
+import { diffLines } from './line-diff'
+
+describe('diffLines', () => {
+ it('pairs unchanged lines and marks the rest', () => {
+ expect(diffLines('a\nb\nc', 'a\nB\nc\nd')).toEqual([
+ { kind: 'same', before: 'a', after: 'a' },
+ { kind: 'changed', before: 'b', after: 'B' },
+ { kind: 'same', before: 'c', after: 'c' },
+ { kind: 'added', before: null, after: 'd' },
+ ])
+ })
+
+ it('reports removed lines', () => {
+ expect(diffLines('a\nb', 'a')).toEqual([
+ { kind: 'same', before: 'a', after: 'a' },
+ { kind: 'removed', before: 'b', after: null },
+ ])
+ })
+
+ it('treats identical texts as unchanged', () => {
+ expect(diffLines('x\ny', 'x\ny').every((row) => row.kind === 'same')).toBe(true)
+ })
+})
diff --git a/packages/dashboard/src/lib/line-diff.ts b/packages/dashboard/src/lib/line-diff.ts
new file mode 100644
index 0000000000..78acfa8aa2
--- /dev/null
+++ b/packages/dashboard/src/lib/line-diff.ts
@@ -0,0 +1,63 @@
+export interface DiffRow {
+ kind: 'same' | 'removed' | 'added' | 'changed'
+ before: string | null
+ after: string | null
+}
+
+/**
+ * Lines of two texts aligned side by side, from their longest common
+ * subsequence: unchanged lines pair up, a removed run next to an added run
+ * pairs line by line as changed.
+ */
+export function diffLines(before: string, after: string): DiffRow[] {
+ const left = before.split('\n')
+ const right = after.split('\n')
+ const lengths: number[][] = Array.from({ length: left.length + 1 }, () =>
+ new Array<number>(right.length + 1).fill(0),
+ )
+
+ for (let i = left.length - 1; i >= 0; i--) {
+ for (let j = right.length - 1; j >= 0; j--) {
+ lengths[i][j] =
+ left[i] === right[j]
+ ? lengths[i + 1][j + 1] + 1
+ : Math.max(lengths[i + 1][j], lengths[i][j + 1])
+ }
+ }
+
+ const rows: DiffRow[] = []
+ let removed: string[] = []
+ let added: string[] = []
+ const flush = () => {
+ const paired = Math.max(removed.length, added.length)
+ for (let k = 0; k < paired; k++) {
+ const was = removed[k] ?? null
+ const now = added[k] ?? null
+ rows.push({
+ kind: was === null ? 'added' : now === null ? 'removed' : 'changed',
+ before: was,
+ after: now,
+ })
+ }
+ removed = []
+ added = []
+ }
+
+ let i = 0
+ let j = 0
+ while (i < left.length || j < right.length) {
+ if (i < left.length && j < right.length && left[i] === right[j]) {
+ flush()
+ rows.push({ kind: 'same', before: left[i], after: right[j] })
+ i++
+ j++
+ } else if (j < right.length && (i === left.length || lengths[i][j + 1] >= lengths[i + 1][j])) {
+ added.push(right[j++])
+ } else {
+ removed.push(left[i++])
+ }
+ }
+ flush()
+
+ return rows
+}
diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.json
index 911626f36a..5e304f0da1 100644
--- a/packages/dashboard/src/locales/ar.json
+++ b/packages/dashboard/src/locales/ar.json
@@ -2161,6 +2161,25 @@
"label": "الضريبة الافتراضية على العمولة",
"help": "تُحتسب على عمولتك عندما لا تحدد نسبة العمولة ولا مزود الضرائب نسبة خاصة. اتركها 0 إذا كانت عمولتك غير خاضعة للضريبة.",
"suffix": "٪"
+ },
+ "preferred_email_accent_color": {
+ "label": "لون التمييز"
+ },
+ "preferred_email_background_color": {
+ "label": "لون الخلفية"
+ },
+ "preferred_email_card_color": {
+ "label": "لون البطاقة"
+ },
+ "preferred_email_text_color": {
+ "label": "لون النص"
+ },
+ "preferred_email_heading_color": {
+ "label": "لون العناوين"
+ },
+ "preferred_email_font": {
+ "label": "الخط",
+ "help": "تستخدم تطبيقات البريد التي لا يمكنها تحميله خطًا مشابهًا."
}
},
"store_credit": {
@@ -3833,7 +3852,21 @@
"section_delivery": "توصيل",
"section_logo": "الشعار",
"subtitle": "عناوين المرسل والإشعارات والشعار المضمن في رسائل البريد الإلكتروني الخاصة بالمعاملات.",
- "title": "إعدادات Email"
+ "title": "إعدادات Email",
+ "branding": {
+ "title": "الهوية البصرية",
+ "description": "ألوان وخط كل رسالة للعملاء. اترك اللون فارغًا للإبقاء على الافتراضي.",
+ "default_color": "افتراضي",
+ "fonts": {
+ "inter": "Inter (افتراضي)",
+ "system": "خط النظام",
+ "helvetica": "Helvetica",
+ "georgia": "Georgia",
+ "roboto": "Roboto",
+ "lato": "Lato",
+ "merriweather": "Merriweather"
+ }
+ }
},
"imports": {
"delete_confirm": {
@@ -5114,7 +5147,8 @@
"webhooks": "نقاط النهاية التي تُخطر عند وقوع الأحداث",
"package_types": "صناديق وكراتين ومنصات وحاويات",
"suppliers": "من تشتري منه المخزون، وكيفية التواصل معه",
- "marketplace": "مدفوعات البائعين، والموافقة على البائعين، ورسائل البائعين، والضريبة على العمولة"
+ "marketplace": "مدفوعات البائعين، والموافقة على البائعين، ورسائل البائعين، والضريبة على العمولة",
+ "email_templates": "عدّل الرسائل التي يتلقاها العملاء"
},
"groups": {
"audit": "التدقيق",
@@ -5152,7 +5186,8 @@
"webhooks": "Webhooks",
"package_types": "أنواع التغليف",
"suppliers": "الموردون",
- "marketplace": "الإعدادات"
+ "marketplace": "الإعدادات",
+ "email_templates": "قوالب الرسائل"
},
"breadcrumbs": {
"marketplace": "السوق"
@@ -6115,6 +6150,158 @@
"page": {
"subtitle": "ما يدين به المتجر من أرصدة مدفوعة مسبقًا لجميع العملاء."
}
+ },
+ "email_templates": {
+ "tabs": {
+ "settings": "الإعدادات",
+ "templates": "القوالب"
+ },
+ "list": {
+ "description": "عدّل الرسائل التي يتلقاها العملاء. تُحفظ التغييرات كمسودة ولا تصل إلى العملاء إلا بعد نشرها.",
+ "groups": {
+ "email": {
+ "title": "رسائل العملاء",
+ "description": "كل رسالة يمكن أن يتلقاها العميل من متجرك."
+ },
+ "layout": {
+ "title": "التخطيط",
+ "description": "الترويسة والتذييل والأنماط حول كل رسالة للعملاء."
+ },
+ "partial": {
+ "title": "أجزاء مشتركة",
+ "description": "أجزاء تستخدمها عدة رسائل، مثل قائمة المنتجات والإجماليات."
+ }
+ },
+ "empty": "لا توجد هنا قوالب رسائل قابلة للتعديل. تأتي قوالب رسائل العملاء مع حزمة رسائل Spree."
+ },
+ "names": {
+ "order_mailer_confirm_email": "تأكيد الطلب",
+ "order_mailer_cancel_email": "إلغاء الطلب",
+ "order_mailer_payment_link_email": "رابط الدفع",
+ "order_group_mailer_confirm_email": "تأكيد طلب من عدة بائعين",
+ "fulfillment_mailer_fulfilled_email": "شحن الطلب",
+ "return_mailer_refunded_email": "استرداد المرتجع",
+ "digital_asset_mailer_files_ready_email": "التنزيلات جاهزة",
+ "customer_mailer_password_reset_email": "إعادة تعيين كلمة المرور",
+ "customer_mailer_data_export_email": "تصدير البيانات الشخصية جاهز",
+ "newsletter_mailer_email_confirmation": "تأكيد النشرة البريدية",
+ "company_mailer_invitation_email": "دعوة إلى شركة",
+ "spree_base_mailer": "تخطيط الرسائل",
+ "shared_line_item": "منتج",
+ "shared_order_summary": "ملخص الطلب",
+ "shared_purchase_totals": "الإجماليات",
+ "shared_fulfillment_group": "شحنة",
+ "shared_summary_row": "سطر الملخص"
+ },
+ "badges": {
+ "customized": "مخصص",
+ "default": "افتراضي",
+ "draft": "مسودة",
+ "default_updated": "حدّثه Spree",
+ "unsaved": "تغييرات غير محفوظة",
+ "showing_draft": "مسودة — يتلقى العملاء النسخة المنشورة",
+ "showing_published": "منشور — ما يتلقاه العملاء",
+ "showing_default": "القالب الافتراضي من Spree — ما يتلقاه العملاء"
+ },
+ "actions": {
+ "save_draft": "حفظ المسودة",
+ "publish": "نشر",
+ "discard_draft": "تجاهل المسودة",
+ "revert": "العودة إلى الافتراضي",
+ "send_test": "إرسال رسالة تجريبية",
+ "history": "السجل"
+ },
+ "confirm": {
+ "discard_title": "تجاهل هذه المسودة؟",
+ "discard_message": "ستُحذف تغييراتك غير المنشورة. يستمر العملاء في تلقي النسخة المنشورة.",
+ "revert_title": "العودة إلى القالب الافتراضي من Spree؟",
+ "revert_message": "سيتلقى العملاء من الآن رسالة Spree الافتراضية وستُحذف المسودة. تبقى النسخ المنشورة في السجل لتتمكن من استعادة إحداها لاحقًا.",
+ "restore_title": "استعادة هذه النسخة؟",
+ "restore_message": "تحل هذه النسخة محل المسودة. انشرها ليتلقاها العملاء."
+ },
+ "editor": {
+ "title": "القالب",
+ "subject": "الموضوع",
+ "body": "شيفرة القالب",
+ "language": "اللغة"
+ },
+ "languages": {
+ "any": "كل اللغات"
+ },
+ "preview": {
+ "title": "معاينة",
+ "frame_title": "معاينة الرسالة",
+ "subject": "الموضوع: {{subject}}",
+ "html": "الرسالة",
+ "text": "نص عادي",
+ "desktop": "عرض الحاسوب",
+ "mobile": "عرض الهاتف",
+ "shown_in": "عرض داخل",
+ "record": "معاينة باستخدام سجل",
+ "record_placeholder": "الأحدث، أو معرّف مثل or_m3Rp9wXz",
+ "unavailable": "تعذر عرض المعاينة."
+ },
+ "problems": {
+ "title": "لا يمكن عرض هذا القالب",
+ "on_line": "السطر {{line}}: {{message}}"
+ },
+ "default_update": {
+ "title": "حدّثه Spree",
+ "description": "غيّر Spree القالب الافتراضي منذ إنشاء نسختك منه. قارن بينهما قبل أن تقرر.",
+ "compare": "مقارنة",
+ "dialog_title": "ما الذي تغيّر في القالب الافتراضي من Spree",
+ "dialog_description": "على اليسار القالب الافتراضي الذي أُنشئت منه نسختك، وعلى اليمين القالب الافتراضي الحالي.",
+ "before": "بدأت نسختك من",
+ "after": "القالب الافتراضي الحالي من Spree",
+ "keep_mine": "الاحتفاظ بنسختي",
+ "start_over": "البدء من القالب الافتراضي الجديد"
+ },
+ "history": {
+ "title": "السجل",
+ "description": "كل نسخة نُشرت بهذه اللغة، الأحدث أولًا.",
+ "empty": "لم يُنشر أي شيء بعد.",
+ "latest": "الأحدث",
+ "version": "النسخة {{number}}",
+ "restore": "استعادة"
+ },
+ "conflict": {
+ "title": "حفظ شخص آخر هذه المسودة",
+ "keep_editing": "متابعة التعديل",
+ "reload": "تحميل نسخته"
+ },
+ "variables": {
+ "title": "المتغيرات",
+ "description": "البيانات التي يمكن أن تعرضها هذه الرسالة. ابدأ بكتابة متغير في الشيفرة لرؤية جميع حقوله.",
+ "order": "الطلب مع منتجاته وعناوينه وإجمالياته.",
+ "resend": "ما إذا كانت هذه نسخة أُعيد إرسالها.",
+ "payment_url": "الرابط الذي يدفع منه العميل.",
+ "order_group": "طلب مقسّم بين عدة بائعين.",
+ "fulfillment": "الشحنة مع رقم تتبعها.",
+ "return": "المرتجع وما تم استرداده.",
+ "downloads": "الملفات التي يمكن للعميل تنزيلها.",
+ "customer": "العميل الذي تُرسل إليه الرسالة.",
+ "reset_url": "رابط اختيار كلمة مرور جديدة.",
+ "download_url": "رابط تنزيل ملف التصدير.",
+ "expires_at": "متى يتوقف الرابط عن العمل.",
+ "confirmation_url": "الرابط الذي يؤكد الاشتراك.",
+ "company": "الشركة التي دُعي إليها العميل.",
+ "accept_url": "الرابط الذي يقبل الدعوة.",
+ "store": "متجرك: الاسم والروابط والشعار والهوية البصرية.",
+ "locale": "اللغة التي تُرسل بها الرسالة."
+ },
+ "messages": {
+ "draft_saved": "تم حفظ المسودة",
+ "draft_discarded": "تم تجاهل المسودة",
+ "published": "تم النشر. سيتلقى العملاء هذه النسخة من الآن.",
+ "reverted": "تمت العودة إلى القالب الافتراضي من Spree",
+ "restored": "تمت استعادة النسخة إلى المسودة",
+ "test_sent": "تم إرسال رسالة تجريبية إلى {{email}}"
+ },
+ "errors": {
+ "load_failed": "تعذر تحميل قوالب الرسائل",
+ "not_allowed": "ليست لديك صلاحية عرض قوالب الرسائل",
+ "test_email_failed": "تعذر إرسال الرسالة التجريبية"
+ }
}
}
}
diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.json
index d3f2fbe6a3..8035d78974 100644
--- a/packages/dashboard/src/locales/de.json
+++ b/packages/dashboard/src/locales/de.json
@@ -2143,6 +2143,25 @@
"label": "Standardsteuer auf Provision",
"help": "Wird auf Ihre Provision berechnet, wenn weder der Provisionssatz noch Ihr Steueranbieter einen eigenen Satz nennt. Bei 0 belassen, wenn auf Ihre Gebühr keine Steuer anfällt.",
"suffix": "%"
+ },
+ "preferred_email_accent_color": {
+ "label": "Akzentfarbe"
+ },
+ "preferred_email_background_color": {
+ "label": "Hintergrundfarbe"
+ },
+ "preferred_email_card_color": {
+ "label": "Kartenfarbe"
+ },
+ "preferred_email_text_color": {
+ "label": "Textfarbe"
+ },
+ "preferred_email_heading_color": {
+ "label": "Überschriftenfarbe"
+ },
+ "preferred_email_font": {
+ "label": "Schrift",
+ "help": "E-Mail-Programme, die sie nicht laden können, verwenden eine ähnliche Schrift."
}
},
"store_credit": {
@@ -3805,7 +3824,21 @@
"section_delivery": "Zustellung",
"section_logo": "Logo",
"subtitle": "Absenderadressen, Benachrichtigungen und das in Transaktions-E-Mails eingebettete Logo.",
- "title": "E-Mail-Einstellungen"
+ "title": "E-Mail-Einstellungen",
+ "branding": {
+ "title": "Branding",
+ "description": "Farben und Schrift für jede Kunden-E-Mail. Lassen Sie eine Farbe leer, um den Standard zu behalten.",
+ "default_color": "Standard",
+ "fonts": {
+ "inter": "Inter (Standard)",
+ "system": "Systemschrift",
+ "helvetica": "Helvetica",
+ "georgia": "Georgia",
+ "roboto": "Roboto",
+ "lato": "Lato",
+ "merriweather": "Merriweather"
+ }
+ }
},
"imports": {
"delete_confirm": {
@@ -5081,7 +5114,8 @@
"webhooks": "Endpunkte, die bei Ereignissen benachrichtigt werden",
"package_types": "Kartons, Paletten und Container",
"suppliers": "Von wem Sie Ware einkaufen und wie Sie sie erreichen",
- "marketplace": "Auszahlungen, Verkäuferfreigabe, Verkäufer-E-Mails und Steuer auf Provision"
+ "marketplace": "Auszahlungen, Verkäuferfreigabe, Verkäufer-E-Mails und Steuer auf Provision",
+ "email_templates": "Die E-Mails bearbeiten, die Kunden erhalten"
},
"groups": {
"audit": "Audit",
@@ -5119,7 +5153,8 @@
"webhooks": "Webhooks",
"package_types": "Verpackungsarten",
"suppliers": "Lieferanten",
- "marketplace": "Einstellungen"
+ "marketplace": "Einstellungen",
+ "email_templates": "E-Mail-Vorlagen"
},
"breadcrumbs": {
"marketplace": "Marktplatz"
@@ -6075,6 +6110,158 @@
"page": {
"subtitle": "Was der Shop an Guthaben schuldet, über alle Kunden hinweg."
}
+ },
+ "email_templates": {
+ "tabs": {
+ "settings": "Einstellungen",
+ "templates": "Vorlagen"
+ },
+ "list": {
+ "description": "Bearbeiten Sie die E-Mails, die Kunden erhalten. Änderungen werden als Entwurf gespeichert und erreichen Kunden erst nach dem Veröffentlichen.",
+ "groups": {
+ "email": {
+ "title": "Kunden-E-Mails",
+ "description": "Jede E-Mail, die ein Kunde von Ihrem Shop erhalten kann."
+ },
+ "layout": {
+ "title": "Layout",
+ "description": "Kopfzeile, Fußzeile und Stile rund um jede Kunden-E-Mail."
+ },
+ "partial": {
+ "title": "Gemeinsame Bausteine",
+ "description": "Teile, die mehrere E-Mails verwenden, etwa die Artikelliste und die Summen."
+ }
+ },
+ "empty": "Hier lassen sich keine E-Mail-Vorlagen bearbeiten. Kunden-E-Mail-Vorlagen kommen mit dem Spree-E-Mail-Paket."
+ },
+ "names": {
+ "order_mailer_confirm_email": "Bestellbestätigung",
+ "order_mailer_cancel_email": "Bestellung storniert",
+ "order_mailer_payment_link_email": "Zahlungslink",
+ "order_group_mailer_confirm_email": "Bestellbestätigung mit mehreren Verkäufern",
+ "fulfillment_mailer_fulfilled_email": "Bestellung versandt",
+ "return_mailer_refunded_email": "Rücksendung erstattet",
+ "digital_asset_mailer_files_ready_email": "Downloads bereit",
+ "customer_mailer_password_reset_email": "Passwort zurücksetzen",
+ "customer_mailer_data_export_email": "Export persönlicher Daten bereit",
+ "newsletter_mailer_email_confirmation": "Newsletter-Bestätigung",
+ "company_mailer_invitation_email": "Firmeneinladung",
+ "spree_base_mailer": "E-Mail-Layout",
+ "shared_line_item": "Artikel",
+ "shared_order_summary": "Bestellübersicht",
+ "shared_purchase_totals": "Summen",
+ "shared_fulfillment_group": "Sendung",
+ "shared_summary_row": "Übersichtszeile"
+ },
+ "badges": {
+ "customized": "Angepasst",
+ "default": "Standard",
+ "draft": "Entwurf",
+ "default_updated": "Von Spree aktualisiert",
+ "unsaved": "Ungespeicherte Änderungen",
+ "showing_draft": "Entwurf – Kunden erhalten die veröffentlichte Version",
+ "showing_published": "Veröffentlicht – das erhalten Kunden",
+ "showing_default": "Spree-Standard – das erhalten Kunden"
+ },
+ "actions": {
+ "save_draft": "Entwurf speichern",
+ "publish": "Veröffentlichen",
+ "discard_draft": "Entwurf verwerfen",
+ "revert": "Auf Standard zurücksetzen",
+ "send_test": "Test-E-Mail senden",
+ "history": "Verlauf"
+ },
+ "confirm": {
+ "discard_title": "Diesen Entwurf verwerfen?",
+ "discard_message": "Ihre unveröffentlichten Änderungen werden gelöscht. Kunden erhalten weiterhin die veröffentlichte Version.",
+ "revert_title": "Auf den Spree-Standard zurücksetzen?",
+ "revert_message": "Kunden erhalten ab sofort die Standard-E-Mail von Spree und der Entwurf wird gelöscht. Veröffentlichte Versionen bleiben im Verlauf, sodass Sie eine später wiederherstellen können.",
+ "restore_title": "Diese Version wiederherstellen?",
+ "restore_message": "Diese Version ersetzt den Entwurf. Veröffentlichen Sie sie, damit Kunden sie erhalten."
+ },
+ "editor": {
+ "title": "Vorlage",
+ "subject": "Betreff",
+ "body": "Vorlagencode",
+ "language": "Sprache"
+ },
+ "languages": {
+ "any": "Alle Sprachen"
+ },
+ "preview": {
+ "title": "Vorschau",
+ "frame_title": "E-Mail-Vorschau",
+ "subject": "Betreff: {{subject}}",
+ "html": "E-Mail",
+ "text": "Nur Text",
+ "desktop": "Desktop-Breite",
+ "mobile": "Mobile Breite",
+ "shown_in": "Anzeigen in",
+ "record": "Vorschau mit Datensatz",
+ "record_placeholder": "Neuester oder eine ID wie or_m3Rp9wXz",
+ "unavailable": "Die Vorschau konnte nicht angezeigt werden."
+ },
+ "problems": {
+ "title": "Diese Vorlage lässt sich nicht darstellen",
+ "on_line": "Zeile {{line}}: {{message}}"
+ },
+ "default_update": {
+ "title": "Von Spree aktualisiert",
+ "description": "Spree hat den Standard dieser Vorlage geändert, seit Ihre Version daraus entstanden ist. Vergleichen Sie beide, bevor Sie sich entscheiden.",
+ "compare": "Vergleichen",
+ "dialog_title": "Was sich am Spree-Standard geändert hat",
+ "dialog_description": "Links der Standard, aus dem Ihre Version entstanden ist. Rechts der aktuelle Standard.",
+ "before": "Ihre Version basiert auf",
+ "after": "Aktueller Spree-Standard",
+ "keep_mine": "Meine Version behalten",
+ "start_over": "Mit dem neuen Standard beginnen"
+ },
+ "history": {
+ "title": "Verlauf",
+ "description": "Jede in dieser Sprache veröffentlichte Version, die neueste zuerst.",
+ "empty": "Noch nichts veröffentlicht.",
+ "latest": "Neueste",
+ "version": "Version {{number}}",
+ "restore": "Wiederherstellen"
+ },
+ "conflict": {
+ "title": "Jemand anderes hat diesen Entwurf gespeichert",
+ "keep_editing": "Weiter bearbeiten",
+ "reload": "Deren Version laden"
+ },
+ "variables": {
+ "title": "Variablen",
+ "description": "Daten, die diese E-Mail anzeigen kann. Beginnen Sie im Code eine Variable zu tippen, um alle ihre Felder zu sehen.",
+ "order": "Die Bestellung mit Artikeln, Adressen und Summen.",
+ "resend": "Ob es sich um eine erneut gesendete Kopie handelt.",
+ "payment_url": "Der Link, über den der Kunde bezahlt.",
+ "order_group": "Eine auf mehrere Verkäufer aufgeteilte Bestellung.",
+ "fulfillment": "Die Sendung mit ihrer Sendungsverfolgung.",
+ "return": "Die Rücksendung und was erstattet wurde.",
+ "downloads": "Die Dateien, die der Kunde herunterladen kann.",
+ "customer": "Der Kunde, an den die E-Mail geht.",
+ "reset_url": "Der Link zum Festlegen eines neuen Passworts.",
+ "download_url": "Der Link zum Herunterladen des Exports.",
+ "expires_at": "Wann der Link nicht mehr funktioniert.",
+ "confirmation_url": "Der Link, der das Abonnement bestätigt.",
+ "company": "Die Firma, zu der der Kunde eingeladen ist.",
+ "accept_url": "Der Link, der die Einladung annimmt.",
+ "store": "Ihr Shop: Name, Links, Logo und Branding.",
+ "locale": "Die Sprache, in der die E-Mail gesendet wird."
+ },
+ "messages": {
+ "draft_saved": "Entwurf gespeichert",
+ "draft_discarded": "Entwurf verworfen",
+ "published": "Veröffentlicht. Kunden erhalten ab sofort diese Version.",
+ "reverted": "Auf den Spree-Standard zurückgesetzt",
+ "restored": "Version in den Entwurf übernommen",
+ "test_sent": "Test-E-Mail an {{email}} gesendet"
+ },
+ "errors": {
+ "load_failed": "E-Mail-Vorlagen konnten nicht geladen werden",
+ "not_allowed": "Sie dürfen E-Mail-Vorlagen nicht ansehen",
+ "test_email_failed": "Die Test-E-Mail konnte nicht gesendet werden"
+ }
}
}
}
diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.json
index ac51e7a49b..83f97437a3 100644
--- a/packages/dashboard/src/locales/en.json
+++ b/packages/dashboard/src/locales/en.json
@@ -2143,6 +2143,25 @@
"label": "Default tax on commission",
"help": "Charged on your commission when neither the commission rate nor your tax provider gives a rate of its own. Leave at 0 if you charge no tax on your fee.",
"suffix": "%"
+ },
+ "preferred_email_accent_color": {
+ "label": "Accent color"
+ },
+ "preferred_email_background_color": {
+ "label": "Background color"
+ },
+ "preferred_email_card_color": {
+ "label": "Card color"
+ },
+ "preferred_email_text_color": {
+ "label": "Text color"
+ },
+ "preferred_email_heading_color": {
+ "label": "Heading color"
+ },
+ "preferred_email_font": {
+ "label": "Font",
+ "help": "Email apps that can't load it fall back to a similar font."
}
},
"store_credit": {
@@ -3805,7 +3824,21 @@
"section_delivery": "Delivery",
"section_logo": "Logo",
"subtitle": "Sender addresses, notifications, and the logo embedded in transactional emails.",
- "title": "Email settings"
+ "title": "Email settings",
+ "branding": {
+ "title": "Branding",
+ "description": "Colors and font for every customer email. Leave a color empty to keep the default.",
+ "default_color": "Default",
+ "fonts": {
+ "inter": "Inter (default)",
+ "system": "System font",
+ "helvetica": "Helvetica",
+ "georgia": "Georgia",
+ "roboto": "Roboto",
+ "lato": "Lato",
+ "merriweather": "Merriweather"
+ }
+ }
},
"imports": {
"delete_confirm": {
@@ -5081,7 +5114,8 @@
"webhooks": "Endpoints notified when events happen",
"package_types": "Boxes, cartons, pallets and containers",
"suppliers": "Who you buy stock from, and how to reach them",
- "marketplace": "Seller payouts, seller approval, seller emails and commission tax"
+ "marketplace": "Seller payouts, seller approval, seller emails and commission tax",
+ "email_templates": "Edit the emails customers receive"
},
"groups": {
"audit": "Audit",
@@ -5119,7 +5153,8 @@
"webhooks": "Webhooks",
"package_types": "Package types",
"suppliers": "Suppliers",
- "marketplace": "Settings"
+ "marketplace": "Settings",
+ "email_templates": "Email templates"
},
"breadcrumbs": {
"marketplace": "Marketplace"
@@ -6075,6 +6110,158 @@
"page": {
"subtitle": "What the store owes in prepaid balances, across every customer."
}
+ },
+ "email_templates": {
+ "tabs": {
+ "settings": "Settings",
+ "templates": "Templates"
+ },
+ "list": {
+ "description": "Edit the emails customers receive. Changes are saved as a draft and reach customers only when you publish them.",
+ "groups": {
+ "email": {
+ "title": "Customer emails",
+ "description": "Each email a customer can receive from your store."
+ },
+ "layout": {
+ "title": "Layout",
+ "description": "The header, footer and styles around every customer email."
+ },
+ "partial": {
+ "title": "Shared blocks",
+ "description": "Pieces used by several emails, such as the list of items and the totals."
+ }
+ },
+ "empty": "No email templates can be edited here. Customer email templates come with the Spree emails package."
+ },
+ "names": {
+ "order_mailer_confirm_email": "Order confirmation",
+ "order_mailer_cancel_email": "Order canceled",
+ "order_mailer_payment_link_email": "Payment link",
+ "order_group_mailer_confirm_email": "Multi-seller order confirmation",
+ "fulfillment_mailer_fulfilled_email": "Order shipped",
+ "return_mailer_refunded_email": "Return refunded",
+ "digital_asset_mailer_files_ready_email": "Downloads ready",
+ "customer_mailer_password_reset_email": "Password reset",
+ "customer_mailer_data_export_email": "Personal data export ready",
+ "newsletter_mailer_email_confirmation": "Newsletter confirmation",
+ "company_mailer_invitation_email": "Company invitation",
+ "spree_base_mailer": "Email layout",
+ "shared_line_item": "Item",
+ "shared_order_summary": "Order summary",
+ "shared_purchase_totals": "Totals",
+ "shared_fulfillment_group": "Shipment",
+ "shared_summary_row": "Summary row"
+ },
+ "badges": {
+ "customized": "Customized",
+ "default": "Default",
+ "draft": "Draft",
+ "default_updated": "Updated by Spree",
+ "unsaved": "Unsaved changes",
+ "showing_draft": "Draft — customers receive the published version",
+ "showing_published": "Published — what customers receive",
+ "showing_default": "Spree's default — what customers receive"
+ },
+ "actions": {
+ "save_draft": "Save draft",
+ "publish": "Publish",
+ "discard_draft": "Discard draft",
+ "revert": "Revert to default",
+ "send_test": "Send test email",
+ "history": "History"
+ },
+ "confirm": {
+ "discard_title": "Discard this draft?",
+ "discard_message": "Your unpublished changes are deleted. Customers keep receiving the published version.",
+ "revert_title": "Revert to Spree's default?",
+ "revert_message": "Customers receive Spree's default email from now on and the draft is deleted. Published versions stay in the history, so you can restore one later.",
+ "restore_title": "Restore this version?",
+ "restore_message": "This version replaces the draft. Publish it for customers to receive it."
+ },
+ "editor": {
+ "title": "Template",
+ "subject": "Subject",
+ "body": "Template code",
+ "language": "Language"
+ },
+ "languages": {
+ "any": "All languages"
+ },
+ "preview": {
+ "title": "Preview",
+ "frame_title": "Email preview",
+ "subject": "Subject: {{subject}}",
+ "html": "Email",
+ "text": "Plain text",
+ "desktop": "Desktop width",
+ "mobile": "Mobile width",
+ "shown_in": "Show inside",
+ "record": "Preview with record",
+ "record_placeholder": "Latest, or an ID such as or_m3Rp9wXz",
+ "unavailable": "The preview could not be shown."
+ },
+ "problems": {
+ "title": "This template does not render",
+ "on_line": "Line {{line}}: {{message}}"
+ },
+ "default_update": {
+ "title": "Updated by Spree",
+ "description": "Spree changed its default for this template since your version was made from it. Compare the two before you decide.",
+ "compare": "Compare",
+ "dialog_title": "What changed in Spree's default",
+ "dialog_description": "On the left, the default your version was made from. On the right, the default now.",
+ "before": "Your version started from",
+ "after": "Spree's default now",
+ "keep_mine": "Keep my version",
+ "start_over": "Start from the new default"
+ },
+ "history": {
+ "title": "History",
+ "description": "Every version published in this language, newest first.",
+ "empty": "Nothing has been published yet.",
+ "latest": "Latest",
+ "version": "Version {{number}}",
+ "restore": "Restore"
+ },
+ "conflict": {
+ "title": "Someone else saved this draft",
+ "keep_editing": "Keep editing",
+ "reload": "Load their version"
+ },
+ "variables": {
+ "title": "Variables",
+ "description": "Data this email can show. Start typing a variable in the code to see all of its fields.",
+ "order": "The order, with its items, addresses and totals.",
+ "resend": "Whether this is a copy sent again.",
+ "payment_url": "The link where the customer pays.",
+ "order_group": "An order split across several sellers.",
+ "fulfillment": "The shipment, with its tracking.",
+ "return": "The return and what was refunded.",
+ "downloads": "The files the customer can download.",
+ "customer": "The customer the email goes to.",
+ "reset_url": "The link to choose a new password.",
+ "download_url": "The link to download the export.",
+ "expires_at": "When the link stops working.",
+ "confirmation_url": "The link that confirms the subscription.",
+ "company": "The company the customer is invited to.",
+ "accept_url": "The link that accepts the invitation.",
+ "store": "Your store: name, links, logo and branding.",
+ "locale": "The language the email is sent in."
+ },
+ "messages": {
+ "draft_saved": "Draft saved",
+ "draft_discarded": "Draft discarded",
+ "published": "Published. Customers receive this version from now on.",
+ "reverted": "Reverted to Spree's default",
+ "restored": "Version restored into the draft",
+ "test_sent": "Test email sent to {{email}}"
+ },
+ "errors": {
+ "load_failed": "Couldn't load email templates",
+ "not_allowed": "You don't have permission to view email templates",
+ "test_email_failed": "Couldn't send the test email"
+ }
}
}
}
diff --git a/packages/dashboard/src/locales/es.json b/packages/dashboard/src/locales/es.json
index d3f0ea672a..aa9e71fd6b 100644
--- a/packages/dashboard/src/locales/es.json
+++ b/packages/dashboard/src/locales/es.json
@@ -469,7 +469,21 @@
"section_delivery": "Entrega",
"section_logo": "Logo",
"subtitle": "Direcciones de remitente, notificaciones y el logo incorporado en los emails transaccionales.",
- "title": "Configuración de email"
+ "title": "Configuración de email",
+ "branding": {
+ "title": "Marca",
+ "description": "Colores y fuente de cada correo para clientes. Deja un color vacío para mantener el predeterminado.",
+ "default_color": "Predeterminado",
+ "fonts": {
+ "inter": "Inter (predeterminada)",
+ "system": "Fuente del sistema",
+ "helvetica": "Helvetica",
+ "georgia": "Georgia",
+ "roboto": "Roboto",
+ "lato": "Lato",
+ "merriweather": "Merriweather"
+ }
+ }
},
"imports": {
"delete_confirm": {
@@ -2168,6 +2182,25 @@
"label": "Impuesto predeterminado sobre la comisión",
"help": "Se aplica a tu comisión cuando ni la tarifa de comisión ni tu proveedor de impuestos indican una propia. Déjalo en 0 si tu comisión no lleva impuesto.",
"suffix": "%"
+ },
+ "preferred_email_accent_color": {
+ "label": "Color de acento"
+ },
+ "preferred_email_background_color": {
+ "label": "Color de fondo"
+ },
+ "preferred_email_card_color": {
+ "label": "Color de la tarjeta"
+ },
+ "preferred_email_text_color": {
+ "label": "Color del texto"
+ },
+ "preferred_email_heading_color": {
+ "label": "Color de los títulos"
+ },
+ "preferred_email_font": {
+ "label": "Fuente",
+ "help": "Las aplicaciones de correo que no puedan cargarla usarán una fuente similar."
}
},
"store_credit": {
@@ -4152,7 +4185,8 @@
"webhooks": "Endpoints notificados cuando ocurren eventos",
"package_types": "Cajas, cajones, palets y contenedores",
"suppliers": "A quién le comprás stock y cómo contactarlos",
- "marketplace": "Pagos a vendedores, aprobación de vendedores, correos a vendedores e impuesto sobre la comisión"
+ "marketplace": "Pagos a vendedores, aprobación de vendedores, correos a vendedores e impuesto sobre la comisión",
+ "email_templates": "Edita los correos que reciben los clientes"
},
"groups": {
"audit": "Auditoría",
@@ -4190,7 +4224,8 @@
"webhooks": "Webhooks",
"package_types": "Tipos de empaque",
"suppliers": "Proveedores",
- "marketplace": "Configuración"
+ "marketplace": "Configuración",
+ "email_templates": "Plantillas de correo"
},
"breadcrumbs": {
"marketplace": "Marketplace"
@@ -6075,6 +6110,158 @@
},
"jurisdiction": {
"everywhere": "En todos lados"
+ },
+ "email_templates": {
+ "tabs": {
+ "settings": "Ajustes",
+ "templates": "Plantillas"
+ },
+ "list": {
+ "description": "Edita los correos que reciben los clientes. Los cambios se guardan como borrador y solo llegan a los clientes cuando los publicas.",
+ "groups": {
+ "email": {
+ "title": "Correos para clientes",
+ "description": "Cada correo que un cliente puede recibir de tu tienda."
+ },
+ "layout": {
+ "title": "Diseño",
+ "description": "El encabezado, el pie y los estilos de cada correo para clientes."
+ },
+ "partial": {
+ "title": "Bloques compartidos",
+ "description": "Piezas que usan varios correos, como la lista de artículos y los totales."
+ }
+ },
+ "empty": "Aquí no hay plantillas de correo editables. Las plantillas de correo para clientes vienen con el paquete de correos de Spree."
+ },
+ "names": {
+ "order_mailer_confirm_email": "Confirmación del pedido",
+ "order_mailer_cancel_email": "Pedido cancelado",
+ "order_mailer_payment_link_email": "Enlace de pago",
+ "order_group_mailer_confirm_email": "Confirmación de pedido con varios vendedores",
+ "fulfillment_mailer_fulfilled_email": "Pedido enviado",
+ "return_mailer_refunded_email": "Devolución reembolsada",
+ "digital_asset_mailer_files_ready_email": "Descargas listas",
+ "customer_mailer_password_reset_email": "Restablecer contraseña",
+ "customer_mailer_data_export_email": "Exportación de datos personales lista",
+ "newsletter_mailer_email_confirmation": "Confirmación del boletín",
+ "company_mailer_invitation_email": "Invitación de empresa",
+ "spree_base_mailer": "Diseño del correo",
+ "shared_line_item": "Artículo",
+ "shared_order_summary": "Resumen del pedido",
+ "shared_purchase_totals": "Totales",
+ "shared_fulfillment_group": "Envío",
+ "shared_summary_row": "Fila de resumen"
+ },
+ "badges": {
+ "customized": "Personalizada",
+ "default": "Predeterminada",
+ "draft": "Borrador",
+ "default_updated": "Actualizada por Spree",
+ "unsaved": "Cambios sin guardar",
+ "showing_draft": "Borrador: los clientes reciben la versión publicada",
+ "showing_published": "Publicada: lo que reciben los clientes",
+ "showing_default": "Predeterminada de Spree: lo que reciben los clientes"
+ },
+ "actions": {
+ "save_draft": "Guardar borrador",
+ "publish": "Publicar",
+ "discard_draft": "Descartar borrador",
+ "revert": "Volver a la predeterminada",
+ "send_test": "Enviar correo de prueba",
+ "history": "Historial"
+ },
+ "confirm": {
+ "discard_title": "¿Descartar este borrador?",
+ "discard_message": "Se eliminan tus cambios sin publicar. Los clientes siguen recibiendo la versión publicada.",
+ "revert_title": "¿Volver a la versión predeterminada de Spree?",
+ "revert_message": "A partir de ahora los clientes reciben el correo predeterminado de Spree y se elimina el borrador. Las versiones publicadas quedan en el historial para restaurarlas más tarde.",
+ "restore_title": "¿Restaurar esta versión?",
+ "restore_message": "Esta versión reemplaza el borrador. Publícala para que la reciban los clientes."
+ },
+ "editor": {
+ "title": "Plantilla",
+ "subject": "Asunto",
+ "body": "Código de la plantilla",
+ "language": "Idioma"
+ },
+ "languages": {
+ "any": "Todos los idiomas"
+ },
+ "preview": {
+ "title": "Vista previa",
+ "frame_title": "Vista previa del correo",
+ "subject": "Asunto: {{subject}}",
+ "html": "Correo",
+ "text": "Texto sin formato",
+ "desktop": "Ancho de escritorio",
+ "mobile": "Ancho móvil",
+ "shown_in": "Mostrar dentro de",
+ "record": "Vista previa con registro",
+ "record_placeholder": "El más reciente o un ID como or_m3Rp9wXz",
+ "unavailable": "No se pudo mostrar la vista previa."
+ },
+ "problems": {
+ "title": "Esta plantilla no se puede mostrar",
+ "on_line": "Línea {{line}}: {{message}}"
+ },
+ "default_update": {
+ "title": "Actualizada por Spree",
+ "description": "Spree cambió su versión predeterminada de esta plantilla desde que se creó la tuya. Compara ambas antes de decidir.",
+ "compare": "Comparar",
+ "dialog_title": "Qué cambió en la versión predeterminada de Spree",
+ "dialog_description": "A la izquierda, la predeterminada de la que partió tu versión. A la derecha, la predeterminada actual.",
+ "before": "Tu versión partió de",
+ "after": "Predeterminada actual de Spree",
+ "keep_mine": "Conservar mi versión",
+ "start_over": "Empezar desde la nueva predeterminada"
+ },
+ "history": {
+ "title": "Historial",
+ "description": "Cada versión publicada en este idioma, de la más reciente a la más antigua.",
+ "empty": "Aún no se ha publicado nada.",
+ "latest": "Más reciente",
+ "version": "Versión {{number}}",
+ "restore": "Restaurar"
+ },
+ "conflict": {
+ "title": "Otra persona guardó este borrador",
+ "keep_editing": "Seguir editando",
+ "reload": "Cargar su versión"
+ },
+ "variables": {
+ "title": "Variables",
+ "description": "Datos que puede mostrar este correo. Empieza a escribir una variable en el código para ver todos sus campos.",
+ "order": "El pedido, con sus artículos, direcciones y totales.",
+ "resend": "Si es una copia enviada de nuevo.",
+ "payment_url": "El enlace donde paga el cliente.",
+ "order_group": "Un pedido repartido entre varios vendedores.",
+ "fulfillment": "El envío, con su seguimiento.",
+ "return": "La devolución y lo reembolsado.",
+ "downloads": "Los archivos que puede descargar el cliente.",
+ "customer": "El cliente que recibe el correo.",
+ "reset_url": "El enlace para elegir una nueva contraseña.",
+ "download_url": "El enlace para descargar la exportación.",
+ "expires_at": "Cuándo deja de funcionar el enlace.",
+ "confirmation_url": "El enlace que confirma la suscripción.",
+ "company": "La empresa a la que se invita al cliente.",
+ "accept_url": "El enlace que acepta la invitación.",
+ "store": "Tu tienda: nombre, enlaces, logotipo y marca.",
+ "locale": "El idioma en que se envía el correo."
+ },
+ "messages": {
+ "draft_saved": "Borrador guardado",
+ "draft_discarded": "Borrador descartado",
+ "published": "Publicada. Los clientes reciben esta versión a partir de ahora.",
+ "reverted": "Se volvió a la versión predeterminada de Spree",
+ "restored": "Versión restaurada en el borrador",
+ "test_sent": "Correo de prueba enviado a {{email}}"
+ },
+ "errors": {
+ "load_failed": "No se pudieron cargar las plantillas de correo",
+ "not_allowed": "No tienes permiso para ver las plantillas de correo",
+ "test_email_failed": "No se pudo enviar el correo de prueba"
+ }
}
}
}
diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.json
index cecf35ecd5..062960bbec 100644
--- a/packages/dashboard/src/locales/fr.json
+++ b/packages/dashboard/src/locales/fr.json
@@ -2143,6 +2143,25 @@
"label": "Taxe par défaut sur la commission",
"help": "Appliquée à votre commission quand ni le taux de commission ni votre fournisseur de taxes n’indique son propre taux. Laissez 0 si votre commission n’est pas taxée.",
"suffix": "%"
+ },
+ "preferred_email_accent_color": {
+ "label": "Couleur d'accent"
+ },
+ "preferred_email_background_color": {
+ "label": "Couleur de fond"
+ },
+ "preferred_email_card_color": {
+ "label": "Couleur de la carte"
+ },
+ "preferred_email_text_color": {
+ "label": "Couleur du texte"
+ },
+ "preferred_email_heading_color": {
+ "label": "Couleur des titres"
+ },
+ "preferred_email_font": {
+ "label": "Police",
+ "help": "Les applications de messagerie qui ne peuvent pas la charger utilisent une police similaire."
}
},
"store_credit": {
@@ -3805,7 +3824,21 @@
"section_delivery": "Distribution",
"section_logo": "Logo",
"subtitle": "Adresses d'expéditeur, notifications et logo intégré aux e-mails transactionnels.",
- "title": "Paramètres d'e-mail"
+ "title": "Paramètres d'e-mail",
+ "branding": {
+ "title": "Image de marque",
+ "description": "Couleurs et police de chaque e-mail client. Laissez une couleur vide pour garder celle par défaut.",
+ "default_color": "Par défaut",
+ "fonts": {
+ "inter": "Inter (par défaut)",
+ "system": "Police du système",
+ "helvetica": "Helvetica",
+ "georgia": "Georgia",
+ "roboto": "Roboto",
+ "lato": "Lato",
+ "merriweather": "Merriweather"
+ }
+ }
},
"imports": {
"delete_confirm": {
@@ -5081,7 +5114,8 @@
"webhooks": "Points de terminaison notifiés lors d'événements",
"package_types": "Cartons, palettes et conteneurs",
"suppliers": "À qui vous achetez votre stock, et comment les joindre",
- "marketplace": "Paiements, validation des vendeurs, e-mails vendeurs et taxe sur la commission"
+ "marketplace": "Paiements, validation des vendeurs, e-mails vendeurs et taxe sur la commission",
+ "email_templates": "Modifier les e-mails que reçoivent les clients"
},
"groups": {
"audit": "Audit",
@@ -5119,7 +5153,8 @@
"webhooks": "Webhooks",
"package_types": "Types d'emballage",
"suppliers": "Fournisseurs",
- "marketplace": "Paramètres"
+ "marketplace": "Paramètres",
+ "email_templates": "Modèles d'e-mail"
},
"breadcrumbs": {
"marketplace": "Marketplace"
@@ -6075,6 +6110,158 @@
"page": {
"subtitle": "Total des avoirs dus par la boutique, tous clients confondus."
}
+ },
+ "email_templates": {
+ "tabs": {
+ "settings": "Paramètres",
+ "templates": "Modèles"
+ },
+ "list": {
+ "description": "Modifiez les e-mails que reçoivent vos clients. Les modifications sont enregistrées en brouillon et n'atteignent les clients qu'une fois publiées.",
+ "groups": {
+ "email": {
+ "title": "E-mails clients",
+ "description": "Chaque e-mail qu'un client peut recevoir de votre boutique."
+ },
+ "layout": {
+ "title": "Mise en page",
+ "description": "L'en-tête, le pied de page et les styles autour de chaque e-mail client."
+ },
+ "partial": {
+ "title": "Blocs partagés",
+ "description": "Éléments utilisés par plusieurs e-mails, comme la liste des articles et les totaux."
+ }
+ },
+ "empty": "Aucun modèle d'e-mail n'est modifiable ici. Les modèles d'e-mails clients sont fournis par le paquet e-mails de Spree."
+ },
+ "names": {
+ "order_mailer_confirm_email": "Confirmation de commande",
+ "order_mailer_cancel_email": "Commande annulée",
+ "order_mailer_payment_link_email": "Lien de paiement",
+ "order_group_mailer_confirm_email": "Confirmation de commande multi-vendeurs",
+ "fulfillment_mailer_fulfilled_email": "Commande expédiée",
+ "return_mailer_refunded_email": "Retour remboursé",
+ "digital_asset_mailer_files_ready_email": "Téléchargements prêts",
+ "customer_mailer_password_reset_email": "Réinitialisation du mot de passe",
+ "customer_mailer_data_export_email": "Export des données personnelles prêt",
+ "newsletter_mailer_email_confirmation": "Confirmation de la newsletter",
+ "company_mailer_invitation_email": "Invitation d'entreprise",
+ "spree_base_mailer": "Mise en page des e-mails",
+ "shared_line_item": "Article",
+ "shared_order_summary": "Récapitulatif de commande",
+ "shared_purchase_totals": "Totaux",
+ "shared_fulfillment_group": "Expédition",
+ "shared_summary_row": "Ligne de récapitulatif"
+ },
+ "badges": {
+ "customized": "Personnalisé",
+ "default": "Par défaut",
+ "draft": "Brouillon",
+ "default_updated": "Mis à jour par Spree",
+ "unsaved": "Modifications non enregistrées",
+ "showing_draft": "Brouillon – les clients reçoivent la version publiée",
+ "showing_published": "Publié – ce que reçoivent les clients",
+ "showing_default": "Modèle par défaut de Spree – ce que reçoivent les clients"
+ },
+ "actions": {
+ "save_draft": "Enregistrer le brouillon",
+ "publish": "Publier",
+ "discard_draft": "Abandonner le brouillon",
+ "revert": "Revenir au modèle par défaut",
+ "send_test": "Envoyer un e-mail de test",
+ "history": "Historique"
+ },
+ "confirm": {
+ "discard_title": "Abandonner ce brouillon ?",
+ "discard_message": "Vos modifications non publiées sont supprimées. Les clients continuent de recevoir la version publiée.",
+ "revert_title": "Revenir au modèle par défaut de Spree ?",
+ "revert_message": "Les clients reçoivent désormais l'e-mail par défaut de Spree et le brouillon est supprimé. Les versions publiées restent dans l'historique pour être restaurées plus tard.",
+ "restore_title": "Restaurer cette version ?",
+ "restore_message": "Cette version remplace le brouillon. Publiez-la pour que les clients la reçoivent."
+ },
+ "editor": {
+ "title": "Modèle",
+ "subject": "Objet",
+ "body": "Code du modèle",
+ "language": "Langue"
+ },
+ "languages": {
+ "any": "Toutes les langues"
+ },
+ "preview": {
+ "title": "Aperçu",
+ "frame_title": "Aperçu de l'e-mail",
+ "subject": "Objet : {{subject}}",
+ "html": "E-mail",
+ "text": "Texte brut",
+ "desktop": "Largeur ordinateur",
+ "mobile": "Largeur mobile",
+ "shown_in": "Afficher dans",
+ "record": "Aperçu avec l'enregistrement",
+ "record_placeholder": "Le plus récent, ou un ID comme or_m3Rp9wXz",
+ "unavailable": "L'aperçu n'a pas pu être affiché."
+ },
+ "problems": {
+ "title": "Ce modèle ne s'affiche pas",
+ "on_line": "Ligne {{line}} : {{message}}"
+ },
+ "default_update": {
+ "title": "Mis à jour par Spree",
+ "description": "Spree a modifié son modèle par défaut depuis que votre version en a été tirée. Comparez les deux avant de décider.",
+ "compare": "Comparer",
+ "dialog_title": "Ce qui a changé dans le modèle par défaut de Spree",
+ "dialog_description": "À gauche, le modèle par défaut dont votre version est issue. À droite, le modèle par défaut actuel.",
+ "before": "Votre version est issue de",
+ "after": "Modèle par défaut actuel de Spree",
+ "keep_mine": "Garder ma version",
+ "start_over": "Repartir du nouveau modèle"
+ },
+ "history": {
+ "title": "Historique",
+ "description": "Chaque version publiée dans cette langue, de la plus récente à la plus ancienne.",
+ "empty": "Rien n'a encore été publié.",
+ "latest": "La plus récente",
+ "version": "Version {{number}}",
+ "restore": "Restaurer"
+ },
+ "conflict": {
+ "title": "Quelqu'un d'autre a enregistré ce brouillon",
+ "keep_editing": "Continuer la modification",
+ "reload": "Charger sa version"
+ },
+ "variables": {
+ "title": "Variables",
+ "description": "Les données que cet e-mail peut afficher. Commencez à saisir une variable dans le code pour voir tous ses champs.",
+ "order": "La commande, avec ses articles, adresses et totaux.",
+ "resend": "S'il s'agit d'une copie renvoyée.",
+ "payment_url": "Le lien où le client paie.",
+ "order_group": "Une commande répartie entre plusieurs vendeurs.",
+ "fulfillment": "L'expédition et son suivi.",
+ "return": "Le retour et ce qui a été remboursé.",
+ "downloads": "Les fichiers que le client peut télécharger.",
+ "customer": "Le client destinataire de l'e-mail.",
+ "reset_url": "Le lien pour choisir un nouveau mot de passe.",
+ "download_url": "Le lien pour télécharger l'export.",
+ "expires_at": "Quand le lien cesse de fonctionner.",
+ "confirmation_url": "Le lien qui confirme l'abonnement.",
+ "company": "L'entreprise à laquelle le client est invité.",
+ "accept_url": "Le lien qui accepte l'invitation.",
+ "store": "Votre boutique : nom, liens, logo et image de marque.",
+ "locale": "La langue dans laquelle l'e-mail est envoyé."
+ },
+ "messages": {
+ "draft_saved": "Brouillon enregistré",
+ "draft_discarded": "Brouillon abandonné",
+ "published": "Publié. Les clients reçoivent désormais cette version.",
+ "reverted": "Retour au modèle par défaut de Spree",
+ "restored": "Version restaurée dans le brouillon",
+ "test_sent": "E-mail de test envoyé à {{email}}"
+ },
+ "errors": {
+ "load_failed": "Impossible de charger les modèles d'e-mail",
+ "not_allowed": "Vous n'avez pas l'autorisation de voir les modèles d'e-mail",
+ "test_email_failed": "Impossible d'envoyer l'e-mail de test"
+ }
}
}
}
diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.json
index b569d9ee6e..16a1c94968 100644
--- a/packages/dashboard/src/locales/pl.json
+++ b/packages/dashboard/src/locales/pl.json
@@ -2161,6 +2161,25 @@
"label": "Domyślny podatek od prowizji",
"help": "Naliczany od Twojej prowizji, gdy ani stawka prowizji, ani dostawca podatków nie podaje własnej stawki. Zostaw 0, jeśli Twoja prowizja nie jest opodatkowana.",
"suffix": "%"
+ },
+ "preferred_email_accent_color": {
+ "label": "Kolor akcentu"
+ },
+ "preferred_email_background_color": {
+ "label": "Kolor tła"
+ },
+ "preferred_email_card_color": {
+ "label": "Kolor karty"
+ },
+ "preferred_email_text_color": {
+ "label": "Kolor tekstu"
+ },
+ "preferred_email_heading_color": {
+ "label": "Kolor nagłówków"
+ },
+ "preferred_email_font": {
+ "label": "Czcionka",
+ "help": "Programy pocztowe, które nie mogą jej wczytać, użyją podobnej czcionki."
}
},
"store_credit": {
@@ -3853,7 +3872,21 @@
"section_delivery": "Dostarczanie",
"section_logo": "Logo",
"subtitle": "Adresy nadawców, powiadomienia i logo umieszczane w e-mailach transakcyjnych.",
- "title": "Ustawienia e-mail"
+ "title": "Ustawienia e-mail",
+ "branding": {
+ "title": "Wygląd marki",
+ "description": "Kolory i czcionka każdego e-maila do klienta. Zostaw kolor pusty, aby zachować domyślny.",
+ "default_color": "Domyślny",
+ "fonts": {
+ "inter": "Inter (domyślna)",
+ "system": "Czcionka systemowa",
+ "helvetica": "Helvetica",
+ "georgia": "Georgia",
+ "roboto": "Roboto",
+ "lato": "Lato",
+ "merriweather": "Merriweather"
+ }
+ }
},
"imports": {
"delete_confirm": {
@@ -5145,7 +5178,8 @@
"webhooks": "Adresy powiadamiane o zdarzeniach",
"package_types": "Kartony, palety i kontenery",
"suppliers": "Od kogo kupujesz towar i jak się z nimi skontaktować",
- "marketplace": "Wypłaty, zatwierdzanie sprzedawców, e-maile do sprzedawców i podatek od prowizji"
+ "marketplace": "Wypłaty, zatwierdzanie sprzedawców, e-maile do sprzedawców i podatek od prowizji",
+ "email_templates": "Edytuj e-maile, które otrzymują klienci"
},
"groups": {
"audit": "Audyt",
@@ -5183,7 +5217,8 @@
"webhooks": "Webhooki",
"package_types": "Rodzaje opakowań",
"suppliers": "Dostawcy",
- "marketplace": "Ustawienia"
+ "marketplace": "Ustawienia",
+ "email_templates": "Szablony e-maili"
},
"breadcrumbs": {
"marketplace": "Marketplace"
@@ -6143,6 +6178,158 @@
"page": {
"subtitle": "Ile sklep jest winien w środkach, w rozbiciu na wszystkich klientów."
}
+ },
+ "email_templates": {
+ "tabs": {
+ "settings": "Ustawienia",
+ "templates": "Szablony"
+ },
+ "list": {
+ "description": "Edytuj e-maile, które otrzymują klienci. Zmiany zapisują się jako szkic i docierają do klientów dopiero po opublikowaniu.",
+ "groups": {
+ "email": {
+ "title": "E-maile do klientów",
+ "description": "Każdy e-mail, który klient może otrzymać z Twojego sklepu."
+ },
+ "layout": {
+ "title": "Układ",
+ "description": "Nagłówek, stopka i style wokół każdego e-maila do klienta."
+ },
+ "partial": {
+ "title": "Wspólne bloki",
+ "description": "Elementy używane w kilku e-mailach, na przykład lista produktów i sumy."
+ }
+ },
+ "empty": "Nie ma tu szablonów e-maili do edycji. Szablony e-maili do klientów dostarcza pakiet e-maili Spree."
+ },
+ "names": {
+ "order_mailer_confirm_email": "Potwierdzenie zamówienia",
+ "order_mailer_cancel_email": "Zamówienie anulowane",
+ "order_mailer_payment_link_email": "Link do płatności",
+ "order_group_mailer_confirm_email": "Potwierdzenie zamówienia od wielu sprzedawców",
+ "fulfillment_mailer_fulfilled_email": "Zamówienie wysłane",
+ "return_mailer_refunded_email": "Zwrot zrefundowany",
+ "digital_asset_mailer_files_ready_email": "Pliki gotowe do pobrania",
+ "customer_mailer_password_reset_email": "Reset hasła",
+ "customer_mailer_data_export_email": "Eksport danych osobowych gotowy",
+ "newsletter_mailer_email_confirmation": "Potwierdzenie newslettera",
+ "company_mailer_invitation_email": "Zaproszenie do firmy",
+ "spree_base_mailer": "Układ e-maili",
+ "shared_line_item": "Produkt",
+ "shared_order_summary": "Podsumowanie zamówienia",
+ "shared_purchase_totals": "Sumy",
+ "shared_fulfillment_group": "Przesyłka",
+ "shared_summary_row": "Wiersz podsumowania"
+ },
+ "badges": {
+ "customized": "Dostosowany",
+ "default": "Domyślny",
+ "draft": "Szkic",
+ "default_updated": "Zaktualizowany przez Spree",
+ "unsaved": "Niezapisane zmiany",
+ "showing_draft": "Szkic – klienci otrzymują opublikowaną wersję",
+ "showing_published": "Opublikowany – to otrzymują klienci",
+ "showing_default": "Domyślny szablon Spree – to otrzymują klienci"
+ },
+ "actions": {
+ "save_draft": "Zapisz szkic",
+ "publish": "Opublikuj",
+ "discard_draft": "Odrzuć szkic",
+ "revert": "Przywróć domyślny",
+ "send_test": "Wyślij testowy e-mail",
+ "history": "Historia"
+ },
+ "confirm": {
+ "discard_title": "Odrzucić ten szkic?",
+ "discard_message": "Twoje nieopublikowane zmiany zostaną usunięte. Klienci nadal otrzymują opublikowaną wersję.",
+ "revert_title": "Przywrócić domyślny szablon Spree?",
+ "revert_message": "Od teraz klienci otrzymują domyślny e-mail Spree, a szkic zostanie usunięty. Opublikowane wersje zostają w historii, więc możesz później przywrócić jedną z nich.",
+ "restore_title": "Przywrócić tę wersję?",
+ "restore_message": "Ta wersja zastąpi szkic. Opublikuj ją, aby otrzymali ją klienci."
+ },
+ "editor": {
+ "title": "Szablon",
+ "subject": "Temat",
+ "body": "Kod szablonu",
+ "language": "Język"
+ },
+ "languages": {
+ "any": "Wszystkie języki"
+ },
+ "preview": {
+ "title": "Podgląd",
+ "frame_title": "Podgląd e-maila",
+ "subject": "Temat: {{subject}}",
+ "html": "E-mail",
+ "text": "Zwykły tekst",
+ "desktop": "Szerokość komputera",
+ "mobile": "Szerokość telefonu",
+ "shown_in": "Pokaż w",
+ "record": "Podgląd z rekordem",
+ "record_placeholder": "Najnowszy lub ID, np. or_m3Rp9wXz",
+ "unavailable": "Nie udało się wyświetlić podglądu."
+ },
+ "problems": {
+ "title": "Tego szablonu nie da się wyświetlić",
+ "on_line": "Wiersz {{line}}: {{message}}"
+ },
+ "default_update": {
+ "title": "Zaktualizowany przez Spree",
+ "description": "Spree zmienił domyślną wersję tego szablonu, odkąd powstała Twoja wersja. Porównaj je, zanim zdecydujesz.",
+ "compare": "Porównaj",
+ "dialog_title": "Co zmieniło się w domyślnym szablonie Spree",
+ "dialog_description": "Po lewej domyślny szablon, z którego powstała Twoja wersja. Po prawej obecny domyślny.",
+ "before": "Twoja wersja powstała z",
+ "after": "Obecny domyślny szablon Spree",
+ "keep_mine": "Zachowaj moją wersję",
+ "start_over": "Zacznij od nowego domyślnego"
+ },
+ "history": {
+ "title": "Historia",
+ "description": "Każda wersja opublikowana w tym języku, od najnowszej.",
+ "empty": "Nic jeszcze nie opublikowano.",
+ "latest": "Najnowsza",
+ "version": "Wersja {{number}}",
+ "restore": "Przywróć"
+ },
+ "conflict": {
+ "title": "Ktoś inny zapisał ten szkic",
+ "keep_editing": "Edytuj dalej",
+ "reload": "Wczytaj jego wersję"
+ },
+ "variables": {
+ "title": "Zmienne",
+ "description": "Dane, które ten e-mail może pokazać. Zacznij wpisywać zmienną w kodzie, aby zobaczyć wszystkie jej pola.",
+ "order": "Zamówienie z produktami, adresami i sumami.",
+ "resend": "Czy to ponownie wysłana kopia.",
+ "payment_url": "Link, pod którym klient płaci.",
+ "order_group": "Zamówienie podzielone między kilku sprzedawców.",
+ "fulfillment": "Przesyłka z numerem śledzenia.",
+ "return": "Zwrot i zwrócona kwota.",
+ "downloads": "Pliki, które klient może pobrać.",
+ "customer": "Klient, do którego trafia e-mail.",
+ "reset_url": "Link do ustawienia nowego hasła.",
+ "download_url": "Link do pobrania eksportu.",
+ "expires_at": "Kiedy link przestaje działać.",
+ "confirmation_url": "Link potwierdzający subskrypcję.",
+ "company": "Firma, do której zaproszono klienta.",
+ "accept_url": "Link przyjmujący zaproszenie.",
+ "store": "Twój sklep: nazwa, linki, logo i wygląd marki.",
+ "locale": "Język, w którym wysyłany jest e-mail."
+ },
+ "messages": {
+ "draft_saved": "Szkic zapisany",
+ "draft_discarded": "Szkic odrzucony",
+ "published": "Opublikowano. Od teraz klienci otrzymują tę wersję.",
+ "reverted": "Przywrócono domyślny szablon Spree",
+ "restored": "Wersja przywrócona do szkicu",
+ "test_sent": "Testowy e-mail wysłany na {{email}}"
+ },
+ "errors": {
+ "load_failed": "Nie udało się wczytać szablonów e-maili",
+ "not_allowed": "Nie masz uprawnień do przeglądania szablonów e-maili",
+ "test_email_failed": "Nie udało się wysłać testowego e-maila"
+ }
}
}
}
diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.json
index cd46e83a25..a063b561db 100644
--- a/packages/dashboard/src/locales/zh-CN.json
+++ b/packages/dashboard/src/locales/zh-CN.json
@@ -2138,6 +2138,25 @@
"label": "佣金默认税率",
"help": "当佣金费率和税务服务商都未给出税率时,按此税率对佣金计税。若佣金不计税,保持为 0。",
"suffix": "%"
+ },
+ "preferred_email_accent_color": {
+ "label": "强调色"
+ },
+ "preferred_email_background_color": {
+ "label": "背景色"
+ },
+ "preferred_email_card_color": {
+ "label": "卡片颜色"
+ },
+ "preferred_email_text_color": {
+ "label": "文字颜色"
+ },
+ "preferred_email_heading_color": {
+ "label": "标题颜色"
+ },
+ "preferred_email_font": {
+ "label": "字体",
+ "help": "无法加载该字体的邮件应用会使用相近的字体。"
}
},
"store_credit": {
@@ -3795,7 +3814,21 @@
"section_delivery": "发送",
"section_logo": "徽标",
"subtitle": "发件人地址、通知,以及嵌入在交易邮件中的徽标。",
- "title": "邮件设置"
+ "title": "邮件设置",
+ "branding": {
+ "title": "品牌样式",
+ "description": "每封客户邮件的颜色和字体。颜色留空则使用默认值。",
+ "default_color": "默认",
+ "fonts": {
+ "inter": "Inter(默认)",
+ "system": "系统字体",
+ "helvetica": "Helvetica",
+ "georgia": "Georgia",
+ "roboto": "Roboto",
+ "lato": "Lato",
+ "merriweather": "Merriweather"
+ }
+ }
},
"imports": {
"delete_confirm": {
@@ -5070,7 +5103,8 @@
"webhooks": "事件发生时接收通知的端点",
"package_types": "纸箱、外箱、托盘与集装箱",
"suppliers": "你从谁那里采购库存,以及如何联系他们",
- "marketplace": "卖家付款、卖家审核、卖家邮件与佣金税"
+ "marketplace": "卖家付款、卖家审核、卖家邮件与佣金税",
+ "email_templates": "编辑客户收到的邮件"
},
"groups": {
"audit": "审计",
@@ -5108,7 +5142,8 @@
"webhooks": "Webhooks",
"package_types": "包装类型",
"suppliers": "供应商",
- "marketplace": "设置"
+ "marketplace": "设置",
+ "email_templates": "邮件模板"
},
"breadcrumbs": {
"marketplace": "平台"
@@ -6062,6 +6097,158 @@
"page": {
"subtitle": "店铺在所有客户中欠下的预付余额总额。"
}
+ },
+ "email_templates": {
+ "tabs": {
+ "settings": "设置",
+ "templates": "模板"
+ },
+ "list": {
+ "description": "编辑客户收到的邮件。更改会保存为草稿,发布后才会发送给客户。",
+ "groups": {
+ "email": {
+ "title": "客户邮件",
+ "description": "客户可能从您的店铺收到的每一封邮件。"
+ },
+ "layout": {
+ "title": "布局",
+ "description": "每封客户邮件周围的页眉、页脚和样式。"
+ },
+ "partial": {
+ "title": "共享模块",
+ "description": "多封邮件共用的部分,例如商品列表和合计。"
+ }
+ },
+ "empty": "这里没有可编辑的邮件模板。客户邮件模板随 Spree 邮件包提供。"
+ },
+ "names": {
+ "order_mailer_confirm_email": "订单确认",
+ "order_mailer_cancel_email": "订单已取消",
+ "order_mailer_payment_link_email": "付款链接",
+ "order_group_mailer_confirm_email": "多卖家订单确认",
+ "fulfillment_mailer_fulfilled_email": "订单已发货",
+ "return_mailer_refunded_email": "退货已退款",
+ "digital_asset_mailer_files_ready_email": "下载已就绪",
+ "customer_mailer_password_reset_email": "重置密码",
+ "customer_mailer_data_export_email": "个人数据导出已就绪",
+ "newsletter_mailer_email_confirmation": "订阅确认",
+ "company_mailer_invitation_email": "公司邀请",
+ "spree_base_mailer": "邮件布局",
+ "shared_line_item": "商品",
+ "shared_order_summary": "订单摘要",
+ "shared_purchase_totals": "合计",
+ "shared_fulfillment_group": "包裹",
+ "shared_summary_row": "摘要行"
+ },
+ "badges": {
+ "customized": "已自定义",
+ "default": "默认",
+ "draft": "草稿",
+ "default_updated": "Spree 已更新",
+ "unsaved": "未保存的更改",
+ "showing_draft": "草稿 — 客户收到的是已发布版本",
+ "showing_published": "已发布 — 客户收到的内容",
+ "showing_default": "Spree 默认 — 客户收到的内容"
+ },
+ "actions": {
+ "save_draft": "保存草稿",
+ "publish": "发布",
+ "discard_draft": "放弃草稿",
+ "revert": "恢复默认",
+ "send_test": "发送测试邮件",
+ "history": "历史记录"
+ },
+ "confirm": {
+ "discard_title": "放弃此草稿?",
+ "discard_message": "未发布的更改将被删除。客户仍会收到已发布的版本。",
+ "revert_title": "恢复为 Spree 默认?",
+ "revert_message": "从现在起客户将收到 Spree 的默认邮件,草稿将被删除。已发布的版本保留在历史记录中,以后可以恢复。",
+ "restore_title": "恢复此版本?",
+ "restore_message": "此版本将替换草稿。发布后客户才会收到。"
+ },
+ "editor": {
+ "title": "模板",
+ "subject": "主题",
+ "body": "模板代码",
+ "language": "语言"
+ },
+ "languages": {
+ "any": "所有语言"
+ },
+ "preview": {
+ "title": "预览",
+ "frame_title": "邮件预览",
+ "subject": "主题:{{subject}}",
+ "html": "邮件",
+ "text": "纯文本",
+ "desktop": "桌面宽度",
+ "mobile": "手机宽度",
+ "shown_in": "显示于",
+ "record": "使用记录预览",
+ "record_placeholder": "最新记录,或如 or_m3Rp9wXz 的 ID",
+ "unavailable": "无法显示预览。"
+ },
+ "problems": {
+ "title": "此模板无法渲染",
+ "on_line": "第 {{line}} 行:{{message}}"
+ },
+ "default_update": {
+ "title": "Spree 已更新",
+ "description": "自您的版本创建以来,Spree 更改了此模板的默认内容。请先比较两者再做决定。",
+ "compare": "比较",
+ "dialog_title": "Spree 默认模板的变化",
+ "dialog_description": "左侧是您的版本所基于的默认模板,右侧是当前的默认模板。",
+ "before": "您的版本基于",
+ "after": "当前的 Spree 默认",
+ "keep_mine": "保留我的版本",
+ "start_over": "从新的默认开始"
+ },
+ "history": {
+ "title": "历史记录",
+ "description": "此语言下发布过的每个版本,最新的在前。",
+ "empty": "尚未发布任何内容。",
+ "latest": "最新",
+ "version": "版本 {{number}}",
+ "restore": "恢复"
+ },
+ "conflict": {
+ "title": "其他人保存了此草稿",
+ "keep_editing": "继续编辑",
+ "reload": "加载对方的版本"
+ },
+ "variables": {
+ "title": "变量",
+ "description": "此邮件可以显示的数据。在代码中开始输入变量即可看到它的所有字段。",
+ "order": "订单,包括商品、地址和合计。",
+ "resend": "是否为重新发送的副本。",
+ "payment_url": "客户付款的链接。",
+ "order_group": "分给多个卖家的订单。",
+ "fulfillment": "包裹及其物流跟踪。",
+ "return": "退货及退款金额。",
+ "downloads": "客户可以下载的文件。",
+ "customer": "邮件的收件客户。",
+ "reset_url": "设置新密码的链接。",
+ "download_url": "下载导出文件的链接。",
+ "expires_at": "链接失效的时间。",
+ "confirmation_url": "确认订阅的链接。",
+ "company": "邀请客户加入的公司。",
+ "accept_url": "接受邀请的链接。",
+ "store": "您的店铺:名称、链接、标志和品牌样式。",
+ "locale": "邮件发送所用的语言。"
+ },
+ "messages": {
+ "draft_saved": "草稿已保存",
+ "draft_discarded": "草稿已放弃",
+ "published": "已发布。客户从现在起会收到此版本。",
+ "reverted": "已恢复为 Spree 默认",
+ "restored": "版本已恢复到草稿",
+ "test_sent": "测试邮件已发送至 {{email}}"
+ },
+ "errors": {
+ "load_failed": "无法加载邮件模板",
+ "not_allowed": "您没有查看邮件模板的权限",
+ "test_email_failed": "无法发送测试邮件"
+ }
}
}
}
diff --git a/packages/dashboard/src/nav/settings.ts b/packages/dashboard/src/nav/settings.ts
index e02577d39f..679c5a5b93 100644
--- a/packages/dashboard/src/nav/settings.ts
+++ b/packages/dashboard/src/nav/settings.ts
@@ -3,6 +3,7 @@ import {
Building2Icon,
ClipboardCheckIcon,
CreditCardIcon,
+ FileCodeIcon,
GlobeIcon,
GlobeLockIcon,
KeyRoundIcon,
@@ -86,6 +87,19 @@ settingsNav.add({
action: 'update',
})
+settingsNav.add({
+ key: 'settings.email_templates',
+ labelKey: 'admin.settings_nav.items.email_templates',
+ descriptionKey: 'admin.settings_nav.descriptions.email_templates',
+ keywords: ['email', 'template', 'liquid', 'mjml', 'order confirmation', 'branding'],
+ path: '/emails/templates',
+ icon: FileCodeIcon,
+ group: 'store',
+ position: 210,
+ subject: Subject.EmailTemplate,
+ action: 'read',
+})
+
settingsNav.add({
key: 'settings.policies',
labelKey: 'admin.settings_nav.items.policies',
diff --git a/packages/dashboard/src/routeTree.gen.ts b/packages/dashboard/src/routeTree.gen.ts
index 69f6955aee..8e47c02238 100644
--- a/packages/dashboard/src/routeTree.gen.ts
+++ b/packages/dashboard/src/routeTree.gen.ts
@@ -53,7 +53,6 @@ import { Route as SettingsPackageTypesRouteImport } from './routes/_authenticate
import { Route as SettingsMarketsRouteImport } from './routes/_authenticated/$storeId/settings/markets'
import { Route as SettingsMarketplaceRouteImport } from './routes/_authenticated/$storeId/settings/marketplace'
import { Route as SettingsIntegrationsRouteImport } from './routes/_authenticated/$storeId/settings/integrations'
-import { Route as SettingsEmailsRouteImport } from './routes/_authenticated/$storeId/settings/emails'
import { Route as SettingsCustomFieldDefinitionsRouteImport } from './routes/_authenticated/$storeId/settings/custom-field-definitions'
import { Route as SettingsCommissionRatesRouteImport } from './routes/_authenticated/$storeId/settings/commission-rates'
import { Route as SettingsChannelsRouteImport } from './routes/_authenticated/$storeId/settings/channels'
@@ -83,6 +82,7 @@ import { Route as CompaniesCompanyIdRouteImport } from './routes/_authenticated/
import { Route as TransfersTransferIdIndexRouteImport } from './routes/_authenticated/$storeId/transfers/$transferId/index'
import { Route as SettingsWebhooksIndexRouteImport } from './routes/_authenticated/$storeId/settings/webhooks/index'
import { Route as SettingsImportsIndexRouteImport } from './routes/_authenticated/$storeId/settings/imports/index'
+import { Route as SettingsEmailsIndexRouteImport } from './routes/_authenticated/$storeId/settings/emails/index'
import { Route as SettingsDeliveryProfilesIndexRouteImport } from './routes/_authenticated/$storeId/settings/delivery-profiles/index'
import { Route as SellersPayoutsIndexRouteImport } from './routes/_authenticated/$storeId/sellers/payouts/index'
import { Route as PurchaseOrdersPurchaseOrderIdIndexRouteImport } from './routes/_authenticated/$storeId/purchase-orders/$purchaseOrderId/index'
@@ -102,8 +102,10 @@ import { Route as ProductsCategoriesNewRouteImport } from './routes/_authenticat
import { Route as ProductsCategoriesCategoryIdRouteImport } from './routes/_authenticated/$storeId/products/categories/$categoryId'
import { Route as ProductsCatalogsCatalogIdRouteImport } from './routes/_authenticated/$storeId/products/catalogs/$catalogId'
import { Route as OrdersOrderIdEditRouteImport } from './routes/_authenticated/$storeId/orders/$orderId/edit'
+import { Route as SettingsEmailsTemplatesIndexRouteImport } from './routes/_authenticated/$storeId/settings/emails/templates/index'
import { Route as SettingsDeliveryProfilesProfileIdIndexRouteImport } from './routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/index'
import { Route as ProductsPriceListsPriceListIdIndexRouteImport } from './routes/_authenticated/$storeId/products/price-lists/$priceListId/index'
+import { Route as SettingsEmailsTemplatesTemplateIdRouteImport } from './routes/_authenticated/$storeId/settings/emails/templates/$templateId'
import { Route as SettingsDeliveryProfilesProfileIdMethodsNewRouteImport } from './routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new'
import { Route as SettingsDeliveryProfilesProfileIdMethodsMethodIdRouteImport } from './routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/$methodId'
@@ -328,11 +330,6 @@ const SettingsIntegrationsRoute = SettingsIntegrationsRouteImport.update({
path: '/integrations',
getParentRoute: () => SettingsRoute,
} as any)
-const SettingsEmailsRoute = SettingsEmailsRouteImport.update({
- id: '/emails',
- path: '/emails',
- getParentRoute: () => SettingsRoute,
-} as any)
const SettingsCustomFieldDefinitionsRoute =
SettingsCustomFieldDefinitionsRouteImport.update({
id: '/custom-field-definitions',
@@ -480,6 +477,11 @@ const SettingsImportsIndexRoute = SettingsImportsIndexRouteImport.update({
path: '/imports/',
getParentRoute: () => SettingsRoute,
} as any)
+const SettingsEmailsIndexRoute = SettingsEmailsIndexRouteImport.update({
+ id: '/emails/',
+ path: '/emails/',
+ getParentRoute: () => SettingsRoute,
+} as any)
const SettingsDeliveryProfilesIndexRoute =
SettingsDeliveryProfilesIndexRouteImport.update({
id: '/delivery-profiles/',
@@ -583,6 +585,12 @@ const OrdersOrderIdEditRoute = OrdersOrderIdEditRouteImport.update({
path: '/orders/$orderId/edit',
getParentRoute: () => authenticatedStoreIdRoute,
} as any)
+const SettingsEmailsTemplatesIndexRoute =
+ SettingsEmailsTemplatesIndexRouteImport.update({
+ id: '/emails/templates/',
+ path: '/emails/templates/',
+ getParentRoute: () => SettingsRoute,
+ } as any)
const SettingsDeliveryProfilesProfileIdIndexRoute =
SettingsDeliveryProfilesProfileIdIndexRouteImport.update({
id: '/delivery-profiles/$profileId/',
@@ -595,6 +603,12 @@ const ProductsPriceListsPriceListIdIndexRoute =
path: '/products/price-lists/$priceListId/',
getParentRoute: () => authenticatedStoreIdRoute,
} as any)
+const SettingsEmailsTemplatesTemplateIdRoute =
+ SettingsEmailsTemplatesTemplateIdRouteImport.update({
+ id: '/emails/templates/$templateId',
+ path: '/emails/templates/$templateId',
+ getParentRoute: () => SettingsRoute,
+ } as any)
const SettingsDeliveryProfilesProfileIdMethodsNewRoute =
SettingsDeliveryProfilesProfileIdMethodsNewRouteImport.update({
id: '/delivery-profiles/$profileId/methods/new',
@@ -650,7 +664,6 @@ export interface FileRoutesByFullPath {
'/$storeId/settings/channels': typeof SettingsChannelsRoute
'/$storeId/settings/commission-rates': typeof SettingsCommissionRatesRoute
'/$storeId/settings/custom-field-definitions': typeof SettingsCustomFieldDefinitionsRoute
- '/$storeId/settings/emails': typeof SettingsEmailsRoute
'/$storeId/settings/integrations': typeof SettingsIntegrationsRoute
'/$storeId/settings/marketplace': typeof SettingsMarketplaceRoute
'/$storeId/settings/markets': typeof SettingsMarketsRoute
@@ -698,11 +711,14 @@ export interface FileRoutesByFullPath {
'/$storeId/purchase-orders/$purchaseOrderId/': typeof PurchaseOrdersPurchaseOrderIdIndexRoute
'/$storeId/sellers/payouts/': typeof SellersPayoutsIndexRoute
'/$storeId/settings/delivery-profiles/': typeof SettingsDeliveryProfilesIndexRoute
+ '/$storeId/settings/emails/': typeof SettingsEmailsIndexRoute
'/$storeId/settings/imports/': typeof SettingsImportsIndexRoute
'/$storeId/settings/webhooks/': typeof SettingsWebhooksIndexRoute
'/$storeId/transfers/$transferId/': typeof TransfersTransferIdIndexRoute
+ '/$storeId/settings/emails/templates/$templateId': typeof SettingsEmailsTemplatesTemplateIdRoute
'/$storeId/products/price-lists/$priceListId/': typeof ProductsPriceListsPriceListIdIndexRoute
'/$storeId/settings/delivery-profiles/$profileId/': typeof SettingsDeliveryProfilesProfileIdIndexRoute
+ '/$storeId/settings/emails/templates/': typeof SettingsEmailsTemplatesIndexRoute
'/$storeId/settings/delivery-profiles/$profileId/methods/$methodId': typeof SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute
'/$storeId/settings/delivery-profiles/$profileId/methods/new': typeof SettingsDeliveryProfilesProfileIdMethodsNewRoute
}
@@ -746,7 +762,6 @@ export interface FileRoutesByTo {
'/$storeId/settings/channels': typeof SettingsChannelsRoute
'/$storeId/settings/commission-rates': typeof SettingsCommissionRatesRoute
'/$storeId/settings/custom-field-definitions': typeof SettingsCustomFieldDefinitionsRoute
- '/$storeId/settings/emails': typeof SettingsEmailsRoute
'/$storeId/settings/integrations': typeof SettingsIntegrationsRoute
'/$storeId/settings/marketplace': typeof SettingsMarketplaceRoute
'/$storeId/settings/markets': typeof SettingsMarketsRoute
@@ -794,11 +809,14 @@ export interface FileRoutesByTo {
'/$storeId/purchase-orders/$purchaseOrderId': typeof PurchaseOrdersPurchaseOrderIdIndexRoute
'/$storeId/sellers/payouts': typeof SellersPayoutsIndexRoute
'/$storeId/settings/delivery-profiles': typeof SettingsDeliveryProfilesIndexRoute
+ '/$storeId/settings/emails': typeof SettingsEmailsIndexRoute
'/$storeId/settings/imports': typeof SettingsImportsIndexRoute
'/$storeId/settings/webhooks': typeof SettingsWebhooksIndexRoute
'/$storeId/transfers/$transferId': typeof TransfersTransferIdIndexRoute
+ '/$storeId/settings/emails/templates/$templateId': typeof SettingsEmailsTemplatesTemplateIdRoute
'/$storeId/products/price-lists/$priceListId': typeof ProductsPriceListsPriceListIdIndexRoute
'/$storeId/settings/delivery-profiles/$profileId': typeof SettingsDeliveryProfilesProfileIdIndexRoute
+ '/$storeId/settings/emails/templates': typeof SettingsEmailsTemplatesIndexRoute
'/$storeId/settings/delivery-profiles/$profileId/methods/$methodId': typeof SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute
'/$storeId/settings/delivery-profiles/$profileId/methods/new': typeof SettingsDeliveryProfilesProfileIdMethodsNewRoute
}
@@ -846,7 +864,6 @@ export interface FileRoutesById {
'/_authenticated/$storeId/settings/channels': typeof SettingsChannelsRoute
'/_authenticated/$storeId/settings/commission-rates': typeof SettingsCommissionRatesRoute
'/_authenticated/$storeId/settings/custom-field-definitions': typeof SettingsCustomFieldDefinitionsRoute
- '/_authenticated/$storeId/settings/emails': typeof SettingsEmailsRoute
'/_authenticated/$storeId/settings/integrations': typeof SettingsIntegrationsRoute
'/_authenticated/$storeId/settings/marketplace': typeof SettingsMarketplaceRoute
'/_authenticated/$storeId/settings/markets': typeof SettingsMarketsRoute
@@ -894,11 +911,14 @@ export interface FileRoutesById {
'/_authenticated/$storeId/purchase-orders/$purchaseOrderId/': typeof PurchaseOrdersPurchaseOrderIdIndexRoute
'/_authenticated/$storeId/sellers/payouts/': typeof SellersPayoutsIndexRoute
'/_authenticated/$storeId/settings/delivery-profiles/': typeof SettingsDeliveryProfilesIndexRoute
+ '/_authenticated/$storeId/settings/emails/': typeof SettingsEmailsIndexRoute
'/_authenticated/$storeId/settings/imports/': typeof SettingsImportsIndexRoute
'/_authenticated/$storeId/settings/webhooks/': typeof SettingsWebhooksIndexRoute
'/_authenticated/$storeId/transfers/$transferId/': typeof TransfersTransferIdIndexRoute
+ '/_authenticated/$storeId/settings/emails/templates/$templateId': typeof SettingsEmailsTemplatesTemplateIdRoute
'/_authenticated/$storeId/products/price-lists/$priceListId/': typeof ProductsPriceListsPriceListIdIndexRoute
'/_authenticated/$storeId/settings/delivery-profiles/$profileId/': typeof SettingsDeliveryProfilesProfileIdIndexRoute
+ '/_authenticated/$storeId/settings/emails/templates/': typeof SettingsEmailsTemplatesIndexRoute
'/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/$methodId': typeof SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute
'/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new': typeof SettingsDeliveryProfilesProfileIdMethodsNewRoute
}
@@ -946,7 +966,6 @@ export interface FileRouteTypes {
| '/$storeId/settings/channels'
| '/$storeId/settings/commission-rates'
| '/$storeId/settings/custom-field-definitions'
- | '/$storeId/settings/emails'
| '/$storeId/settings/integrations'
| '/$storeId/settings/marketplace'
| '/$storeId/settings/markets'
@@ -994,11 +1013,14 @@ export interface FileRouteTypes {
| '/$storeId/purchase-orders/$purchaseOrderId/'
| '/$storeId/sellers/payouts/'
| '/$storeId/settings/delivery-profiles/'
+ | '/$storeId/settings/emails/'
| '/$storeId/settings/imports/'
| '/$storeId/settings/webhooks/'
| '/$storeId/transfers/$transferId/'
+ | '/$storeId/settings/emails/templates/$templateId'
| '/$storeId/products/price-lists/$priceListId/'
| '/$storeId/settings/delivery-profiles/$profileId/'
+ | '/$storeId/settings/emails/templates/'
| '/$storeId/settings/delivery-profiles/$profileId/methods/$methodId'
| '/$storeId/settings/delivery-profiles/$profileId/methods/new'
fileRoutesByTo: FileRoutesByTo
@@ -1042,7 +1064,6 @@ export interface FileRouteTypes {
| '/$storeId/settings/channels'
| '/$storeId/settings/commission-rates'
| '/$storeId/settings/custom-field-definitions'
- | '/$storeId/settings/emails'
| '/$storeId/settings/integrations'
| '/$storeId/settings/marketplace'
| '/$storeId/settings/markets'
@@ -1090,11 +1111,14 @@ export interface FileRouteTypes {
| '/$storeId/purchase-orders/$purchaseOrderId'
| '/$storeId/sellers/payouts'
| '/$storeId/settings/delivery-profiles'
+ | '/$storeId/settings/emails'
| '/$storeId/settings/imports'
| '/$storeId/settings/webhooks'
| '/$storeId/transfers/$transferId'
+ | '/$storeId/settings/emails/templates/$templateId'
| '/$storeId/products/price-lists/$priceListId'
| '/$storeId/settings/delivery-profiles/$profileId'
+ | '/$storeId/settings/emails/templates'
| '/$storeId/settings/delivery-profiles/$profileId/methods/$methodId'
| '/$storeId/settings/delivery-profiles/$profileId/methods/new'
id:
@@ -1141,7 +1165,6 @@ export interface FileRouteTypes {
| '/_authenticated/$storeId/settings/channels'
| '/_authenticated/$storeId/settings/commission-rates'
| '/_authenticated/$storeId/settings/custom-field-definitions'
- | '/_authenticated/$storeId/settings/emails'
| '/_authenticated/$storeId/settings/integrations'
| '/_authenticated/$storeId/settings/marketplace'
| '/_authenticated/$storeId/settings/markets'
@@ -1189,11 +1212,14 @@ export interface FileRouteTypes {
| '/_authenticated/$storeId/purchase-orders/$purchaseOrderId/'
| '/_authenticated/$storeId/sellers/payouts/'
| '/_authenticated/$storeId/settings/delivery-profiles/'
+ | '/_authenticated/$storeId/settings/emails/'
| '/_authenticated/$storeId/settings/imports/'
| '/_authenticated/$storeId/settings/webhooks/'
| '/_authenticated/$storeId/transfers/$transferId/'
+ | '/_authenticated/$storeId/settings/emails/templates/$templateId'
| '/_authenticated/$storeId/products/price-lists/$priceListId/'
| '/_authenticated/$storeId/settings/delivery-profiles/$profileId/'
+ | '/_authenticated/$storeId/settings/emails/templates/'
| '/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/$methodId'
| '/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new'
fileRoutesById: FileRoutesById
@@ -1517,13 +1543,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof SettingsIntegrationsRouteImport
parentRoute: typeof SettingsRoute
}
- '/_authenticated/$storeId/settings/emails': {
- id: '/_authenticated/$storeId/settings/emails'
- path: '/emails'
- fullPath: '/$storeId/settings/emails'
- preLoaderRoute: typeof SettingsEmailsRouteImport
- parentRoute: typeof SettingsRoute
- }
'/_authenticated/$storeId/settings/custom-field-definitions': {
id: '/_authenticated/$storeId/settings/custom-field-definitions'
path: '/custom-field-definitions'
@@ -1727,6 +1746,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof SettingsImportsIndexRouteImport
parentRoute: typeof SettingsRoute
}
+ '/_authenticated/$storeId/settings/emails/': {
+ id: '/_authenticated/$storeId/settings/emails/'
+ path: '/emails'
+ fullPath: '/$storeId/settings/emails/'
+ preLoaderRoute: typeof SettingsEmailsIndexRouteImport
+ parentRoute: typeof SettingsRoute
+ }
'/_authenticated/$storeId/settings/delivery-profiles/': {
id: '/_authenticated/$storeId/settings/delivery-profiles/'
path: '/delivery-profiles'
@@ -1860,6 +1886,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof OrdersOrderIdEditRouteImport
parentRoute: typeof authenticatedStoreIdRoute
}
+ '/_authenticated/$storeId/settings/emails/templates/': {
+ id: '/_authenticated/$storeId/settings/emails/templates/'
+ path: '/emails/templates'
+ fullPath: '/$storeId/settings/emails/templates/'
+ preLoaderRoute: typeof SettingsEmailsTemplatesIndexRouteImport
+ parentRoute: typeof SettingsRoute
+ }
'/_authenticated/$storeId/settings/delivery-profiles/$profileId/': {
id: '/_authenticated/$storeId/settings/delivery-profiles/$profileId/'
path: '/delivery-profiles/$profileId'
@@ -1874,6 +1907,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof ProductsPriceListsPriceListIdIndexRouteImport
parentRoute: typeof authenticatedStoreIdRoute
}
+ '/_authenticated/$storeId/settings/emails/templates/$templateId': {
+ id: '/_authenticated/$storeId/settings/emails/templates/$templateId'
+ path: '/emails/templates/$templateId'
+ fullPath: '/$storeId/settings/emails/templates/$templateId'
+ preLoaderRoute: typeof SettingsEmailsTemplatesTemplateIdRouteImport
+ parentRoute: typeof SettingsRoute
+ }
'/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new': {
id: '/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new'
path: '/delivery-profiles/$profileId/methods/new'
@@ -1897,7 +1937,6 @@ interface SettingsRouteChildren {
SettingsChannelsRoute: typeof SettingsChannelsRoute
SettingsCommissionRatesRoute: typeof SettingsCommissionRatesRoute
SettingsCustomFieldDefinitionsRoute: typeof SettingsCustomFieldDefinitionsRoute
- SettingsEmailsRoute: typeof SettingsEmailsRoute
SettingsIntegrationsRoute: typeof SettingsIntegrationsRoute
SettingsMarketplaceRoute: typeof SettingsMarketplaceRoute
SettingsMarketsRoute: typeof SettingsMarketsRoute
@@ -1917,9 +1956,12 @@ interface SettingsRouteChildren {
SettingsIndexRoute: typeof SettingsIndexRoute
SettingsWebhooksWebhookEndpointIdRoute: typeof SettingsWebhooksWebhookEndpointIdRoute
SettingsDeliveryProfilesIndexRoute: typeof SettingsDeliveryProfilesIndexRoute
+ SettingsEmailsIndexRoute: typeof SettingsEmailsIndexRoute
SettingsImportsIndexRoute: typeof SettingsImportsIndexRoute
SettingsWebhooksIndexRoute: typeof SettingsWebhooksIndexRoute
+ SettingsEmailsTemplatesTemplateIdRoute: typeof SettingsEmailsTemplatesTemplateIdRoute
SettingsDeliveryProfilesProfileIdIndexRoute: typeof SettingsDeliveryProfilesProfileIdIndexRoute
+ SettingsEmailsTemplatesIndexRoute: typeof SettingsEmailsTemplatesIndexRoute
SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute: typeof SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute
SettingsDeliveryProfilesProfileIdMethodsNewRoute: typeof SettingsDeliveryProfilesProfileIdMethodsNewRoute
}
@@ -1930,7 +1972,6 @@ const SettingsRouteChildren: SettingsRouteChildren = {
SettingsChannelsRoute: SettingsChannelsRoute,
SettingsCommissionRatesRoute: SettingsCommissionRatesRoute,
SettingsCustomFieldDefinitionsRoute: SettingsCustomFieldDefinitionsRoute,
- SettingsEmailsRoute: SettingsEmailsRoute,
SettingsIntegrationsRoute: SettingsIntegrationsRoute,
SettingsMarketplaceRoute: SettingsMarketplaceRoute,
SettingsMarketsRoute: SettingsMarketsRoute,
@@ -1951,10 +1992,14 @@ const SettingsRouteChildren: SettingsRouteChildren = {
SettingsWebhooksWebhookEndpointIdRoute:
SettingsWebhooksWebhookEndpointIdRoute,
SettingsDeliveryProfilesIndexRoute: SettingsDeliveryProfilesIndexRoute,
+ SettingsEmailsIndexRoute: SettingsEmailsIndexRoute,
SettingsImportsIndexRoute: SettingsImportsIndexRoute,
SettingsWebhooksIndexRoute: SettingsWebhooksIndexRoute,
+ SettingsEmailsTemplatesTemplateIdRoute:
+ SettingsEmailsTemplatesTemplateIdRoute,
SettingsDeliveryProfilesProfileIdIndexRoute:
SettingsDeliveryProfilesProfileIdIndexRoute,
+ SettingsEmailsTemplatesIndexRoute: SettingsEmailsTemplatesIndexRoute,
SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute:
SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute,
SettingsDeliveryProfilesProfileIdMethodsNewRoute:
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails/index.tsx
similarity index 64%
rename from packages/dashboard/src/routes/_authenticated/$storeId/settings/emails.tsx
rename to packages/dashboard/src/routes/_authenticated/$storeId/settings/emails/index.tsx
index e55fd64f8d..e660f8bd24 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails/index.tsx
@@ -1,11 +1,19 @@
import { zodResolver } from '@hookform/resolvers/zod'
import { SpreeError, type Store, type StoreUpdateParams } from '@spree/admin-sdk'
-import { ImageUploadField, mapSpreeErrorsToForm, PageHeader } from '@spree/dashboard-core'
+import {
+ ImageUploadField,
+ mapSpreeErrorsToForm,
+ PageHeader,
+ Subject,
+ usePermissions,
+} from '@spree/dashboard-core'
import {
Card,
CardContent,
+ CardDescription,
CardHeader,
CardTitle,
+ ColorPicker,
ErrorState,
Field,
FieldDescription,
@@ -15,18 +23,35 @@ import {
FormActions,
Input,
ResourceLayout,
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
Skeleton,
Switch,
toastManager,
+ useDebouncedValue,
useFormSubmitShortcut,
} from '@spree/dashboard-ui'
import { createFileRoute } from '@tanstack/react-router'
+import { useEffect } from 'react'
import { Controller, useForm } from 'react-hook-form'
import { useTranslation } from 'react-i18next'
-import { useStoreSettings, useUpdateStoreSettings } from '../../../../hooks/use-store-settings'
-import { type StoreEmailsFormValues, storeEmailsFormSchema } from '../../../../schemas/store-emails'
+import { EmailPreviewFrame } from '../../../../../components/spree/email-templates/email-preview-frame'
+import { EmailsTabs } from '../../../../../components/spree/email-templates/emails-tabs'
+import { useEmailTemplatePreview } from '../../../../../hooks/use-email-templates'
+import { useStoreSettings, useUpdateStoreSettings } from '../../../../../hooks/use-store-settings'
+import {
+ EMAIL_BRANDING_COLORS,
+ EMAIL_FONTS,
+ type StoreEmailsFormValues,
+ storeEmailsFormSchema,
+} from '../../../../../schemas/store-emails'
+
+const BRANDING_PREVIEW_TEMPLATE = 'spree.order_mailer.confirm_email'
-export const Route = createFileRoute('/_authenticated/$storeId/settings/emails')({
+export const Route = createFileRoute('/_authenticated/$storeId/settings/emails/')({
component: EmailSettingsPage,
})
@@ -37,6 +62,12 @@ function storeToFormValues(store: Store): StoreEmailsFormValues {
new_order_notifications_email: store.new_order_notifications_email ?? '',
preferred_send_consumer_transactional_emails:
store.preferred_send_consumer_transactional_emails,
+ preferred_email_accent_color: store.preferred_email_accent_color ?? '',
+ preferred_email_background_color: store.preferred_email_background_color ?? '',
+ preferred_email_card_color: store.preferred_email_card_color ?? '',
+ preferred_email_text_color: store.preferred_email_text_color ?? '',
+ preferred_email_heading_color: store.preferred_email_heading_color ?? '',
+ preferred_email_font: store.preferred_email_font ?? 'inter',
mailer_logo_signed_id: null,
mailer_logo_preview_url: null,
mailer_logo_cleared: false,
@@ -50,6 +81,12 @@ function formValuesToApiParams(values: StoreEmailsFormValues): StoreUpdateParams
new_order_notifications_email: values.new_order_notifications_email?.trim() || null,
preferred_send_consumer_transactional_emails:
values.preferred_send_consumer_transactional_emails,
+ preferred_email_accent_color: values.preferred_email_accent_color || null,
+ preferred_email_background_color: values.preferred_email_background_color || null,
+ preferred_email_card_color: values.preferred_email_card_color || null,
+ preferred_email_text_color: values.preferred_email_text_color || null,
+ preferred_email_heading_color: values.preferred_email_heading_color || null,
+ preferred_email_font: values.preferred_email_font,
}
// Three states for the logo: untouched (omit), uploaded (send signed_id),
// explicitly cleared (send null). Sending an empty value would be ambiguous.
@@ -143,6 +180,8 @@ function EmailSettingsForm({ store }: { store: Store }) {
}
main={
<>
+ <EmailsTabs current="settings" />
+
{errors.root?.message && (
<p className="text-sm text-destructive" role="alert">
{errors.root.message}
@@ -252,6 +291,8 @@ function EmailSettingsForm({ store }: { store: Store }) {
<LogoField form={form} initialLogoUrl={store.mailer_logo_url} />
</CardContent>
</Card>
+
+ <BrandingCard form={form} />
</>
)}
</>
@@ -292,3 +333,121 @@ function LogoField({
/>
)
}
+
+function BrandingCard({ form }: { form: ReturnType<typeof useForm<StoreEmailsFormValues>> }) {
+ const { t } = useTranslation()
+ const { permissions } = usePermissions()
+ const { errors } = form.formState
+ const fontOptions = EMAIL_FONTS.map((font) => ({
+ value: font,
+ label: t(`admin.pages.settings.emails.branding.fonts.${font}`),
+ }))
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>{t('admin.pages.settings.emails.branding.title')}</CardTitle>
+ <CardDescription>{t('admin.pages.settings.emails.branding.description')}</CardDescription>
+ </CardHeader>
+ <CardContent className="grid gap-6 lg:grid-cols-2">
+ <FieldGroup>
+ {EMAIL_BRANDING_COLORS.map((color) => {
+ const name = `preferred_email_${color}` as const
+ return (
+ <Field key={color}>
+ <FieldLabel htmlFor={`store-email-${color}`}>
+ {t(`admin.fields.store.${name}.label`)}
+ </FieldLabel>
+ <Controller
+ name={name}
+ control={form.control}
+ render={({ field }) => (
+ <ColorPicker
+ id={`store-email-${color}`}
+ value={field.value}
+ onChange={(value) => field.onChange(value ?? '')}
+ placeholder={t('admin.pages.settings.emails.branding.default_color')}
+ aria-invalid={!!errors[name] || undefined}
+ />
+ )}
+ />
+ <FieldError errors={[errors[name]]} />
+ </Field>
+ )
+ })}
+ <Field>
+ <FieldLabel htmlFor="store-email-font">
+ {t('admin.fields.store.preferred_email_font.label')}
+ </FieldLabel>
+ <Controller
+ name="preferred_email_font"
+ control={form.control}
+ render={({ field }) => (
+ <Select
+ items={fontOptions}
+ value={field.value}
+ onValueChange={(value) => field.onChange(value)}
+ >
+ <SelectTrigger id="store-email-font">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {fontOptions.map((option) => (
+ <SelectItem key={option.value} value={option.value}>
+ {option.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ )}
+ />
+ <FieldDescription>{t('admin.fields.store.preferred_email_font.help')}</FieldDescription>
+ </Field>
+ </FieldGroup>
+ {permissions.can('update', Subject.EmailTemplate) && <BrandingPreview form={form} />}
+ </CardContent>
+ </Card>
+ )
+}
+
+function BrandingPreview({ form }: { form: ReturnType<typeof useForm<StoreEmailsFormValues>> }) {
+ const { t } = useTranslation()
+ const preview = useEmailTemplatePreview(BRANDING_PREVIEW_TEMPLATE)
+ const [accent, background, card, text, heading, font] = form.watch([
+ 'preferred_email_accent_color',
+ 'preferred_email_background_color',
+ 'preferred_email_card_color',
+ 'preferred_email_text_color',
+ 'preferred_email_heading_color',
+ 'preferred_email_font',
+ ])
+ const branding = useDebouncedValue(
+ JSON.stringify({
+ accent_color: accent,
+ background_color: background,
+ card_color: card,
+ text_color: text,
+ heading_color: heading,
+ font,
+ }),
+ 600,
+ )
+ const { mutate } = preview
+
+ useEffect(() => {
+ mutate({ branding: JSON.parse(branding) })
+ }, [branding, mutate])
+
+ // No customer emails installed, so there is nothing to preview.
+ if (preview.error instanceof SpreeError && preview.error.status === 404) return null
+
+ if (preview.error) {
+ return (
+ <p className="text-sm text-muted-foreground">
+ {preview.error.message || t('admin.email_templates.preview.unavailable')}
+ </p>
+ )
+ }
+
+ return <EmailPreviewFrame html={preview.data?.html} className="h-[32rem]" />
+}
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails/templates/$templateId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails/templates/$templateId.tsx
new file mode 100644
index 0000000000..953528f8d0
--- /dev/null
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails/templates/$templateId.tsx
@@ -0,0 +1,794 @@
+import { type EmailTemplate, type EmailTemplatePreview, SpreeError } from '@spree/admin-sdk'
+import {
+ PageHeader,
+ Subject,
+ useDisplayName,
+ usePermissions,
+ useStore,
+} from '@spree/dashboard-core'
+import {
+ Alert,
+ AlertAction,
+ AlertDescription,
+ AlertTitle,
+ Badge,
+ Button,
+ Card,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ DropdownMenuItem,
+ ErrorState,
+ Field,
+ FieldLabel,
+ Input,
+ ResourceLayout,
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+ Skeleton,
+ Tabs,
+ TabsList,
+ TabsTrigger,
+ toastManager,
+ useConfirm,
+ useDebouncedValue,
+} from '@spree/dashboard-ui'
+import {
+ HistoryIcon,
+ MonitorIcon,
+ RotateCcwIcon,
+ SendIcon,
+ SmartphoneIcon,
+ Trash2Icon,
+} from '@spree/dashboard-ui/icons'
+import { CodeEditor, type CodeEditorCompletion } from '@spree/dashboard-ui/ui/code-editor'
+import { createFileRoute } from '@tanstack/react-router'
+import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import { useTranslation } from 'react-i18next'
+import { DefaultDiffDialog } from '../../../../../../components/spree/email-templates/default-diff-dialog'
+import {
+ EmailPreviewFrame,
+ type EmailPreviewWidth,
+} from '../../../../../../components/spree/email-templates/email-preview-frame'
+import { EmailTemplateHistorySheet } from '../../../../../../components/spree/email-templates/history-sheet'
+import {
+ type EmailTemplateProblem,
+ templateProblems,
+ useDiscardEmailTemplateDraft,
+ useEmailTemplate,
+ useEmailTemplatePreview,
+ useEmailTemplateRevisions,
+ useEmailTemplates,
+ usePublishEmailTemplate,
+ useRestoreEmailTemplateRevision,
+ useRevertEmailTemplate,
+ useSaveEmailTemplateDraft,
+ useSendTestEmail,
+} from '../../../../../../hooks/use-email-templates'
+import { emailTemplateName } from '../../../../../../lib/email-template-name'
+import {
+ EMAIL_TEMPLATE_FILTERS,
+ EMAIL_TEMPLATE_VARIABLES,
+ type EmailTemplateVariable,
+ flattenVariables,
+ SHARED_EMAIL_VARIABLES,
+} from '../../../../../../lib/email-template-variables'
+
+export const Route = createFileRoute(
+ '/_authenticated/$storeId/settings/emails/templates/$templateId',
+)({
+ component: EmailTemplateEditorPage,
+})
+
+const ANY_LANGUAGE = 'any'
+const PREVIEW_DELAY_MS = 600
+
+function EmailTemplateEditorPage() {
+ const { t } = useTranslation()
+ const { templateId } = Route.useParams()
+ const [language, setLanguage] = useState(ANY_LANGUAGE)
+ const [reloads, setReloads] = useState(0)
+ const { data: template, isLoading, error, refetch } = useEmailTemplate(templateId, language)
+
+ if (error) {
+ return (
+ <ErrorState
+ title={t('admin.email_templates.errors.load_failed')}
+ description={error.message}
+ onRetry={() => refetch()}
+ />
+ )
+ }
+
+ if (isLoading || !template) {
+ return (
+ <div className="flex flex-col gap-6">
+ <Skeleton className="h-8 w-64" />
+ <Skeleton className="h-[32rem] w-full" />
+ </div>
+ )
+ }
+
+ return (
+ <EmailTemplateEditor
+ key={`${template.id}:${language}:${reloads}`}
+ template={template}
+ language={language}
+ onLanguageChange={setLanguage}
+ onReload={async () => {
+ await refetch()
+ setReloads((count) => count + 1)
+ }}
+ />
+ )
+}
+
+interface Version {
+ subject: string
+ body: string
+}
+
+/** What the editor opens on: the draft, else what customers receive now. */
+function startingVersion(template: EmailTemplate): Version {
+ const source = template.draft ?? template
+ return { subject: source.subject ?? '', body: source.body }
+}
+
+function EmailTemplateEditor({
+ template,
+ language,
+ onLanguageChange,
+ onReload,
+}: {
+ template: EmailTemplate
+ language: string
+ onLanguageChange: (language: string) => void
+ onReload: () => void
+}) {
+ const { t } = useTranslation()
+ const confirm = useConfirm()
+ const { permissions } = usePermissions()
+ const canEdit = permissions.can('update', Subject.EmailTemplate)
+ const isEmail = template.kind === 'email'
+
+ const [saved, setSaved] = useState<Version>(() => startingVersion(template))
+ const [subject, setSubject] = useState(saved.subject)
+ const [body, setBody] = useState(saved.body)
+ const [lockVersion, setLockVersion] = useState(template.draft?.lock_version)
+ const [hasDraft, setHasDraft] = useState(!!template.draft)
+ const [problems, setProblems] = useState<EmailTemplateProblem[]>([])
+ const [conflict, setConflict] = useState<string | null>(null)
+ const [historyOpen, setHistoryOpen] = useState(false)
+ const [diffOpen, setDiffOpen] = useState(false)
+ const dirty = subject !== saved.subject || body !== saved.body
+
+ const save = useSaveEmailTemplateDraft(template.id)
+ const discard = useDiscardEmailTemplateDraft(template.id)
+ const publish = usePublishEmailTemplate(template.id)
+ const revert = useRevertEmailTemplate(template.id)
+ const restore = useRestoreEmailTemplateRevision(template.id)
+ const sendTest = useSendTestEmail(template.id)
+ const revisions = useEmailTemplateRevisions(template.id, language, historyOpen)
+
+ const applyResponse = useCallback((next: EmailTemplate) => {
+ const version = startingVersion(next)
+ setSaved(version)
+ setSubject(version.subject)
+ setBody(version.body)
+ setLockVersion(next.draft?.lock_version)
+ setHasDraft(!!next.draft)
+ setProblems([])
+ }, [])
+
+ const handleError = (error: unknown) => {
+ if (error instanceof SpreeError && error.status === 409) {
+ setConflict(error.message)
+ return
+ }
+ const listed = templateProblems(error)
+ if (listed.length > 0) setProblems(listed)
+ else if (error instanceof Error) toastManager.add({ type: 'error', title: error.message })
+ }
+
+ const saveDraft = async (extra: { rebase?: boolean; version?: Version } = {}) => {
+ const version = extra.version ?? { subject, body }
+ try {
+ const next = await save.mutateAsync({
+ language,
+ body: version.body,
+ ...(isEmail ? { subject: version.subject } : {}),
+ lock_version: lockVersion,
+ rebase: extra.rebase,
+ })
+ // Keep what is being typed: only the saved copy moves on.
+ setSaved(version)
+ setLockVersion(next.draft?.lock_version)
+ setHasDraft(true)
+ setProblems([])
+ return next
+ } catch (error) {
+ handleError(error)
+ return null
+ }
+ }
+
+ const handlePublish = async () => {
+ if ((dirty || !hasDraft) && !(await saveDraft())) return
+ try {
+ applyResponse(await publish.mutateAsync(language))
+ } catch (error) {
+ handleError(error)
+ }
+ }
+
+ const handleDiscard = async () => {
+ const confirmed = await confirm({
+ title: t('admin.email_templates.confirm.discard_title'),
+ message: t('admin.email_templates.confirm.discard_message'),
+ confirmLabel: t('admin.email_templates.actions.discard_draft'),
+ variant: 'destructive',
+ })
+ if (!confirmed) return
+ try {
+ applyResponse(await discard.mutateAsync(language))
+ } catch {
+ // The mutation already reported the failure.
+ }
+ }
+
+ const handleRevert = async () => {
+ const confirmed = await confirm({
+ title: t('admin.email_templates.confirm.revert_title'),
+ message: t('admin.email_templates.confirm.revert_message'),
+ confirmLabel: t('admin.email_templates.actions.revert'),
+ variant: 'destructive',
+ })
+ if (!confirmed) return
+ try {
+ applyResponse(await revert.mutateAsync(language))
+ } catch {
+ // The mutation already reported the failure.
+ }
+ }
+
+ const handleRestore = async (revisionId: string) => {
+ const confirmed = await confirm({
+ title: t('admin.email_templates.confirm.restore_title'),
+ message: t('admin.email_templates.confirm.restore_message'),
+ confirmLabel: t('admin.email_templates.history.restore'),
+ variant: dirty ? 'destructive' : 'default',
+ })
+ if (!confirmed) return
+ try {
+ applyResponse(await restore.mutateAsync({ revisionId, language, lock_version: lockVersion }))
+ setHistoryOpen(false)
+ } catch (error) {
+ handleError(error)
+ }
+ }
+
+ const handleKeepMine = async () => {
+ if (await saveDraft({ rebase: true })) setDiffOpen(false)
+ }
+
+ const handleStartOver = async () => {
+ const version = { subject: template.default_subject ?? '', body: template.default_body }
+ if (await saveDraft({ rebase: true, version })) {
+ setSubject(version.subject)
+ setBody(version.body)
+ setDiffOpen(false)
+ }
+ }
+
+ const preview = useLivePreview(template.id, {
+ language,
+ subject: isEmail ? subject : undefined,
+ body,
+ })
+
+ const handleSendTest = async () => {
+ try {
+ const { sent_to } = await sendTest.mutateAsync({
+ language,
+ body,
+ ...(isEmail ? { subject } : {}),
+ record_id: preview.recordId || undefined,
+ email_key: preview.emailKey || undefined,
+ })
+ toastManager.add({
+ type: 'success',
+ title: t('admin.email_templates.messages.test_sent', { email: sent_to }),
+ })
+ } catch (error) {
+ handleError(error)
+ }
+ }
+
+ const shownProblems = problems.length > 0 ? problems : preview.problems
+ const diagnostics = shownProblems
+ .filter((problem) => !problem.email || problem.email === template.id)
+ .map((problem) => ({ line: problem.line, message: problem.message }))
+
+ const busy = save.isPending || publish.isPending || discard.isPending || revert.isPending
+
+ return (
+ <ResourceLayout
+ header={
+ <PageHeader
+ backTo="settings/emails/templates"
+ title={emailTemplateName(t, template.key)}
+ badges={<VersionBadge template={template} dirty={dirty} hasDraft={hasDraft} />}
+ actions={
+ canEdit && (
+ <>
+ <Button variant="outline" disabled={busy || !dirty} onClick={() => saveDraft()}>
+ {t('admin.email_templates.actions.save_draft')}
+ </Button>
+ <Button disabled={busy || (!dirty && !hasDraft)} onClick={handlePublish}>
+ {t('admin.email_templates.actions.publish')}
+ </Button>
+ </>
+ )
+ }
+ dropdownItems={
+ <>
+ {canEdit && (
+ <DropdownMenuItem disabled={sendTest.isPending} onClick={handleSendTest}>
+ <SendIcon className="size-4" />
+ {t('admin.email_templates.actions.send_test')}
+ </DropdownMenuItem>
+ )}
+ <DropdownMenuItem onClick={() => setHistoryOpen(true)}>
+ <HistoryIcon className="size-4" />
+ {t('admin.email_templates.actions.history')}
+ </DropdownMenuItem>
+ </>
+ }
+ destructiveItems={
+ canEdit && (
+ <>
+ {hasDraft && (
+ <DropdownMenuItem variant="destructive" disabled={busy} onClick={handleDiscard}>
+ <Trash2Icon className="size-4" />
+ {t('admin.email_templates.actions.discard_draft')}
+ </DropdownMenuItem>
+ )}
+ {(template.customized || hasDraft) && (
+ <DropdownMenuItem variant="destructive" disabled={busy} onClick={handleRevert}>
+ <RotateCcwIcon className="size-4" />
+ {t('admin.email_templates.actions.revert')}
+ </DropdownMenuItem>
+ )}
+ </>
+ )
+ }
+ />
+ }
+ main={
+ <div className="flex flex-col gap-4">
+ {template.default_changed && template.base_body !== null && (
+ <Alert variant="warning">
+ <AlertTitle>{t('admin.email_templates.default_update.title')}</AlertTitle>
+ <AlertDescription>
+ {t('admin.email_templates.default_update.description')}
+ </AlertDescription>
+ <AlertAction>
+ <Button size="sm" variant="outline" onClick={() => setDiffOpen(true)}>
+ {t('admin.email_templates.default_update.compare')}
+ </Button>
+ </AlertAction>
+ </Alert>
+ )}
+
+ {shownProblems.length > 0 && <ProblemsAlert problems={shownProblems} />}
+
+ <div className="grid gap-4 xl:grid-cols-2">
+ <Card>
+ <CardHeader className="flex flex-row items-center justify-between gap-4">
+ <CardTitle>{t('admin.email_templates.editor.title')}</CardTitle>
+ <LanguageSelect value={language} onChange={onLanguageChange} disabled={dirty} />
+ </CardHeader>
+ <CardContent className="flex flex-col gap-4">
+ {isEmail && (
+ <Field>
+ <FieldLabel htmlFor="email-template-subject">
+ {t('admin.email_templates.editor.subject')}
+ </FieldLabel>
+ <Input
+ id="email-template-subject"
+ value={subject}
+ readOnly={!canEdit}
+ onChange={(event) => setSubject(event.target.value)}
+ />
+ </Field>
+ )}
+ <CodeEditor
+ aria-label={t('admin.email_templates.editor.body')}
+ value={body}
+ onChange={setBody}
+ readOnly={!canEdit}
+ completions={preview.completions}
+ filters={FILTER_COMPLETIONS}
+ diagnostics={diagnostics}
+ onSave={() => canEdit && dirty && saveDraft()}
+ className="h-[36rem]"
+ />
+ </CardContent>
+ </Card>
+
+ <PreviewCard template={template} preview={preview} />
+ </div>
+
+ <VariablesCard templateId={template.id} />
+
+ <EmailTemplateHistorySheet
+ open={historyOpen}
+ onOpenChange={setHistoryOpen}
+ revisions={revisions.data?.data}
+ isLoading={revisions.isLoading}
+ canRestore={canEdit}
+ restoring={restore.isPending}
+ onRestore={(revision) => handleRestore(revision.id)}
+ />
+ <DefaultDiffDialog
+ open={diffOpen}
+ onOpenChange={setDiffOpen}
+ before={template.base_body ?? ''}
+ after={template.default_body}
+ pending={save.isPending}
+ onKeepMine={handleKeepMine}
+ onStartOver={handleStartOver}
+ />
+ <ConflictDialog
+ message={conflict}
+ onClose={() => setConflict(null)}
+ onReload={() => {
+ setConflict(null)
+ onReload()
+ }}
+ />
+ </div>
+ }
+ />
+ )
+}
+
+const FILTER_COMPLETIONS: CodeEditorCompletion[] = EMAIL_TEMPLATE_FILTERS.map((filter) => ({
+ label: filter,
+}))
+
+function VersionBadge({
+ template,
+ dirty,
+ hasDraft,
+}: {
+ template: EmailTemplate
+ dirty: boolean
+ hasDraft: boolean
+}) {
+ const { t } = useTranslation()
+
+ if (dirty) return <Badge variant="warning">{t('admin.email_templates.badges.unsaved')}</Badge>
+ if (hasDraft)
+ return <Badge variant="info">{t('admin.email_templates.badges.showing_draft')}</Badge>
+ if (template.customized) {
+ return <Badge variant="success">{t('admin.email_templates.badges.showing_published')}</Badge>
+ }
+ return <Badge variant="outline">{t('admin.email_templates.badges.showing_default')}</Badge>
+}
+
+function LanguageSelect({
+ value,
+ onChange,
+ disabled,
+}: {
+ value: string
+ onChange: (value: string) => void
+ disabled: boolean
+}) {
+ const { t } = useTranslation()
+ const { locales } = useStore()
+ const languageName = useDisplayName('language')
+ const options = [
+ { value: ANY_LANGUAGE, label: t('admin.email_templates.languages.any') },
+ ...locales.map((code) => ({ value: code, label: languageName(code) ?? code })),
+ ]
+
+ return (
+ <Select
+ items={options}
+ value={value}
+ disabled={disabled}
+ onValueChange={(next) => next && onChange(next as string)}
+ >
+ <SelectTrigger className="w-48" aria-label={t('admin.email_templates.editor.language')}>
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {options.map((option) => (
+ <SelectItem key={option.value} value={option.value}>
+ {option.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ )
+}
+
+function ProblemsAlert({ problems }: { problems: EmailTemplateProblem[] }) {
+ const { t } = useTranslation()
+
+ return (
+ <Alert variant="destructive">
+ <AlertTitle>{t('admin.email_templates.problems.title')}</AlertTitle>
+ <AlertDescription>
+ <ul className="list-disc pl-4">
+ {problems.map((problem) => (
+ <li key={`${problem.email}:${problem.line}:${problem.message}`}>
+ {problem.email && `${emailTemplateName(t, problem.email.replace(/\./g, '/'))}: `}
+ {problem.line
+ ? t('admin.email_templates.problems.on_line', {
+ line: problem.line,
+ message: problem.message,
+ })
+ : problem.message}
+ </li>
+ ))}
+ </ul>
+ </AlertDescription>
+ </Alert>
+ )
+}
+
+interface LivePreview {
+ data?: EmailTemplatePreview
+ problems: EmailTemplateProblem[]
+ unavailable?: string
+ completions: CodeEditorCompletion[]
+ recordId: string
+ setRecordId: (value: string) => void
+ emailKey: string
+ setEmailKey: (value: string) => void
+}
+
+/**
+ * Re-renders the template on the server once typing pauses. Only the latest
+ * request's answer is kept, so a slow render never overwrites a newer one.
+ */
+function useLivePreview(
+ templateId: string,
+ unsaved: { language: string; subject?: string; body: string },
+): LivePreview {
+ const { t } = useTranslation()
+ const [recordId, setRecordId] = useState('')
+ const [emailKey, setEmailKey] = useState('')
+ const [data, setData] = useState<EmailTemplatePreview>()
+ const [problems, setProblems] = useState<EmailTemplateProblem[]>([])
+ const [unavailable, setUnavailable] = useState<string>()
+ const { mutateAsync } = useEmailTemplatePreview(templateId)
+ const latest = useRef(0)
+
+ const request = useDebouncedValue(
+ JSON.stringify({
+ ...unsaved,
+ record_id: recordId || undefined,
+ email_key: emailKey || undefined,
+ }),
+ PREVIEW_DELAY_MS,
+ )
+
+ useEffect(() => {
+ const id = ++latest.current
+ mutateAsync(JSON.parse(request))
+ .then((result) => {
+ if (id !== latest.current) return
+ setData(result)
+ setProblems([])
+ setUnavailable(undefined)
+ })
+ .catch((error: unknown) => {
+ if (id !== latest.current) return
+ const listed = templateProblems(error)
+ setProblems(listed)
+ setUnavailable(listed.length > 0 ? undefined : (error as Error).message)
+ })
+ }, [request, mutateAsync])
+
+ const completions = useMemo(() => {
+ const documented = [...(EMAIL_TEMPLATE_VARIABLES[templateId] ?? []), ...SHARED_EMAIL_VARIABLES]
+ const descriptions = new Map(
+ documented.map((variable) => [variable.name, t(variable.descriptionKey)]),
+ )
+ const fromPreview = flattenVariables(data?.variables ?? {}).map(({ path, sample }) => ({
+ label: path,
+ detail: sample.length > 40 ? `${sample.slice(0, 40)}…` : sample,
+ info: descriptions.get(path),
+ }))
+ const known = new Set(fromPreview.map((completion) => completion.label))
+ const documentedOnly = documented
+ .filter((variable) => !known.has(variable.name))
+ .map((variable) => ({ label: variable.name, info: descriptions.get(variable.name) }))
+ return [...fromPreview, ...documentedOnly]
+ }, [data, templateId, t])
+
+ return { data, problems, unavailable, completions, recordId, setRecordId, emailKey, setEmailKey }
+}
+
+function PreviewCard({ template, preview }: { template: EmailTemplate; preview: LivePreview }) {
+ const { t } = useTranslation()
+ const [view, setView] = useState<'html' | 'text'>('html')
+ const [width, setWidth] = useState<EmailPreviewWidth>('desktop')
+ const { data: templates } = useEmailTemplates()
+ const emailOptions = (templates?.data ?? [])
+ .filter((entry) => entry.kind === 'email')
+ .map((entry) => ({ value: entry.id, label: emailTemplateName(t, entry.key) }))
+
+ return (
+ <Card>
+ <CardHeader className="flex flex-row flex-wrap items-center justify-between gap-2">
+ <div className="flex flex-col gap-1">
+ <CardTitle>{t('admin.email_templates.preview.title')}</CardTitle>
+ {preview.data && (
+ <CardDescription className="truncate">
+ {t('admin.email_templates.preview.subject', { subject: preview.data.subject })}
+ </CardDescription>
+ )}
+ </div>
+ <div className="flex items-center gap-2">
+ <Tabs value={view} onValueChange={(value) => setView(value as 'html' | 'text')}>
+ <TabsList>
+ <TabsTrigger value="html">{t('admin.email_templates.preview.html')}</TabsTrigger>
+ <TabsTrigger value="text">{t('admin.email_templates.preview.text')}</TabsTrigger>
+ </TabsList>
+ </Tabs>
+ <Button
+ size="icon-sm"
+ variant={width === 'desktop' ? 'outline' : 'ghost'}
+ aria-pressed={width === 'desktop'}
+ aria-label={t('admin.email_templates.preview.desktop')}
+ onClick={() => setWidth('desktop')}
+ >
+ <MonitorIcon className="size-4" />
+ </Button>
+ <Button
+ size="icon-sm"
+ variant={width === 'mobile' ? 'outline' : 'ghost'}
+ aria-pressed={width === 'mobile'}
+ aria-label={t('admin.email_templates.preview.mobile')}
+ onClick={() => setWidth('mobile')}
+ >
+ <SmartphoneIcon className="size-4" />
+ </Button>
+ </div>
+ </CardHeader>
+ <CardContent className="flex flex-col gap-3">
+ <div className="grid gap-3 sm:grid-cols-2">
+ {template.kind !== 'email' && (
+ <Field>
+ <FieldLabel htmlFor="email-template-preview-email">
+ {t('admin.email_templates.preview.shown_in')}
+ </FieldLabel>
+ <Select
+ items={emailOptions}
+ value={preview.emailKey || preview.data?.email_key || ''}
+ onValueChange={(value) => preview.setEmailKey((value as string) ?? '')}
+ >
+ <SelectTrigger id="email-template-preview-email">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {emailOptions.map((option) => (
+ <SelectItem key={option.value} value={option.value}>
+ {option.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </Field>
+ )}
+ <Field>
+ <FieldLabel htmlFor="email-template-preview-record">
+ {t('admin.email_templates.preview.record')}
+ </FieldLabel>
+ <Input
+ id="email-template-preview-record"
+ placeholder={t('admin.email_templates.preview.record_placeholder')}
+ value={preview.recordId}
+ onChange={(event) => preview.setRecordId(event.target.value.trim())}
+ />
+ </Field>
+ </div>
+ {preview.unavailable ? (
+ <p className="rounded-md border border-border p-4 text-sm text-muted-foreground">
+ {preview.unavailable}
+ </p>
+ ) : (
+ <EmailPreviewFrame
+ html={preview.data?.html}
+ text={preview.data?.text}
+ view={view}
+ width={width}
+ className="h-[36rem]"
+ />
+ )}
+ </CardContent>
+ </Card>
+ )
+}
+
+function VariablesCard({ templateId }: { templateId: string }) {
+ const { t } = useTranslation()
+ const variables: EmailTemplateVariable[] = [
+ ...(EMAIL_TEMPLATE_VARIABLES[templateId] ?? []),
+ ...SHARED_EMAIL_VARIABLES,
+ ]
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>{t('admin.email_templates.variables.title')}</CardTitle>
+ <CardDescription>{t('admin.email_templates.variables.description')}</CardDescription>
+ </CardHeader>
+ <CardContent>
+ <dl className="grid gap-3 sm:grid-cols-2">
+ {variables.map((variable) => (
+ <div key={variable.name} className="flex flex-col gap-1">
+ <dt className="font-mono text-sm">{`{{ ${variable.name} }}`}</dt>
+ <dd className="text-sm text-muted-foreground">{t(variable.descriptionKey)}</dd>
+ {variable.fields && (
+ <dd className="flex flex-wrap gap-1">
+ {variable.fields.map((field) => (
+ <code key={field} className="rounded bg-muted px-1.5 py-0.5 text-xs">
+ {`${variable.name}.${field}`}
+ </code>
+ ))}
+ </dd>
+ )}
+ </div>
+ ))}
+ </dl>
+ </CardContent>
+ </Card>
+ )
+}
+
+function ConflictDialog({
+ message,
+ onReload,
+ onClose,
+}: {
+ message: string | null
+ onReload: () => void
+ onClose: () => void
+}) {
+ const { t } = useTranslation()
+
+ return (
+ <Dialog open={!!message} onOpenChange={(open) => !open && onClose()}>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>{t('admin.email_templates.conflict.title')}</DialogTitle>
+ <DialogDescription>{message}</DialogDescription>
+ </DialogHeader>
+ <DialogFooter>
+ <Button variant="outline" onClick={onClose}>
+ {t('admin.email_templates.conflict.keep_editing')}
+ </Button>
+ <Button variant="destructive" onClick={onReload}>
+ {t('admin.email_templates.conflict.reload')}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )
+}
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails/templates/index.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails/templates/index.tsx
new file mode 100644
index 0000000000..0c0b481bc7
--- /dev/null
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/emails/templates/index.tsx
@@ -0,0 +1,140 @@
+import type { EmailTemplate } from '@spree/admin-sdk'
+import { PageHeader, Subject, usePermissions } from '@spree/dashboard-core'
+import {
+ Badge,
+ Card,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
+ ErrorState,
+ ResourceLayout,
+ Skeleton,
+} from '@spree/dashboard-ui'
+import { ChevronRightIcon } from '@spree/dashboard-ui/icons'
+import { createFileRoute, Link } from '@tanstack/react-router'
+import { useTranslation } from 'react-i18next'
+import { EmailsTabs } from '../../../../../../components/spree/email-templates/emails-tabs'
+import { useEmailTemplates } from '../../../../../../hooks/use-email-templates'
+import { emailTemplateName } from '../../../../../../lib/email-template-name'
+
+export const Route = createFileRoute('/_authenticated/$storeId/settings/emails/templates/')({
+ component: EmailTemplatesPage,
+})
+
+const GROUPS = ['email', 'layout', 'partial'] as const
+
+function EmailTemplatesPage() {
+ const { t } = useTranslation()
+ const { permissions } = usePermissions()
+ const { data, isLoading, error, refetch } = useEmailTemplates()
+
+ if (!permissions.can('read', Subject.EmailTemplate)) {
+ return <ErrorState title={t('admin.email_templates.errors.not_allowed')} />
+ }
+
+ return (
+ <ResourceLayout
+ header={
+ <PageHeader
+ docsPath="settings/emails"
+ title={t('admin.pages.settings.emails.title')}
+ description={t('admin.email_templates.list.description')}
+ />
+ }
+ main={
+ <>
+ <EmailsTabs current="templates" />
+ {error ? (
+ <ErrorState
+ title={t('admin.email_templates.errors.load_failed')}
+ description={error.message}
+ onRetry={() => refetch()}
+ />
+ ) : isLoading || !data ? (
+ <Skeleton className="h-96 w-full" />
+ ) : data.data.length === 0 ? (
+ <Card>
+ <CardContent className="py-10 text-center text-sm text-muted-foreground">
+ {t('admin.email_templates.list.empty')}
+ </CardContent>
+ </Card>
+ ) : (
+ GROUPS.map((kind) => (
+ <TemplateGroup
+ key={kind}
+ kind={kind}
+ templates={data.data.filter((template) => template.kind === kind)}
+ />
+ ))
+ )}
+ </>
+ }
+ />
+ )
+}
+
+function TemplateGroup({
+ kind,
+ templates,
+}: {
+ kind: (typeof GROUPS)[number]
+ templates: EmailTemplate[]
+}) {
+ const { t } = useTranslation()
+ const { storeId } = Route.useParams()
+ if (templates.length === 0) return null
+
+ return (
+ <Card>
+ <CardHeader>
+ <CardTitle>{t(`admin.email_templates.list.groups.${kind}.title`)}</CardTitle>
+ <CardDescription>
+ {t(`admin.email_templates.list.groups.${kind}.description`)}
+ </CardDescription>
+ </CardHeader>
+ <CardContent className="p-0">
+ <ul className="divide-y divide-border">
+ {templates.map((template) => (
+ <li key={template.id}>
+ <Link
+ to="/$storeId/settings/emails/templates/$templateId"
+ params={{ storeId, templateId: template.id }}
+ className="flex items-center gap-3 px-4 py-3 hover:bg-accent"
+ >
+ <div className="flex min-w-0 flex-1 flex-col">
+ <span className="font-medium">{emailTemplateName(t, template.key)}</span>
+ {template.subject && template.kind === 'email' && (
+ <span className="truncate text-sm text-muted-foreground">
+ {template.subject}
+ </span>
+ )}
+ </div>
+ <TemplateBadges template={template} />
+ <ChevronRightIcon className="size-4 text-muted-foreground" aria-hidden />
+ </Link>
+ </li>
+ ))}
+ </ul>
+ </CardContent>
+ </Card>
+ )
+}
+
+function TemplateBadges({ template }: { template: EmailTemplate }) {
+ const { t } = useTranslation()
+
+ return (
+ <div className="flex flex-wrap justify-end gap-1">
+ {template.default_changed && (
+ <Badge variant="warning">{t('admin.email_templates.badges.default_updated')}</Badge>
+ )}
+ {template.draft && <Badge variant="info">{t('admin.email_templates.badges.draft')}</Badge>}
+ {template.customized_languages.length > 0 ? (
+ <Badge variant="success">{t('admin.email_templates.badges.customized')}</Badge>
+ ) : (
+ <Badge variant="outline">{t('admin.email_templates.badges.default')}</Badge>
+ )}
+ </div>
+ )
+}
diff --git a/packages/dashboard/src/schemas/store-emails.ts b/packages/dashboard/src/schemas/store-emails.ts
index 9b976c6936..afb9a08dd8 100644
--- a/packages/dashboard/src/schemas/store-emails.ts
+++ b/packages/dashboard/src/schemas/store-emails.ts
@@ -5,6 +5,32 @@ import { z } from 'zod/v4'
// empty input without tripping the email validator. The mapper to API params
// converts empty strings to `null` so the backend treats them as cleared.
const optionalEmail = z.string().email().or(z.literal('')).optional()
+const optionalColor = z
+ .string()
+ .regex(/^#[0-9A-Fa-f]{6}$/)
+ .or(z.literal(''))
+ .nullable()
+ .optional()
+
+/** Fonts customer emails can use; mirrors `Spree::Emails::Branding::FONTS`. */
+export const EMAIL_FONTS = [
+ 'inter',
+ 'system',
+ 'helvetica',
+ 'georgia',
+ 'roboto',
+ 'lato',
+ 'merriweather',
+] as const
+
+/** Colors customer emails can be branded with, in the order the card shows them. */
+export const EMAIL_BRANDING_COLORS = [
+ 'accent_color',
+ 'background_color',
+ 'card_color',
+ 'text_color',
+ 'heading_color',
+] as const
export const storeEmailsFormSchema = z.object({
mail_from_address: z
@@ -14,6 +40,12 @@ export const storeEmailsFormSchema = z.object({
customer_support_email: optionalEmail,
new_order_notifications_email: optionalEmail,
preferred_send_consumer_transactional_emails: z.boolean(),
+ preferred_email_accent_color: optionalColor,
+ preferred_email_background_color: optionalColor,
+ preferred_email_card_color: optionalColor,
+ preferred_email_text_color: optionalColor,
+ preferred_email_heading_color: optionalColor,
+ preferred_email_font: z.enum(EMAIL_FONTS),
// Active Storage signed_id from a fresh direct upload. Frontend-only state.
mailer_logo_signed_id: z.string().nullable().optional(),
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 34f02c8b5b..7bfb62b62e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -529,6 +529,33 @@ importers:
'@base-ui/react':
specifier: 1.8.0
+ '@codemirror/autocomplete':
+ specifier: 6.20.3
+ version: 6.20.3
+ '@codemirror/commands':
+ specifier: 6.11.1
+ version: 6.11.1
+ '@codemirror/lang-html':
+ specifier: 6.4.12
+ version: 6.4.12
+ '@codemirror/lang-liquid':
+ specifier: 6.3.3
+ version: 6.3.3
+ '@codemirror/language':
+ specifier: 6.12.4
+ version: 6.12.4
+ '@codemirror/lint':
+ specifier: 6.9.7
+ version: 6.9.7
+ '@codemirror/search':
+ specifier: 6.7.2
+ version: 6.7.2
+ '@codemirror/state':
+ specifier: 6.7.6
+ version: 6.7.6
+ '@codemirror/view':
+ specifier: 6.43.13
+ version: 6.43.13
'@dnd-kit/core':
specifier: 6.3.1
@@ -1210,6 +1237,39 @@ packages:
resolution: {integrity: sha512-GgcWwRCs/xPtaqlMy8qRhPnZf9vlWcWZNHAitnVQ3yk7JmSralSiq5q07yaffYE8SogtDm7zFeKccx1QNVARpw==}
engines: {node: '>= 20.12.0'}
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-tlosUqb+3BbxCxZdu4tKeRghPFC+QM7q4X5YhKV2eCmPG+1r2F3f4AaSz5sCrFqUtX4Jh20VFTKecl16MgiV9g==}
+
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-O/4hG3SC1YwcmQ0d2UVNDs+AsaNWd1iHVxbTeEBuqH+6bExAiPK3iS/BvpY6rZGURALv4ZD3sIgcCmRvw3ehBg==}
+
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-kr5fwBGiGtmz6l0LSJIbno9QrifNMUusivHbnA1H6Dmqy4HZFte3UAICix1VuKo0lMPKQr2rqB+0BkKi/S3Ejg==}
+
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-pw2ReWKUqSkbvh76RAT4NYxiogRu+PWkR2ukAwO9uOgrm8uipkzjtKKtNpyeAQwHOqxEeSvAXZ6vr3AfyB9y/w==}
+
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-zD4e5mS+50htS7F+TYjBPsiIFGanfVqg4HyUz6WNFikgOPf2BgKlx+TQedI1w6n/IqRBVBbBWmGFdLB/7uxO4A==}
+
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-U9EnyzWuAx1TX3MZSKDXydKH734n1Aogk/ijKdW+jdIwmbf9zSPQYOIKggC/b2PTRjQb7ddvMktmxnfTLuv/SQ==}
+
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-1q4PaT+o6PbgpkJt4Q8Fv5XJxTy4FUZ4MWETtyiDw3J0Pyr9E2vqcKL+k9wcvjNTIsauxvE7OfmWj3FRPHQ76A==}
+
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-28/+iWLYxKxsvGYhSYL7zaCZqLz5+FFFDq9tVsvGv9kv8RY4fFAchJ5WX9M3YrrRlTIsECjsXPqeNgnSmNP2dg==}
+
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-gUYkYhT2+n/+VGZ+8EzE5WFkYZUZYm1VOKDudIsNqh42uRVQJ0a6Yss9sdKT3MeOYfuL1N6AZA57oza0Oyr0LA==}
+
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-kAz+AncRtKuIknedxT1bq4XwXv4UowhbkHU1myPrtVb/jZtImWuV5BXzv5vK6i3kYACsdiZiQKFQQ5Mq7elW8w==}
+
+ '@codemirror/[email protected]':
+ resolution: {integrity: sha512-sihaFrUzAsYBQsL9J2t69y8nfMQGwcYmggAZsk+kjPbjYZMyuf2hU8tUNTZ+P+isb6XRr8JE22TZlJxBoVdH1A==}
+
'@date-fns/[email protected]':
resolution: {integrity: sha512-P5LUNhtbj6YfI3iJjw5EL9eUAG6OitD0W3fWQcpQjDRc/QIsL0tRNuO1PcDvPccWL1fSTXXdE1ds+l95DV/OFA==}
@@ -1508,12 +1568,33 @@ packages:
'@jridgewell/[email protected]':
resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}
+ '@lezer/[email protected]':
+ resolution: {integrity: sha512-H0iErY4e43LpXbYDyBci5W4v/RwTgGV3YzYOlJPiGZ8RY8w51kVE+xLn1tg3Z6UmSfyETvtsUK3r7YsgDQEI7Q==}
+
+ '@lezer/[email protected]':
+ resolution: {integrity: sha512-EJn1zcL9qoDptief6ipWKZKLiOpXkxSe0+t8CH9oiMVcZlq7NBWrjCqnc/41EIjeo/ITj1gFFiATdTkaJDL+Og==}
+
+ '@lezer/[email protected]':
+ resolution: {integrity: sha512-O1GMVKgtf5YspFaRzpmqkVgMtIk2HG9uMAbH6wdAIdNh3TVzCsch/+cRi+6l2//UGDKe6NB9BW3cvuR5ezMQ0w==}
+
+ '@lezer/[email protected]':
+ resolution: {integrity: sha512-oI7n6NJml729m7pjm9lvLvmXbdoMoi2f+1pwSDJkl9d68zGr7a9Btz8NdHTGQZtW2DA25ybeuv/SyDb9D5tseg==}
+
+ '@lezer/[email protected]':
+ resolution: {integrity: sha512-sWg4yX1J6XW67AaAynVt0iwF0M5c+np36TEu+P2ifAJ8haRYvHnWDV28r1jdwnJehWCwXECutAUy56K4RBZIyg==}
+
+ '@lezer/[email protected]':
+ resolution: {integrity: sha512-rnCpTIBafOx4mRp43xOxDJbFipJm/c0cia/V5TiGlhmMa+wsSdoGmUN3w5Bqrks/09Q/D4tNAmWaT8p6NRi77A==}
+
'@manypkg/[email protected]':
resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==}
'@manypkg/[email protected]':
resolution: {integrity: sha512-fo+QhuU3qE/2TQMQmbVMqaQ6EWbMhi4ABWP+O4AM1NqPBuy0OrApV5LO6BrrgnhtAHS2NH6RrVk9OL181tTi8A==}
+ '@marijn/[email protected]':
+ resolution: {integrity: sha512-Wy0V7+SGUjnF9/TkiM1hKVDPj7jKXduPNboMVtHTA8dySMURWqfg/JZ9E2Sq8JgSJmkl7k7Qe9FLeMSrSraWmQ==}
+
'@modelcontextprotocol/[email protected]':
resolution: {integrity: sha512-zo37mZA9hJWpULgkRpowewez1y6ML5GsXJPY8FI0tBBCd77HEvza4jDqRKOXgHNn867PVGCyTdzqpz0izu5ZjQ==}
engines: {node: '>=18'}
@@ -2828,6 +2909,9 @@ packages:
typescript:
optional: true
+ resolution: {integrity: sha512-aK6BbWfhf4U/wCcLHKPJl/xa6VkVstRaPywWtMKGwuOLc/wZTyQYuoxgvZnNsBvv7Kg3YTBQYYBCggcviQczuA==}
+
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
engines: {node: '>= 8'}
@@ -4319,6 +4403,9 @@ packages:
resolution: {integrity: sha512-aulFJcD6YK8V1G7iRB5tigAP4TsHBZZrOV8pjV++zdUwmeV8uzbY7yn6h9MswN62adStNZFuCIx4haBnRuMDaw==}
engines: {node: '>=18'}
+ resolution: {integrity: sha512-XXWIQt633/EpAFx8aZDOTjBzrCaGmhvEQlQo6MVPfa2OzO2cWo+4hV9h+6UkHYlXGfy+ODXKUdP7Pthmcu5ATw==}
+
resolution: {integrity: sha512-DhuTmvZWux4H1UOnWMB3sk0sbaCVOoQZjv8u1rDoTV0HTdGem9hkAZtl4JZy8P2z4Bg0nT+YMeOFyVr4zcG5Tw==}
engines: {node: '>=16 || 14 >=14.17'}
@@ -5167,6 +5254,93 @@ snapshots:
fast-wrap-ansi: 0.2.0
sisteransi: 1.0.5
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/language': 6.12.4
+ '@codemirror/state': 6.7.6
+ '@codemirror/view': 6.43.13
+ '@lezer/common': 1.5.3
+
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/language': 6.12.4
+ '@codemirror/state': 6.7.6
+ '@codemirror/view': 6.43.13
+ '@lezer/common': 1.5.3
+
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/autocomplete': 6.20.3
+ '@codemirror/language': 6.12.4
+ '@codemirror/state': 6.7.6
+ '@lezer/common': 1.5.3
+ '@lezer/css': 1.3.8
+
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/autocomplete': 6.20.3
+ '@codemirror/lang-css': 6.3.1
+ '@codemirror/lang-javascript': 6.2.5
+ '@codemirror/language': 6.12.4
+ '@codemirror/state': 6.7.6
+ '@codemirror/view': 6.43.13
+ '@lezer/common': 1.5.3
+ '@lezer/css': 1.3.8
+ '@lezer/html': 1.3.13
+
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/autocomplete': 6.20.3
+ '@codemirror/language': 6.12.4
+ '@codemirror/lint': 6.9.7
+ '@codemirror/state': 6.7.6
+ '@codemirror/view': 6.43.13
+ '@lezer/common': 1.5.3
+ '@lezer/javascript': 1.5.5
+
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/autocomplete': 6.20.3
+ '@codemirror/lang-html': 6.4.12
+ '@codemirror/language': 6.12.4
+ '@codemirror/state': 6.7.6
+ '@codemirror/view': 6.43.13
+ '@lezer/common': 1.5.3
+ '@lezer/highlight': 1.2.5
+ '@lezer/lr': 1.4.10
+
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/state': 6.7.6
+ '@codemirror/view': 6.43.13
+ '@lezer/common': 1.5.3
+ '@lezer/highlight': 1.2.5
+ '@lezer/lr': 1.4.10
+ style-mod: 4.1.4
+
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/state': 6.7.6
+ '@codemirror/view': 6.43.13
+ crelt: 1.0.7
+
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/state': 6.7.6
+ '@codemirror/view': 6.43.13
+ crelt: 1.0.7
+
+ '@codemirror/[email protected]':
+ dependencies:
+ '@marijn/find-cluster-break': 1.0.4
+
+ '@codemirror/[email protected]':
+ dependencies:
+ '@codemirror/state': 6.7.6
+ crelt: 1.0.7
+ style-mod: 4.1.4
+ w3c-keyname: 2.2.8
+
'@date-fns/[email protected]': {}
@@ -5399,6 +5573,34 @@ snapshots:
'@jridgewell/resolve-uri': 3.1.2
'@jridgewell/sourcemap-codec': 1.5.5
+ '@lezer/[email protected]': {}
+
+ '@lezer/[email protected]':
+ dependencies:
+ '@lezer/common': 1.5.3
+ '@lezer/highlight': 1.2.5
+ '@lezer/lr': 1.4.10
+
+ '@lezer/[email protected]':
+ dependencies:
+ '@lezer/common': 1.5.3
+
+ '@lezer/[email protected]':
+ dependencies:
+ '@lezer/common': 1.5.3
+ '@lezer/highlight': 1.2.5
+ '@lezer/lr': 1.4.10
+
+ '@lezer/[email protected]':
+ dependencies:
+ '@lezer/common': 1.5.3
+ '@lezer/highlight': 1.2.5
+ '@lezer/lr': 1.4.10
+
+ '@lezer/[email protected]':
+ dependencies:
+ '@lezer/common': 1.5.3
+
'@manypkg/[email protected]':
dependencies:
'@babel/runtime': 7.29.7
@@ -5415,6 +5617,8 @@ snapshots:
globby: 11.1.0
read-yaml-file: 2.1.0
+ '@marijn/[email protected]': {}
+
'@modelcontextprotocol/[email protected]([email protected])':
dependencies:
'@hono/node-server': 1.19.17([email protected])
@@ -6570,6 +6774,8 @@ snapshots:
optionalDependencies:
typescript: 6.0.3
+
dependencies:
path-key: 3.1.1
@@ -8019,6 +8225,8 @@ snapshots:
+
dependencies:
'@jridgewell/gen-mapping': 0.3.13