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.

Offer CSV import from the Getting Started add-products task

Damian Legawiec560afe37e482
diff --git a/docs/plans/5.6-admin-spa-csv-import.md b/docs/plans/5.6-admin-spa-csv-import.md
index 27ee6fc03a..5a4ec71474 100644
--- a/docs/plans/5.6-admin-spa-csv-import.md
+++ b/docs/plans/5.6-admin-spa-csv-import.md
@@ -344,7 +344,7 @@ Plus `useImports()` (history list), `useImportRows(id, params)` (5s `refetchInte
- **Processing**: `<Progress>` bar from `(completed + failed) / rows_count`, counter copy ("1,240 of 5,000 rows processed · 12 failed"), indeterminate "Preparing rows…" while `rows_count == 0`, and the failed-rows table streaming in below as failures appear. A **retry pass** is derivable (`completed + failed ≈ rows_count` while `processing`) — show "Retrying failed rows · N remaining" driven by the shrinking `failed_rows_count` instead of the (already full) bar.
- **Results**: success/partial summary (completed vs failed counts), paginated failed-rows table (row number, error message, expandable raw `data`), a **"Retry failed rows (N)"** button when `failed_rows_count > 0` (calls `retryFailedRows`; status flips to `processing` and the poll resumes automatically), and an "Import another" back-link. File-level `failed` shows `processing_errors` prominently.
-**Wiring:** inside the existing `<ResourceTable actions={(ctx) => …}>` render prop (`ResourceActionsContext`, `packages/dashboard-core/src/components/resource-table.tsx`) on the products index (`type="Spree::Imports::Products" subject={Subject.Product}`) and customers index (`type="Spree::Imports::Customers"` + the customer subject from the `Subject` map), next to the existing `ExportButton`. Unlike `ExportButton`, `ImportButton` ignores the context — imports don't consume filters. Product translations import stays backend-only until the translations dashboard work (`5.5-6.0-resource-translations-api.md`) surfaces it.
+**Wiring:** inside the existing `<ResourceTable actions={(ctx) => …}>` render prop (`ResourceActionsContext`, `packages/dashboard-core/src/components/resource-table.tsx`) on the products index (`type="Spree::Imports::Products" subject={Subject.Product}`) and customers index (`type="Spree::Imports::Customers"` + the customer subject from the `Subject` map), next to the existing `ExportButton`. Unlike `ExportButton`, `ImportButton` ignores the context — imports don't consume filters. The Getting Started "Add products" task also offers it (a registered `add_products` slot body: manual CTA + "Import products from CSV"; the created import lands on the products page with the wizard open). Product translations import stays backend-only until the translations dashboard work (`5.5-6.0-resource-translations-api.md`) surfaces it.
**i18n:** dashboard-core keys under `admin.components.import_button.*`, app keys under `admin.imports.*` — added to **all six** locale files (`en`, `de`, `fr`, `zh-CN`, `ar`, `pl`) in both packages.
diff --git a/packages/dashboard/src/components/spree/setup-tasks/add-products-task.tsx b/packages/dashboard/src/components/spree/setup-tasks/add-products-task.tsx
new file mode 100644
index 0000000000..f3b5770c63
--- /dev/null
+++ b/packages/dashboard/src/components/spree/setup-tasks/add-products-task.tsx
@@ -0,0 +1,41 @@
+import { ImportButton, Subject } from '@spree/dashboard-core'
+import { Button } from '@spree/dashboard-ui'
+import { Link, useNavigate } from '@tanstack/react-router'
+import { useTranslation } from 'react-i18next'
+import type { SetupTaskSlotContext } from './types'
+
+// Card body for the add_products task: the manual path (products page) plus
+// the bulk path — the CSV import sheet opens right here, and the created
+// import lands on the products page with the wizard dialog open (its
+// `?import=` search param).
+export function AddProductsTask({ task, storeId }: SetupTaskSlotContext) {
+ const { t } = useTranslation()
+ const navigate = useNavigate()
+
+ return (
+ <>
+ <p className="text-muted-foreground text-sm">
+ {t('admin.pages.getting_started.tasks.add_products.description')}
+ </p>
+ <div className="flex flex-wrap items-center gap-2">
+ <Button asChild variant={task.done ? 'outline' : 'default'}>
+ <Link to="/$storeId/products" params={{ storeId }}>
+ {t('admin.pages.getting_started.tasks.add_products.cta')}
+ </Link>
+ </Button>
+ <ImportButton
+ type="Spree::Imports::Products"
+ subject={Subject.Product}
+ label={t('admin.pages.getting_started.tasks.add_products.import_cta')}
+ onCreated={(imp) =>
+ navigate({
+ to: '/$storeId/products',
+ params: { storeId },
+ search: { import: imp.id } as never,
+ })
+ }
+ />
+ </div>
+ </>
+ )
+}
diff --git a/packages/dashboard/src/components/spree/setup-tasks/register.ts b/packages/dashboard/src/components/spree/setup-tasks/register.ts
index 15173fb925..ff73ddaf23 100644
--- a/packages/dashboard/src/components/spree/setup-tasks/register.ts
+++ b/packages/dashboard/src/components/spree/setup-tasks/register.ts
@@ -1,4 +1,5 @@
import { registerSlot } from '@spree/dashboard-core'
+import { AddProductsTask } from './add-products-task'
import { StorefrontConnectTask } from './storefront-connect-task'
import { type SetupTaskSlotContext, setupTaskSlot } from './types'
@@ -14,3 +15,8 @@ registerSlot<SetupTaskSlotContext>(setupTaskSlot('setup_storefront'), {
id: 'builtin',
component: StorefrontConnectTask,
})
+
+registerSlot<SetupTaskSlotContext>(setupTaskSlot('add_products'), {
+ id: 'builtin',
+ component: AddProductsTask,
+})
diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.json
index afb94b918b..3cc264a7c7 100644
--- a/packages/dashboard/src/locales/ar.json
+++ b/packages/dashboard/src/locales/ar.json
@@ -1698,7 +1698,8 @@
"add_products": {
"title": "إضافة المنتجات",
"description": "أضف منتجات إلى متجرك — منتجاتك الخاصة أو ادعُ بائعين خارجيين للبيع معًا.",
- "cta": "إضافة المنتجات"
+ "cta": "إضافة المنتجات",
+ "import_cta": "استيراد المنتجات من CSV"
},
"set_customer_support_email": {
"title": "تعيين البريد الإلكتروني لدعم العملاء",
diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.json
index 7e1df9eb5b..e3153581ed 100644
--- a/packages/dashboard/src/locales/de.json
+++ b/packages/dashboard/src/locales/de.json
@@ -1650,7 +1650,8 @@
"add_products": {
"title": "Produkte hinzufügen",
"description": "Fügen Sie Ihrem Shop Produkte hinzu — eigene oder laden Sie Drittanbieter ein, gemeinsam zu verkaufen.",
- "cta": "Produkte hinzufügen"
+ "cta": "Produkte hinzufügen",
+ "import_cta": "Produkte aus CSV importieren"
},
"set_customer_support_email": {
"title": "Kundensupport-E-Mail festlegen",
diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.json
index 67eabac89c..97612d24b7 100644
--- a/packages/dashboard/src/locales/en.json
+++ b/packages/dashboard/src/locales/en.json
@@ -1698,7 +1698,8 @@
"add_products": {
"title": "Add products",
"description": "Add products to your store — your own, or invite third-party vendors to sell together.",
- "cta": "Add products"
+ "cta": "Add products",
+ "import_cta": "Import products from CSV"
},
"set_customer_support_email": {
"title": "Set customer support email",
diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.json
index 4c57a051c2..941837ec29 100644
--- a/packages/dashboard/src/locales/fr.json
+++ b/packages/dashboard/src/locales/fr.json
@@ -1650,7 +1650,8 @@
"add_products": {
"title": "Ajouter des produits",
"description": "Ajoutez des produits à votre boutique — les vôtres, ou invitez des vendeurs tiers à vendre avec vous.",
- "cta": "Ajouter des produits"
+ "cta": "Ajouter des produits",
+ "import_cta": "Importer des produits depuis un CSV"
},
"set_customer_support_email": {
"title": "Définir l'e-mail du support client",
diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.json
index 0a07ab2c60..4754fa71c8 100644
--- a/packages/dashboard/src/locales/pl.json
+++ b/packages/dashboard/src/locales/pl.json
@@ -1670,7 +1670,8 @@
"add_products": {
"title": "Dodaj produkty",
"description": "Dodaj produkty do swojego sklepu — własne lub zaproś zewnętrznych sprzedawców do wspólnej sprzedaży.",
- "cta": "Dodaj produkty"
+ "cta": "Dodaj produkty",
+ "import_cta": "Importuj produkty z pliku CSV"
},
"set_customer_support_email": {
"title": "Ustaw e-mail obsługi klienta",
diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.json
index b27ddf7060..9747ea9e22 100644
--- a/packages/dashboard/src/locales/zh-CN.json
+++ b/packages/dashboard/src/locales/zh-CN.json
@@ -1698,7 +1698,8 @@
"add_products": {
"title": "添加商品",
"description": "为您的店铺添加商品——您自己的商品,或邀请第三方卖家共同销售。",
- "cta": "添加商品"
+ "cta": "添加商品",
+ "import_cta": "从 CSV 导入产品"
},
"set_customer_support_email": {
"title": "设置客服邮箱",