@medusajs/dashboard 3.0.0-snapshot-20251216103925 → 3.0.0-snapshot-20251216135612
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.
- package/dist/{add-campaign-promotions-PHAHMGXP.mjs → add-campaign-promotions-OYPGISTF.mjs} +4 -4
- package/dist/{api-key-management-detail-NRGL7HHX.mjs → api-key-management-detail-6RCDH73M.mjs} +5 -5
- package/dist/{api-key-management-list-LJSWRAGE.mjs → api-key-management-list-KC5GOWAU.mjs} +5 -5
- package/dist/{api-key-management-sales-channels-3GRNDBZ4.mjs → api-key-management-sales-channels-LUB5G6RC.mjs} +5 -5
- package/dist/app.js +3752 -133
- package/dist/app.mjs +2 -2
- package/dist/{campaign-detail-22Q6XWGL.mjs → campaign-detail-5Q4BYCPX.mjs} +5 -5
- package/dist/{campaign-list-OH566KWW.mjs → campaign-list-PEOTTWBA.mjs} +6 -6
- package/dist/{category-detail-RRKJPMEG.mjs → category-detail-S5IPXMHX.mjs} +4 -4
- package/dist/{category-list-4HZP4FRE.mjs → category-list-QBYJ4T3R.mjs} +4 -4
- package/dist/{category-products-EFZRTCSF.mjs → category-products-KPW6BA5J.mjs} +4 -4
- package/dist/{chunk-LCEKY54O.mjs → chunk-27MGH3HR.mjs} +1 -1
- package/dist/{chunk-KQ4LC2YV.mjs → chunk-2DULKOPN.mjs} +1 -1
- package/dist/{chunk-SUYYSKCB.mjs → chunk-535OVBXR.mjs} +8 -1
- package/dist/{chunk-32FPYJ3S.mjs → chunk-AHZLMCZF.mjs} +1 -1
- package/dist/{chunk-5IFK2ZTA.mjs → chunk-APGDAT7X.mjs} +2 -2
- package/dist/{chunk-2X25XWOW.mjs → chunk-BTYBTKWK.mjs} +1 -1
- package/dist/{chunk-DNUVCBN7.mjs → chunk-CCQD65EY.mjs} +160 -58
- package/dist/{chunk-RL5EYTP6.mjs → chunk-CVHJAKLQ.mjs} +1 -1
- package/dist/{chunk-DZWH2RV6.mjs → chunk-DFFLVEZ5.mjs} +1 -1
- package/dist/{chunk-YTN73JYH.mjs → chunk-DTZXEQXZ.mjs} +1 -1
- package/dist/{chunk-7R743WZ6.mjs → chunk-EHU67PIM.mjs} +1 -1
- package/dist/{chunk-VX2HE7O5.mjs → chunk-FBYTX6K7.mjs} +1 -1
- package/dist/{chunk-RMDYKRWW.mjs → chunk-KFYQTOGB.mjs} +1 -1
- package/dist/{chunk-GA3UMQMZ.mjs → chunk-O7JNIATG.mjs} +1 -1
- package/dist/{chunk-OHY2N2Q4.mjs → chunk-OL24RDYM.mjs} +3 -3
- package/dist/{chunk-M4Q5Q4I3.mjs → chunk-PA3T6IWL.mjs} +2 -2
- package/dist/{chunk-NL376WAO.mjs → chunk-QISH26J3.mjs} +1 -1
- package/dist/{chunk-PVW6M64S.mjs → chunk-QOCJPBRB.mjs} +1 -1
- package/dist/{chunk-2GWGNMAA.mjs → chunk-R4ZOO4ON.mjs} +1 -1
- package/dist/{chunk-43X7ZR3P.mjs → chunk-RS7DWLEP.mjs} +1 -1
- package/dist/{chunk-ROKB75YP.mjs → chunk-VT2JJ5C2.mjs} +1 -1
- package/dist/{chunk-DK7IWUMK.mjs → chunk-WYATCUOM.mjs} +3 -3
- package/dist/{chunk-CV65NY6Y.mjs → chunk-YFIYCS7F.mjs} +1 -1
- package/dist/{chunk-O7WJSSQR.mjs → chunk-YKYVCQRS.mjs} +3346 -93
- package/dist/{chunk-GU5PJRPM.mjs → chunk-ZQJPHZKI.mjs} +1 -1
- package/dist/{collection-add-products-XUMV6XR7.mjs → collection-add-products-FU2BS3D3.mjs} +4 -4
- package/dist/{collection-detail-ONRBKJLN.mjs → collection-detail-VJE7XHLV.mjs} +4 -4
- package/dist/{collection-list-XCC4SIPJ.mjs → collection-list-IGA6SCNF.mjs} +4 -4
- package/dist/{customer-detail-FR6J37ZC.mjs → customer-detail-MOV2T3LF.mjs} +6 -6
- package/dist/{customer-group-add-customers-DM4VLTNB.mjs → customer-group-add-customers-XMR2WBXX.mjs} +6 -6
- package/dist/{customer-group-detail-YSKSNETG.mjs → customer-group-detail-6T7OXGQD.mjs} +6 -6
- package/dist/{customer-group-list-XBCD4FZH.mjs → customer-group-list-AJEAF5D2.mjs} +3 -3
- package/dist/{customer-list-TG4D4QOT.mjs → customer-list-UI5EQDII.mjs} +6 -6
- package/dist/{customers-add-customer-group-Q7FMR2Y5.mjs → customers-add-customer-group-QVTVSQYM.mjs} +4 -4
- package/dist/{inventory-create-3XONKYMZ.mjs → inventory-create-ANYUM4P5.mjs} +1 -1
- package/dist/{inventory-detail-6A6GOLB6.mjs → inventory-detail-ZPSEMYI2.mjs} +4 -4
- package/dist/{inventory-list-2CJLAK3X.mjs → inventory-list-RXJPSVZE.mjs} +4 -4
- package/dist/{inventory-stock-S3ZYYCMZ.mjs → inventory-stock-FD4ZM4BB.mjs} +2 -2
- package/dist/{location-fulfillment-providers-WM6DT252.mjs → location-fulfillment-providers-7ZUJAGNY.mjs} +4 -4
- package/dist/{location-sales-channels-WLVTMU4Z.mjs → location-sales-channels-P3QJTFDT.mjs} +5 -5
- package/dist/{location-service-zone-create-3FWF3DG5.mjs → location-service-zone-create-J43WN6G4.mjs} +5 -5
- package/dist/{location-service-zone-manage-areas-YFEAZUUN.mjs → location-service-zone-manage-areas-6ZPMKMSX.mjs} +5 -5
- package/dist/{location-service-zone-shipping-option-create-MJPH3WKX.mjs → location-service-zone-shipping-option-create-ZJ4GIBTJ.mjs} +2 -2
- package/dist/{location-service-zone-shipping-option-pricing-6IRNPWJY.mjs → location-service-zone-shipping-option-pricing-CR4BVYG3.mjs} +2 -2
- package/dist/{order-create-claim-GUYTLVPB.mjs → order-create-claim-SCDJGM46.mjs} +4 -4
- package/dist/{order-create-edit-ODIN6GRW.mjs → order-create-edit-JIE3HDHP.mjs} +4 -4
- package/dist/{order-create-exchange-ZT5RBRKL.mjs → order-create-exchange-LQU4YN7F.mjs} +4 -4
- package/dist/{order-create-return-E2KILJX2.mjs → order-create-return-52GHGW5Z.mjs} +4 -4
- package/dist/{order-detail-HFJONELJ.mjs → order-detail-PVPGEWGY.mjs} +2 -2
- package/dist/{order-export-4MZUPMGD.mjs → order-export-LE363ZLB.mjs} +3 -3
- package/dist/{order-list-ACSFGIPD.mjs → order-list-GRLQWN4L.mjs} +7 -7
- package/dist/{price-list-configuration-IHPSUNZJ.mjs → price-list-configuration-6S3MLNXQ.mjs} +5 -5
- package/dist/{price-list-create-YHXRQSC3.mjs → price-list-create-MFRUQADC.mjs} +7 -7
- package/dist/{price-list-detail-FR3FQR3H.mjs → price-list-detail-Q5VG5VGW.mjs} +5 -5
- package/dist/{price-list-list-YSEM6IAI.mjs → price-list-list-DG5YEZ44.mjs} +4 -4
- package/dist/{price-list-prices-add-GJVI47OY.mjs → price-list-prices-add-SDU5YZAT.mjs} +6 -6
- package/dist/{price-list-prices-edit-E4Q5TQPM.mjs → price-list-prices-edit-5USQR4D4.mjs} +2 -2
- package/dist/{product-attributes-QD3BWV5V.mjs → product-attributes-EFIRUBRO.mjs} +2 -2
- package/dist/{product-create-E2GZYQX4.mjs → product-create-K6EWZHIT.mjs} +7 -7
- package/dist/{product-create-variant-KEBN5OR7.mjs → product-create-variant-ERKHTEJZ.mjs} +1 -1
- package/dist/{product-detail-QBGGKRZ2.mjs → product-detail-DKPZDEIY.mjs} +4 -4
- package/dist/{product-edit-YP4KOQ4T.mjs → product-edit-55YXTIGO.mjs} +2 -2
- package/dist/{product-export-WUZYHPS5.mjs → product-export-5AD7NELI.mjs} +3 -3
- package/dist/{product-image-variants-edit-Y363J5NG.mjs → product-image-variants-edit-M6QF2RLE.mjs} +4 -4
- package/dist/{product-list-DNTS7WUN.mjs → product-list-EUWZIFTM.mjs} +7 -7
- package/dist/{product-organization-H557PLLB.mjs → product-organization-N3VBRXF4.mjs} +2 -2
- package/dist/{product-prices-JOG6IIQ7.mjs → product-prices-4C36AG4R.mjs} +1 -1
- package/dist/{product-sales-channels-ANCFZZ5S.mjs → product-sales-channels-PPXUG4KT.mjs} +5 -5
- package/dist/{product-stock-NYUFMEVG.mjs → product-stock-VEGE6SUZ.mjs} +2 -2
- package/dist/{product-tag-detail-EHBB3WUB.mjs → product-tag-detail-I3MBZX7U.mjs} +10 -10
- package/dist/{product-tag-list-LSW5FFVN.mjs → product-tag-list-JUWSOMB7.mjs} +10 -10
- package/dist/{product-type-detail-3VB6AWUW.mjs → product-type-detail-RKHT5NBL.mjs} +4 -4
- package/dist/{product-type-list-FD3TGPNP.mjs → product-type-list-QQKAHBJ3.mjs} +6 -6
- package/dist/{product-variant-detail-43T33AQP.mjs → product-variant-detail-XAYG5CKE.mjs} +4 -4
- package/dist/{profile-detail-BMC7IZBY.mjs → profile-detail-FRZ74HAF.mjs} +1 -1
- package/dist/{profile-edit-YZCUGEXF.mjs → profile-edit-ZNXO6WME.mjs} +1 -1
- package/dist/{promotion-detail-VJB55PJK.mjs → promotion-detail-QC36KXB3.mjs} +3 -3
- package/dist/{promotion-list-TMWKPLMJ.mjs → promotion-list-L22GJE3P.mjs} +4 -4
- package/dist/{refund-reason-list-URYYYEK6.mjs → refund-reason-list-OJYYEYJE.mjs} +8 -8
- package/dist/{region-add-countries-7U4J5RW6.mjs → region-add-countries-2VAVXMJQ.mjs} +4 -4
- package/dist/{region-create-IUGX33M5.mjs → region-create-NA7Y2LN4.mjs} +4 -4
- package/dist/{region-detail-D3JBW34A.mjs → region-detail-3BARMXUE.mjs} +4 -4
- package/dist/{region-list-JAQXIBYD.mjs → region-list-V4R2REMH.mjs} +4 -4
- package/dist/{reservation-list-2DN3YHIJ.mjs → reservation-list-B47DXTA7.mjs} +5 -5
- package/dist/{return-reason-list-IFFIDA5O.mjs → return-reason-list-SCBGTOEI.mjs} +10 -10
- package/dist/{sales-channel-add-products-VH5T3GDA.mjs → sales-channel-add-products-F7YV4MO5.mjs} +4 -4
- package/dist/{sales-channel-detail-I2ZHVXMG.mjs → sales-channel-detail-MXIPZCGA.mjs} +4 -4
- package/dist/{sales-channel-list-3FV4S2NN.mjs → sales-channel-list-RLGL7FM3.mjs} +5 -5
- package/dist/{shipping-option-type-list-ZMZMXFME.mjs → shipping-option-type-list-DIOX7VG7.mjs} +5 -5
- package/dist/{shipping-profiles-list-H3CBZKRH.mjs → shipping-profiles-list-WRPIJBZZ.mjs} +4 -4
- package/dist/{store-add-currencies-ZFS3WZHG.mjs → store-add-currencies-OX2WXFMS.mjs} +4 -4
- package/dist/{store-add-locales-IZOZP5C6.mjs → store-add-locales-VJ4RJ7UI.mjs} +4 -4
- package/dist/{store-detail-4IBAEVSD.mjs → store-detail-JSNPOB2F.mjs} +4 -4
- package/dist/{tax-region-detail-O2T7BI3V.mjs → tax-region-detail-2AE2EFI3.mjs} +13 -13
- package/dist/{tax-region-province-detail-2W7RXAM5.mjs → tax-region-province-detail-4ERSEQFF.mjs} +13 -13
- package/dist/{tax-region-tax-override-create-7IM4ZVPH.mjs → tax-region-tax-override-create-PHCGEF7V.mjs} +11 -11
- package/dist/{tax-region-tax-override-edit-3ZT5IZYR.mjs → tax-region-tax-override-edit-SMRPSILC.mjs} +12 -12
- package/dist/{translation-list-IAKEB7MY.mjs → translation-list-S5Z6PG2R.mjs} +8 -5
- package/dist/translations-edit-HUNKY7CO.mjs +708 -0
- package/dist/{user-invite-XB635N26.mjs → user-invite-GAGIM5DO.mjs} +4 -4
- package/dist/{user-list-YYUOQKQY.mjs → user-list-YTZQNYSO.mjs} +4 -4
- package/dist/{workflow-execution-list-IZVF2XMJ.mjs → workflow-execution-list-C3EJMVSZ.mjs} +4 -4
- package/package.json +9 -9
- package/src/components/data-grid/components/data-grid-cell-container.tsx +16 -4
- package/src/components/data-grid/components/data-grid-readonly-cell.tsx +16 -3
- package/src/components/data-grid/components/data-grid-root.tsx +19 -4
- package/src/components/data-grid/components/data-grid-text-cell.tsx +79 -9
- package/src/i18n/languages.ts +7 -0
- package/src/i18n/translations/index.ts +4 -0
- package/src/i18n/translations/zhTW.json +3249 -0
- package/src/routes/translations/translation-list/translation-list.tsx +9 -8
- package/src/routes/translations/translations-edit/components/translations-edit-form/translations-edit-form.tsx +388 -90
- package/src/routes/translations/translations-edit/translations-edit.tsx +0 -1
- package/dist/translations-edit-QKLE4L5B.mjs +0 -458
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DataGrid,
|
|
3
|
-
createDataGridHelper
|
|
4
|
-
} from "./chunk-DNUVCBN7.mjs";
|
|
5
|
-
import "./chunk-DK4WIVY6.mjs";
|
|
6
|
-
import "./chunk-IUCDCPJU.mjs";
|
|
7
|
-
import {
|
|
8
|
-
KeyboundForm
|
|
9
|
-
} from "./chunk-6HTZNHPT.mjs";
|
|
10
|
-
import "./chunk-WVA4O7QS.mjs";
|
|
11
|
-
import {
|
|
12
|
-
RouteFocusModal,
|
|
13
|
-
useRouteModal
|
|
14
|
-
} from "./chunk-D6UW7URG.mjs";
|
|
15
|
-
import {
|
|
16
|
-
useFeatureFlag
|
|
17
|
-
} from "./chunk-G4BWCU5P.mjs";
|
|
18
|
-
import "./chunk-LPEUYMRK.mjs";
|
|
19
|
-
import "./chunk-OC7BQLYI.mjs";
|
|
20
|
-
import {
|
|
21
|
-
useDocumentDirection
|
|
22
|
-
} from "./chunk-S4DMV3ZT.mjs";
|
|
23
|
-
import "./chunk-OBQI23QM.mjs";
|
|
24
|
-
import {
|
|
25
|
-
useBatchTranslations,
|
|
26
|
-
useReferenceTranslations,
|
|
27
|
-
useTranslationSettings
|
|
28
|
-
} from "./chunk-GRZSG4EP.mjs";
|
|
29
|
-
import "./chunk-I4OBEAOJ.mjs";
|
|
30
|
-
import "./chunk-HI6URQ7H.mjs";
|
|
31
|
-
import "./chunk-6CLQKVAU.mjs";
|
|
32
|
-
import "./chunk-KI7TOXBR.mjs";
|
|
33
|
-
import "./chunk-UJ2TMPV4.mjs";
|
|
34
|
-
import "./chunk-23GTCEOV.mjs";
|
|
35
|
-
import "./chunk-WAXMT4IY.mjs";
|
|
36
|
-
import "./chunk-DYDGGABK.mjs";
|
|
37
|
-
import "./chunk-LGNTHZ5Y.mjs";
|
|
38
|
-
import "./chunk-CN7JXSGW.mjs";
|
|
39
|
-
import "./chunk-5BQQRHQS.mjs";
|
|
40
|
-
import "./chunk-HTCYX4VD.mjs";
|
|
41
|
-
import "./chunk-5AFMB7XQ.mjs";
|
|
42
|
-
import "./chunk-UWY5ZV66.mjs";
|
|
43
|
-
import "./chunk-A63RZVX6.mjs";
|
|
44
|
-
import "./chunk-HBXV7ENS.mjs";
|
|
45
|
-
import "./chunk-CDORR33H.mjs";
|
|
46
|
-
import "./chunk-4JQR6QNW.mjs";
|
|
47
|
-
import "./chunk-FYWHE3W5.mjs";
|
|
48
|
-
import "./chunk-OSHH5GAS.mjs";
|
|
49
|
-
import "./chunk-2XTBDCGE.mjs";
|
|
50
|
-
import "./chunk-3BF5SC66.mjs";
|
|
51
|
-
import {
|
|
52
|
-
useStore
|
|
53
|
-
} from "./chunk-VCSSQVPD.mjs";
|
|
54
|
-
import "./chunk-HP2JH45P.mjs";
|
|
55
|
-
import "./chunk-SQDIZZDW.mjs";
|
|
56
|
-
import "./chunk-Z6BFNHEO.mjs";
|
|
57
|
-
import "./chunk-HGRIOEAR.mjs";
|
|
58
|
-
import "./chunk-FXYH54JP.mjs";
|
|
59
|
-
import "./chunk-774WSTCC.mjs";
|
|
60
|
-
import "./chunk-NFEK63OE.mjs";
|
|
61
|
-
import "./chunk-QZ7TP4HQ.mjs";
|
|
62
|
-
|
|
63
|
-
// src/routes/translations/translations-edit/translations-edit.tsx
|
|
64
|
-
import { useNavigate, useSearchParams } from "react-router-dom";
|
|
65
|
-
|
|
66
|
-
// src/routes/translations/translations-edit/components/translations-edit-form/translations-edit-form.tsx
|
|
67
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
68
|
-
import { Button, ProgressTabs, toast } from "@medusajs/ui";
|
|
69
|
-
import { useMemo, useRef } from "react";
|
|
70
|
-
import { useForm } from "react-hook-form";
|
|
71
|
-
import { useTranslation } from "react-i18next";
|
|
72
|
-
import { z } from "zod";
|
|
73
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
74
|
-
var LocaleTranslationSchema = z.object({
|
|
75
|
-
id: z.string().nullish(),
|
|
76
|
-
locale_code: z.string(),
|
|
77
|
-
fields: z.record(z.string().optional())
|
|
78
|
-
});
|
|
79
|
-
var EntityTranslationsSchema = z.object({
|
|
80
|
-
locales: z.record(LocaleTranslationSchema)
|
|
81
|
-
});
|
|
82
|
-
var TranslationsFormSchema = z.object({
|
|
83
|
-
entities: z.record(EntityTranslationsSchema)
|
|
84
|
-
});
|
|
85
|
-
function isEntityRow(row) {
|
|
86
|
-
return row._type === "entity";
|
|
87
|
-
}
|
|
88
|
-
function initTranslationsFormState(translations, references, availableLocales, translatableFields) {
|
|
89
|
-
const existingMap = /* @__PURE__ */ new Map();
|
|
90
|
-
for (const t of translations) {
|
|
91
|
-
existingMap.set(`${t.reference_id}:${t.locale_code}`, t);
|
|
92
|
-
}
|
|
93
|
-
const entitiesTranslationState = {};
|
|
94
|
-
for (const reference of references) {
|
|
95
|
-
const locales = {};
|
|
96
|
-
for (const locale of availableLocales) {
|
|
97
|
-
const key = `${reference.id}:${locale.locale_code}`;
|
|
98
|
-
const existing = existingMap.get(key);
|
|
99
|
-
const fields = {};
|
|
100
|
-
for (const fieldName of translatableFields) {
|
|
101
|
-
const fieldValue = existing?.translations?.[fieldName] ?? "";
|
|
102
|
-
fields[fieldName] = fieldValue;
|
|
103
|
-
}
|
|
104
|
-
locales[locale.locale_code] = {
|
|
105
|
-
id: existing?.id ?? null,
|
|
106
|
-
locale_code: locale.locale_code,
|
|
107
|
-
fields
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
entitiesTranslationState[reference.id] = { locales };
|
|
111
|
-
}
|
|
112
|
-
return {
|
|
113
|
-
entities: entitiesTranslationState
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
function buildTranslationRows(references, translatableFields) {
|
|
117
|
-
return references.map((reference) => ({
|
|
118
|
-
_type: "entity",
|
|
119
|
-
reference_id: reference.id,
|
|
120
|
-
subRows: translatableFields.map((fieldName) => ({
|
|
121
|
-
_type: "field",
|
|
122
|
-
reference_id: reference.id,
|
|
123
|
-
field_name: fieldName
|
|
124
|
-
}))
|
|
125
|
-
}));
|
|
126
|
-
}
|
|
127
|
-
function transformToBatchPayload(currentState, initialState, entityType) {
|
|
128
|
-
const payload = {
|
|
129
|
-
create: [],
|
|
130
|
-
update: [],
|
|
131
|
-
delete: []
|
|
132
|
-
};
|
|
133
|
-
for (const [entityId, entityData] of Object.entries(currentState.entities)) {
|
|
134
|
-
for (const [localeCode, localeTranslations] of Object.entries(
|
|
135
|
-
entityData.locales
|
|
136
|
-
)) {
|
|
137
|
-
const initial = initialState.entities[entityId]?.locales[localeCode];
|
|
138
|
-
const hasContent = Object.values(localeTranslations.fields).some(
|
|
139
|
-
(v) => v !== void 0 && v.trim() !== ""
|
|
140
|
-
);
|
|
141
|
-
const hadContent = initial && Object.values(initial.fields).some(
|
|
142
|
-
(v) => v !== void 0 && v.trim() !== ""
|
|
143
|
-
);
|
|
144
|
-
if (!localeTranslations.id && hasContent) {
|
|
145
|
-
payload.create.push({
|
|
146
|
-
reference_id: entityId,
|
|
147
|
-
reference: entityType,
|
|
148
|
-
locale_code: localeTranslations.locale_code,
|
|
149
|
-
translations: localeTranslations.fields
|
|
150
|
-
});
|
|
151
|
-
} else if (localeTranslations.id && hasContent) {
|
|
152
|
-
const hasChanged = !initial || JSON.stringify(localeTranslations.fields) !== JSON.stringify(initial.fields);
|
|
153
|
-
if (hasChanged) {
|
|
154
|
-
payload.update.push({
|
|
155
|
-
id: localeTranslations.id,
|
|
156
|
-
translations: localeTranslations.fields
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
} else if (localeTranslations.id && !hasContent && hadContent) {
|
|
160
|
-
payload.delete.push(localeTranslations.id);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return payload;
|
|
165
|
-
}
|
|
166
|
-
var columnHelper = createDataGridHelper();
|
|
167
|
-
function useTranslationsGridColumns({
|
|
168
|
-
entities,
|
|
169
|
-
translatableFields,
|
|
170
|
-
availableLocales,
|
|
171
|
-
modalFields = []
|
|
172
|
-
}) {
|
|
173
|
-
const { t } = useTranslation();
|
|
174
|
-
const columns = useMemo(() => {
|
|
175
|
-
return [
|
|
176
|
-
columnHelper.column({
|
|
177
|
-
id: "field",
|
|
178
|
-
name: "field",
|
|
179
|
-
header: void 0,
|
|
180
|
-
cell: (context) => {
|
|
181
|
-
const row = context.row.original;
|
|
182
|
-
if (isEntityRow(row)) {
|
|
183
|
-
return /* @__PURE__ */ jsx(DataGrid.ReadonlyCell, { context });
|
|
184
|
-
}
|
|
185
|
-
return /* @__PURE__ */ jsx(DataGrid.ReadonlyCell, { context, color: "normal", children: /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center gap-x-2 overflow-hidden", children: /* @__PURE__ */ jsx("span", { className: "truncate", children: t(`fields.${row.field_name}`, {
|
|
186
|
-
defaultValue: row.field_name
|
|
187
|
-
}) }) }) });
|
|
188
|
-
},
|
|
189
|
-
disableHiding: true
|
|
190
|
-
}),
|
|
191
|
-
columnHelper.column({
|
|
192
|
-
id: "original",
|
|
193
|
-
name: "original",
|
|
194
|
-
size: 300,
|
|
195
|
-
header: t("general.original"),
|
|
196
|
-
disableHiding: true,
|
|
197
|
-
cell: (context) => {
|
|
198
|
-
const row = context.row.original;
|
|
199
|
-
if (isEntityRow(row)) {
|
|
200
|
-
return /* @__PURE__ */ jsx(DataGrid.ReadonlyCell, { context });
|
|
201
|
-
}
|
|
202
|
-
const entity = entities.find(
|
|
203
|
-
(entity2) => entity2.id === row.reference_id
|
|
204
|
-
);
|
|
205
|
-
if (!entity) {
|
|
206
|
-
return null;
|
|
207
|
-
}
|
|
208
|
-
return /* @__PURE__ */ jsx(DataGrid.ReadonlyCell, { context, children: entity[row.field_name] });
|
|
209
|
-
}
|
|
210
|
-
}),
|
|
211
|
-
...availableLocales.map((locale) => {
|
|
212
|
-
return columnHelper.column({
|
|
213
|
-
id: locale.locale_code,
|
|
214
|
-
name: locale.locale.name,
|
|
215
|
-
size: 300,
|
|
216
|
-
header: () => locale.locale.name,
|
|
217
|
-
cell: (context) => {
|
|
218
|
-
const row = context.row.original;
|
|
219
|
-
if (isEntityRow(row)) {
|
|
220
|
-
return /* @__PURE__ */ jsx(
|
|
221
|
-
DataGrid.ReadonlyCell,
|
|
222
|
-
{
|
|
223
|
-
context
|
|
224
|
-
}
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
const useModal = modalFields.includes(row.field_name);
|
|
228
|
-
if (useModal) {
|
|
229
|
-
return /* @__PURE__ */ jsx(
|
|
230
|
-
DataGrid.ExpandableTextCell,
|
|
231
|
-
{
|
|
232
|
-
context,
|
|
233
|
-
fieldLabel: row.field_name
|
|
234
|
-
}
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
return /* @__PURE__ */ jsx(DataGrid.TextCell, { context });
|
|
238
|
-
},
|
|
239
|
-
field: (context) => {
|
|
240
|
-
const row = context.row.original;
|
|
241
|
-
if (isEntityRow(row)) {
|
|
242
|
-
return null;
|
|
243
|
-
}
|
|
244
|
-
return `entities.${row.reference_id}.locales.${locale.locale_code}.fields.${row.field_name}`;
|
|
245
|
-
},
|
|
246
|
-
type: "text"
|
|
247
|
-
});
|
|
248
|
-
})
|
|
249
|
-
];
|
|
250
|
-
}, [t, translatableFields, availableLocales, modalFields]);
|
|
251
|
-
return columns;
|
|
252
|
-
}
|
|
253
|
-
var TranslationsEditForm = ({
|
|
254
|
-
translations,
|
|
255
|
-
references,
|
|
256
|
-
entityType,
|
|
257
|
-
availableLocales,
|
|
258
|
-
translatableFields,
|
|
259
|
-
modalFields = [],
|
|
260
|
-
fetchNextPage,
|
|
261
|
-
hasNextPage,
|
|
262
|
-
isFetchingNextPage,
|
|
263
|
-
referenceCount
|
|
264
|
-
}) => {
|
|
265
|
-
const { t } = useTranslation();
|
|
266
|
-
const { handleSuccess, setCloseOnEscape } = useRouteModal();
|
|
267
|
-
const direction = useDocumentDirection();
|
|
268
|
-
const entities = useMemo(() => references, [references]);
|
|
269
|
-
const totalCount = useMemo(
|
|
270
|
-
() => referenceCount * (translatableFields.length + 1),
|
|
271
|
-
[referenceCount, translatableFields]
|
|
272
|
-
);
|
|
273
|
-
const initialState = useRef(
|
|
274
|
-
initTranslationsFormState(
|
|
275
|
-
translations,
|
|
276
|
-
entities,
|
|
277
|
-
availableLocales,
|
|
278
|
-
translatableFields
|
|
279
|
-
)
|
|
280
|
-
);
|
|
281
|
-
const form = useForm({
|
|
282
|
-
resolver: zodResolver(TranslationsFormSchema),
|
|
283
|
-
defaultValues: initialState.current
|
|
284
|
-
});
|
|
285
|
-
const rows = useMemo(
|
|
286
|
-
() => buildTranslationRows(entities, translatableFields),
|
|
287
|
-
[entities, translatableFields]
|
|
288
|
-
);
|
|
289
|
-
const { mutateAsync, isPending } = useBatchTranslations(entityType);
|
|
290
|
-
const handleSubmit = form.handleSubmit(async (values) => {
|
|
291
|
-
const payload = transformToBatchPayload(
|
|
292
|
-
values,
|
|
293
|
-
initialState.current,
|
|
294
|
-
entityType
|
|
295
|
-
);
|
|
296
|
-
if (payload.create.length === 0 && payload.update.length === 0 && payload.delete.length === 0) {
|
|
297
|
-
toast.info(
|
|
298
|
-
t("translations.noChanges", { defaultValue: "No changes to save" })
|
|
299
|
-
);
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
const BATCH_SIZE = 150;
|
|
303
|
-
const totalItems = payload.create.length + payload.update.length + payload.delete.length;
|
|
304
|
-
const batchCount = Math.ceil(totalItems / BATCH_SIZE);
|
|
305
|
-
for (let i = 0; i < batchCount; i++) {
|
|
306
|
-
let currentBatchAvailable = BATCH_SIZE;
|
|
307
|
-
const currentBatch = {
|
|
308
|
-
create: [],
|
|
309
|
-
update: [],
|
|
310
|
-
delete: []
|
|
311
|
-
};
|
|
312
|
-
if (payload.create.length > 0) {
|
|
313
|
-
currentBatch.create = payload.create.splice(0, currentBatchAvailable);
|
|
314
|
-
currentBatchAvailable -= currentBatch.create.length;
|
|
315
|
-
}
|
|
316
|
-
if (payload.update.length > 0) {
|
|
317
|
-
currentBatch.update = payload.update.splice(0, currentBatchAvailable);
|
|
318
|
-
currentBatchAvailable -= currentBatch.update.length;
|
|
319
|
-
}
|
|
320
|
-
if (payload.delete.length > 0) {
|
|
321
|
-
currentBatch.delete = payload.delete.splice(0, currentBatchAvailable);
|
|
322
|
-
currentBatchAvailable -= currentBatch.delete.length;
|
|
323
|
-
}
|
|
324
|
-
await mutateAsync(currentBatch, {
|
|
325
|
-
onSuccess: () => {
|
|
326
|
-
if (i === batchCount - 1) {
|
|
327
|
-
toast.success(
|
|
328
|
-
t("translations.edit.successToast", {
|
|
329
|
-
defaultValue: "Translations updated successfully"
|
|
330
|
-
})
|
|
331
|
-
);
|
|
332
|
-
handleSuccess();
|
|
333
|
-
}
|
|
334
|
-
},
|
|
335
|
-
onError: (error) => {
|
|
336
|
-
toast.error(error.message);
|
|
337
|
-
}
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
const columns = useTranslationsGridColumns({
|
|
342
|
-
entities,
|
|
343
|
-
translatableFields,
|
|
344
|
-
availableLocales,
|
|
345
|
-
modalFields
|
|
346
|
-
});
|
|
347
|
-
return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsx(KeyboundForm, { onSubmit: handleSubmit, className: "flex h-full flex-col", children: /* @__PURE__ */ jsxs(
|
|
348
|
-
ProgressTabs,
|
|
349
|
-
{
|
|
350
|
-
dir: direction,
|
|
351
|
-
defaultValue: entityType,
|
|
352
|
-
className: "flex h-full flex-col overflow-hidden",
|
|
353
|
-
children: [
|
|
354
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Header, { children: /* @__PURE__ */ jsx("div", { className: "-my-2 w-full border-l", children: /* @__PURE__ */ jsx(ProgressTabs.List, { className: "justify-start-start flex w-full items-center", children: /* @__PURE__ */ jsx(ProgressTabs.Trigger, { value: entityType, children: entityType.split("_").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ") }) }) }) }),
|
|
355
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "size-full overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
356
|
-
ProgressTabs.Content,
|
|
357
|
-
{
|
|
358
|
-
value: entityType,
|
|
359
|
-
className: "size-full overflow-y-auto",
|
|
360
|
-
children: /* @__PURE__ */ jsx(
|
|
361
|
-
DataGrid,
|
|
362
|
-
{
|
|
363
|
-
columns,
|
|
364
|
-
data: rows,
|
|
365
|
-
getSubRows: (row) => {
|
|
366
|
-
if (isEntityRow(row)) {
|
|
367
|
-
return row.subRows;
|
|
368
|
-
}
|
|
369
|
-
},
|
|
370
|
-
state: form,
|
|
371
|
-
onEditingChange: (editing) => setCloseOnEscape(!editing),
|
|
372
|
-
totalRowCount: totalCount,
|
|
373
|
-
onFetchMore: fetchNextPage,
|
|
374
|
-
isFetchingMore: isFetchingNextPage,
|
|
375
|
-
hasNextPage
|
|
376
|
-
}
|
|
377
|
-
)
|
|
378
|
-
}
|
|
379
|
-
) }),
|
|
380
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
381
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: t("actions.cancel") }) }),
|
|
382
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: t("actions.save") })
|
|
383
|
-
] }) })
|
|
384
|
-
]
|
|
385
|
-
}
|
|
386
|
-
) }) });
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
// src/routes/translations/translations-edit/translations-edit.tsx
|
|
390
|
-
import { useEffect } from "react";
|
|
391
|
-
import { keepPreviousData } from "@tanstack/react-query";
|
|
392
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
393
|
-
var TranslationsEdit = () => {
|
|
394
|
-
const isTranslationsEnabled = useFeatureFlag("translation");
|
|
395
|
-
const navigate = useNavigate();
|
|
396
|
-
const [searchParams] = useSearchParams();
|
|
397
|
-
const reference = searchParams.get("reference");
|
|
398
|
-
const referenceIdParam = searchParams.getAll("reference_id");
|
|
399
|
-
useEffect(() => {
|
|
400
|
-
if (!reference || !isTranslationsEnabled) {
|
|
401
|
-
navigate(-1);
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
}, [reference, navigate, isTranslationsEnabled]);
|
|
405
|
-
const {
|
|
406
|
-
translatable_fields,
|
|
407
|
-
isPending: isTranslationSettingsPending,
|
|
408
|
-
isError: isTranslationSettingsError,
|
|
409
|
-
error: translationSettingsError
|
|
410
|
-
} = useTranslationSettings({ entity_type: reference });
|
|
411
|
-
const {
|
|
412
|
-
translations,
|
|
413
|
-
references,
|
|
414
|
-
fetchNextPage,
|
|
415
|
-
count,
|
|
416
|
-
isFetchingNextPage,
|
|
417
|
-
hasNextPage,
|
|
418
|
-
isPending,
|
|
419
|
-
isError,
|
|
420
|
-
error
|
|
421
|
-
} = useReferenceTranslations(
|
|
422
|
-
reference,
|
|
423
|
-
translatable_fields?.[reference] ?? [],
|
|
424
|
-
referenceIdParam,
|
|
425
|
-
{
|
|
426
|
-
enabled: !!translatable_fields && !!reference,
|
|
427
|
-
placeholderData: keepPreviousData
|
|
428
|
-
}
|
|
429
|
-
);
|
|
430
|
-
const {
|
|
431
|
-
store,
|
|
432
|
-
isPending: isStorePending,
|
|
433
|
-
isError: isStoreError,
|
|
434
|
-
error: storeError
|
|
435
|
-
} = useStore();
|
|
436
|
-
const ready = !isPending && !!translations && !!translatable_fields && !isTranslationSettingsPending && !!references && !isStorePending && !!store;
|
|
437
|
-
if (isError || isStoreError || isTranslationSettingsError) {
|
|
438
|
-
throw error || storeError || translationSettingsError;
|
|
439
|
-
}
|
|
440
|
-
return /* @__PURE__ */ jsx2(RouteFocusModal, { prev: referenceIdParam.length ? -1 : "..", children: ready && /* @__PURE__ */ jsx2(
|
|
441
|
-
TranslationsEditForm,
|
|
442
|
-
{
|
|
443
|
-
translations,
|
|
444
|
-
references,
|
|
445
|
-
entityType: reference,
|
|
446
|
-
availableLocales: store?.supported_locales ?? [],
|
|
447
|
-
translatableFields: translatable_fields[reference],
|
|
448
|
-
modalFields: translatable_fields[reference],
|
|
449
|
-
fetchNextPage,
|
|
450
|
-
hasNextPage,
|
|
451
|
-
isFetchingNextPage,
|
|
452
|
-
referenceCount: count
|
|
453
|
-
}
|
|
454
|
-
) });
|
|
455
|
-
};
|
|
456
|
-
export {
|
|
457
|
-
TranslationsEdit as Component
|
|
458
|
-
};
|