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 subpath exports for the dashboard's auth building blocks (#14716)

Damian Legawiec9cd3d42efa3a
diff --git a/.changeset/dashboard-auth-building-blocks.md b/.changeset/dashboard-auth-building-blocks.md
new file mode 100644
index 0000000000..ea0ac359ca
--- /dev/null
+++ b/.changeset/dashboard-auth-building-blocks.md
@@ -0,0 +1,6 @@
+---
+"@spree/dashboard": minor
+"@spree/dashboard-core": minor
+---
+
+Host apps that build their own screens on the dashboard packages can now import the sign-in building blocks directly: `@spree/dashboard/components/spree/auth-shell` (`AuthShell`), `@spree/dashboard/hooks/use-auth-providers` (`useAuthProviders`, plus `authCallbackErrorKey` for the errors the SSO callback redirects back with) and `@spree/dashboard/schemas/auth` (the auth form schemas). The `admin.fields.setup.*` translations moved to `@spree/dashboard-core`, so `StoreSetupFields` renders translated outside the full dashboard too.
diff --git a/docs/developer/dashboard/public-api.mdx b/docs/developer/dashboard/public-api.mdx
index b92858f3a4..e28c96c6a4 100644
--- a/docs/developer/dashboard/public-api.mdx
+++ b/docs/developer/dashboard/public-api.mdx
@@ -229,6 +229,17 @@ import { spreeDashboardPlugin } from '@spree/dashboard/vite' // Vite plugin: Ta
import '@spree/dashboard/styles.css' // the app's CSS entry
```
+A host app that builds its own sign-in or onboarding screens, rather than mounting `<Dashboard />`, can reuse the dashboard's building blocks one module at a time without pulling in the app shell:
+
+```ts
+import { AuthShell } from '@spree/dashboard/components/spree/auth-shell' // two-column sign-in layout
+import { StoreSetupFields } from '@spree/dashboard/components/spree/store-setup-fields' // store name, country, language, currency
+import { useAuthProviders, authCallbackErrorKey } from '@spree/dashboard/hooks/use-auth-providers' // password + SSO options, SSO error copy
+import { loginFormSchema, resetPasswordFormSchema } from '@spree/dashboard/schemas/auth' // Zod schemas for the auth forms
+```
+
+Their translations ship with `@spree/dashboard-core`, so they render translated as soon as its i18n instance is loaded.
+
A few names exist in both re-exported packages — the design system ships a presentational component and the framework wraps it with data (`ResourceCombobox`, `StatusCard`, `Slot`, `DateRange`, `ResourceMultiAutocomplete`). The facade gives you the framework's version, which is the one an application wants. Reach past it when you want the presentational half:
```ts
diff --git a/packages/dashboard-core/src/locales/ar.json b/packages/dashboard-core/src/locales/ar.json
index 0207ee1e9a..1feca8451b 100644
--- a/packages/dashboard-core/src/locales/ar.json
+++ b/packages/dashboard-core/src/locales/ar.json
@@ -690,6 +690,32 @@
"quantity": {
"label": "الكمية"
},
+ "setup": {
+ "country_code": {
+ "help": "من أين تشحن. يمكن لمتجرك البيع في جميع أنحاء العالم — هذا يحدد فقط العملة والمستودع ومناطق التوصيل الأولية، ويمكن تغييرها لاحقًا.",
+ "label": "البلد",
+ "placeholder": "ابحث عن البلدان"
+ },
+ "currency": {
+ "help": "عملتك الافتراضية. أضف المزيد في أي وقت.",
+ "label": "العملة",
+ "placeholder": "ابحث عن العملات"
+ },
+ "locale": {
+ "help": "لغتك الافتراضية. أضف المزيد في أي وقت.",
+ "label": "اللغة"
+ },
+ "password_confirmation": {
+ "label": "تأكيد كلمة المرور"
+ },
+ "sample_data": {
+ "help": "يضيف في الخلفية منتجات وفئات وعملاء وطلبات تجريبية لاستكشاف لوحة التحكم. يستغرق بضع دقائق ويقوم بتنزيل صور المنتجات.",
+ "label": "تحميل بيانات تجريبية"
+ },
+ "store_name": {
+ "label": "اسم المتجر"
+ }
+ },
"shipping": {
"label": "الشحن"
},
diff --git a/packages/dashboard-core/src/locales/de.json b/packages/dashboard-core/src/locales/de.json
index 9598bb1acc..08eef12900 100644
--- a/packages/dashboard-core/src/locales/de.json
+++ b/packages/dashboard-core/src/locales/de.json
@@ -690,6 +690,32 @@
"quantity": {
"label": "Menge"
},
+ "setup": {
+ "country_code": {
+ "help": "Von wo Sie versenden. Ihr Shop kann weltweit verkaufen — dies legt nur Startwährung, Lager und Liefergebiete fest, alle später änderbar.",
+ "label": "Land",
+ "placeholder": "Länder durchsuchen"
+ },
+ "currency": {
+ "help": "Ihre Standardwährung. Jederzeit erweiterbar.",
+ "label": "Währung",
+ "placeholder": "Währungen durchsuchen"
+ },
+ "locale": {
+ "help": "Ihre Standardsprache. Jederzeit erweiterbar.",
+ "label": "Sprache"
+ },
+ "password_confirmation": {
+ "label": "Passwort bestätigen"
+ },
+ "sample_data": {
+ "help": "Fügt im Hintergrund Demo-Produkte, Kategorien, Kunden und Bestellungen hinzu, damit Sie das Dashboard erkunden können. Dauert einige Minuten und lädt Produktbilder herunter.",
+ "label": "Beispieldaten laden"
+ },
+ "store_name": {
+ "label": "Shopname"
+ }
+ },
"shipping": {
"label": "Versand"
},
diff --git a/packages/dashboard-core/src/locales/en.json b/packages/dashboard-core/src/locales/en.json
index a6eb02d50f..3f59a18086 100644
--- a/packages/dashboard-core/src/locales/en.json
+++ b/packages/dashboard-core/src/locales/en.json
@@ -692,6 +692,32 @@
"quantity": {
"label": "Quantity"
},
+ "setup": {
+ "country_code": {
+ "help": "Where you ship from. Your store can sell worldwide — this just sets the starting currency, warehouse and delivery zones, all editable later.",
+ "label": "Country",
+ "placeholder": "Search countries"
+ },
+ "currency": {
+ "help": "Your default currency. Add more anytime.",
+ "label": "Currency",
+ "placeholder": "Search currencies"
+ },
+ "locale": {
+ "help": "Your default language. Add more anytime.",
+ "label": "Language"
+ },
+ "password_confirmation": {
+ "label": "Confirm password"
+ },
+ "sample_data": {
+ "help": "Adds demo products, categories, customers and orders in the background so you can explore the dashboard. Takes a few minutes and downloads product images.",
+ "label": "Load sample data"
+ },
+ "store_name": {
+ "label": "Store name"
+ }
+ },
"shipping": {
"label": "Shipping"
},
diff --git a/packages/dashboard-core/src/locales/es.json b/packages/dashboard-core/src/locales/es.json
index 9cd739069f..6918d14b11 100644
--- a/packages/dashboard-core/src/locales/es.json
+++ b/packages/dashboard-core/src/locales/es.json
@@ -722,6 +722,32 @@
"quantity": {
"label": "Cantidad"
},
+ "setup": {
+ "country_code": {
+ "help": "Desde dónde enviás. Tu tienda puede vender en todo el mundo: esto solo define la moneda, el depósito y las zonas de entrega de inicio, todo editable después.",
+ "label": "País",
+ "placeholder": "Buscar países"
+ },
+ "currency": {
+ "help": "Tu moneda predeterminada. Agregá más cuando quieras.",
+ "label": "Moneda",
+ "placeholder": "Buscar monedas"
+ },
+ "locale": {
+ "help": "Tu idioma predeterminado. Agregá más cuando quieras.",
+ "label": "Idioma"
+ },
+ "password_confirmation": {
+ "label": "Confirmar contraseña"
+ },
+ "sample_data": {
+ "help": "Agrega productos, categorías, clientes y pedidos de demostración en segundo plano para que puedas explorar el dashboard. Tarda unos minutos y descarga imágenes de productos.",
+ "label": "Cargar datos de ejemplo"
+ },
+ "store_name": {
+ "label": "Nombre de la tienda"
+ }
+ },
"shipping": {
"label": "Envío"
},
diff --git a/packages/dashboard-core/src/locales/fr.json b/packages/dashboard-core/src/locales/fr.json
index c533f7bb73..73032ac81b 100644
--- a/packages/dashboard-core/src/locales/fr.json
+++ b/packages/dashboard-core/src/locales/fr.json
@@ -690,6 +690,32 @@
"quantity": {
"label": "Quantité"
},
+ "setup": {
+ "country_code": {
+ "help": "D'où vous expédiez. Votre boutique peut vendre dans le monde entier — ceci définit seulement la devise, l'entrepôt et les zones de livraison de départ, tous modifiables ensuite.",
+ "label": "Pays",
+ "placeholder": "Rechercher un pays"
+ },
+ "currency": {
+ "help": "Votre devise par défaut. Ajoutez-en d’autres quand vous voulez.",
+ "label": "Devise",
+ "placeholder": "Rechercher une devise"
+ },
+ "locale": {
+ "help": "Votre langue par défaut. Ajoutez-en d’autres quand vous voulez.",
+ "label": "Langue"
+ },
+ "password_confirmation": {
+ "label": "Confirmer le mot de passe"
+ },
+ "sample_data": {
+ "help": "Ajoute en arrière-plan des produits, catégories, clients et commandes de démonstration pour explorer le tableau de bord. Le chargement prend quelques minutes et télécharge les images des produits.",
+ "label": "Charger des données d’exemple"
+ },
+ "store_name": {
+ "label": "Nom de la boutique"
+ }
+ },
"shipping": {
"label": "Livraison"
},
diff --git a/packages/dashboard-core/src/locales/pl.json b/packages/dashboard-core/src/locales/pl.json
index 2afcec76ca..67b917c6d8 100644
--- a/packages/dashboard-core/src/locales/pl.json
+++ b/packages/dashboard-core/src/locales/pl.json
@@ -691,6 +691,32 @@
"quantity": {
"label": "Ilość"
},
+ "setup": {
+ "country_code": {
+ "help": "Skąd wysyłasz. Twój sklep może sprzedawać na całym świecie — to ustala tylko początkową walutę, magazyn i strefy dostawy, które później zmienisz.",
+ "label": "Kraj",
+ "placeholder": "Szukaj krajów"
+ },
+ "currency": {
+ "help": "Twoja domyślna waluta. Kolejne dodasz w każdej chwili.",
+ "label": "Waluta",
+ "placeholder": "Szukaj walut"
+ },
+ "locale": {
+ "help": "Twój domyślny język. Kolejne dodasz w każdej chwili.",
+ "label": "Język"
+ },
+ "password_confirmation": {
+ "label": "Potwierdź hasło"
+ },
+ "sample_data": {
+ "help": "Dodaje w tle przykładowe produkty, kategorie, klientów i zamówienia, aby można było poznać panel. Trwa kilka minut i pobiera zdjęcia produktów.",
+ "label": "Wczytaj dane przykładowe"
+ },
+ "store_name": {
+ "label": "Nazwa sklepu"
+ }
+ },
"shipping": {
"label": "Wysyłka"
},
diff --git a/packages/dashboard-core/src/locales/zh-CN.json b/packages/dashboard-core/src/locales/zh-CN.json
index 991987d688..fc12d9b239 100644
--- a/packages/dashboard-core/src/locales/zh-CN.json
+++ b/packages/dashboard-core/src/locales/zh-CN.json
@@ -690,6 +690,32 @@
"quantity": {
"label": "数量"
},
+ "setup": {
+ "country_code": {
+ "help": "您的发货地。您的商店可以面向全球销售——这只设置初始货币、仓库和配送区域,之后均可修改。",
+ "label": "国家/地区",
+ "placeholder": "搜索国家/地区"
+ },
+ "currency": {
+ "help": "您的默认货币。随时可添加更多。",
+ "label": "货币",
+ "placeholder": "搜索货币"
+ },
+ "locale": {
+ "help": "您的默认语言。随时可添加更多。",
+ "label": "语言"
+ },
+ "password_confirmation": {
+ "label": "确认密码"
+ },
+ "sample_data": {
+ "help": "在后台添加演示商品、分类、客户和订单,方便您浏览后台。需要几分钟并会下载商品图片。",
+ "label": "加载示例数据"
+ },
+ "store_name": {
+ "label": "商店名称"
+ }
+ },
"shipping": {
"label": "运费"
},
diff --git a/packages/dashboard/package.json b/packages/dashboard/package.json
index 60df692093..6f4aa17738 100644
--- a/packages/dashboard/package.json
+++ b/packages/dashboard/package.json
@@ -31,7 +31,10 @@
"default": "./dist/vite-plugin/route-collisions.js"
},
"./components/spree/payment-method-editors/types": "./src/components/spree/payment-method-editors/types.ts",
- "./components/spree/store-setup-fields": "./src/components/spree/store-setup-fields.tsx"
+ "./components/spree/auth-shell": "./src/components/spree/auth-shell.tsx",
+ "./components/spree/store-setup-fields": "./src/components/spree/store-setup-fields.tsx",
+ "./hooks/use-auth-providers": "./src/hooks/use-auth-providers.ts",
+ "./schemas/auth": "./src/schemas/auth.ts"
},
"files": [
"src",
diff --git a/packages/dashboard/src/components/spree/store-setup-fields.test.tsx b/packages/dashboard/src/components/spree/store-setup-fields.test.tsx
new file mode 100644
index 0000000000..1c43f0c350
--- /dev/null
+++ b/packages/dashboard/src/components/spree/store-setup-fields.test.tsx
@@ -0,0 +1,23 @@
+import { renderToStaticMarkup } from 'react-dom/server'
+import { useForm } from 'react-hook-form'
+import { describe, expect, it } from 'vitest'
+import { StoreSetupFields } from './store-setup-fields'
+
+function SetupForm() {
+ const form = useForm({
+ defaultValues: { store_name: '', country_code: '', locale: 'en', currency: 'USD' },
+ })
+ return <StoreSetupFields form={form} countries={[]} />
+}
+
+// Deliberately no `i18n-setup` import: a host app mounting these fields on
+// their own screens only has the framework's translations loaded.
+describe('StoreSetupFields', () => {
+ it('renders translated labels with only the framework translations loaded', () => {
+ const html = renderToStaticMarkup(<SetupForm />)
+
+ expect(html).toContain('Store name')
+ expect(html).toContain('Country')
+ expect(html).not.toContain('admin.fields.setup')
+ })
+})
diff --git a/packages/dashboard/src/hooks/use-auth-providers.test.ts b/packages/dashboard/src/hooks/use-auth-providers.test.ts
new file mode 100644
index 0000000000..8439571cf6
--- /dev/null
+++ b/packages/dashboard/src/hooks/use-auth-providers.test.ts
@@ -0,0 +1,16 @@
+import { describe, expect, it } from 'vitest'
+import { authCallbackErrorKey } from './use-auth-providers'
+
+describe('authCallbackErrorKey', () => {
+ it('maps a known callback error code to its copy', () => {
+ expect(authCallbackErrorKey('account_not_provisioned')).toBe(
+ 'admin.auth.login.account_not_provisioned',
+ )
+ })
+
+ it('falls back to the generic message for unknown and inherited names', () => {
+ for (const code of ['something_else', 'constructor', '__proto__', 'toString']) {
+ expect(authCallbackErrorKey(code)).toBe('admin.auth.login.sso_failed')
+ }
+ })
+})
diff --git a/packages/dashboard/src/hooks/use-auth-providers.ts b/packages/dashboard/src/hooks/use-auth-providers.ts
index f9c3346621..95a0710cd0 100644
--- a/packages/dashboard/src/hooks/use-auth-providers.ts
+++ b/packages/dashboard/src/hooks/use-auth-providers.ts
@@ -31,3 +31,29 @@ export function useAuthProviders() {
),
}
}
+
+/**
+ * Server error codes (`ERROR_CODES` in the Admin API) to their copy. A rejected
+ * SSO sign-in is not a failed credential check — the person proved who they are
+ * to the identity provider — so each code says what actually needs to happen.
+ */
+const CALLBACK_ERROR_KEYS: Record<string, string> = {
+ account_not_provisioned: 'admin.auth.login.account_not_provisioned',
+ invalid_oauth_state: 'admin.auth.login.invalid_oauth_state',
+ invalid_provider: 'admin.auth.login.sso_failed',
+ authentication_failed: 'admin.auth.login.sso_failed',
+ // Temporary and self-clearing — say so, rather than implying the provider is broken.
+ rate_limit_exceeded: 'admin.auth.login.rate_limit_exceeded',
+}
+
+/**
+ * Translation key for the `error` code the SSO callback redirects back to the
+ * login page with. Unknown codes fall back to the generic message.
+ */
+export function authCallbackErrorKey(code: string): string {
+ // `code` comes from the URL, so `constructor` or `__proto__` must not resolve
+ // to an inherited property.
+ return Object.hasOwn(CALLBACK_ERROR_KEYS, code)
+ ? CALLBACK_ERROR_KEYS[code]
+ : 'admin.auth.login.sso_failed'
+}
diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.json
index 20b38aab84..7abb612867 100644
--- a/packages/dashboard/src/locales/ar.json
+++ b/packages/dashboard/src/locales/ar.json
@@ -1869,32 +1869,6 @@
"label": "الضريبة يورّدها"
}
},
- "setup": {
- "country_code": {
- "help": "من أين تشحن. يمكن لمتجرك البيع في جميع أنحاء العالم — هذا يحدد فقط العملة والمستودع ومناطق التوصيل الأولية، ويمكن تغييرها لاحقًا.",
- "label": "البلد",
- "placeholder": "ابحث عن البلدان"
- },
- "currency": {
- "help": "عملتك الافتراضية. أضف المزيد في أي وقت.",
- "label": "العملة",
- "placeholder": "ابحث عن العملات"
- },
- "locale": {
- "help": "لغتك الافتراضية. أضف المزيد في أي وقت.",
- "label": "اللغة"
- },
- "password_confirmation": {
- "label": "تأكيد كلمة المرور"
- },
- "sample_data": {
- "help": "يضيف في الخلفية منتجات وفئات وعملاء وطلبات تجريبية لاستكشاف لوحة التحكم. يستغرق بضع دقائق ويقوم بتنزيل صور المنتجات.",
- "label": "تحميل بيانات تجريبية"
- },
- "store_name": {
- "label": "اسم المتجر"
- }
- },
"state": {
"label": "المنطقة"
},
diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.json
index c816408510..50519882e4 100644
--- a/packages/dashboard/src/locales/de.json
+++ b/packages/dashboard/src/locales/de.json
@@ -1851,32 +1851,6 @@
"label": "Steuer abgeführt von"
}
},
- "setup": {
- "country_code": {
- "help": "Von wo Sie versenden. Ihr Shop kann weltweit verkaufen — dies legt nur Startwährung, Lager und Liefergebiete fest, alle später änderbar.",
- "label": "Land",
- "placeholder": "Länder durchsuchen"
- },
- "currency": {
- "help": "Ihre Standardwährung. Jederzeit erweiterbar.",
- "label": "Währung",
- "placeholder": "Währungen durchsuchen"
- },
- "locale": {
- "help": "Ihre Standardsprache. Jederzeit erweiterbar.",
- "label": "Sprache"
- },
- "password_confirmation": {
- "label": "Passwort bestätigen"
- },
- "sample_data": {
- "help": "Fügt im Hintergrund Demo-Produkte, Kategorien, Kunden und Bestellungen hinzu, damit Sie das Dashboard erkunden können. Dauert einige Minuten und lädt Produktbilder herunter.",
- "label": "Beispieldaten laden"
- },
- "store_name": {
- "label": "Shopname"
- }
- },
"state": {
"label": "Bundesland"
},
diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.json
index 9b1f2f2ea5..d7e7da5414 100644
--- a/packages/dashboard/src/locales/en.json
+++ b/packages/dashboard/src/locales/en.json
@@ -1851,32 +1851,6 @@
"label": "Tax remitted by"
}
},
- "setup": {
- "country_code": {
- "help": "Where you ship from. Your store can sell worldwide — this just sets the starting currency, warehouse and delivery zones, all editable later.",
- "label": "Country",
- "placeholder": "Search countries"
- },
- "currency": {
- "help": "Your default currency. Add more anytime.",
- "label": "Currency",
- "placeholder": "Search currencies"
- },
- "locale": {
- "help": "Your default language. Add more anytime.",
- "label": "Language"
- },
- "password_confirmation": {
- "label": "Confirm password"
- },
- "sample_data": {
- "help": "Adds demo products, categories, customers and orders in the background so you can explore the dashboard. Takes a few minutes and downloads product images.",
- "label": "Load sample data"
- },
- "store_name": {
- "label": "Store name"
- }
- },
"state": {
"label": "State"
},
diff --git a/packages/dashboard/src/locales/es.json b/packages/dashboard/src/locales/es.json
index 3a83f06021..889041f2c2 100644
--- a/packages/dashboard/src/locales/es.json
+++ b/packages/dashboard/src/locales/es.json
@@ -1836,32 +1836,6 @@
"label": "Impuesto declarado por"
}
},
- "setup": {
- "country_code": {
- "help": "Desde dónde enviás. Tu tienda puede vender en todo el mundo: esto solo define la moneda, el depósito y las zonas de entrega de inicio, todo editable después.",
- "label": "País",
- "placeholder": "Buscar países"
- },
- "currency": {
- "help": "Tu moneda predeterminada. Agregá más cuando quieras.",
- "label": "Moneda",
- "placeholder": "Buscar monedas"
- },
- "locale": {
- "help": "Tu idioma predeterminado. Agregá más cuando quieras.",
- "label": "Idioma"
- },
- "password_confirmation": {
- "label": "Confirmar contraseña"
- },
- "sample_data": {
- "help": "Agrega productos, categorías, clientes y pedidos de demostración en segundo plano para que puedas explorar el dashboard. Tarda unos minutos y descarga imágenes de productos.",
- "label": "Cargar datos de ejemplo"
- },
- "store_name": {
- "label": "Nombre de la tienda"
- }
- },
"state": {
"label": "Provincia / Estado"
},
diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.json
index 3ed5dcfb9a..36c1282959 100644
--- a/packages/dashboard/src/locales/fr.json
+++ b/packages/dashboard/src/locales/fr.json
@@ -1851,32 +1851,6 @@
"label": "Taxe reversée par"
}
},
- "setup": {
- "country_code": {
- "help": "D'où vous expédiez. Votre boutique peut vendre dans le monde entier — ceci définit seulement la devise, l'entrepôt et les zones de livraison de départ, tous modifiables ensuite.",
- "label": "Pays",
- "placeholder": "Rechercher un pays"
- },
- "currency": {
- "help": "Votre devise par défaut. Ajoutez-en d’autres quand vous voulez.",
- "label": "Devise",
- "placeholder": "Rechercher une devise"
- },
- "locale": {
- "help": "Votre langue par défaut. Ajoutez-en d’autres quand vous voulez.",
- "label": "Langue"
- },
- "password_confirmation": {
- "label": "Confirmer le mot de passe"
- },
- "sample_data": {
- "help": "Ajoute en arrière-plan des produits, catégories, clients et commandes de démonstration pour explorer le tableau de bord. Le chargement prend quelques minutes et télécharge les images des produits.",
- "label": "Charger des données d’exemple"
- },
- "store_name": {
- "label": "Nom de la boutique"
- }
- },
"state": {
"label": "Région"
},
diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.json
index 311246ead8..ec0b10a972 100644
--- a/packages/dashboard/src/locales/pl.json
+++ b/packages/dashboard/src/locales/pl.json
@@ -1869,32 +1869,6 @@
"label": "Podatek rozlicza"
}
},
- "setup": {
- "country_code": {
- "help": "Skąd wysyłasz. Twój sklep może sprzedawać na całym świecie — to ustala tylko początkową walutę, magazyn i strefy dostawy, które później zmienisz.",
- "label": "Kraj",
- "placeholder": "Szukaj krajów"
- },
- "currency": {
- "help": "Twoja domyślna waluta. Kolejne dodasz w każdej chwili.",
- "label": "Waluta",
- "placeholder": "Szukaj walut"
- },
- "locale": {
- "help": "Twój domyślny język. Kolejne dodasz w każdej chwili.",
- "label": "Język"
- },
- "password_confirmation": {
- "label": "Potwierdź hasło"
- },
- "sample_data": {
- "help": "Dodaje w tle przykładowe produkty, kategorie, klientów i zamówienia, aby można było poznać panel. Trwa kilka minut i pobiera zdjęcia produktów.",
- "label": "Wczytaj dane przykładowe"
- },
- "store_name": {
- "label": "Nazwa sklepu"
- }
- },
"state": {
"label": "Region"
},
diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.json
index c7f2336884..164cf8aa89 100644
--- a/packages/dashboard/src/locales/zh-CN.json
+++ b/packages/dashboard/src/locales/zh-CN.json
@@ -1846,32 +1846,6 @@
"label": "税务申报方"
}
},
- "setup": {
- "country_code": {
- "help": "您的发货地。您的商店可以面向全球销售——这只设置初始货币、仓库和配送区域,之后均可修改。",
- "label": "国家/地区",
- "placeholder": "搜索国家/地区"
- },
- "currency": {
- "help": "您的默认货币。随时可添加更多。",
- "label": "货币",
- "placeholder": "搜索货币"
- },
- "locale": {
- "help": "您的默认语言。随时可添加更多。",
- "label": "语言"
- },
- "password_confirmation": {
- "label": "确认密码"
- },
- "sample_data": {
- "help": "在后台添加演示商品、分类、客户和订单,方便您浏览后台。需要几分钟并会下载商品图片。",
- "label": "加载示例数据"
- },
- "store_name": {
- "label": "商店名称"
- }
- },
"state": {
"label": "省/州"
},
diff --git a/packages/dashboard/src/routes/login.tsx b/packages/dashboard/src/routes/login.tsx
index 3efddda997..a03ddea7aa 100644
--- a/packages/dashboard/src/routes/login.tsx
+++ b/packages/dashboard/src/routes/login.tsx
@@ -8,7 +8,7 @@ import { createFileRoute, Link, Navigate } from '@tanstack/react-router'
import { useForm } from 'react-hook-form'
import { useTranslation } from 'react-i18next'
import { AuthShell } from '../components/spree/auth-shell'
-import { useAuthProviders } from '../hooks/use-auth-providers'
+import { authCallbackErrorKey, useAuthProviders } from '../hooks/use-auth-providers'
import { type LoginFormValues, loginFormSchema } from '../schemas/auth'
/** Error code the SSO callback redirects back with when it rejects a sign-in. */
@@ -239,27 +239,8 @@ function ProvidersUnavailable() {
)
}
-/**
- * Server error codes (`ERROR_CODES` in the Admin API) to their copy. A rejected
- * SSO sign-in is not a failed credential check — the person proved who they are
- * to the identity provider — so each code says what actually needs to happen.
- * Unknown codes fall back to the generic message.
- */
-const CALLBACK_ERROR_KEYS: Record<string, string> = {
- account_not_provisioned: 'admin.auth.login.account_not_provisioned',
- invalid_oauth_state: 'admin.auth.login.invalid_oauth_state',
- invalid_provider: 'admin.auth.login.sso_failed',
- authentication_failed: 'admin.auth.login.sso_failed',
- // Temporary and self-clearing — say so, rather than implying the provider is broken.
- rate_limit_exceeded: 'admin.auth.login.rate_limit_exceeded',
-}
-
function CallbackError({ code }: { code: string }) {
const { t } = useTranslation()
- return (
- <p className="text-sm text-destructive">
- {t(CALLBACK_ERROR_KEYS[code] ?? 'admin.auth.login.sso_failed')}
- </p>
- )
+ return <p className="text-sm text-destructive">{t(authCallbackErrorKey(code))}</p>
}