@mercurjs/admin 2.0.1 → 2.1.0-canary.4
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-TA7QC32P.js → add-campaign-promotions-MTQ7OZDE.js} +3 -3
- package/dist/{adjust-inventory-W4H5F2JA.js → adjust-inventory-5KY3SJY4.js} +1 -1
- package/dist/{api-key-management-detail-LMKKDTRJ.js → api-key-management-detail-D7NH5LTC.js} +1 -1
- package/dist/{attribute-create-IRJTPQCF.js → attribute-create-SXEM4KJD.js} +1 -1
- package/dist/{attribute-detail-7FLCTP3I.js → attribute-detail-Y3GONKA7.js} +1 -1
- package/dist/{attribute-edit-6YNHG3QV.js → attribute-edit-NGJEWLXP.js} +1 -1
- package/dist/{attribute-list-C5NS26AD.js → attribute-list-VODH4R2I.js} +1 -1
- package/dist/{campaign-detail-E37P67AC.js → campaign-detail-EFU3O644.js} +5 -5
- package/dist/{categories-metadata-34L5C2TK.js → categories-metadata-53FPHDOQ.js} +1 -1
- package/dist/{category-detail-B23F726Q.js → category-detail-6BSTZK72.js} +3 -3
- package/dist/{category-products-2LKOHEWO.js → category-products-SEL2KF5R.js} +2 -2
- package/dist/{chunk-HS322YUO.js → chunk-2SNDWSS5.js} +1 -1
- package/dist/{chunk-UYKWOC5A.js → chunk-627NOMMX.js} +1 -1
- package/dist/{chunk-KERA6OZN.js → chunk-6O25AZDD.js} +1 -1
- package/dist/{chunk-RRAIAUBR.js → chunk-7U6RLIWB.js} +1 -1
- package/dist/{chunk-BBANQAF4.js → chunk-C4V5XT6K.js} +1 -1
- package/dist/{chunk-F7VTQIU7.js → chunk-CZSJ7E5Q.js} +1 -1
- package/dist/{chunk-A2TQNJZP.js → chunk-FNHNSA3H.js} +2 -1
- package/dist/{chunk-ZFEGVWHT.js → chunk-GZWI6ROZ.js} +38 -6
- package/dist/{chunk-QIZUNM6F.js → chunk-HV7ETS5U.js} +1 -1
- package/dist/{chunk-EVGVH6CU.js → chunk-JN3XBZHG.js} +1 -1
- package/dist/{chunk-6OTK5LAS.js → chunk-L5SYZUAC.js} +1 -1
- package/dist/{chunk-LW57KBYK.js → chunk-LVUJDBZC.js} +1 -1
- package/dist/{chunk-M3YP3NX4.js → chunk-OVPKR4G7.js} +9 -0
- package/dist/{chunk-RVAVU222.js → chunk-PUNC2TLV.js} +1 -1
- package/dist/{chunk-WSR2ZXAJ.js → chunk-R2UP4YIY.js} +1 -1
- package/dist/{chunk-ZMDE5HEV.js → chunk-RMMKSTB4.js} +32 -4
- package/dist/{chunk-MMTCBVUV.js → chunk-TKRQTEWN.js} +1 -1
- package/dist/{chunk-AVXOG7CE.js → chunk-VTH3LTDK.js} +1 -1
- package/dist/{chunk-G4LGZF5F.js → chunk-VWE3LQEJ.js} +1 -1
- package/dist/{chunk-GYKVLGU4.js → chunk-WYJSLRW5.js} +1 -1
- package/dist/{chunk-N7QGYSFB.js → chunk-XGCSSCLB.js} +1 -1
- package/dist/{chunk-UBS6VEGB.js → chunk-XJHXEWWX.js} +1 -1
- package/dist/{chunk-NRKVFULI.js → chunk-XVRT2TFF.js} +353 -116
- package/dist/{chunk-CMX37MSO.js → chunk-ZRWRLDAH.js} +1 -1
- package/dist/{collection-add-products-RHIQZ37R.js → collection-add-products-4QUC6CYD.js} +2 -2
- package/dist/{collection-detail-SJ4ZZLWY.js → collection-detail-YS424JMR.js} +3 -3
- package/dist/{collection-list-OFZGXVJA.js → collection-list-4LAFOABI.js} +2 -2
- package/dist/{collection-metadata-3CDRKSCP.js → collection-metadata-GA7WIUTG.js} +1 -1
- package/dist/{commission-rate-create-OOVFRTYM.js → commission-rate-create-NZY3GFV4.js} +3 -3
- package/dist/{commission-rate-detail-5XFV6XH2.js → commission-rate-detail-Z3P43MU7.js} +1 -1
- package/dist/{commission-rate-edit-6B4P2GOV.js → commission-rate-edit-EOO7YGWQ.js} +3 -3
- package/dist/{customer-detail-Q4K56AZ4.js → customer-detail-EHMESZAY.js} +1 -1
- package/dist/{customer-group-detail-NSEFUNCF.js → customer-group-detail-CXVPY32U.js} +1 -1
- package/dist/{customer-group-list-GCEKCBUE.js → customer-group-list-L474CRAE.js} +1 -1
- package/dist/{customer-group-metadata-LXJK3IMS.js → customer-group-metadata-YO3J3DWX.js} +1 -1
- package/dist/{customer-metadata-ZZSCYFHY.js → customer-metadata-T4Y3LP5Y.js} +1 -1
- package/dist/{customers-add-customer-group-TIBDJPYF.js → customers-add-customer-group-J7EZP5OJ.js} +1 -1
- package/dist/{edit-inventory-item-Y3CIG6L5.js → edit-inventory-item-DBMS75NM.js} +1 -1
- package/dist/{edit-inventory-item-attributes-CZNIVWXY.js → edit-inventory-item-attributes-655BP5CZ.js} +1 -1
- package/dist/{edit-rules-G7GRUQL6.js → edit-rules-JNV3HBLD.js} +1 -1
- package/dist/index.js +157 -156
- package/dist/{inventory-create-MFCGCJFB.js → inventory-create-ZHD7BUCH.js} +1 -1
- package/dist/{inventory-detail-6V43ZQDK.js → inventory-detail-TQSQQAOS.js} +1 -1
- package/dist/{inventory-metadata-PFXMJTSB.js → inventory-metadata-YHRVDL3T.js} +1 -1
- package/dist/{inventory-stock-B4FYZAQB.js → inventory-stock-BF2G57RR.js} +1 -1
- package/dist/{location-detail-NOUHQA4M.js → location-detail-OMR5VQNR.js} +1 -1
- package/dist/{location-fulfillment-providers-A27CQMJN.js → location-fulfillment-providers-LRVFTKYQ.js} +2 -2
- package/dist/{location-list-AVCPUKBH.js → location-list-TJWKHGHC.js} +1 -1
- package/dist/{location-service-zone-shipping-option-create-DREWJ7SR.js → location-service-zone-shipping-option-create-TE7I3OGE.js} +1 -1
- package/dist/{login-QCYKZCZP.js → login-2UEH2J2Z.js} +1 -1
- package/dist/{marketplace-detail-CYMZCRWM.js → marketplace-detail-RHJL3RKS.js} +1 -1
- package/dist/{marketplace-metadata-LYNL3W6L.js → marketplace-metadata-IPXXRTER.js} +1 -1
- package/dist/{order-create-claim-HWZI4OEK.js → order-create-claim-KGBBZAJ4.js} +1 -1
- package/dist/{order-create-edit-VIIAC2AA.js → order-create-edit-5IHO5BMD.js} +1 -1
- package/dist/{order-create-exchange-KRGBFSCC.js → order-create-exchange-FRKAMGEB.js} +1 -1
- package/dist/{order-create-fulfillment-K4LB6U6E.js → order-create-fulfillment-ZXPUXY2M.js} +1 -1
- package/dist/{order-create-refund-2OCPOAJS.js → order-create-refund-SBU4PTFE.js} +1 -1
- package/dist/{order-create-shipment-BD3DKSJX.js → order-create-shipment-BUDXW54A.js} +1 -1
- package/dist/{order-detail-GETGE7YJ.js → order-detail-J7SR4MOZ.js} +2 -2
- package/dist/{order-edit-billing-address-3GN3QU4Y.js → order-edit-billing-address-LITRQ5LJ.js} +2 -2
- package/dist/{order-edit-email-D6KSNSY4.js → order-edit-email-TACZI5EX.js} +1 -1
- package/dist/{order-edit-shipping-address-Z7RP4UBB.js → order-edit-shipping-address-FPTJB5L5.js} +1 -1
- package/dist/{order-list-727TI7BS.js → order-list-D44NOK54.js} +2 -2
- package/dist/{order-metadata-UCAS6KEK.js → order-metadata-6JOL5X6I.js} +1 -1
- package/dist/{order-receive-return-YZGUVELT.js → order-receive-return-5YMKBTQ3.js} +1 -1
- package/dist/{order-request-transfer-DBXAIXEG.js → order-request-transfer-LSANIPZ5.js} +1 -1
- package/dist/pages/index.d.ts +165 -165
- package/dist/pages/index.js +23 -23
- package/dist/{price-list-create-SJBCYSRX.js → price-list-create-P5JB34NQ.js} +3 -3
- package/dist/{price-list-detail-VA4F6JQJ.js → price-list-detail-Y5GY2XNE.js} +3 -3
- package/dist/{price-list-prices-add-BLORGT25.js → price-list-prices-add-3PIDYNA4.js} +3 -3
- package/dist/{price-list-prices-edit-7WHKIZHY.js → price-list-prices-edit-DCESLO3A.js} +1 -1
- package/dist/{product-create-KEJB3U44.js → product-create-DRZFQDRY.js} +4 -4
- package/dist/{product-create-variant-YZODW67L.js → product-create-variant-ZB3IHAFV.js} +1 -1
- package/dist/{product-detail-Y24FRUWA.js → product-detail-57X454TL.js} +1 -1
- package/dist/{product-export-4G44DDXA.js → product-export-I3PPG7KC.js} +2 -2
- package/dist/{product-import-TIPIYEJJ.js → product-import-MNEGYIKE.js} +1 -1
- package/dist/{product-list-BLFQWHIA.js → product-list-UZQDS36T.js} +3 -3
- package/dist/{product-media-IKMGI2QA.js → product-media-X6GYGJDU.js} +2 -2
- package/dist/{product-metadata-SKNZWKWO.js → product-metadata-6P42YQNI.js} +1 -1
- package/dist/{product-stock-WIPVYJUH.js → product-stock-P2QSUR4K.js} +1 -1
- package/dist/{product-tag-create-3QK7MKMI.js → product-tag-create-QKHJET6O.js} +1 -1
- package/dist/{product-tag-detail-LSMLNJW6.js → product-tag-detail-NQGZEEFG.js} +3 -3
- package/dist/{product-tag-edit-NHRQ55DX.js → product-tag-edit-TC3UMIAJ.js} +1 -1
- package/dist/{product-tag-list-UHBM6KBT.js → product-tag-list-3DLJ3G7X.js} +2 -2
- package/dist/{product-tag-metadata-DGH7UF4L.js → product-tag-metadata-DKYMVBXL.js} +1 -1
- package/dist/{product-type-detail-GNRN4KTB.js → product-type-detail-VJJITHJS.js} +3 -3
- package/dist/{product-type-metadata-NFMNORIB.js → product-type-metadata-I4RC764V.js} +1 -1
- package/dist/{product-variant-detail-TGSUSOEB.js → product-variant-detail-Z3BZJ6EJ.js} +1 -1
- package/dist/{product-variant-edit-6OJRQWC6.js → product-variant-edit-P3NBX6LJ.js} +1 -1
- package/dist/{product-variant-metadata-4MWJAXYI.js → product-variant-metadata-HMBGDFCO.js} +1 -1
- package/dist/{promotion-create-CPRWDBDW.js → promotion-create-JMTQ5U53.js} +1 -1
- package/dist/{promotion-detail-KGIX6TA2.js → promotion-detail-CWBF3HPU.js} +4 -4
- package/dist/{promotion-list-U7PXQLZT.js → promotion-list-JVR5ZF26.js} +4 -4
- package/dist/{refund-reason-create-KYM2BCJ2.js → refund-reason-create-H6BJDVQQ.js} +1 -1
- package/dist/{refund-reason-edit-JIG7FL7D.js → refund-reason-edit-JXP5LXF6.js} +1 -1
- package/dist/{refund-reason-list-IO4INIKF.js → refund-reason-list-O26REP5X.js} +1 -1
- package/dist/region-create-NI7QPOS5.js +659 -0
- package/dist/{region-edit-75ZVOJ3U.js → region-edit-AGC3N4RU.js} +5 -1
- package/dist/{region-metadata-NJUXGJJZ.js → region-metadata-JUTPPKPR.js} +1 -1
- package/dist/{reservation-detail-TKILHE26.js → reservation-detail-4EJK3HEF.js} +1 -1
- package/dist/{reservation-metadata-V7BLDGSJ.js → reservation-metadata-VOJDR77H.js} +1 -1
- package/dist/{reset-password-SXAC55FW.js → reset-password-FCS4752B.js} +1 -1
- package/dist/{sales-channel-add-products-27YLUPZP.js → sales-channel-add-products-MOA6UWOB.js} +2 -2
- package/dist/{sales-channel-detail-EW2YN7VL.js → sales-channel-detail-RZES4ARA.js} +3 -3
- package/dist/{sales-channel-list-JOSLAWUO.js → sales-channel-list-7VVGSGC5.js} +1 -1
- package/dist/{sales-channel-metadata-YABMFKT3.js → sales-channel-metadata-U4JWJDUK.js} +1 -1
- package/dist/{shipping-option-type-create-KXRPACLG.js → shipping-option-type-create-3S6VXMCK.js} +1 -1
- package/dist/{shipping-option-type-detail-KHX2BRFP.js → shipping-option-type-detail-6QINYVWX.js} +1 -1
- package/dist/{shipping-option-type-edit-N3L4TPUK.js → shipping-option-type-edit-2JFDG4D5.js} +1 -1
- package/dist/{shipping-option-type-list-5A676BZT.js → shipping-option-type-list-FGCS5LGL.js} +1 -1
- package/dist/{shipping-profile-metadata-WDM4Y653.js → shipping-profile-metadata-NBCZ3JVM.js} +1 -1
- package/dist/{store-address-edit-7BBZSSIP.js → store-address-edit-ATQ6TYQO.js} +1 -1
- package/dist/{store-closure-edit-CN5JR4F5.js → store-closure-edit-5KFXHH6R.js} +1 -1
- package/dist/{store-create-FUYTHJL5.js → store-create-3S5LJOUB.js} +1 -1
- package/dist/{store-details-65JQK3M3.js → store-details-UB3QR3RN.js} +12 -3
- package/dist/{store-edit-IQAVLFU5.js → store-edit-O4D6F4SA.js} +3 -3
- package/dist/{store-list-DWFAFCKV.js → store-list-35G4TP5I.js} +3 -3
- package/dist/{store-member-invite-GAWCXSWL.js → store-member-invite-2SEYT7EL.js} +1 -1
- package/dist/{store-payment-details-edit-Z3GLY4TO.js → store-payment-details-edit-DAULPMDU.js} +1 -1
- package/dist/{store-professional-details-edit-7KWQOK46.js → store-professional-details-edit-CVQW4R4J.js} +1 -1
- package/dist/{tax-region-create-6VHCIPP7.js → tax-region-create-Q6TXHTRE.js} +2 -2
- package/dist/{tax-region-detail-AZVNX4QN.js → tax-region-detail-BSLXK42P.js} +1 -1
- package/dist/{tax-region-edit-7A6MZBXC.js → tax-region-edit-3FNGCVR2.js} +1 -1
- package/dist/{tax-region-metadata-UZYHKPTE.js → tax-region-metadata-WSHLDCN6.js} +1 -1
- package/dist/{tax-region-province-detail-7ERAOT3Y.js → tax-region-province-detail-4RV3L5QO.js} +1 -1
- package/dist/{tax-region-tax-override-create-TIPPPVTR.js → tax-region-tax-override-create-HEY53Y3G.js} +3 -3
- package/dist/{tax-region-tax-override-edit-HDQ4NS5I.js → tax-region-tax-override-edit-6KET7TJP.js} +3 -3
- package/dist/{user-metadata-JGCXU4OO.js → user-metadata-JNQQLJAM.js} +1 -1
- package/package.json +5 -5
- package/dist/region-create-BFA7ATKB.js +0 -508
|
@@ -1,508 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useCountries,
|
|
3
|
-
useCountryTableColumns,
|
|
4
|
-
useCountryTableQuery
|
|
5
|
-
} from "./chunk-TUJIAA5O.js";
|
|
6
|
-
import {
|
|
7
|
-
formatProvider
|
|
8
|
-
} from "./chunk-VW56KWO2.js";
|
|
9
|
-
import {
|
|
10
|
-
countries
|
|
11
|
-
} from "./chunk-JRTZWK77.js";
|
|
12
|
-
import "./chunk-FQERBIVS.js";
|
|
13
|
-
import {
|
|
14
|
-
_DataTable,
|
|
15
|
-
useDataTable
|
|
16
|
-
} from "./chunk-ULJ3OMWU.js";
|
|
17
|
-
import "./chunk-YBZWO4ZV.js";
|
|
18
|
-
import "./chunk-KAZ5BYTQ.js";
|
|
19
|
-
import "./chunk-3EF54XFY.js";
|
|
20
|
-
import {
|
|
21
|
-
currencies
|
|
22
|
-
} from "./chunk-IQPN4PZJ.js";
|
|
23
|
-
import {
|
|
24
|
-
useComboboxData
|
|
25
|
-
} from "./chunk-AEFDAU3Y.js";
|
|
26
|
-
import {
|
|
27
|
-
Combobox
|
|
28
|
-
} from "./chunk-AW77UWCZ.js";
|
|
29
|
-
import "./chunk-TKGWSUEI.js";
|
|
30
|
-
import {
|
|
31
|
-
KeyboundForm
|
|
32
|
-
} from "./chunk-U2ZFCAPX.js";
|
|
33
|
-
import "./chunk-INNFZYX2.js";
|
|
34
|
-
import {
|
|
35
|
-
useDocumentDirection
|
|
36
|
-
} from "./chunk-Y7QKP6QU.js";
|
|
37
|
-
import "./chunk-KBYZLKI4.js";
|
|
38
|
-
import "./chunk-YWWUOGJA.js";
|
|
39
|
-
import "./chunk-THHRRYRS.js";
|
|
40
|
-
import "./chunk-UZWFZMOX.js";
|
|
41
|
-
import "./chunk-XQNVC4Q7.js";
|
|
42
|
-
import {
|
|
43
|
-
RouteFocusModal,
|
|
44
|
-
StackedFocusModal,
|
|
45
|
-
useRouteModal,
|
|
46
|
-
useStackedModal
|
|
47
|
-
} from "./chunk-OV7R2AH5.js";
|
|
48
|
-
import {
|
|
49
|
-
Form
|
|
50
|
-
} from "./chunk-3QSRE5LS.js";
|
|
51
|
-
import {
|
|
52
|
-
useCreateRegion
|
|
53
|
-
} from "./chunk-W5UPPL3W.js";
|
|
54
|
-
import {
|
|
55
|
-
useStore
|
|
56
|
-
} from "./chunk-LC6TM5OT.js";
|
|
57
|
-
import "./chunk-7SJC6BWZ.js";
|
|
58
|
-
import "./chunk-RHKRREUU.js";
|
|
59
|
-
import "./chunk-ZA2KFUFR.js";
|
|
60
|
-
import {
|
|
61
|
-
sdk
|
|
62
|
-
} from "./chunk-RIN4CBRB.js";
|
|
63
|
-
import "./chunk-NBMM2TZK.js";
|
|
64
|
-
|
|
65
|
-
// src/pages/regions/region-create/components/create-region-form/create-region-form.tsx
|
|
66
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
67
|
-
import { XMarkMini } from "@medusajs/icons";
|
|
68
|
-
import {
|
|
69
|
-
Button,
|
|
70
|
-
Checkbox,
|
|
71
|
-
Heading,
|
|
72
|
-
Input,
|
|
73
|
-
Select,
|
|
74
|
-
Switch,
|
|
75
|
-
Text,
|
|
76
|
-
clx,
|
|
77
|
-
toast
|
|
78
|
-
} from "@medusajs/ui";
|
|
79
|
-
import { createColumnHelper } from "@tanstack/react-table";
|
|
80
|
-
import { useMemo, useState } from "react";
|
|
81
|
-
import { useForm, useWatch } from "react-hook-form";
|
|
82
|
-
import { useTranslation } from "react-i18next";
|
|
83
|
-
import * as zod from "zod";
|
|
84
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
85
|
-
var CreateRegionSchema = zod.object({
|
|
86
|
-
name: zod.string().min(1),
|
|
87
|
-
currency_code: zod.string().min(2, "Select a currency"),
|
|
88
|
-
automatic_taxes: zod.boolean(),
|
|
89
|
-
is_tax_inclusive: zod.boolean(),
|
|
90
|
-
countries: zod.array(zod.object({ code: zod.string(), name: zod.string() })),
|
|
91
|
-
payment_providers: zod.array(zod.string()).min(1)
|
|
92
|
-
});
|
|
93
|
-
var PREFIX = "cr";
|
|
94
|
-
var PAGE_SIZE = 50;
|
|
95
|
-
var STACKED_MODAL_ID = "countries-modal";
|
|
96
|
-
var CreateRegionForm = ({ currencies: currencies2 }) => {
|
|
97
|
-
const { setIsOpen } = useStackedModal();
|
|
98
|
-
const [rowSelection, setRowSelection] = useState({});
|
|
99
|
-
const { handleSuccess } = useRouteModal();
|
|
100
|
-
const direction = useDocumentDirection();
|
|
101
|
-
const form = useForm({
|
|
102
|
-
defaultValues: {
|
|
103
|
-
name: "",
|
|
104
|
-
currency_code: "",
|
|
105
|
-
automatic_taxes: true,
|
|
106
|
-
is_tax_inclusive: false,
|
|
107
|
-
countries: [],
|
|
108
|
-
payment_providers: []
|
|
109
|
-
},
|
|
110
|
-
resolver: zodResolver(CreateRegionSchema)
|
|
111
|
-
});
|
|
112
|
-
const selectedCountries = useWatch({
|
|
113
|
-
control: form.control,
|
|
114
|
-
name: "countries",
|
|
115
|
-
defaultValue: []
|
|
116
|
-
});
|
|
117
|
-
const { t } = useTranslation();
|
|
118
|
-
const { mutateAsync: createRegion, isPending: isPendingRegion } = useCreateRegion();
|
|
119
|
-
const handleSubmit = form.handleSubmit(async (values) => {
|
|
120
|
-
await createRegion(
|
|
121
|
-
{
|
|
122
|
-
name: values.name,
|
|
123
|
-
countries: values.countries.map((c) => c.code),
|
|
124
|
-
currency_code: values.currency_code,
|
|
125
|
-
payment_providers: values.payment_providers,
|
|
126
|
-
automatic_taxes: values.automatic_taxes,
|
|
127
|
-
is_tax_inclusive: values.is_tax_inclusive
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
onSuccess: ({ region }) => {
|
|
131
|
-
toast.success(t("regions.toast.create"));
|
|
132
|
-
handleSuccess(`../${region.id}`);
|
|
133
|
-
},
|
|
134
|
-
onError: (e) => {
|
|
135
|
-
toast.error(e.message);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
);
|
|
139
|
-
});
|
|
140
|
-
const { searchParams, raw } = useCountryTableQuery({
|
|
141
|
-
pageSize: PAGE_SIZE,
|
|
142
|
-
prefix: PREFIX
|
|
143
|
-
});
|
|
144
|
-
const { countries: countries2, count } = useCountries({
|
|
145
|
-
countries: countries.map((c, i) => ({
|
|
146
|
-
display_name: c.display_name,
|
|
147
|
-
name: c.name,
|
|
148
|
-
id: i,
|
|
149
|
-
iso_2: c.iso_2,
|
|
150
|
-
iso_3: c.iso_3,
|
|
151
|
-
num_code: c.num_code,
|
|
152
|
-
region_id: null,
|
|
153
|
-
region: {}
|
|
154
|
-
})),
|
|
155
|
-
...searchParams
|
|
156
|
-
});
|
|
157
|
-
const columns = useColumns();
|
|
158
|
-
const { table } = useDataTable({
|
|
159
|
-
data: countries2 || [],
|
|
160
|
-
columns,
|
|
161
|
-
count,
|
|
162
|
-
enablePagination: true,
|
|
163
|
-
enableRowSelection: true,
|
|
164
|
-
rowSelection: {
|
|
165
|
-
state: rowSelection,
|
|
166
|
-
updater: setRowSelection
|
|
167
|
-
},
|
|
168
|
-
getRowId: (row) => row.iso_2,
|
|
169
|
-
pageSize: PAGE_SIZE,
|
|
170
|
-
prefix: PREFIX
|
|
171
|
-
});
|
|
172
|
-
const saveCountries = () => {
|
|
173
|
-
const selected = Object.keys(rowSelection).filter(
|
|
174
|
-
(key) => rowSelection[key]
|
|
175
|
-
);
|
|
176
|
-
form.setValue(
|
|
177
|
-
"countries",
|
|
178
|
-
selected.map((key) => ({
|
|
179
|
-
code: key,
|
|
180
|
-
name: countries.find((c) => c.iso_2 === key).display_name
|
|
181
|
-
})),
|
|
182
|
-
{ shouldDirty: true, shouldTouch: true }
|
|
183
|
-
);
|
|
184
|
-
setIsOpen(STACKED_MODAL_ID, false);
|
|
185
|
-
};
|
|
186
|
-
const removeCountry = (code) => {
|
|
187
|
-
const update = selectedCountries.filter((c) => c.code !== code);
|
|
188
|
-
const ids = update.map((c) => c.code).reduce((acc, c) => {
|
|
189
|
-
acc[c] = true;
|
|
190
|
-
return acc;
|
|
191
|
-
}, {});
|
|
192
|
-
form.setValue("countries", update, { shouldDirty: true, shouldTouch: true });
|
|
193
|
-
setRowSelection(ids);
|
|
194
|
-
};
|
|
195
|
-
const clearCountries = () => {
|
|
196
|
-
form.setValue("countries", [], { shouldDirty: true, shouldTouch: true });
|
|
197
|
-
setRowSelection({});
|
|
198
|
-
};
|
|
199
|
-
const comboboxProviders = useComboboxData({
|
|
200
|
-
queryFn: (params) => sdk.admin.payment.listPaymentProviders({ ...params, is_enabled: true }),
|
|
201
|
-
queryKey: ["payment_providers"],
|
|
202
|
-
getOptions: (data) => data.payment_providers.map((pp) => ({
|
|
203
|
-
label: formatProvider(pp.id),
|
|
204
|
-
value: pp.id
|
|
205
|
-
}))
|
|
206
|
-
});
|
|
207
|
-
return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, "data-testid": "region-create-form", children: /* @__PURE__ */ jsxs(
|
|
208
|
-
KeyboundForm,
|
|
209
|
-
{
|
|
210
|
-
className: "flex h-full flex-col overflow-hidden",
|
|
211
|
-
onSubmit: handleSubmit,
|
|
212
|
-
children: [
|
|
213
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Header, { "data-testid": "region-create-form-header" }),
|
|
214
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex overflow-hidden", "data-testid": "region-create-form-body", children: /* @__PURE__ */ jsx(
|
|
215
|
-
"div",
|
|
216
|
-
{
|
|
217
|
-
className: clx(
|
|
218
|
-
"flex h-full w-full flex-col items-center overflow-y-auto p-16"
|
|
219
|
-
),
|
|
220
|
-
id: "form-section",
|
|
221
|
-
children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children: [
|
|
222
|
-
/* @__PURE__ */ jsxs("div", { "data-testid": "region-create-form-header-section", children: [
|
|
223
|
-
/* @__PURE__ */ jsx(Heading, { "data-testid": "region-create-form-heading", children: t("regions.createRegion") }),
|
|
224
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", "data-testid": "region-create-form-hint", children: t("regions.createRegionHint") })
|
|
225
|
-
] }),
|
|
226
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-4", children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: [
|
|
227
|
-
/* @__PURE__ */ jsx(
|
|
228
|
-
Form.Field,
|
|
229
|
-
{
|
|
230
|
-
control: form.control,
|
|
231
|
-
name: "name",
|
|
232
|
-
render: ({ field }) => {
|
|
233
|
-
return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "region-create-form-name-item", children: [
|
|
234
|
-
/* @__PURE__ */ jsx(Form.Label, { "data-testid": "region-create-form-name-label", children: t("fields.name") }),
|
|
235
|
-
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "region-create-form-name-control", children: /* @__PURE__ */ jsx(Input, { ...field, "data-testid": "region-create-form-name-input" }) }),
|
|
236
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "region-create-form-name-error" })
|
|
237
|
-
] });
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
),
|
|
241
|
-
/* @__PURE__ */ jsx(
|
|
242
|
-
Form.Field,
|
|
243
|
-
{
|
|
244
|
-
control: form.control,
|
|
245
|
-
name: "currency_code",
|
|
246
|
-
render: ({ field: { onChange, ref, ...field } }) => {
|
|
247
|
-
return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "region-create-form-currency-item", children: [
|
|
248
|
-
/* @__PURE__ */ jsx(Form.Label, { "data-testid": "region-create-form-currency-label", children: t("fields.currency") }),
|
|
249
|
-
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "region-create-form-currency-control", children: /* @__PURE__ */ jsxs(
|
|
250
|
-
Select,
|
|
251
|
-
{
|
|
252
|
-
dir: direction,
|
|
253
|
-
...field,
|
|
254
|
-
onValueChange: onChange,
|
|
255
|
-
"data-testid": "region-create-form-currency-select",
|
|
256
|
-
children: [
|
|
257
|
-
/* @__PURE__ */ jsx(Select.Trigger, { ref, "data-testid": "region-create-form-currency-select-trigger", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
258
|
-
/* @__PURE__ */ jsx(Select.Content, { "data-testid": "region-create-form-currency-select-content", children: currencies2.map((currency) => /* @__PURE__ */ jsx(
|
|
259
|
-
Select.Item,
|
|
260
|
-
{
|
|
261
|
-
value: currency.code,
|
|
262
|
-
"data-testid": `region-create-form-currency-select-option-${currency.code}`,
|
|
263
|
-
children: currency.name
|
|
264
|
-
},
|
|
265
|
-
currency.code
|
|
266
|
-
)) })
|
|
267
|
-
]
|
|
268
|
-
}
|
|
269
|
-
) }),
|
|
270
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "region-create-form-currency-error" })
|
|
271
|
-
] });
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
)
|
|
275
|
-
] }) }),
|
|
276
|
-
/* @__PURE__ */ jsx(
|
|
277
|
-
Form.Field,
|
|
278
|
-
{
|
|
279
|
-
control: form.control,
|
|
280
|
-
name: "automatic_taxes",
|
|
281
|
-
render: ({ field: { value, onChange, ...field } }) => {
|
|
282
|
-
return /* @__PURE__ */ jsx(Form.Item, { "data-testid": "region-create-form-automatic-taxes-item", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
283
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between", children: [
|
|
284
|
-
/* @__PURE__ */ jsx(Form.Label, { "data-testid": "region-create-form-automatic-taxes-label", children: t("fields.automaticTaxes") }),
|
|
285
|
-
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "region-create-form-automatic-taxes-control", children: /* @__PURE__ */ jsx(
|
|
286
|
-
Switch,
|
|
287
|
-
{
|
|
288
|
-
dir: "ltr",
|
|
289
|
-
className: "rtl:rotate-180",
|
|
290
|
-
...field,
|
|
291
|
-
checked: value,
|
|
292
|
-
onCheckedChange: onChange,
|
|
293
|
-
"data-testid": "region-create-form-automatic-taxes-switch"
|
|
294
|
-
}
|
|
295
|
-
) })
|
|
296
|
-
] }),
|
|
297
|
-
/* @__PURE__ */ jsx(Form.Hint, { "data-testid": "region-create-form-automatic-taxes-hint", children: t("regions.automaticTaxesHint") }),
|
|
298
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "region-create-form-automatic-taxes-error" })
|
|
299
|
-
] }) });
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
),
|
|
303
|
-
/* @__PURE__ */ jsx(
|
|
304
|
-
Form.Field,
|
|
305
|
-
{
|
|
306
|
-
control: form.control,
|
|
307
|
-
name: "is_tax_inclusive",
|
|
308
|
-
render: ({ field: { value, onChange, ...field } }) => {
|
|
309
|
-
return /* @__PURE__ */ jsx(Form.Item, { "data-testid": "region-create-form-tax-inclusive-item", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
310
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between", children: [
|
|
311
|
-
/* @__PURE__ */ jsx(Form.Label, { "data-testid": "region-create-form-tax-inclusive-label", children: t("fields.taxInclusivePricing") }),
|
|
312
|
-
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "region-create-form-tax-inclusive-control", children: /* @__PURE__ */ jsx(
|
|
313
|
-
Switch,
|
|
314
|
-
{
|
|
315
|
-
className: "rtl:rotate-180",
|
|
316
|
-
dir: "ltr",
|
|
317
|
-
...field,
|
|
318
|
-
checked: value,
|
|
319
|
-
onCheckedChange: onChange,
|
|
320
|
-
"data-testid": "region-create-form-tax-inclusive-switch"
|
|
321
|
-
}
|
|
322
|
-
) })
|
|
323
|
-
] }),
|
|
324
|
-
/* @__PURE__ */ jsx(Form.Hint, { "data-testid": "region-create-form-tax-inclusive-hint", children: t("regions.taxInclusiveHint") }),
|
|
325
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "region-create-form-tax-inclusive-error" })
|
|
326
|
-
] }) });
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
),
|
|
330
|
-
/* @__PURE__ */ jsx("div", { className: "bg-ui-border-base h-px w-full" }),
|
|
331
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", "data-testid": "region-create-form-countries-section", children: [
|
|
332
|
-
/* @__PURE__ */ jsxs("div", { "data-testid": "region-create-form-countries-header", children: [
|
|
333
|
-
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", "data-testid": "region-create-form-countries-label", children: t("fields.countries") }),
|
|
334
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", "data-testid": "region-create-form-countries-hint", children: t("regions.countriesHint") })
|
|
335
|
-
] }),
|
|
336
|
-
selectedCountries.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", "data-testid": "region-create-form-countries-selected", children: [
|
|
337
|
-
selectedCountries.map((country) => /* @__PURE__ */ jsx(
|
|
338
|
-
CountryTag,
|
|
339
|
-
{
|
|
340
|
-
country,
|
|
341
|
-
onRemove: removeCountry
|
|
342
|
-
},
|
|
343
|
-
country.code
|
|
344
|
-
)),
|
|
345
|
-
/* @__PURE__ */ jsx(
|
|
346
|
-
Button,
|
|
347
|
-
{
|
|
348
|
-
variant: "transparent",
|
|
349
|
-
size: "small",
|
|
350
|
-
className: "text-ui-fg-muted hover:text-ui-fg-subtle",
|
|
351
|
-
onClick: clearCountries,
|
|
352
|
-
"data-testid": "region-create-form-countries-clear-all-button",
|
|
353
|
-
children: t("actions.clearAll")
|
|
354
|
-
}
|
|
355
|
-
)
|
|
356
|
-
] }),
|
|
357
|
-
/* @__PURE__ */ jsxs(StackedFocusModal, { id: STACKED_MODAL_ID, "data-testid": "region-create-form-countries-modal", children: [
|
|
358
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ jsx(StackedFocusModal.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", "data-testid": "region-create-form-countries-add-button", children: t("regions.addCountries") }) }) }),
|
|
359
|
-
/* @__PURE__ */ jsx(StackedFocusModal.Content, { "data-testid": "region-create-form-countries-modal-content", children: /* @__PURE__ */ jsxs("div", { className: "flex size-full flex-col overflow-hidden", children: [
|
|
360
|
-
/* @__PURE__ */ jsx(StackedFocusModal.Header, { "data-testid": "region-create-form-countries-modal-header", children: /* @__PURE__ */ jsx(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: t("regions.addCountries") }) }) }),
|
|
361
|
-
/* @__PURE__ */ jsx(StackedFocusModal.Body, { className: "overflow-hidden", "data-testid": "region-create-form-countries-modal-body", children: /* @__PURE__ */ jsx(
|
|
362
|
-
_DataTable,
|
|
363
|
-
{
|
|
364
|
-
table,
|
|
365
|
-
columns,
|
|
366
|
-
count,
|
|
367
|
-
pageSize: PAGE_SIZE,
|
|
368
|
-
orderBy: [
|
|
369
|
-
{ key: "display_name", label: t("fields.name") },
|
|
370
|
-
{ key: "iso_2", label: t("fields.code") }
|
|
371
|
-
],
|
|
372
|
-
pagination: true,
|
|
373
|
-
search: "autofocus",
|
|
374
|
-
layout: "fill",
|
|
375
|
-
queryObject: raw,
|
|
376
|
-
prefix: PREFIX,
|
|
377
|
-
"data-testid": "region-create-form-countries-modal-table"
|
|
378
|
-
}
|
|
379
|
-
) }),
|
|
380
|
-
/* @__PURE__ */ jsx(StackedFocusModal.Footer, { "data-testid": "region-create-form-countries-modal-footer", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
381
|
-
/* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", "data-testid": "region-create-form-countries-modal-cancel-button", children: t("actions.cancel") }) }),
|
|
382
|
-
/* @__PURE__ */ jsx(
|
|
383
|
-
Button,
|
|
384
|
-
{
|
|
385
|
-
size: "small",
|
|
386
|
-
type: "button",
|
|
387
|
-
onClick: saveCountries,
|
|
388
|
-
"data-testid": "region-create-form-countries-modal-save-button",
|
|
389
|
-
children: t("actions.save")
|
|
390
|
-
}
|
|
391
|
-
)
|
|
392
|
-
] }) })
|
|
393
|
-
] }) })
|
|
394
|
-
] })
|
|
395
|
-
] }),
|
|
396
|
-
/* @__PURE__ */ jsx("div", { className: "bg-ui-border-base h-px w-full" }),
|
|
397
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", "data-testid": "region-create-form-payment-providers-section", children: [
|
|
398
|
-
/* @__PURE__ */ jsxs("div", { "data-testid": "region-create-form-payment-providers-header", children: [
|
|
399
|
-
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", weight: "plus", "data-testid": "region-create-form-payment-providers-label", children: t("fields.providers") }),
|
|
400
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", "data-testid": "region-create-form-payment-providers-hint", children: t("regions.providersHint") })
|
|
401
|
-
] }),
|
|
402
|
-
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-2", children: /* @__PURE__ */ jsx(
|
|
403
|
-
Form.Field,
|
|
404
|
-
{
|
|
405
|
-
control: form.control,
|
|
406
|
-
name: "payment_providers",
|
|
407
|
-
render: ({ field }) => {
|
|
408
|
-
return /* @__PURE__ */ jsxs(Form.Item, { "data-testid": "region-create-form-payment-providers-item", children: [
|
|
409
|
-
/* @__PURE__ */ jsx(Form.Label, { "data-testid": "region-create-form-payment-providers-item-label", children: t("fields.paymentProviders") }),
|
|
410
|
-
/* @__PURE__ */ jsx(Form.Control, { "data-testid": "region-create-form-payment-providers-item-control", children: /* @__PURE__ */ jsx(
|
|
411
|
-
Combobox,
|
|
412
|
-
{
|
|
413
|
-
forceHideInput: true,
|
|
414
|
-
options: comboboxProviders.options,
|
|
415
|
-
fetchNextPage: comboboxProviders.fetchNextPage,
|
|
416
|
-
...field,
|
|
417
|
-
"data-testid": "region-create-form-payment-providers-combobox"
|
|
418
|
-
}
|
|
419
|
-
) }),
|
|
420
|
-
/* @__PURE__ */ jsx(Form.ErrorMessage, { "data-testid": "region-create-form-payment-providers-item-error" })
|
|
421
|
-
] });
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
) })
|
|
425
|
-
] })
|
|
426
|
-
] })
|
|
427
|
-
}
|
|
428
|
-
) }),
|
|
429
|
-
/* @__PURE__ */ jsxs(RouteFocusModal.Footer, { "data-testid": "region-create-form-footer", children: [
|
|
430
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", "data-testid": "region-create-form-cancel-button", children: t("actions.cancel") }) }),
|
|
431
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPendingRegion, "data-testid": "region-create-form-save-button", children: t("actions.save") })
|
|
432
|
-
] })
|
|
433
|
-
]
|
|
434
|
-
}
|
|
435
|
-
) });
|
|
436
|
-
};
|
|
437
|
-
var columnHelper = createColumnHelper();
|
|
438
|
-
var useColumns = () => {
|
|
439
|
-
const base = useCountryTableColumns();
|
|
440
|
-
return useMemo(
|
|
441
|
-
() => [
|
|
442
|
-
columnHelper.display({
|
|
443
|
-
id: "select",
|
|
444
|
-
header: ({ table }) => {
|
|
445
|
-
return /* @__PURE__ */ jsx(
|
|
446
|
-
Checkbox,
|
|
447
|
-
{
|
|
448
|
-
checked: table.getIsSomePageRowsSelected() ? "indeterminate" : table.getIsAllPageRowsSelected(),
|
|
449
|
-
onCheckedChange: (value) => table.toggleAllPageRowsSelected(!!value),
|
|
450
|
-
"data-testid": "region-create-form-countries-modal-select-all-checkbox"
|
|
451
|
-
}
|
|
452
|
-
);
|
|
453
|
-
},
|
|
454
|
-
cell: ({ row }) => {
|
|
455
|
-
const isPreselected = !row.getCanSelect();
|
|
456
|
-
return /* @__PURE__ */ jsx(
|
|
457
|
-
Checkbox,
|
|
458
|
-
{
|
|
459
|
-
checked: row.getIsSelected() || isPreselected,
|
|
460
|
-
disabled: isPreselected,
|
|
461
|
-
onCheckedChange: (value) => row.toggleSelected(!!value),
|
|
462
|
-
onClick: (e) => {
|
|
463
|
-
e.stopPropagation();
|
|
464
|
-
},
|
|
465
|
-
"data-testid": `region-create-form-countries-modal-select-checkbox-${row.original.iso_2}`
|
|
466
|
-
}
|
|
467
|
-
);
|
|
468
|
-
}
|
|
469
|
-
}),
|
|
470
|
-
...base
|
|
471
|
-
],
|
|
472
|
-
[base]
|
|
473
|
-
);
|
|
474
|
-
};
|
|
475
|
-
var CountryTag = ({
|
|
476
|
-
country,
|
|
477
|
-
onRemove
|
|
478
|
-
}) => {
|
|
479
|
-
return /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-field shadow-borders-base transition-fg hover:bg-ui-bg-field-hover flex h-7 items-center overflow-hidden rounded-md", "data-testid": `region-create-form-country-tag-${country.code}`, children: [
|
|
480
|
-
/* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus flex h-full select-none items-center justify-center px-2 py-0.5", "data-testid": `region-create-form-country-tag-${country.code}-name`, children: country.name }),
|
|
481
|
-
/* @__PURE__ */ jsx(
|
|
482
|
-
"button",
|
|
483
|
-
{
|
|
484
|
-
type: "button",
|
|
485
|
-
onClick: () => onRemove(country.code),
|
|
486
|
-
className: "focus-visible:bg-ui-bg-field-hover transition-fg hover:bg-ui-bg-field-hover flex h-full w-7 items-center justify-center border-l outline-none",
|
|
487
|
-
"data-testid": `region-create-form-country-tag-${country.code}-remove-button`,
|
|
488
|
-
children: /* @__PURE__ */ jsx(XMarkMini, { className: "text-ui-fg-muted" })
|
|
489
|
-
}
|
|
490
|
-
)
|
|
491
|
-
] });
|
|
492
|
-
};
|
|
493
|
-
|
|
494
|
-
// src/pages/regions/region-create/region-create.tsx
|
|
495
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
496
|
-
var RegionCreate = () => {
|
|
497
|
-
const { store, isPending: isLoading, isError, error } = useStore();
|
|
498
|
-
const storeCurrencies = (store?.supported_currencies ?? []).map(
|
|
499
|
-
(c) => currencies[c.currency_code.toUpperCase()]
|
|
500
|
-
);
|
|
501
|
-
if (isError) {
|
|
502
|
-
throw error;
|
|
503
|
-
}
|
|
504
|
-
return /* @__PURE__ */ jsx2(RouteFocusModal, { "data-testid": "region-create-modal", children: !isLoading && store && /* @__PURE__ */ jsx2(CreateRegionForm, { currencies: storeCurrencies }) });
|
|
505
|
-
};
|
|
506
|
-
export {
|
|
507
|
-
RegionCreate as Component
|
|
508
|
-
};
|