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 Digital files card to the seller panel

Damian Legawiec98a79cab9387
diff --git a/.changeset/seller-digital-assets.md b/.changeset/seller-digital-assets.md
new file mode 100644
index 0000000000..9a79404c94
--- /dev/null
+++ b/.changeset/seller-digital-assets.md
@@ -0,0 +1,8 @@
+---
+"@spree/seller-sdk": minor
+"@spree/seller-dashboard": minor
+"@spree/dashboard-core": minor
+"@spree/dashboard": patch
+---
+
+Sellers can manage the downloadable files on their own digital products. The Seller SDK adds `products.digitalAssets` (`list`, `get`, `create`, `update`, `delete`), and the seller panel's product page shows the same Digital files card as the dashboard: upload, replace and delete files, and set per-file download limits. The card now lives in `@spree/dashboard-core` as `DigitalAssetsCard`, and a panel enables it by registering `digitalAssets` on its API client.
diff --git a/packages/dashboard-core/src/api-client.ts b/packages/dashboard-core/src/api-client.ts
index dbc31b7197..693b32e325 100644
--- a/packages/dashboard-core/src/api-client.ts
+++ b/packages/dashboard-core/src/api-client.ts
@@ -15,7 +15,12 @@ import type { PackageTypeKind, PickupStockPolicy } from '@spree/core'
* promise the seller panel methods its API does not have.
*/
-import type { PermissionRule, UploadFileOptions } from '@spree/admin-sdk'
+import type {
+ DigitalAssetProvider,
+ PaginationMeta,
+ PermissionRule,
+ UploadFileOptions,
+} from '@spree/admin-sdk'
import type { CountryCode, DimensionUnit, WeightUnit } from '@spree/core'
/** What a panel may change on the signed-in person's own account. */
@@ -229,6 +234,29 @@ export interface PanelApiClient {
}
/** Removing a file already on a product. */
deleteProductMedia?(productId: string, mediaId: string): Promise<void>
+ /**
+ * The downloadable files a digital product delivers to its buyers.
+ *
+ * Registered rather than imported for the same reason as everything else
+ * here: the Digital files card is one component serving both panels.
+ * `providers` is operator-only — a provider is the marketplace's own code
+ * reaching into its internal systems — so a seller's client leaves it out
+ * and the card offers file uploads alone.
+ */
+ digitalAssets?: {
+ list(
+ productId: string,
+ params?: { page?: number; limit?: number },
+ ): Promise<{ data: PanelDigitalAsset[]; meta?: PaginationMeta }>
+ create(productId: string, params: PanelDigitalAssetParams): Promise<PanelDigitalAsset>
+ update(
+ productId: string,
+ id: string,
+ params: PanelDigitalAssetParams,
+ ): Promise<PanelDigitalAsset>
+ delete(productId: string, id: string): Promise<void>
+ providers?(productId: string): Promise<{ data: DigitalAssetProvider[] }>
+ }
/**
* The store-wide media library, for placing a file already uploaded onto
* another product. Operator-only: a seller sees their own product's files,
@@ -497,6 +525,42 @@ export interface PanelExport {
filename?: string | null
}
+/**
+ * A downloadable file, as the Digital files card reads it. Structural, like
+ * the other records here: both serializers carry these fields, and only the
+ * operator's adds `provider_settings`.
+ */
+export interface PanelDigitalAsset {
+ id: string
+ variant_id: string | null
+ filename: string | null
+ content_type: string | null
+ byte_size: number | null
+ /** Null means the store's download settings apply. */
+ authorized_clicks: number | null
+ authorized_days: number | null
+ /** The limits in force, after the store-settings fallback. */
+ effective_authorized_clicks: number
+ effective_authorized_days: number
+ provider_type: string | null
+ provider_name: string
+ download_url: string | null
+ provider_settings?: Record<string, unknown>
+}
+
+/**
+ * What either panel writes. The provider fields are the operator's alone; a
+ * seller's API refuses them.
+ */
+export interface PanelDigitalAssetParams {
+ signed_id?: string
+ variant_id?: string
+ authorized_clicks?: number | null
+ authorized_days?: number | null
+ provider_type?: string
+ provider_settings?: Record<string, unknown>
+}
+
/** A library file, as the picker lists it. */
export interface PanelMediaRecord {
id: string
diff --git a/packages/dashboard-core/src/index.ts b/packages/dashboard-core/src/index.ts
index 512abf1100..ffadb5c1ed 100644
--- a/packages/dashboard-core/src/index.ts
+++ b/packages/dashboard-core/src/index.ts
@@ -136,6 +136,7 @@ export * from './pages/stock-locations'
// Plugin facade — re-exported for convenience; same API as `/plugin` subpath
// ---------------------------------------------------------------------------
export * from './plugin'
+export * from './products/digital-assets-card'
export * from './products/normalize-customs'
export * from './products/normalize-quantity'
export * from './products/product-form-cards'
diff --git a/packages/dashboard-core/src/locales/ar.json b/packages/dashboard-core/src/locales/ar.json
index 1267b5641b..d2314b7906 100644
--- a/packages/dashboard-core/src/locales/ar.json
+++ b/packages/dashboard-core/src/locales/ar.json
@@ -948,6 +948,14 @@
"order_multiple": {
"label": "مضاعف الطلب",
"help": "كل زيادة فوق الحد الأدنى. اتركه فارغًا للسماح بأي كمية."
+ },
+ "store": {
+ "digital_asset_authorized_clicks": {
+ "label": "التنزيلات المسموح بها"
+ },
+ "digital_asset_authorized_days": {
+ "label": "الأيام المتاحة"
+ }
}
},
"image_upload": {
@@ -2050,6 +2058,35 @@
"description": "يجب على البائع تقديم عنوان للمرتجعات"
}
}
+ },
+ "digital_assets": {
+ "add": "إضافة",
+ "all_variants": "كل المتغيرات",
+ "columns": {
+ "file": "الملف",
+ "variant": "المتغير",
+ "size": "الحجم",
+ "downloads": "التنزيلات",
+ "days": "الأيام"
+ },
+ "delete_description": "لن يتمكن من اشترى «{{name}}» من تنزيله بعد الآن. يسري هذا فورًا.",
+ "delete_title": "حذف هذا الملف؟",
+ "description": "ملفات يمكن للمشترين تنزيلها بعد الشراء. أرفقها بمنتج رقمي، أو بمنتج مادي لتسليم دليل أو ضمان مع البضاعة.",
+ "download": "تنزيل",
+ "drop_hint": "اسحب الملفات وأفلتها هنا، أو انقر للتصفح",
+ "empty": "لا توجد ملفات بعد",
+ "limit_invalid": "يجب أن تكون الحدود أعدادًا صحيحة من 1 فأكثر، أو فارغة.",
+ "limits_help": "اترك حدود التنزيل والأيام فارغة لاستخدام إعدادات المتجر.",
+ "source": {
+ "upload": "رفع ملف"
+ },
+ "store_default": "{{count}} (افتراضي المتجر)",
+ "title": "الملفات الرقمية",
+ "untitled": "ملف بدون اسم",
+ "upload": "إضافة ملف",
+ "upload_failed": "فشل رفع {{name}}: {{message}}",
+ "uploading": "جارٍ رفع {{name}}…",
+ "uploading_short": "جارٍ الرفع…"
}
}
}
diff --git a/packages/dashboard-core/src/locales/de.json b/packages/dashboard-core/src/locales/de.json
index 44692828b7..c6c95e911f 100644
--- a/packages/dashboard-core/src/locales/de.json
+++ b/packages/dashboard-core/src/locales/de.json
@@ -948,6 +948,14 @@
"order_multiple": {
"label": "Bestellvielfaches",
"help": "Jeder Schritt über der Mindestmenge. Leer lassen für beliebige Mengen."
+ },
+ "store": {
+ "digital_asset_authorized_clicks": {
+ "label": "Erlaubte Downloads"
+ },
+ "digital_asset_authorized_days": {
+ "label": "Verfügbare Tage"
+ }
}
},
"image_upload": {
@@ -2045,6 +2053,35 @@
"description": "Der Verkäufer muss eine Rücksendeadresse angeben"
}
}
+ },
+ "digital_assets": {
+ "add": "Hinzufügen",
+ "all_variants": "Alle Varianten",
+ "columns": {
+ "file": "Datei",
+ "variant": "Variante",
+ "size": "Größe",
+ "downloads": "Downloads",
+ "days": "Tage"
+ },
+ "delete_description": "„{{name}}“ kann von niemandem mehr heruntergeladen werden, der sie gekauft hat. Dies wirkt sofort.",
+ "delete_title": "Diese Datei löschen?",
+ "description": "Dateien, die Käufer nach dem Kauf herunterladen können. Fügen Sie sie einem digitalen Produkt hinzu oder einem physischen Produkt, um eine Anleitung oder Garantie mitzuliefern.",
+ "download": "Herunterladen",
+ "drop_hint": "Dateien hierher ziehen und ablegen oder zum Durchsuchen klicken",
+ "empty": "Noch keine Dateien",
+ "limit_invalid": "Limits müssen ganze Zahlen ab 1 sein oder leer bleiben.",
+ "limits_help": "Lassen Sie die Download- und Tageslimits leer, um die Einstellungen des Shops zu verwenden.",
+ "source": {
+ "upload": "Datei hochladen"
+ },
+ "store_default": "{{count}} (Shop-Standard)",
+ "title": "Digitale Dateien",
+ "untitled": "Unbenannte Datei",
+ "upload": "Datei hinzufügen",
+ "upload_failed": "Hochladen von {{name}} fehlgeschlagen: {{message}}",
+ "uploading": "{{name}} wird hochgeladen…",
+ "uploading_short": "Wird hochgeladen…"
}
}
}
diff --git a/packages/dashboard-core/src/locales/en.json b/packages/dashboard-core/src/locales/en.json
index 6333a0eebe..d4aa7d68ba 100644
--- a/packages/dashboard-core/src/locales/en.json
+++ b/packages/dashboard-core/src/locales/en.json
@@ -950,6 +950,14 @@
"order_multiple": {
"label": "Order multiple",
"help": "Each step up from the minimum. Leave blank for any quantity."
+ },
+ "store": {
+ "digital_asset_authorized_clicks": {
+ "label": "Downloads allowed"
+ },
+ "digital_asset_authorized_days": {
+ "label": "Days available"
+ }
}
},
"image_upload": {
@@ -2047,6 +2055,35 @@
"description": "The seller must provide an address for returns"
}
}
+ },
+ "digital_assets": {
+ "add": "Add",
+ "all_variants": "All variants",
+ "columns": {
+ "file": "File",
+ "variant": "Variant",
+ "size": "Size",
+ "downloads": "Downloads",
+ "days": "Days"
+ },
+ "delete_description": "\"{{name}}\" will no longer be downloadable by anyone who bought it. This takes effect immediately.",
+ "delete_title": "Delete this file?",
+ "description": "Files buyers can download after purchase. Attach them to a digital product, or to a physical one to deliver a manual or warranty alongside the goods.",
+ "download": "Download",
+ "drop_hint": "Drag & drop files here, or click to browse",
+ "empty": "No files yet",
+ "limit_invalid": "Limits must be whole numbers of 1 or more, or blank.",
+ "limits_help": "Leave the download and day limits blank to use the store's settings.",
+ "source": {
+ "upload": "Upload a file"
+ },
+ "store_default": "{{count}} (store default)",
+ "title": "Digital files",
+ "untitled": "Untitled file",
+ "upload": "Add file",
+ "upload_failed": "Failed to upload {{name}}: {{message}}",
+ "uploading": "Uploading {{name}}…",
+ "uploading_short": "Uploading…"
}
}
}
diff --git a/packages/dashboard-core/src/locales/es.json b/packages/dashboard-core/src/locales/es.json
index 47d664504f..9668874af0 100644
--- a/packages/dashboard-core/src/locales/es.json
+++ b/packages/dashboard-core/src/locales/es.json
@@ -976,6 +976,14 @@
"order_multiple": {
"label": "Múltiplo de pedido",
"help": "Cada escalón por encima del mínimo. Dejalo en blanco para cualquier cantidad."
+ },
+ "store": {
+ "digital_asset_authorized_clicks": {
+ "label": "Descargas permitidas"
+ },
+ "digital_asset_authorized_days": {
+ "label": "Días disponibles"
+ }
}
},
"products": {
@@ -2047,6 +2055,35 @@
},
"media_library": {
"download": "Descargar"
+ },
+ "digital_assets": {
+ "add": "Agregar",
+ "all_variants": "Todas las variantes",
+ "columns": {
+ "file": "Archivo",
+ "variant": "Variante",
+ "size": "Tamaño",
+ "downloads": "Descargas",
+ "days": "Días"
+ },
+ "delete_description": "«{{name}}» ya no será descargable por nadie que lo haya comprado. Se aplica de inmediato.",
+ "delete_title": "¿Eliminar este archivo?",
+ "description": "Archivos que los compradores pueden descargar después de comprar. Adjuntalos a un producto digital, o a uno físico para entregar un manual o una garantía junto con la mercadería.",
+ "download": "Descargar",
+ "drop_hint": "Arrastrá y soltá los archivos acá, o hacé clic para explorar",
+ "empty": "Todavía no hay archivos",
+ "limit_invalid": "Los límites deben ser números enteros de 1 o más, o estar en blanco.",
+ "limits_help": "Dejá los límites de descarga y de días en blanco para usar la config de la tienda.",
+ "source": {
+ "upload": "Subir un archivo"
+ },
+ "store_default": "{{count}} (predeterminado de la tienda)",
+ "title": "Archivos digitales",
+ "untitled": "Archivo sin título",
+ "upload": "Agregar archivo",
+ "upload_failed": "No se pudo subir {{name}}: {{message}}",
+ "uploading": "Subiendo {{name}}…",
+ "uploading_short": "Subiendo…"
}
}
}
diff --git a/packages/dashboard-core/src/locales/fr.json b/packages/dashboard-core/src/locales/fr.json
index a5a4499be4..732f974cf9 100644
--- a/packages/dashboard-core/src/locales/fr.json
+++ b/packages/dashboard-core/src/locales/fr.json
@@ -948,6 +948,14 @@
"order_multiple": {
"label": "Multiple de commande",
"help": "Chaque palier au-dessus du minimum. Laisser vide pour toute quantité."
+ },
+ "store": {
+ "digital_asset_authorized_clicks": {
+ "label": "Téléchargements autorisés"
+ },
+ "digital_asset_authorized_days": {
+ "label": "Jours de disponibilité"
+ }
}
},
"image_upload": {
@@ -2045,6 +2053,35 @@
"description": "Le vendeur doit fournir une adresse pour les retours"
}
}
+ },
+ "digital_assets": {
+ "add": "Ajouter",
+ "all_variants": "Toutes les variantes",
+ "columns": {
+ "file": "Fichier",
+ "variant": "Variante",
+ "size": "Taille",
+ "downloads": "Téléchargements",
+ "days": "Jours"
+ },
+ "delete_description": "« {{name}} » ne sera plus téléchargeable par les personnes qui l'ont acheté. Effet immédiat.",
+ "delete_title": "Supprimer ce fichier ?",
+ "description": "Fichiers que les acheteurs peuvent télécharger après l'achat. Associez-les à un produit numérique, ou à un produit physique pour livrer un manuel ou une garantie.",
+ "download": "Télécharger",
+ "drop_hint": "Glissez-déposez des fichiers ici, ou cliquez pour parcourir",
+ "empty": "Aucun fichier pour le moment",
+ "limit_invalid": "Les limites doivent être des entiers supérieurs ou égaux à 1, ou vides.",
+ "limits_help": "Laissez les limites de téléchargements et de jours vides pour utiliser les paramètres de la boutique.",
+ "source": {
+ "upload": "Téléverser un fichier"
+ },
+ "store_default": "{{count}} (par défaut)",
+ "title": "Fichiers numériques",
+ "untitled": "Fichier sans nom",
+ "upload": "Ajouter un fichier",
+ "upload_failed": "Échec du téléversement de {{name}} : {{message}}",
+ "uploading": "Téléversement de {{name}}…",
+ "uploading_short": "Téléversement…"
}
}
}
diff --git a/packages/dashboard-core/src/locales/pl.json b/packages/dashboard-core/src/locales/pl.json
index fb1c170598..fa597b1c1e 100644
--- a/packages/dashboard-core/src/locales/pl.json
+++ b/packages/dashboard-core/src/locales/pl.json
@@ -949,6 +949,14 @@
"order_multiple": {
"label": "Wielokrotność zamówienia",
"help": "Każdy kolejny krok powyżej minimum. Pozostaw puste, aby dopuścić dowolną ilość."
+ },
+ "store": {
+ "digital_asset_authorized_clicks": {
+ "label": "Dozwolone pobrania"
+ },
+ "digital_asset_authorized_days": {
+ "label": "Dostępne dni"
+ }
}
},
"image_upload": {
@@ -2074,6 +2082,35 @@
"description": "Sprzedawca musi podać adres do zwrotów"
}
}
+ },
+ "digital_assets": {
+ "add": "Dodaj",
+ "all_variants": "Wszystkie warianty",
+ "columns": {
+ "file": "Plik",
+ "variant": "Wariant",
+ "size": "Rozmiar",
+ "downloads": "Pobrania",
+ "days": "Dni"
+ },
+ "delete_description": "„{{name}}” nie będzie już dostępny do pobrania dla osób, które go kupiły. Zmiana działa natychmiast.",
+ "delete_title": "Usunąć ten plik?",
+ "description": "Pliki, które kupujący mogą pobrać po zakupie. Dołącz je do produktu cyfrowego lub do fizycznego, aby dostarczyć instrukcję albo gwarancję.",
+ "download": "Pobierz",
+ "drop_hint": "Przeciągnij i upuść pliki tutaj lub kliknij, aby wybrać",
+ "empty": "Brak plików",
+ "limit_invalid": "Limity muszą być liczbami całkowitymi od 1 lub puste.",
+ "limits_help": "Pozostaw limity pobrań i dni puste, aby użyć ustawień sklepu.",
+ "source": {
+ "upload": "Prześlij plik"
+ },
+ "store_default": "{{count}} (domyślne sklepu)",
+ "title": "Pliki cyfrowe",
+ "untitled": "Plik bez nazwy",
+ "upload": "Dodaj plik",
+ "upload_failed": "Nie udało się przesłać {{name}}: {{message}}",
+ "uploading": "Przesyłanie {{name}}…",
+ "uploading_short": "Przesyłanie…"
}
}
}
diff --git a/packages/dashboard-core/src/locales/zh-CN.json b/packages/dashboard-core/src/locales/zh-CN.json
index 0701dac0bd..db6110627b 100644
--- a/packages/dashboard-core/src/locales/zh-CN.json
+++ b/packages/dashboard-core/src/locales/zh-CN.json
@@ -948,6 +948,14 @@
"order_multiple": {
"label": "订购倍数",
"help": "在最小起订量之上的每一档增量。留空表示不限数量。"
+ },
+ "store": {
+ "digital_asset_authorized_clicks": {
+ "label": "允许的下载次数"
+ },
+ "digital_asset_authorized_days": {
+ "label": "可用天数"
+ }
}
},
"image_upload": {
@@ -2044,6 +2052,35 @@
"description": "卖家必须提供退货地址"
}
}
+ },
+ "digital_assets": {
+ "add": "添加",
+ "all_variants": "所有变体",
+ "columns": {
+ "file": "文件",
+ "variant": "变体",
+ "size": "大小",
+ "downloads": "下载次数",
+ "days": "天数"
+ },
+ "delete_description": "购买过“{{name}}”的人将无法再下载它。此操作立即生效。",
+ "delete_title": "删除此文件?",
+ "description": "买家购买后可下载的文件。可附加到数字商品,也可附加到实体商品以随货提供说明书或保修卡。",
+ "download": "下载",
+ "drop_hint": "将文件拖放到此处,或点击浏览",
+ "empty": "暂无文件",
+ "limit_invalid": "限制必须是不小于 1 的整数,或留空。",
+ "limits_help": "将下载次数和天数限制留空即可使用商店设置。",
+ "source": {
+ "upload": "上传文件"
+ },
+ "store_default": "{{count}}(商店默认)",
+ "title": "数字文件",
+ "untitled": "未命名文件",
+ "upload": "添加文件",
+ "upload_failed": "上传 {{name}} 失败:{{message}}",
+ "uploading": "正在上传 {{name}}…",
+ "uploading_short": "上传中…"
}
}
}
diff --git a/packages/dashboard/src/components/spree/products/digital-asset-edit-sheet.tsx b/packages/dashboard-core/src/products/digital-asset-edit-sheet.tsx
similarity index 91%
rename from packages/dashboard/src/components/spree/products/digital-asset-edit-sheet.tsx
rename to packages/dashboard-core/src/products/digital-asset-edit-sheet.tsx
index 02f2df855c..0bac5f0ffd 100644
--- a/packages/dashboard/src/components/spree/products/digital-asset-edit-sheet.tsx
+++ b/packages/dashboard-core/src/products/digital-asset-edit-sheet.tsx
@@ -1,4 +1,4 @@
-import type { DigitalAsset, DigitalAssetProviderSettingField, Variant } from '@spree/admin-sdk'
+import type { DigitalAssetProviderSettingField } from '@spree/admin-sdk'
import {
Button,
Field,
@@ -17,13 +17,21 @@ import {
} from '@spree/dashboard-ui'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { useUpdateDigitalAsset } from '../../../hooks/use-digital-assets'
+import type { PanelDigitalAsset } from '../api-client'
import { ProviderSettingsFields } from './provider-settings-fields'
+import { useUpdateDigitalAsset } from './use-digital-assets'
+
+/** What the variant picker reads off either panel's variant. */
+export interface DigitalAssetVariantOption {
+ id: string
+ options_text?: string | null
+ sku?: string | null
+}
interface Props {
productId: string
- asset: DigitalAsset | null
- variants?: Variant[]
+ asset: PanelDigitalAsset | null
+ variants?: DigitalAssetVariantOption[]
/** Fields for a provider-backed asset; empty for an uploaded file. */
settingsSchema?: DigitalAssetProviderSettingField[]
open: boolean
@@ -132,7 +140,7 @@ export function DigitalAssetEditSheet({
<SelectContent>
{variants?.map((variant) => (
<SelectItem key={variant.id} value={variant.id}>
- {variant.options_text || variant.sku}
+ {variant.options_text || variant.sku || variant.id}
</SelectItem>
))}
</SelectContent>
diff --git a/packages/dashboard/src/components/spree/products/digital-asset-provider-sheet.tsx b/packages/dashboard-core/src/products/digital-asset-provider-sheet.tsx
similarity index 97%
rename from packages/dashboard/src/components/spree/products/digital-asset-provider-sheet.tsx
rename to packages/dashboard-core/src/products/digital-asset-provider-sheet.tsx
index 5d17803322..7a1135f9d3 100644
--- a/packages/dashboard/src/components/spree/products/digital-asset-provider-sheet.tsx
+++ b/packages/dashboard-core/src/products/digital-asset-provider-sheet.tsx
@@ -9,8 +9,8 @@ import {
} from '@spree/dashboard-ui'
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { useCreateDigitalAsset } from '../../../hooks/use-digital-assets'
import { defaultProviderSettings, ProviderSettingsFields } from './provider-settings-fields'
+import { useCreateDigitalAsset } from './use-digital-assets'
interface Props {
productId: string
diff --git a/packages/dashboard/src/components/spree/products/digital-assets-card.tsx b/packages/dashboard-core/src/products/digital-assets-card.tsx
similarity index 96%
rename from packages/dashboard/src/components/spree/products/digital-assets-card.tsx
rename to packages/dashboard-core/src/products/digital-assets-card.tsx
index 57f149fd6b..af189de896 100644
--- a/packages/dashboard/src/components/spree/products/digital-assets-card.tsx
+++ b/packages/dashboard-core/src/products/digital-assets-card.tsx
@@ -1,4 +1,4 @@
-import type { DigitalAsset, DigitalAssetProvider, Variant } from '@spree/admin-sdk'
+import type { DigitalAssetProvider } from '@spree/admin-sdk'
import { formatFileSize, useFileUpload } from '@spree/dashboard-core'
import {
Button,
@@ -34,28 +34,29 @@ import {
} from '@spree/dashboard-ui/icons'
import { useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
+import type { PanelDigitalAsset } from '../api-client'
+import { DigitalAssetEditSheet, type DigitalAssetVariantOption } from './digital-asset-edit-sheet'
+import { DigitalAssetProviderSheet } from './digital-asset-provider-sheet'
import {
useCreateDigitalAsset,
useDeleteDigitalAsset,
useDigitalAssetProviders,
useDigitalAssets,
-} from '../../../hooks/use-digital-assets'
-import { DigitalAssetEditSheet } from './digital-asset-edit-sheet'
-import { DigitalAssetProviderSheet } from './digital-asset-provider-sheet'
+} from './use-digital-assets'
export function DigitalAssetsCard({
productId,
variants,
}: {
productId?: string
- variants?: Variant[]
+ variants?: DigitalAssetVariantOption[]
}) {
const { t } = useTranslation()
const confirm = useConfirm()
const fileInputRef = useRef<HTMLInputElement>(null)
const [uploading, setUploading] = useState(false)
const [page, setPage] = useState(1)
- const [editing, setEditing] = useState<DigitalAsset | null>(null)
+ const [editing, setEditing] = useState<PanelDigitalAsset | null>(null)
// The provider whose settings sheet is open, before its asset is created.
const [configuring, setConfiguring] = useState<DigitalAssetProvider | null>(null)
@@ -67,7 +68,7 @@ export function DigitalAssetsCard({
const createAsset = useCreateDigitalAsset(productId ?? '')
const deleteAsset = useDeleteDigitalAsset(productId ?? '')
- const assets: DigitalAsset[] = data?.data ?? []
+ const assets: PanelDigitalAsset[] = data?.data ?? []
const meta = data?.meta
const hasVariants = (variants?.length ?? 0) > 1
const providers = providersData?.data ?? []
@@ -137,7 +138,7 @@ export function DigitalAssetsCard({
}
}
- async function handleDelete(asset: DigitalAsset) {
+ async function handleDelete(asset: PanelDigitalAsset) {
const confirmed = await confirm({
title: t('admin.digital_assets.delete_title'),
message: t('admin.digital_assets.delete_description', {
diff --git a/packages/dashboard/src/components/spree/products/provider-settings-fields.tsx b/packages/dashboard-core/src/products/provider-settings-fields.tsx
similarity index 100%
rename from packages/dashboard/src/components/spree/products/provider-settings-fields.tsx
rename to packages/dashboard-core/src/products/provider-settings-fields.tsx
diff --git a/packages/dashboard-core/src/products/use-digital-assets.ts b/packages/dashboard-core/src/products/use-digital-assets.ts
new file mode 100644
index 0000000000..4420fd2d64
--- /dev/null
+++ b/packages/dashboard-core/src/products/use-digital-assets.ts
@@ -0,0 +1,60 @@
+import { getApiClient, i18n, useResourceKey, useResourceMutation } from '@spree/dashboard-core'
+import { useQuery } from '@tanstack/react-query'
+import type { PanelDigitalAssetParams } from '../api-client'
+
+// The logical invalidation key (tenant id auto-injected by useResourceMutation).
+const digitalAssetsKey = (productId: string) => ['products', productId, 'digital-assets']
+
+function digitalAssetsClient() {
+ const client = getApiClient().digitalAssets
+ if (!client) throw new Error('This panel cannot manage digital files.')
+ return client
+}
+
+export function useDigitalAssets(productId: string, page = 1, enabled = true) {
+ return useQuery({
+ queryKey: useResourceKey('products', productId, 'digital-assets', page),
+ queryFn: () => digitalAssetsClient().list(productId, { page, limit: 25 }),
+ enabled: enabled && Boolean(productId),
+ })
+}
+
+// The selectable sources for a new asset. Almost always just the File default,
+// so a host with no extra provider gets a one-entry list and the card keeps its
+// plain "Add file" button. A panel whose client registers no providers (a
+// seller's) never asks.
+export function useDigitalAssetProviders(productId: string, enabled = true) {
+ const providers = getApiClient().digitalAssets?.providers
+ return useQuery({
+ queryKey: useResourceKey('products', productId, 'digital-asset-providers'),
+ queryFn: () => providers!(productId),
+ enabled: enabled && Boolean(productId) && Boolean(providers),
+ staleTime: Number.POSITIVE_INFINITY, // the registry doesn't change at runtime
+ })
+}
+
+export function useCreateDigitalAsset(productId: string) {
+ return useResourceMutation({
+ mutationFn: (params: PanelDigitalAssetParams) =>
+ digitalAssetsClient().create(productId, params),
+ invalidate: [digitalAssetsKey(productId)],
+ successMessage: i18n.t('admin.messages.digital_asset_saved'),
+ })
+}
+
+export function useUpdateDigitalAsset(productId: string) {
+ return useResourceMutation({
+ mutationFn: ({ id, ...params }: PanelDigitalAssetParams & { id: string }) =>
+ digitalAssetsClient().update(productId, id, params),
+ invalidate: [digitalAssetsKey(productId)],
+ successMessage: i18n.t('admin.messages.digital_asset_saved'),
+ })
+}
+
+export function useDeleteDigitalAsset(productId: string) {
+ return useResourceMutation({
+ mutationFn: (id: string) => digitalAssetsClient().delete(productId, id),
+ invalidate: [digitalAssetsKey(productId)],
+ successMessage: i18n.t('admin.messages.digital_asset_removed'),
+ })
+}
diff --git a/packages/dashboard/e2e/seller-panel-products.spec.ts b/packages/dashboard/e2e/seller-panel-products.spec.ts
index 88123beb15..12321fd2c8 100644
--- a/packages/dashboard/e2e/seller-panel-products.spec.ts
+++ b/packages/dashboard/e2e/seller-panel-products.spec.ts
@@ -1,5 +1,13 @@
+import * as path from 'node:path'
+import { fileURLToPath } from 'node:url'
import { expect, type Page, test } from '@playwright/test'
-import { clickBulkAction, FIXTURE_SELLER_WRITER_EMAIL, sellerLogin } from './helpers'
+import { clickBulkAction, FIXTURE_SELLER_WRITER_EMAIL, openRowMenu, sellerLogin } from './helpers'
+
+// The card serves whatever is attached, so the shared image fixture will do.
+const DIGITAL_FILE = path.join(
+ path.dirname(fileURLToPath(import.meta.url)),
+ 'fixtures/test-image.png',
+)
/** Lists a product from the panel's form and returns to the seller's product list. */
async function listProduct(page: Page, home: string, name: string) {
@@ -73,4 +81,44 @@ test.describe('seller panel — products', () => {
await expect(productRow(page, name)).toHaveCount(0, { timeout: 15_000 })
})
+
+ // A seller selling downloads manages the files on their own listing.
+ test('uploads a digital file, sets its download limits, then removes it', async ({ page }) => {
+ const home = await sellerLogin(page, FIXTURE_SELLER_WRITER_EMAIL)
+ await listProduct(page, home, `E2E Amp Model ${Date.now()}`)
+
+ const digitalCard = page
+ .locator('[data-slot="card"]')
+ .filter({ has: page.locator('[data-slot="card-title"]', { hasText: /^Digital files$/ }) })
+ await expect(digitalCard).toHaveCount(1)
+
+ const fileName = path.basename(DIGITAL_FILE)
+ await digitalCard.locator('input[type="file"]').setInputFiles(DIGITAL_FILE)
+
+ const fileRow = digitalCard.locator('tr').filter({ hasText: fileName })
+ await expect(fileRow).toBeVisible({ timeout: 30_000 })
+
+ await openRowMenu(page, fileName)
+ await page.getByRole('menuitem', { name: /^edit$/i }).click()
+ const sheet = page.getByRole('dialog')
+ await sheet.getByLabel(/downloads allowed/i).fill('3')
+ await sheet.getByLabel(/days available/i).fill('30')
+ await sheet.getByRole('button', { name: /^save$/i }).click()
+ await expect(sheet).toBeHidden()
+
+ await expect(fileRow.getByRole('cell', { name: '3', exact: true })).toBeVisible({
+ timeout: 15_000,
+ })
+ await expect(fileRow.getByRole('cell', { name: '30', exact: true })).toBeVisible()
+
+ await openRowMenu(page, fileName)
+ await page.getByRole('menuitem', { name: /^delete$/i }).click()
+ await page
+ .getByRole('dialog')
+ .getByRole('button', { name: /^confirm$/i })
+ .click()
+
+ await expect(fileRow).toBeHidden({ timeout: 15_000 })
+ await expect(digitalCard.getByText(/drag & drop files here/i)).toBeVisible()
+ })
})
diff --git a/packages/dashboard/src/api-client-setup.ts b/packages/dashboard/src/api-client-setup.ts
index 82eca35c5b..1f0dbba017 100644
--- a/packages/dashboard/src/api-client-setup.ts
+++ b/packages/dashboard/src/api-client-setup.ts
@@ -85,6 +85,14 @@ setApiClient({
delete: (id) => adminClient.packageTypes.delete(id),
},
deleteProductMedia: (productId, mediaId) => adminClient.products.media.delete(productId, mediaId),
+ digitalAssets: {
+ list: (productId, params) => adminClient.products.digitalAssets.list(productId, params),
+ create: (productId, params) => adminClient.products.digitalAssets.create(productId, params),
+ update: (productId, id, params) =>
+ adminClient.products.digitalAssets.update(productId, id, params),
+ delete: (productId, id) => adminClient.products.digitalAssets.delete(productId, id),
+ providers: (productId) => adminClient.products.digitalAssets.providers(productId),
+ },
mediaLibrary: { list: (params) => adminClient.media.list(runtimeListParams(params)) },
tags: {
list: (params) => adminClient.tags.list(params as { taggable_type: string; q?: string }),
diff --git a/packages/dashboard/src/hooks/use-digital-assets.ts b/packages/dashboard/src/hooks/use-digital-assets.ts
index 0643100fb5..b6965ddd04 100644
--- a/packages/dashboard/src/hooks/use-digital-assets.ts
+++ b/packages/dashboard/src/hooks/use-digital-assets.ts
@@ -1,57 +1,4 @@
-import { adminClient, i18n, useResourceKey, useResourceMutation } from '@spree/dashboard-core'
-import { useQuery } from '@tanstack/react-query'
-
-type DigitalAssetCreateParams = Parameters<typeof adminClient.products.digitalAssets.create>[1]
-type DigitalAssetUpdateParams = Parameters<typeof adminClient.products.digitalAssets.update>[2]
-
-// The logical invalidation key (tenant id auto-injected by useResourceMutation).
-const digitalAssetsKey = (productId: string) => ['products', productId, 'digital-assets']
-
-export function useDigitalAssets(productId: string, page = 1, enabled = true) {
- return useQuery({
- queryKey: useResourceKey('products', productId, 'digital-assets', page),
- queryFn: () => adminClient.products.digitalAssets.list(productId, { page, limit: 25 }),
- enabled: enabled && Boolean(productId),
- })
-}
-
-// The selectable sources for a new asset. Almost always just the File default,
-// so a host with no extra provider gets a one-entry list and the card keeps its
-// plain "Add file" button.
-export function useDigitalAssetProviders(productId: string, enabled = true) {
- return useQuery({
- queryKey: useResourceKey('products', productId, 'digital-asset-providers'),
- queryFn: () => adminClient.products.digitalAssets.providers(productId),
- enabled: enabled && Boolean(productId),
- staleTime: Number.POSITIVE_INFINITY, // the registry doesn't change at runtime
- })
-}
-
-export function useCreateDigitalAsset(productId: string) {
- return useResourceMutation({
- mutationFn: (params: DigitalAssetCreateParams) =>
- adminClient.products.digitalAssets.create(productId, params),
- invalidate: [digitalAssetsKey(productId)],
- successMessage: i18n.t('admin.messages.digital_asset_saved'),
- })
-}
-
-export function useUpdateDigitalAsset(productId: string) {
- return useResourceMutation({
- mutationFn: ({ id, ...params }: DigitalAssetUpdateParams & { id: string }) =>
- adminClient.products.digitalAssets.update(productId, id, params),
- invalidate: [digitalAssetsKey(productId)],
- successMessage: i18n.t('admin.messages.digital_asset_saved'),
- })
-}
-
-export function useDeleteDigitalAsset(productId: string) {
- return useResourceMutation({
- mutationFn: (id: string) => adminClient.products.digitalAssets.delete(productId, id),
- invalidate: [digitalAssetsKey(productId)],
- successMessage: i18n.t('admin.messages.digital_asset_removed'),
- })
-}
+import { adminClient, i18n, useResourceMutation } from '@spree/dashboard-core'
export function useResendDigitalLinks(orderId: string) {
return useResourceMutation({
diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.json
index 29fb885616..8f54a853b1 100644
--- a/packages/dashboard/src/locales/ar.json
+++ b/packages/dashboard/src/locales/ar.json
@@ -954,35 +954,6 @@
"to_placeholder": "إلى",
"toggle_states": "عرض مناطق {{country}}"
},
- "digital_assets": {
- "add": "إضافة",
- "all_variants": "كل المتغيرات",
- "columns": {
- "file": "الملف",
- "variant": "المتغير",
- "size": "الحجم",
- "downloads": "التنزيلات",
- "days": "الأيام"
- },
- "delete_description": "لن يتمكن من اشترى «{{name}}» من تنزيله بعد الآن. يسري هذا فورًا.",
- "delete_title": "حذف هذا الملف؟",
- "description": "ملفات يمكن للمشترين تنزيلها بعد الشراء. أرفقها بمنتج رقمي، أو بمنتج مادي لتسليم دليل أو ضمان مع البضاعة.",
- "download": "تنزيل",
- "drop_hint": "اسحب الملفات وأفلتها هنا، أو انقر للتصفح",
- "empty": "لا توجد ملفات بعد",
- "limit_invalid": "يجب أن تكون الحدود أعدادًا صحيحة من 1 فأكثر، أو فارغة.",
- "limits_help": "اترك حدود التنزيل والأيام فارغة لاستخدام إعدادات المتجر.",
- "source": {
- "upload": "رفع ملف"
- },
- "store_default": "{{count}} (افتراضي المتجر)",
- "title": "الملفات الرقمية",
- "untitled": "ملف بدون اسم",
- "upload": "إضافة ملف",
- "upload_failed": "فشل رفع {{name}}: {{message}}",
- "uploading": "جارٍ رفع {{name}}…",
- "uploading_short": "جارٍ الرفع…"
- },
"digital_links": {
"columns": {
"file": "الملف",
@@ -2345,16 +2316,10 @@
"help": "عند الإيقاف يمكن للمشترين التنزيل بلا حدود.",
"label": "تحديد عدد التنزيلات"
},
- "digital_asset_authorized_clicks": {
- "label": "التنزيلات المسموح بها"
- },
"limit_digital_download_days": {
"help": "عند الإيقاف لا تنتهي صلاحية روابط التنزيل أبدًا.",
"label": "تحديد مدة التنزيل"
},
- "digital_asset_authorized_days": {
- "label": "الأيام المتاحة"
- },
"default_package_dimensions": {
"height": "الارتفاع",
"help": "الصندوق المعتاد للشحن، تستخدمه شركات النقل لتسعير الوزن الحجمي — بوصات للنظام الإمبراطوري وسنتيمترات للمتري. تلزم القيم الثلاث ليصبح ساريًا.",
diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.json
index 75db248dce..932b93485e 100644
--- a/packages/dashboard/src/locales/de.json
+++ b/packages/dashboard/src/locales/de.json
@@ -936,35 +936,6 @@
"to_placeholder": "Bis",
"toggle_states": "Bundesländer von {{country}} anzeigen"
},
- "digital_assets": {
- "add": "Hinzufügen",
- "all_variants": "Alle Varianten",
- "columns": {
- "file": "Datei",
- "variant": "Variante",
- "size": "Größe",
- "downloads": "Downloads",
- "days": "Tage"
- },
- "delete_description": "„{{name}}“ kann von niemandem mehr heruntergeladen werden, der sie gekauft hat. Dies wirkt sofort.",
- "delete_title": "Diese Datei löschen?",
- "description": "Dateien, die Käufer nach dem Kauf herunterladen können. Fügen Sie sie einem digitalen Produkt hinzu oder einem physischen Produkt, um eine Anleitung oder Garantie mitzuliefern.",
- "download": "Herunterladen",
- "drop_hint": "Dateien hierher ziehen und ablegen oder zum Durchsuchen klicken",
- "empty": "Noch keine Dateien",
- "limit_invalid": "Limits müssen ganze Zahlen ab 1 sein oder leer bleiben.",
- "limits_help": "Lassen Sie die Download- und Tageslimits leer, um die Einstellungen des Shops zu verwenden.",
- "source": {
- "upload": "Datei hochladen"
- },
- "store_default": "{{count}} (Shop-Standard)",
- "title": "Digitale Dateien",
- "untitled": "Unbenannte Datei",
- "upload": "Datei hinzufügen",
- "upload_failed": "Hochladen von {{name}} fehlgeschlagen: {{message}}",
- "uploading": "{{name}} wird hochgeladen…",
- "uploading_short": "Wird hochgeladen…"
- },
"digital_links": {
"columns": {
"file": "Datei",
@@ -2327,16 +2298,10 @@
"help": "Aus bedeutet, dass Käufer beliebig oft herunterladen können.",
"label": "Anzahl der Downloads begrenzen"
},
- "digital_asset_authorized_clicks": {
- "label": "Erlaubte Downloads"
- },
"limit_digital_download_days": {
"help": "Aus bedeutet, dass Download-Links nie ablaufen.",
"label": "Download-Zeitraum begrenzen"
},
- "digital_asset_authorized_days": {
- "label": "Verfügbare Tage"
- },
"default_package_dimensions": {
"height": "Höhe",
"help": "Der übliche Versandkarton, von Carrier-Tarifanbietern für Volumengewicht-Preise genutzt — Zoll bei imperial, Zentimeter bei metrisch. Wirksam nur mit allen drei Werten.",
diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.json
index da399a02dc..534f9f41d9 100644
--- a/packages/dashboard/src/locales/en.json
+++ b/packages/dashboard/src/locales/en.json
@@ -936,35 +936,6 @@
"to_placeholder": "To",
"toggle_states": "Show states of {{country}}"
},
- "digital_assets": {
- "add": "Add",
- "all_variants": "All variants",
- "columns": {
- "file": "File",
- "variant": "Variant",
- "size": "Size",
- "downloads": "Downloads",
- "days": "Days"
- },
- "delete_description": "\"{{name}}\" will no longer be downloadable by anyone who bought it. This takes effect immediately.",
- "delete_title": "Delete this file?",
- "description": "Files buyers can download after purchase. Attach them to a digital product, or to a physical one to deliver a manual or warranty alongside the goods.",
- "download": "Download",
- "drop_hint": "Drag & drop files here, or click to browse",
- "empty": "No files yet",
- "limit_invalid": "Limits must be whole numbers of 1 or more, or blank.",
- "limits_help": "Leave the download and day limits blank to use the store's settings.",
- "source": {
- "upload": "Upload a file"
- },
- "store_default": "{{count}} (store default)",
- "title": "Digital files",
- "untitled": "Untitled file",
- "upload": "Add file",
- "upload_failed": "Failed to upload {{name}}: {{message}}",
- "uploading": "Uploading {{name}}…",
- "uploading_short": "Uploading…"
- },
"digital_links": {
"columns": {
"file": "File",
@@ -2327,16 +2298,10 @@
"help": "Off means buyers can download as often as they like.",
"label": "Limit number of downloads"
},
- "digital_asset_authorized_clicks": {
- "label": "Downloads allowed"
- },
"limit_digital_download_days": {
"help": "Off means download links never expire.",
"label": "Limit download period"
},
- "digital_asset_authorized_days": {
- "label": "Days available"
- },
"default_package_dimensions": {
"height": "Height",
"help": "The box you usually ship in, used by carrier rate providers for dimensional-weight pricing — inches for imperial, centimeters for metric. All three are needed to take effect.",
diff --git a/packages/dashboard/src/locales/es.json b/packages/dashboard/src/locales/es.json
index b23b4b691a..03ba008ff7 100644
--- a/packages/dashboard/src/locales/es.json
+++ b/packages/dashboard/src/locales/es.json
@@ -2238,16 +2238,10 @@
"help": "Desactivado, los compradores pueden descargar las veces que quieran.",
"label": "Limitar cantidad de descargas"
},
- "digital_asset_authorized_clicks": {
- "label": "Descargas permitidas"
- },
"limit_digital_download_days": {
"help": "Desactivado, los enlaces de descarga nunca vencen.",
"label": "Limitar período de descarga"
},
- "digital_asset_authorized_days": {
- "label": "Días disponibles"
- },
"default_package_dimensions": {
"height": "Alto",
"help": "La caja en la que sueles enviar, usada por los proveedores de tarifas de transporte para el precio por peso dimensional: pulgadas en imperial, centímetros en métrico. Se necesitan los tres para que surta efecto.",
@@ -5543,35 +5537,6 @@
},
"load_failed": "No se pudieron cargar las entregas."
},
- "digital_assets": {
- "add": "Agregar",
- "all_variants": "Todas las variantes",
- "columns": {
- "file": "Archivo",
- "variant": "Variante",
- "size": "Tamaño",
- "downloads": "Descargas",
- "days": "Días"
- },
- "delete_description": "«{{name}}» ya no será descargable por nadie que lo haya comprado. Se aplica de inmediato.",
- "delete_title": "¿Eliminar este archivo?",
- "description": "Archivos que los compradores pueden descargar después de comprar. Adjuntalos a un producto digital, o a uno físico para entregar un manual o una garantía junto con la mercadería.",
- "download": "Descargar",
- "drop_hint": "Arrastrá y soltá los archivos acá, o hacé clic para explorar",
- "empty": "Todavía no hay archivos",
- "limit_invalid": "Los límites deben ser números enteros de 1 o más, o estar en blanco.",
- "limits_help": "Dejá los límites de descarga y de días en blanco para usar la config de la tienda.",
- "source": {
- "upload": "Subir un archivo"
- },
- "store_default": "{{count}} (predeterminado de la tienda)",
- "title": "Archivos digitales",
- "untitled": "Archivo sin título",
- "upload": "Agregar archivo",
- "upload_failed": "No se pudo subir {{name}}: {{message}}",
- "uploading": "Subiendo {{name}}…",
- "uploading_short": "Subiendo…"
- },
"package_types": {
"table_title": "Tipos de empaque",
"search_placeholder": "Buscar empaques",
diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.json
index 5bbcb74e08..c146aa8985 100644
--- a/packages/dashboard/src/locales/fr.json
+++ b/packages/dashboard/src/locales/fr.json
@@ -936,35 +936,6 @@
"to_placeholder": "À",
"toggle_states": "Afficher les régions de {{country}}"
},
- "digital_assets": {
- "add": "Ajouter",
- "all_variants": "Toutes les variantes",
- "columns": {
- "file": "Fichier",
- "variant": "Variante",
- "size": "Taille",
- "downloads": "Téléchargements",
- "days": "Jours"
- },
- "delete_description": "« {{name}} » ne sera plus téléchargeable par les personnes qui l'ont acheté. Effet immédiat.",
- "delete_title": "Supprimer ce fichier ?",
- "description": "Fichiers que les acheteurs peuvent télécharger après l'achat. Associez-les à un produit numérique, ou à un produit physique pour livrer un manuel ou une garantie.",
- "download": "Télécharger",
- "drop_hint": "Glissez-déposez des fichiers ici, ou cliquez pour parcourir",
- "empty": "Aucun fichier pour le moment",
- "limit_invalid": "Les limites doivent être des entiers supérieurs ou égaux à 1, ou vides.",
- "limits_help": "Laissez les limites de téléchargements et de jours vides pour utiliser les paramètres de la boutique.",
- "source": {
- "upload": "Téléverser un fichier"
- },
- "store_default": "{{count}} (par défaut)",
- "title": "Fichiers numériques",
- "untitled": "Fichier sans nom",
- "upload": "Ajouter un fichier",
- "upload_failed": "Échec du téléversement de {{name}} : {{message}}",
- "uploading": "Téléversement de {{name}}…",
- "uploading_short": "Téléversement…"
- },
"digital_links": {
"columns": {
"file": "Fichier",
@@ -2327,16 +2298,10 @@
"help": "Désactivé, les acheteurs peuvent télécharger autant de fois qu'ils le souhaitent.",
"label": "Limiter le nombre de téléchargements"
},
- "digital_asset_authorized_clicks": {
- "label": "Téléchargements autorisés"
- },
"limit_digital_download_days": {
"help": "Désactivé, les liens de téléchargement n'expirent jamais.",
"label": "Limiter la période de téléchargement"
},
- "digital_asset_authorized_days": {
- "label": "Jours de disponibilité"
- },
"default_package_dimensions": {
"height": "Hauteur",
"help": "Le carton habituel d'expédition, utilisé par les transporteurs pour le poids volumétrique — pouces en impérial, centimètres en métrique. Les trois valeurs sont requises.",
diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.json
index e25a88d9c8..5e8cd65307 100644
--- a/packages/dashboard/src/locales/pl.json
+++ b/packages/dashboard/src/locales/pl.json
@@ -954,35 +954,6 @@
"to_placeholder": "Do",
"toggle_states": "Pokaż regiony kraju {{country}}"
},
- "digital_assets": {
- "add": "Dodaj",
- "all_variants": "Wszystkie warianty",
- "columns": {
- "file": "Plik",
- "variant": "Wariant",
- "size": "Rozmiar",
- "downloads": "Pobrania",
- "days": "Dni"
- },
- "delete_description": "„{{name}}” nie będzie już dostępny do pobrania dla osób, które go kupiły. Zmiana działa natychmiast.",
- "delete_title": "Usunąć ten plik?",
- "description": "Pliki, które kupujący mogą pobrać po zakupie. Dołącz je do produktu cyfrowego lub do fizycznego, aby dostarczyć instrukcję albo gwarancję.",
- "download": "Pobierz",
- "drop_hint": "Przeciągnij i upuść pliki tutaj lub kliknij, aby wybrać",
- "empty": "Brak plików",
- "limit_invalid": "Limity muszą być liczbami całkowitymi od 1 lub puste.",
- "limits_help": "Pozostaw limity pobrań i dni puste, aby użyć ustawień sklepu.",
- "source": {
- "upload": "Prześlij plik"
- },
- "store_default": "{{count}} (domyślne sklepu)",
- "title": "Pliki cyfrowe",
- "untitled": "Plik bez nazwy",
- "upload": "Dodaj plik",
- "upload_failed": "Nie udało się przesłać {{name}}: {{message}}",
- "uploading": "Przesyłanie {{name}}…",
- "uploading_short": "Przesyłanie…"
- },
"digital_links": {
"columns": {
"file": "Plik",
@@ -2345,16 +2316,10 @@
"help": "Wyłączone oznacza, że kupujący mogą pobierać dowolną liczbę razy.",
"label": "Ogranicz liczbę pobrań"
},
- "digital_asset_authorized_clicks": {
- "label": "Dozwolone pobrania"
- },
"limit_digital_download_days": {
"help": "Wyłączone oznacza, że linki do pobrania nigdy nie wygasają.",
"label": "Ogranicz okres pobierania"
},
- "digital_asset_authorized_days": {
- "label": "Dostępne dni"
- },
"default_package_dimensions": {
"height": "Wysokość",
"help": "Karton, w którym zwykle wysyłasz, używany przez przewoźników do wyceny wagi wymiarowej — cale dla systemu imperialnego, centymetry dla metrycznego. Działa dopiero po podaniu wszystkich trzech.",
diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.json
index 4de132d3c7..1e83371384 100644
--- a/packages/dashboard/src/locales/zh-CN.json
+++ b/packages/dashboard/src/locales/zh-CN.json
@@ -931,35 +931,6 @@
"to_placeholder": "止",
"toggle_states": "显示 {{country}} 的省/州"
},
- "digital_assets": {
- "add": "添加",
- "all_variants": "所有变体",
- "columns": {
- "file": "文件",
- "variant": "变体",
- "size": "大小",
- "downloads": "下载次数",
- "days": "天数"
- },
- "delete_description": "购买过“{{name}}”的人将无法再下载它。此操作立即生效。",
- "delete_title": "删除此文件?",
- "description": "买家购买后可下载的文件。可附加到数字商品,也可附加到实体商品以随货提供说明书或保修卡。",
- "download": "下载",
- "drop_hint": "将文件拖放到此处,或点击浏览",
- "empty": "暂无文件",
- "limit_invalid": "限制必须是不小于 1 的整数,或留空。",
- "limits_help": "将下载次数和天数限制留空即可使用商店设置。",
- "source": {
- "upload": "上传文件"
- },
- "store_default": "{{count}}(商店默认)",
- "title": "数字文件",
- "untitled": "未命名文件",
- "upload": "添加文件",
- "upload_failed": "上传 {{name}} 失败:{{message}}",
- "uploading": "正在上传 {{name}}…",
- "uploading_short": "上传中…"
- },
"digital_links": {
"columns": {
"file": "文件",
@@ -2322,16 +2293,10 @@
"help": "关闭后,买家可以不限次数下载。",
"label": "限制下载次数"
},
- "digital_asset_authorized_clicks": {
- "label": "允许的下载次数"
- },
"limit_digital_download_days": {
"help": "关闭后,下载链接永不过期。",
"label": "限制下载期限"
},
- "digital_asset_authorized_days": {
- "label": "可用天数"
- },
"default_package_dimensions": {
"height": "高",
"help": "常用的发货纸箱尺寸,承运商费率提供方据此计算体积重量——英制为英寸,公制为厘米。三项都填写后才生效。",
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx
index 8592bce862..7c87f40df3 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx
@@ -3,6 +3,7 @@ import { type Product, SpreeError } from '@spree/admin-sdk'
import {
adminClient,
CategorizationCard,
+ DigitalAssetsCard,
extensionFormValues,
extensionSubmitValues,
GeneralCard,
@@ -41,7 +42,6 @@ import { useTranslation } from 'react-i18next'
import { CustomFieldsInlineCard } from '../../../../components/spree/custom-fields/custom-fields-inline'
import '../../../../components/spree/custom-fields/register'
import { MediaRichTextEditor } from '../../../../components/spree/media-rich-text-editor'
-import { DigitalAssetsCard } from '../../../../components/spree/products/digital-assets-card'
import { ProductCustomFieldsProvider } from '../../../../components/spree/products/product-custom-fields-provider'
import { ProductReviewActions } from '../../../../components/spree/products/product-review-actions'
import { ProductSellerCard } from '../../../../components/spree/products/product-seller-card'
diff --git a/packages/seller-dashboard/src/api-client.ts b/packages/seller-dashboard/src/api-client.ts
index 9b3d298b1b..68a52400b2 100644
--- a/packages/seller-dashboard/src/api-client.ts
+++ b/packages/seller-dashboard/src/api-client.ts
@@ -146,6 +146,16 @@ export function createSellerApiClient({
update: (id, params) => sellerClient().packageTypes.update(id, params),
delete: (id) => sellerClient().packageTypes.delete(id),
},
+ // No `providers`: a provider is the marketplace's own integration, so a
+ // seller's Digital files card offers file uploads alone.
+ digitalAssets: {
+ list: (productId, params) => sellerClient().products.digitalAssets.list(productId, params),
+ create: (productId, params) =>
+ sellerClient().products.digitalAssets.create(productId, params),
+ update: (productId, id, params) =>
+ sellerClient().products.digitalAssets.update(productId, id, params),
+ delete: (productId, id) => sellerClient().products.digitalAssets.delete(productId, id),
+ },
})
return client
diff --git a/packages/seller-dashboard/src/pages/product.tsx b/packages/seller-dashboard/src/pages/product.tsx
index 444cead184..8ae9d11e1c 100644
--- a/packages/seller-dashboard/src/pages/product.tsx
+++ b/packages/seller-dashboard/src/pages/product.tsx
@@ -1,6 +1,7 @@
import { zodResolver } from '@hookform/resolvers/zod'
import {
CategorizationCard,
+ DigitalAssetsCard,
extensionFormValues,
extensionRowValues,
extensionSubmitValues,
@@ -253,6 +254,11 @@ export function ProductPage({ mode }: { mode: 'new' | 'edit' }) {
defaultCurrency={profile?.default_currency}
/>
<InventoryCard form={form} />
+ {/* Writes on its own, file by file, so it needs a saved product
+ and stays outside the Save button's payload. */}
+ {productId && (
+ <DigitalAssetsCard productId={productId} variants={product?.variants ?? []} />
+ )}
<Slot name="seller.product.form_main" context={{ product, mode }} />
</>
}