@open-mercato/checkout 0.6.5-develop.4534.1.b459babe6d → 0.6.5-develop.4559.1.839e136509
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/.turbo/turbo-build.log +1 -1
- package/dist/modules/checkout/__integration__/TC-CHKT-039-null-gateway-edit.spec.js +118 -0
- package/dist/modules/checkout/__integration__/TC-CHKT-039-null-gateway-edit.spec.js.map +7 -0
- package/dist/modules/checkout/__integration__/TC-CHKT-039-stale-delete-lock.spec.js +66 -0
- package/dist/modules/checkout/__integration__/TC-CHKT-039-stale-delete-lock.spec.js.map +7 -0
- package/dist/modules/checkout/commands/links.js +13 -0
- package/dist/modules/checkout/commands/links.js.map +2 -2
- package/dist/modules/checkout/commands/templates.js +13 -0
- package/dist/modules/checkout/commands/templates.js.map +2 -2
- package/dist/modules/checkout/components/LinkTemplateForm.js +27 -7
- package/dist/modules/checkout/components/LinkTemplateForm.js.map +2 -2
- package/dist/modules/checkout/data/validators.js +11 -2
- package/dist/modules/checkout/data/validators.js.map +2 -2
- package/package.json +5 -5
- package/src/modules/checkout/__integration__/TC-CHKT-039-null-gateway-edit.spec.ts +134 -0
- package/src/modules/checkout/__integration__/TC-CHKT-039-stale-delete-lock.spec.ts +98 -0
- package/src/modules/checkout/commands/__tests__/optimistic-lock.test.ts +261 -0
- package/src/modules/checkout/commands/links.ts +13 -0
- package/src/modules/checkout/commands/templates.ts +13 -0
- package/src/modules/checkout/components/LinkTemplateForm.tsx +27 -7
- package/src/modules/checkout/data/__tests__/validators.test.ts +59 -1
- package/src/modules/checkout/data/validators.ts +11 -2
|
@@ -24,7 +24,9 @@ import { CrudForm } from "@open-mercato/ui/backend/CrudForm";
|
|
|
24
24
|
import { ComboboxInput } from "@open-mercato/ui/backend/inputs";
|
|
25
25
|
import { Page, PageBody } from "@open-mercato/ui/backend/Page";
|
|
26
26
|
import { SwitchableMarkdownInput } from "@open-mercato/ui/backend/inputs";
|
|
27
|
-
import { apiCall, apiCallOrThrow, readApiResultOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
|
|
27
|
+
import { apiCall, apiCallOrThrow, readApiResultOrThrow, withScopedApiRequestHeaders } from "@open-mercato/ui/backend/utils/apiCall";
|
|
28
|
+
import { buildOptimisticLockHeader } from "@open-mercato/ui/backend/utils/optimisticLock";
|
|
29
|
+
import { surfaceRecordConflict } from "@open-mercato/ui/backend/conflicts";
|
|
28
30
|
import { collectCustomFieldValues } from "@open-mercato/ui/backend/utils/customFieldValues";
|
|
29
31
|
import { Button } from "@open-mercato/ui/primitives/button";
|
|
30
32
|
import { ColorPicker } from "@open-mercato/ui/primitives/color-picker";
|
|
@@ -203,6 +205,7 @@ function normalizeFormValues(value, t) {
|
|
|
203
205
|
primaryColor: readString(source.primaryColor).trim() || defaults.primaryColor,
|
|
204
206
|
secondaryColor: readString(source.secondaryColor).trim() || defaults.secondaryColor,
|
|
205
207
|
backgroundColor: readString(source.backgroundColor).trim() || defaults.backgroundColor,
|
|
208
|
+
gatewayProviderKey: readString(source.gatewayProviderKey).trim(),
|
|
206
209
|
gatewaySettings: isRecord(source.gatewaySettings) ? source.gatewaySettings : {},
|
|
207
210
|
customFieldsetCode: readString(source.customFieldsetCode).trim() || null,
|
|
208
211
|
collectCustomerDetails: readBoolean(source.collectCustomerDetails, true),
|
|
@@ -1419,11 +1422,20 @@ function LinkTemplateForm({ mode, recordId }) {
|
|
|
1419
1422
|
customFields: collectCustomFieldValues(values)
|
|
1420
1423
|
};
|
|
1421
1424
|
const endpoint = `/api/checkout/${mode === "link" ? "links" : "templates"}${recordId ? `/${encodeURIComponent(recordId)}` : ""}`;
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1425
|
+
let response;
|
|
1426
|
+
try {
|
|
1427
|
+
response = await withScopedApiRequestHeaders(
|
|
1428
|
+
recordId ? buildOptimisticLockHeader(readString(initialValues?.updatedAt) || null) : {},
|
|
1429
|
+
() => readApiResultOrThrow(endpoint, {
|
|
1430
|
+
method: recordId ? "PUT" : "POST",
|
|
1431
|
+
headers: { "Content-Type": "application/json" },
|
|
1432
|
+
body: JSON.stringify(payload)
|
|
1433
|
+
})
|
|
1434
|
+
);
|
|
1435
|
+
} catch (error) {
|
|
1436
|
+
if (surfaceRecordConflict(error, t)) return;
|
|
1437
|
+
throw error;
|
|
1438
|
+
}
|
|
1427
1439
|
const targetId = recordId ?? (typeof response?.id === "string" ? response.id : null);
|
|
1428
1440
|
const logoAttachmentId = readString(values.logoAttachmentId);
|
|
1429
1441
|
if (!recordId && targetId && logoAttachmentId && logoAttachmentId !== initialLogoAttachmentIdRef.current) {
|
|
@@ -1459,7 +1471,15 @@ function LinkTemplateForm({ mode, recordId }) {
|
|
|
1459
1471
|
)}&type=success` : `/backend/checkout/templates?flash=${encodeURIComponent(t("checkout.common.flash.saved"))}&type=success`;
|
|
1460
1472
|
},
|
|
1461
1473
|
onDelete: recordId ? async () => {
|
|
1462
|
-
|
|
1474
|
+
try {
|
|
1475
|
+
await withScopedApiRequestHeaders(
|
|
1476
|
+
buildOptimisticLockHeader(readString(initialValues?.updatedAt) || null),
|
|
1477
|
+
() => apiCallOrThrow(`/api/checkout/${mode === "link" ? "links" : "templates"}/${encodeURIComponent(recordId)}`, { method: "DELETE" })
|
|
1478
|
+
);
|
|
1479
|
+
} catch (error) {
|
|
1480
|
+
if (surfaceRecordConflict(error, t)) return;
|
|
1481
|
+
throw error;
|
|
1482
|
+
}
|
|
1463
1483
|
window.location.href = mode === "link" ? `/backend/checkout/pay-links?flash=${encodeURIComponent(t("checkout.common.flash.deleted"))}&type=success` : `/backend/checkout/templates?flash=${encodeURIComponent(t("checkout.common.flash.deleted"))}&type=success`;
|
|
1464
1484
|
} : void 0
|
|
1465
1485
|
},
|