@medusajs/dashboard 2.11.4-preview-20251106090134 → 2.11.4-preview-20251106150143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/{add-campaign-promotions-LEOARUW3.mjs → add-campaign-promotions-UR3UM3MV.mjs} +4 -4
  2. package/dist/{api-key-management-detail-RLTUSE44.mjs → api-key-management-detail-Z6V22XWR.mjs} +5 -5
  3. package/dist/{api-key-management-list-4KEBDRVQ.mjs → api-key-management-list-TVLEYYQO.mjs} +5 -5
  4. package/dist/{api-key-management-sales-channels-IGRPAJJ2.mjs → api-key-management-sales-channels-Y25FWD5A.mjs} +5 -5
  5. package/dist/app.js +51 -20
  6. package/dist/app.mjs +2 -2
  7. package/dist/{campaign-detail-VM2EHCYQ.mjs → campaign-detail-YDLSCIRO.mjs} +5 -5
  8. package/dist/{campaign-list-XRDVPCXE.mjs → campaign-list-M2462W5W.mjs} +6 -6
  9. package/dist/{category-detail-ZXA36JL5.mjs → category-detail-IZ3AWOCP.mjs} +4 -4
  10. package/dist/{category-list-AI2IGO67.mjs → category-list-BJLRBYZC.mjs} +4 -4
  11. package/dist/{category-products-Z5LZJ32F.mjs → category-products-55LDLRRQ.mjs} +4 -4
  12. package/dist/{chunk-6WFWT22M.mjs → chunk-2GWGNMAA.mjs} +1 -1
  13. package/dist/{chunk-76FLG6KU.mjs → chunk-2X25XWOW.mjs} +1 -1
  14. package/dist/{chunk-R7OR4HQQ.mjs → chunk-3BE5PBQZ.mjs} +1 -1
  15. package/dist/{chunk-N32YWZXM.mjs → chunk-5IFK2ZTA.mjs} +2 -2
  16. package/dist/{chunk-3JJBLFYN.mjs → chunk-7M7DFNIM.mjs} +21 -8
  17. package/dist/{chunk-TYTNUPXB.mjs → chunk-BYOPZAGX.mjs} +13 -4
  18. package/dist/{chunk-L7BOZCK7.mjs → chunk-CV65NY6Y.mjs} +1 -1
  19. package/dist/{chunk-E2J2KSDG.mjs → chunk-DCY4DKCQ.mjs} +97 -89
  20. package/dist/{chunk-3OGLDF4U.mjs → chunk-DZWH2RV6.mjs} +1 -1
  21. package/dist/{chunk-A4C2VYJH.mjs → chunk-GA3UMQMZ.mjs} +1 -1
  22. package/dist/{chunk-CB3UMLV2.mjs → chunk-GU5PJRPM.mjs} +1 -1
  23. package/dist/{chunk-IFICCCPS.mjs → chunk-IHH6OCSU.mjs} +1 -1
  24. package/dist/{chunk-RXXSK34K.mjs → chunk-M4Q5Q4I3.mjs} +2 -2
  25. package/dist/{chunk-EZNWSOIF.mjs → chunk-NL376WAO.mjs} +1 -1
  26. package/dist/{chunk-YNULA6PU.mjs → chunk-PVW6M64S.mjs} +1 -1
  27. package/dist/{chunk-BBLXCYME.mjs → chunk-ROKB75YP.mjs} +1 -1
  28. package/dist/{chunk-QPMPMKGJ.mjs → chunk-S5GNHYAG.mjs} +3 -3
  29. package/dist/{chunk-MHC2COUJ.mjs → chunk-SUYYSKCB.mjs} +18 -18
  30. package/dist/{chunk-F7E4I7W6.mjs → chunk-T57MRRCF.mjs} +1 -1
  31. package/dist/{chunk-BT4EIAAA.mjs → chunk-VEYZCWO5.mjs} +3 -3
  32. package/dist/{chunk-UDR6GM4C.mjs → chunk-WGIRB6HY.mjs} +1 -1
  33. package/dist/{chunk-UQKW4TKL.mjs → chunk-YA5PS6KW.mjs} +1 -1
  34. package/dist/{chunk-NJ6OPV6N.mjs → chunk-YGLRZQ4C.mjs} +1 -1
  35. package/dist/{chunk-43WSJSKM.mjs → chunk-YTN73JYH.mjs} +1 -1
  36. package/dist/{collection-add-products-T2N7QSJ3.mjs → collection-add-products-7CFVTCLK.mjs} +4 -4
  37. package/dist/{collection-detail-G6XV2433.mjs → collection-detail-3NMMB3CC.mjs} +4 -4
  38. package/dist/{collection-list-5UAWKYF3.mjs → collection-list-VNKB3725.mjs} +4 -4
  39. package/dist/{customer-detail-47EEVPS2.mjs → customer-detail-PAYUFGP6.mjs} +6 -6
  40. package/dist/{customer-group-add-customers-TPKDPKQB.mjs → customer-group-add-customers-MW2XH2F6.mjs} +6 -6
  41. package/dist/{customer-group-detail-B2OAKFTS.mjs → customer-group-detail-LJ6YVB2C.mjs} +6 -6
  42. package/dist/{customer-group-list-BOJHNJII.mjs → customer-group-list-M2OOZLIZ.mjs} +3 -3
  43. package/dist/{customer-list-7K5U27LG.mjs → customer-list-MZ7ZRERV.mjs} +6 -6
  44. package/dist/{customers-add-customer-group-K6TUA74U.mjs → customers-add-customer-group-IAIRRQ2I.mjs} +4 -4
  45. package/dist/en.json +1 -0
  46. package/dist/{inventory-detail-ASB73KWV.mjs → inventory-detail-ZJ5U5FSA.mjs} +4 -4
  47. package/dist/{inventory-list-C2MMQTES.mjs → inventory-list-HHTQRKQW.mjs} +4 -4
  48. package/dist/{location-fulfillment-providers-XP6WHPBF.mjs → location-fulfillment-providers-DNIVH7XD.mjs} +4 -4
  49. package/dist/{location-sales-channels-56Q6CXKL.mjs → location-sales-channels-3JAXXM3Q.mjs} +5 -5
  50. package/dist/{location-service-zone-create-ULDHY2U2.mjs → location-service-zone-create-D2HXXX63.mjs} +5 -5
  51. package/dist/{location-service-zone-manage-areas-IYJNAX7D.mjs → location-service-zone-manage-areas-LVVT6XBE.mjs} +5 -5
  52. package/dist/{order-create-claim-7NKA24P7.mjs → order-create-claim-2FPE6XP2.mjs} +4 -4
  53. package/dist/{order-create-edit-LJX4W7NG.mjs → order-create-edit-PVGKIS6G.mjs} +4 -4
  54. package/dist/{order-create-exchange-3SGVPVEW.mjs → order-create-exchange-G4JY4FSX.mjs} +4 -4
  55. package/dist/{order-create-return-D46V464L.mjs → order-create-return-VEUCH5BA.mjs} +4 -4
  56. package/dist/{order-detail-D32BXAWE.mjs → order-detail-2EFNG3UB.mjs} +2 -2
  57. package/dist/{order-list-E6MQYTOJ.mjs → order-list-EEC3VSLN.mjs} +8 -8
  58. package/dist/{price-list-configuration-5AMFLA3C.mjs → price-list-configuration-WQEQFG6M.mjs} +5 -5
  59. package/dist/{price-list-create-SF6ELAMF.mjs → price-list-create-36BOXETM.mjs} +5 -5
  60. package/dist/{price-list-detail-ESVZHRYB.mjs → price-list-detail-6CJ63F65.mjs} +5 -5
  61. package/dist/{price-list-list-JANFOZQI.mjs → price-list-list-2HDOJIC6.mjs} +4 -4
  62. package/dist/{price-list-prices-add-5FADNOGB.mjs → price-list-prices-add-AVPP57TL.mjs} +4 -4
  63. package/dist/{product-attributes-5MY4SGFX.mjs → product-attributes-IT2R62P3.mjs} +3 -3
  64. package/dist/{product-create-OWPAOIJU.mjs → product-create-X7MYHYRX.mjs} +8 -8
  65. package/dist/{product-detail-XLUTUYUE.mjs → product-detail-ZOO3E5SI.mjs} +5 -5
  66. package/dist/{product-edit-XDWFGRKM.mjs → product-edit-LX6OFTYL.mjs} +3 -3
  67. package/dist/{product-export-NVWDLE4I.mjs → product-export-5WBXPUYP.mjs} +3 -3
  68. package/dist/{product-image-variants-edit-E6I5E6QB.mjs → product-image-variants-edit-T3STDZJG.mjs} +4 -4
  69. package/dist/{product-import-5VLF2ZN4.mjs → product-import-YC7GJ4BW.mjs} +3 -2
  70. package/dist/{product-list-D2PWRKUE.mjs → product-list-BX2QNNQK.mjs} +7 -7
  71. package/dist/{product-media-Z3NNTB7H.mjs → product-media-O7M2YCTQ.mjs} +2 -2
  72. package/dist/{product-organization-NGKGAMVF.mjs → product-organization-AFRDTFZR.mjs} +3 -3
  73. package/dist/{product-sales-channels-IPOW5T64.mjs → product-sales-channels-LRMOPHMH.mjs} +5 -5
  74. package/dist/{product-shipping-profile-DHTDAKYL.mjs → product-shipping-profile-XMIIH5QP.mjs} +3 -3
  75. package/dist/{product-tag-detail-FXWXYI5Z.mjs → product-tag-detail-LDKRRJWH.mjs} +10 -10
  76. package/dist/{product-tag-list-IVXSYMFL.mjs → product-tag-list-3ERYK5WE.mjs} +10 -10
  77. package/dist/{product-type-detail-BWLICDYA.mjs → product-type-detail-UJ6QTCGQ.mjs} +4 -4
  78. package/dist/{product-type-list-LDCQKDKZ.mjs → product-type-list-73DQPW4H.mjs} +6 -6
  79. package/dist/{product-variant-detail-BSRN246J.mjs → product-variant-detail-JMPD7LEZ.mjs} +4 -4
  80. package/dist/{profile-detail-5Z3SFDB4.mjs → profile-detail-MEZKVQAB.mjs} +1 -1
  81. package/dist/{profile-edit-2MJF3JMT.mjs → profile-edit-XAHDV2DG.mjs} +1 -1
  82. package/dist/{promotion-detail-6HFB6Y6E.mjs → promotion-detail-L3FNHH6O.mjs} +3 -3
  83. package/dist/{promotion-list-2VADJJQM.mjs → promotion-list-R5JKSO4I.mjs} +4 -4
  84. package/dist/{refund-reason-list-ZYTUTZBO.mjs → refund-reason-list-NS4SVHGZ.mjs} +8 -8
  85. package/dist/{region-add-countries-VK4EJ4LD.mjs → region-add-countries-G5BOUL2E.mjs} +4 -4
  86. package/dist/{region-create-PYW22J5X.mjs → region-create-MLPUWT5W.mjs} +4 -4
  87. package/dist/{region-detail-6ORFQWHD.mjs → region-detail-RICQRZUA.mjs} +4 -4
  88. package/dist/{region-list-YLAWL5RJ.mjs → region-list-CJYT43SH.mjs} +4 -4
  89. package/dist/{reservation-list-4BFZSJIH.mjs → reservation-list-XP4YX4TR.mjs} +5 -5
  90. package/dist/{return-reason-list-JTXR53J7.mjs → return-reason-list-7MBVORVO.mjs} +10 -10
  91. package/dist/{sales-channel-add-products-IVZVKUVT.mjs → sales-channel-add-products-GQQ7Z3PT.mjs} +4 -4
  92. package/dist/{sales-channel-detail-ZRL7SHZV.mjs → sales-channel-detail-P2HXFYB4.mjs} +4 -4
  93. package/dist/{sales-channel-list-IMUI5QXS.mjs → sales-channel-list-4PJLCQ77.mjs} +5 -5
  94. package/dist/{shipping-option-type-list-XRDHS2W5.mjs → shipping-option-type-list-AWJRR7U5.mjs} +5 -5
  95. package/dist/{shipping-profiles-list-2DGSDS7S.mjs → shipping-profiles-list-7SVGIP72.mjs} +4 -4
  96. package/dist/{store-add-currencies-M6Y2Y5BO.mjs → store-add-currencies-V3IBSI45.mjs} +4 -4
  97. package/dist/{store-detail-QOCZCOUL.mjs → store-detail-3WFTRPJW.mjs} +4 -4
  98. package/dist/{tax-region-detail-LUS323UE.mjs → tax-region-detail-HXVZA2PP.mjs} +13 -13
  99. package/dist/{tax-region-province-detail-SRM2JTYP.mjs → tax-region-province-detail-VT3BUKLS.mjs} +13 -13
  100. package/dist/{tax-region-tax-override-create-TUJHJXIQ.mjs → tax-region-tax-override-create-RZUVOGNR.mjs} +11 -11
  101. package/dist/{tax-region-tax-override-edit-H5W5BMGJ.mjs → tax-region-tax-override-edit-OEQOEE6I.mjs} +12 -12
  102. package/dist/{user-invite-W6QLJ6H4.mjs → user-invite-QK3ZCSGG.mjs} +4 -4
  103. package/dist/{user-list-V2JUUJID.mjs → user-list-RH43CTBN.mjs} +4 -4
  104. package/dist/{workflow-execution-list-AULV5YFO.mjs → workflow-execution-list-6UTBTVX4.mjs} +4 -4
  105. package/package.json +9 -9
  106. package/src/components/common/file-upload/file-upload.tsx +23 -6
  107. package/src/components/layout/main-layout/main-layout.tsx +1 -0
  108. package/src/components/layout/nav-item/nav-item.tsx +14 -4
  109. package/src/dashboard-app/dashboard-app.tsx +1 -0
  110. package/src/dashboard-app/types.ts +1 -0
  111. package/src/i18n/languages.ts +18 -18
  112. package/src/i18n/translations/$schema.json +3 -0
  113. package/src/i18n/translations/en.json +1 -0
  114. package/src/routes/products/common/components/upload-media-form-item/upload-media-form-item.tsx +25 -7
  115. package/src/routes/products/product-import/components/upload-import.tsx +1 -0
@@ -9,23 +9,23 @@ import "./chunk-LQTHYS2Z.mjs";
9
9
  import {
10
10
  _DataTable,
11
11
  useDataTable
12
- } from "./chunk-43WSJSKM.mjs";
12
+ } from "./chunk-YTN73JYH.mjs";
13
13
  import "./chunk-HQKGZADC.mjs";
14
14
  import "./chunk-EMIHDNB7.mjs";
15
- import "./chunk-CB3UMLV2.mjs";
15
+ import "./chunk-GU5PJRPM.mjs";
16
16
  import {
17
17
  SingleColumnPage
18
18
  } from "./chunk-GIZFNLKK.mjs";
19
19
  import {
20
20
  useQueryParams
21
21
  } from "./chunk-C76H5USB.mjs";
22
- import "./chunk-3OGLDF4U.mjs";
22
+ import "./chunk-DZWH2RV6.mjs";
23
23
  import {
24
24
  useExtension
25
25
  } from "./chunk-C5P5PL3E.mjs";
26
26
  import "./chunk-LPEUYMRK.mjs";
27
27
  import "./chunk-S4DMV3ZT.mjs";
28
- import "./chunk-MHC2COUJ.mjs";
28
+ import "./chunk-SUYYSKCB.mjs";
29
29
  import {
30
30
  useWorkflowExecutions
31
31
  } from "./chunk-QTCZFYFH.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/dashboard",
3
- "version": "2.11.4-preview-20251106090134",
3
+ "version": "2.11.4-preview-20251106150143",
4
4
  "scripts": {
5
5
  "generate:static": "node ./scripts/generate-currencies.js && prettier --write ./src/lib/currencies.ts",
6
6
  "dev": "vite",
@@ -46,10 +46,10 @@
46
46
  "@dnd-kit/utilities": "^3.2.2",
47
47
  "@hookform/error-message": "^2.0.1",
48
48
  "@hookform/resolvers": "3.4.2",
49
- "@medusajs/admin-shared": "2.11.4-preview-20251106090134",
50
- "@medusajs/icons": "2.11.4-preview-20251106090134",
51
- "@medusajs/js-sdk": "2.11.4-preview-20251106090134",
52
- "@medusajs/ui": "4.0.28-preview-20251106090134",
49
+ "@medusajs/admin-shared": "2.11.4-preview-20251106150143",
50
+ "@medusajs/icons": "2.11.4-preview-20251106150143",
51
+ "@medusajs/js-sdk": "2.11.4-preview-20251106150143",
52
+ "@medusajs/ui": "4.0.28-preview-20251106150143",
53
53
  "@radix-ui/react-dialog": "1.1.4",
54
54
  "@radix-ui/react-dismissable-layer": "1.1.4",
55
55
  "@tanstack/react-query": "5.64.2",
@@ -81,10 +81,10 @@
81
81
  "zod": "3.25.76"
82
82
  },
83
83
  "devDependencies": {
84
- "@medusajs/admin-shared": "2.11.4-preview-20251106090134",
85
- "@medusajs/admin-vite-plugin": "2.11.4-preview-20251106090134",
86
- "@medusajs/types": "2.11.4-preview-20251106090134",
87
- "@medusajs/ui-preset": "2.11.4-preview-20251106090134"
84
+ "@medusajs/admin-shared": "2.11.4-preview-20251106150143",
85
+ "@medusajs/admin-vite-plugin": "2.11.4-preview-20251106150143",
86
+ "@medusajs/types": "2.11.4-preview-20251106150143",
87
+ "@medusajs/ui-preset": "2.11.4-preview-20251106150143"
88
88
  },
89
89
  "packageManager": "yarn@3.2.1"
90
90
  }
@@ -8,21 +8,30 @@ export interface FileType {
8
8
  file: File
9
9
  }
10
10
 
11
+ export interface RejectedFile {
12
+ file: File
13
+ reason: "size" | "format"
14
+ }
15
+
11
16
  export interface FileUploadProps {
12
17
  label: string
13
18
  multiple?: boolean
14
19
  hint?: string
15
20
  hasError?: boolean
16
21
  formats: string[]
17
- onUploaded: (files: FileType[]) => void
22
+ maxFileSize?: number // in bytes, defaults to 1MB. Set to Infinity to disable.
23
+ onUploaded: (files: FileType[], rejectedFiles?: RejectedFile[]) => void
18
24
  }
19
25
 
26
+ const DEFAULT_MAX_FILE_SIZE = 1024 * 1024 // 1MB
27
+
20
28
  export const FileUpload = ({
21
29
  label,
22
30
  hint,
23
31
  multiple = true,
24
32
  hasError,
25
33
  formats,
34
+ maxFileSize = DEFAULT_MAX_FILE_SIZE,
26
35
  onUploaded,
27
36
  }: FileUploadProps) => {
28
37
  const [isDragOver, setIsDragOver] = useState<boolean>(false)
@@ -65,18 +74,26 @@ export const FileUpload = ({
65
74
  }
66
75
 
67
76
  const fileList = Array.from(files)
68
- const fileObj = fileList.map((file) => {
69
- const id = Math.random().toString(36).substring(7)
77
+ const validFiles: FileType[] = []
78
+ const rejectedFiles: RejectedFile[] = []
79
+ const normalizedMaxFileSize = Math.min(maxFileSize, Infinity)
80
+
81
+ fileList.forEach((file) => {
82
+ if (file.size > normalizedMaxFileSize) {
83
+ rejectedFiles.push({ file, reason: "size" })
84
+ return
85
+ }
70
86
 
87
+ const id = Math.random().toString(36).substring(7)
71
88
  const previewUrl = URL.createObjectURL(file)
72
- return {
89
+ validFiles.push({
73
90
  id: id,
74
91
  url: previewUrl,
75
92
  file,
76
- }
93
+ })
77
94
  })
78
95
 
79
- onUploaded(fileObj)
96
+ onUploaded(validFiles, rejectedFiles)
80
97
  }
81
98
 
82
99
  const handleDrop = (event: DragEvent) => {
@@ -348,6 +348,7 @@ const ExtensionRouteSection = () => {
348
348
  label={item.label}
349
349
  icon={item.icon ? item.icon : <SquaresPlus />}
350
350
  items={item.items}
351
+ translationNs={item.translationNs}
351
352
  type="extension"
352
353
  />
353
354
  )
@@ -17,6 +17,7 @@ type ItemType = "core" | "extension" | "setting"
17
17
  type NestedItemProps = {
18
18
  label: string
19
19
  to: string
20
+ translationNs?: string
20
21
  }
21
22
 
22
23
  export type INavItem = {
@@ -27,6 +28,7 @@ export type INavItem = {
27
28
  type?: ItemType
28
29
  from?: string
29
30
  nested?: string
31
+ translationNs?: string
30
32
  }
31
33
 
32
34
  const BASE_NAV_LINK_CLASSES =
@@ -90,10 +92,15 @@ export const NavItem = ({
90
92
  items,
91
93
  type = "core",
92
94
  from,
95
+ translationNs,
93
96
  }: INavItem) => {
97
+ const { t } = useTranslation(translationNs as any)
94
98
  const { pathname } = useLocation()
95
99
  const [open, setOpen] = useState(getIsOpen(to, items, pathname))
96
100
 
101
+ // Use translation if translationNs is provided, otherwise use label as-is
102
+ const displayLabel: string = translationNs ? t(label) : label
103
+
97
104
  useEffect(() => {
98
105
  setOpen(getIsOpen(to, items, pathname))
99
106
  }, [pathname, to, items])
@@ -150,7 +157,7 @@ export const NavItem = ({
150
157
  </div>
151
158
  )}
152
159
  <Text size="small" weight="plus" leading="compact">
153
- {label}
160
+ {displayLabel}
154
161
  </Text>
155
162
  </NavLink>
156
163
  </NavItemTooltip>
@@ -166,7 +173,7 @@ export const NavItem = ({
166
173
  <Icon icon={icon} type={type} />
167
174
  </div>
168
175
  <Text size="small" weight="plus" leading="compact">
169
- {label}
176
+ {displayLabel}
170
177
  </Text>
171
178
  </RadixCollapsible.Trigger>
172
179
  <RadixCollapsible.Content>
@@ -189,12 +196,15 @@ export const NavItem = ({
189
196
  }}
190
197
  >
191
198
  <Text size="small" weight="plus" leading="compact">
192
- {label}
199
+ {displayLabel}
193
200
  </Text>
194
201
  </NavLink>
195
202
  </NavItemTooltip>
196
203
  </li>
197
204
  {items.map((item) => {
205
+ const { t: itemT } = useTranslation(item.translationNs as any)
206
+ const itemLabel: string = item.translationNs ? itemT(item.label) : item.label
207
+
198
208
  return (
199
209
  <li key={item.to} className="flex h-7 items-center">
200
210
  <NavItemTooltip to={item.to}>
@@ -213,7 +223,7 @@ export const NavItem = ({
213
223
  }}
214
224
  >
215
225
  <Text size="small" weight="plus" leading="compact">
216
- {item.label}
226
+ {itemLabel}
217
227
  </Text>
218
228
  </NavLink>
219
229
  </NavItemTooltip>
@@ -187,6 +187,7 @@ export class DashboardApp {
187
187
  icon: item.icon ? <item.icon /> : undefined,
188
188
  items: [],
189
189
  nested: item.nested,
190
+ translationNs: item.translationNs,
190
191
  }
191
192
 
192
193
  if (parentPath !== "/" && tempRegistry[parentPath]) {
@@ -24,6 +24,7 @@ export type MenuItemExtension = {
24
24
  path: string
25
25
  icon?: ComponentType
26
26
  nested?: NestedRoutePosition
27
+ translationNs?: string
27
28
  }
28
29
 
29
30
  export type WidgetExtension = {
@@ -1,34 +1,34 @@
1
1
  import {
2
- de,
2
+ ar,
3
3
  bg,
4
+ bs,
5
+ cs,
6
+ de,
7
+ el,
4
8
  enUS,
5
9
  es,
10
+ faIR,
6
11
  fr,
7
12
  he,
13
+ hu,
14
+ id,
8
15
  it,
9
16
  ja,
17
+ ko,
18
+ lt,
19
+ mk,
20
+ mn,
21
+ nl,
10
22
  pl,
23
+ pt,
11
24
  ptBR,
12
- ptPT,
25
+ ro,
26
+ ru,
13
27
  th,
14
28
  tr,
15
29
  uk,
16
- ro,
17
- mk,
18
- mn,
19
- ar,
20
- zhCN,
21
- faIR,
22
- cs,
23
- ru,
24
- el,
25
- lt,
26
30
  vi,
27
- ko,
28
- nl,
29
- hu,
30
- bs,
31
- id,
31
+ zhCN,
32
32
  } from "date-fns/locale"
33
33
  import { Language } from "./types"
34
34
 
@@ -115,7 +115,7 @@ export const languages: Language[] = [
115
115
  code: "ptPT",
116
116
  display_name: "Português (Portugal)",
117
117
  ltr: true,
118
- date_locale: ptPT,
118
+ date_locale: pt,
119
119
  },
120
120
  {
121
121
  code: "tr",
@@ -1935,6 +1935,9 @@
1935
1935
  "invalidFileType": {
1936
1936
  "type": "string"
1937
1937
  },
1938
+ "fileTooLarge": {
1939
+ "type": "string"
1940
+ },
1938
1941
  "failedToUpload": {
1939
1942
  "type": "string"
1940
1943
  },
@@ -513,6 +513,7 @@
513
513
  "uploadImagesLabel": "Upload images",
514
514
  "uploadImagesHint": "Drag and drop images here or click to upload.",
515
515
  "invalidFileType": "'{{name}}' is not a supported file type. Supported file types are: {{types}}.",
516
+ "fileTooLarge": "'{{name}}' exceeds the maximum file size of {{size}}. Please upload a smaller file.",
516
517
  "failedToUpload": "Failed to upload the added media. Please try again.",
517
518
  "deleteWarning_one": "You are about to delete {{count}} image. This action cannot be undone.",
518
519
  "deleteWarning_other": "You are about to delete {{count}} images. This action cannot be undone.",
@@ -5,6 +5,7 @@ import { z } from "zod"
5
5
  import {
6
6
  FileType,
7
7
  FileUpload,
8
+ RejectedFile,
8
9
  } from "../../../../../components/common/file-upload"
9
10
  import { Form } from "../../../../../components/common/form"
10
11
  import { MediaSchema } from "../../../product-create/constants"
@@ -47,11 +48,13 @@ export const UploadMediaFormItem = ({
47
48
  const { t } = useTranslation()
48
49
 
49
50
  const hasInvalidFiles = useCallback(
50
- (fileList: FileType[]) => {
51
+ (fileList: FileType[] = [], rejectedFiles: RejectedFile[] = []) => {
51
52
  const invalidFile = fileList.find(
52
- (f) => !SUPPORTED_FORMATS.includes(f.file.type)
53
+ (f) => !SUPPORTED_FORMATS.includes(f?.file?.type)
53
54
  )
54
55
 
56
+ let hasInvalidFile = false;
57
+
55
58
  if (invalidFile) {
56
59
  form.setError("media", {
57
60
  type: "invalid_file",
@@ -61,22 +64,37 @@ export const UploadMediaFormItem = ({
61
64
  }),
62
65
  })
63
66
 
64
- return true
67
+ hasInvalidFile = true;
68
+ }
69
+
70
+ const fileSizeRejections = rejectedFiles.filter((f) => f?.reason === "size")
71
+
72
+ if (fileSizeRejections.length) {
73
+ const fileNames = fileSizeRejections.map((f) => f.file.name).join(", ")
74
+ form.setError("media", {
75
+ type: "file_too_large",
76
+ message: t("products.media.fileTooLarge", {
77
+ name: fileNames,
78
+ size: "1MB",
79
+ }),
80
+ })
81
+
82
+ hasInvalidFile = true;
65
83
  }
66
84
 
67
- return false
85
+ return hasInvalidFile;
68
86
  },
69
87
  [form, t]
70
88
  )
71
89
 
72
90
  const onUploaded = useCallback(
73
- (files: FileType[]) => {
91
+ (files: FileType[] = [], rejectedFiles: RejectedFile[] = []) => {
74
92
  form.clearErrors("media")
75
- if (hasInvalidFiles(files)) {
93
+ if (hasInvalidFiles(files, rejectedFiles)) {
76
94
  return
77
95
  }
78
96
 
79
- files.forEach((f) => append({ ...f, isThumbnail: false }))
97
+ files?.forEach((f) => append({ ...f, isThumbnail: false }))
80
98
  },
81
99
  [form, append, hasInvalidFiles]
82
100
  )
@@ -48,6 +48,7 @@ export const UploadImport = ({
48
48
  }
49
49
  onUploaded(files[0].file)
50
50
  }}
51
+ maxFileSize={Infinity}
51
52
  />
52
53
 
53
54
  {error && (