@medusajs/draft-order 2.10.2-preview-20250904000308 → 2.10.2-preview-20250904031023
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/.medusa/server/src/admin/index.js +647 -647
- package/.medusa/server/src/admin/index.mjs +647 -647
- package/package.json +16 -16
|
@@ -9554,6 +9554,196 @@ const ID = () => {
|
|
|
9554
9554
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9555
9555
|
] });
|
|
9556
9556
|
};
|
|
9557
|
+
const BillingAddress = () => {
|
|
9558
|
+
const { id } = useParams();
|
|
9559
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
9560
|
+
fields: "+billing_address"
|
|
9561
|
+
});
|
|
9562
|
+
if (isError) {
|
|
9563
|
+
throw error;
|
|
9564
|
+
}
|
|
9565
|
+
const isReady = !isPending && !!order;
|
|
9566
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9567
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
9568
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
9569
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
9570
|
+
] }),
|
|
9571
|
+
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
9572
|
+
] });
|
|
9573
|
+
};
|
|
9574
|
+
const BillingAddressForm = ({ order }) => {
|
|
9575
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
9576
|
+
const form = useForm({
|
|
9577
|
+
defaultValues: {
|
|
9578
|
+
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
9579
|
+
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
9580
|
+
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
9581
|
+
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
9582
|
+
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
9583
|
+
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
9584
|
+
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
9585
|
+
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
9586
|
+
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9587
|
+
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9588
|
+
},
|
|
9589
|
+
resolver: zodResolver(schema$5)
|
|
9590
|
+
});
|
|
9591
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9592
|
+
const { handleSuccess } = useRouteModal();
|
|
9593
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
9594
|
+
await mutateAsync(
|
|
9595
|
+
{ billing_address: data },
|
|
9596
|
+
{
|
|
9597
|
+
onSuccess: () => {
|
|
9598
|
+
handleSuccess();
|
|
9599
|
+
},
|
|
9600
|
+
onError: (error) => {
|
|
9601
|
+
toast.error(error.message);
|
|
9602
|
+
}
|
|
9603
|
+
}
|
|
9604
|
+
);
|
|
9605
|
+
});
|
|
9606
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
9607
|
+
KeyboundForm,
|
|
9608
|
+
{
|
|
9609
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
9610
|
+
onSubmit,
|
|
9611
|
+
children: [
|
|
9612
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
9613
|
+
/* @__PURE__ */ jsx(
|
|
9614
|
+
Form$2.Field,
|
|
9615
|
+
{
|
|
9616
|
+
control: form.control,
|
|
9617
|
+
name: "country_code",
|
|
9618
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9619
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
9620
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
9621
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9622
|
+
] })
|
|
9623
|
+
}
|
|
9624
|
+
),
|
|
9625
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9626
|
+
/* @__PURE__ */ jsx(
|
|
9627
|
+
Form$2.Field,
|
|
9628
|
+
{
|
|
9629
|
+
control: form.control,
|
|
9630
|
+
name: "first_name",
|
|
9631
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9632
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
9633
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9634
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9635
|
+
] })
|
|
9636
|
+
}
|
|
9637
|
+
),
|
|
9638
|
+
/* @__PURE__ */ jsx(
|
|
9639
|
+
Form$2.Field,
|
|
9640
|
+
{
|
|
9641
|
+
control: form.control,
|
|
9642
|
+
name: "last_name",
|
|
9643
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9644
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
9645
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9646
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9647
|
+
] })
|
|
9648
|
+
}
|
|
9649
|
+
)
|
|
9650
|
+
] }),
|
|
9651
|
+
/* @__PURE__ */ jsx(
|
|
9652
|
+
Form$2.Field,
|
|
9653
|
+
{
|
|
9654
|
+
control: form.control,
|
|
9655
|
+
name: "company",
|
|
9656
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9657
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
9658
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9659
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9660
|
+
] })
|
|
9661
|
+
}
|
|
9662
|
+
),
|
|
9663
|
+
/* @__PURE__ */ jsx(
|
|
9664
|
+
Form$2.Field,
|
|
9665
|
+
{
|
|
9666
|
+
control: form.control,
|
|
9667
|
+
name: "address_1",
|
|
9668
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9669
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
9670
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9671
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9672
|
+
] })
|
|
9673
|
+
}
|
|
9674
|
+
),
|
|
9675
|
+
/* @__PURE__ */ jsx(
|
|
9676
|
+
Form$2.Field,
|
|
9677
|
+
{
|
|
9678
|
+
control: form.control,
|
|
9679
|
+
name: "address_2",
|
|
9680
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9681
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
9682
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9683
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9684
|
+
] })
|
|
9685
|
+
}
|
|
9686
|
+
),
|
|
9687
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
9688
|
+
/* @__PURE__ */ jsx(
|
|
9689
|
+
Form$2.Field,
|
|
9690
|
+
{
|
|
9691
|
+
control: form.control,
|
|
9692
|
+
name: "postal_code",
|
|
9693
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9694
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
9695
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9696
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9697
|
+
] })
|
|
9698
|
+
}
|
|
9699
|
+
),
|
|
9700
|
+
/* @__PURE__ */ jsx(
|
|
9701
|
+
Form$2.Field,
|
|
9702
|
+
{
|
|
9703
|
+
control: form.control,
|
|
9704
|
+
name: "city",
|
|
9705
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9706
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
9707
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9708
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9709
|
+
] })
|
|
9710
|
+
}
|
|
9711
|
+
)
|
|
9712
|
+
] }),
|
|
9713
|
+
/* @__PURE__ */ jsx(
|
|
9714
|
+
Form$2.Field,
|
|
9715
|
+
{
|
|
9716
|
+
control: form.control,
|
|
9717
|
+
name: "province",
|
|
9718
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9719
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
9720
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9721
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9722
|
+
] })
|
|
9723
|
+
}
|
|
9724
|
+
),
|
|
9725
|
+
/* @__PURE__ */ jsx(
|
|
9726
|
+
Form$2.Field,
|
|
9727
|
+
{
|
|
9728
|
+
control: form.control,
|
|
9729
|
+
name: "phone",
|
|
9730
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
9731
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
9732
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
9733
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
9734
|
+
] })
|
|
9735
|
+
}
|
|
9736
|
+
)
|
|
9737
|
+
] }) }),
|
|
9738
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9739
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9740
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
9741
|
+
] }) })
|
|
9742
|
+
]
|
|
9743
|
+
}
|
|
9744
|
+
) });
|
|
9745
|
+
};
|
|
9746
|
+
const schema$5 = addressSchema;
|
|
9557
9747
|
const CustomItems = () => {
|
|
9558
9748
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9559
9749
|
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
@@ -9562,7 +9752,7 @@ const CustomItems = () => {
|
|
|
9562
9752
|
};
|
|
9563
9753
|
const CustomItemsForm = () => {
|
|
9564
9754
|
const form = useForm({
|
|
9565
|
-
resolver: zodResolver(schema$
|
|
9755
|
+
resolver: zodResolver(schema$4)
|
|
9566
9756
|
});
|
|
9567
9757
|
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9568
9758
|
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
@@ -9572,7 +9762,7 @@ const CustomItemsForm = () => {
|
|
|
9572
9762
|
] }) })
|
|
9573
9763
|
] }) });
|
|
9574
9764
|
};
|
|
9575
|
-
const schema$
|
|
9765
|
+
const schema$4 = objectType({
|
|
9576
9766
|
email: stringType().email()
|
|
9577
9767
|
});
|
|
9578
9768
|
const Email = () => {
|
|
@@ -9597,7 +9787,7 @@ const EmailForm = ({ order }) => {
|
|
|
9597
9787
|
defaultValues: {
|
|
9598
9788
|
email: order.email ?? ""
|
|
9599
9789
|
},
|
|
9600
|
-
resolver: zodResolver(schema$
|
|
9790
|
+
resolver: zodResolver(schema$3)
|
|
9601
9791
|
});
|
|
9602
9792
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9603
9793
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9640,7 +9830,7 @@ const EmailForm = ({ order }) => {
|
|
|
9640
9830
|
}
|
|
9641
9831
|
) });
|
|
9642
9832
|
};
|
|
9643
|
-
const schema$
|
|
9833
|
+
const schema$3 = objectType({
|
|
9644
9834
|
email: stringType().email()
|
|
9645
9835
|
});
|
|
9646
9836
|
const NumberInput = forwardRef(
|
|
@@ -10617,148 +10807,425 @@ const customItemSchema = objectType({
|
|
|
10617
10807
|
quantity: numberType(),
|
|
10618
10808
|
unit_price: unionType([numberType(), stringType()])
|
|
10619
10809
|
});
|
|
10620
|
-
const
|
|
10621
|
-
|
|
10622
|
-
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
...props,
|
|
10632
|
-
children: [
|
|
10633
|
-
/* @__PURE__ */ jsx(
|
|
10634
|
-
"div",
|
|
10635
|
-
{
|
|
10636
|
-
role: "presentation",
|
|
10637
|
-
className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
10638
|
-
"bg-ui-tag-orange-icon": variant === "warning"
|
|
10639
|
-
})
|
|
10640
|
-
}
|
|
10641
|
-
),
|
|
10642
|
-
/* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
|
|
10643
|
-
/* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
10644
|
-
labelValue,
|
|
10645
|
-
":"
|
|
10646
|
-
] }),
|
|
10647
|
-
" ",
|
|
10648
|
-
children
|
|
10649
|
-
] })
|
|
10650
|
-
]
|
|
10651
|
-
}
|
|
10652
|
-
);
|
|
10653
|
-
}
|
|
10654
|
-
);
|
|
10655
|
-
InlineTip.displayName = "InlineTip";
|
|
10656
|
-
const MetadataFieldSchema = objectType({
|
|
10657
|
-
key: stringType(),
|
|
10658
|
-
disabled: booleanType().optional(),
|
|
10659
|
-
value: anyType()
|
|
10660
|
-
});
|
|
10661
|
-
const MetadataSchema = objectType({
|
|
10662
|
-
metadata: arrayType(MetadataFieldSchema)
|
|
10663
|
-
});
|
|
10664
|
-
const Metadata = () => {
|
|
10665
|
-
const { id } = useParams();
|
|
10666
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
10667
|
-
fields: "metadata"
|
|
10668
|
-
});
|
|
10669
|
-
if (isError) {
|
|
10670
|
-
throw error;
|
|
10671
|
-
}
|
|
10672
|
-
const isReady = !isPending && !!order;
|
|
10673
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
10674
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
10675
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Metadata" }) }),
|
|
10676
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
10677
|
-
] }),
|
|
10678
|
-
!isReady ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
10679
|
-
] });
|
|
10810
|
+
const PROMOTION_QUERY_KEY = "promotions";
|
|
10811
|
+
const promotionsQueryKeys = {
|
|
10812
|
+
list: (query2) => [
|
|
10813
|
+
PROMOTION_QUERY_KEY,
|
|
10814
|
+
query2 ? query2 : void 0
|
|
10815
|
+
],
|
|
10816
|
+
detail: (id, query2) => [
|
|
10817
|
+
PROMOTION_QUERY_KEY,
|
|
10818
|
+
id,
|
|
10819
|
+
query2 ? query2 : void 0
|
|
10820
|
+
]
|
|
10680
10821
|
};
|
|
10681
|
-
const
|
|
10682
|
-
const
|
|
10683
|
-
|
|
10822
|
+
const usePromotions = (query2, options) => {
|
|
10823
|
+
const { data, ...rest } = useQuery({
|
|
10824
|
+
queryKey: promotionsQueryKeys.list(query2),
|
|
10825
|
+
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
10826
|
+
...options
|
|
10827
|
+
});
|
|
10828
|
+
return { ...data, ...rest };
|
|
10829
|
+
};
|
|
10830
|
+
const Promotions = () => {
|
|
10831
|
+
const { id } = useParams();
|
|
10832
|
+
const {
|
|
10833
|
+
order: preview,
|
|
10834
|
+
isError: isPreviewError,
|
|
10835
|
+
error: previewError
|
|
10836
|
+
} = useOrderPreview(id, void 0);
|
|
10837
|
+
useInitiateOrderEdit({ preview });
|
|
10838
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
10839
|
+
if (isPreviewError) {
|
|
10840
|
+
throw previewError;
|
|
10841
|
+
}
|
|
10842
|
+
const isReady = !!preview;
|
|
10843
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
10844
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Promotions" }) }) }),
|
|
10845
|
+
isReady && /* @__PURE__ */ jsx(PromotionForm, { preview })
|
|
10846
|
+
] });
|
|
10847
|
+
};
|
|
10848
|
+
const PromotionForm = ({ preview }) => {
|
|
10849
|
+
const { items, shipping_methods } = preview;
|
|
10850
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
10851
|
+
const [comboboxValue, setComboboxValue] = useState("");
|
|
10684
10852
|
const { handleSuccess } = useRouteModal();
|
|
10685
|
-
const
|
|
10686
|
-
const
|
|
10687
|
-
const
|
|
10688
|
-
|
|
10689
|
-
|
|
10853
|
+
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
10854
|
+
const promoCodes = getPromotionCodes(items, shipping_methods);
|
|
10855
|
+
const { promotions, isPending, isError, error } = usePromotions(
|
|
10856
|
+
{
|
|
10857
|
+
code: promoCodes
|
|
10690
10858
|
},
|
|
10691
|
-
|
|
10859
|
+
{
|
|
10860
|
+
enabled: !!promoCodes.length
|
|
10861
|
+
}
|
|
10862
|
+
);
|
|
10863
|
+
const comboboxData = useComboboxData({
|
|
10864
|
+
queryKey: ["promotions", "combobox", promoCodes],
|
|
10865
|
+
queryFn: async (params) => {
|
|
10866
|
+
return await sdk.admin.promotion.list({
|
|
10867
|
+
...params,
|
|
10868
|
+
code: {
|
|
10869
|
+
$nin: promoCodes
|
|
10870
|
+
}
|
|
10871
|
+
});
|
|
10872
|
+
},
|
|
10873
|
+
getOptions: (data) => {
|
|
10874
|
+
return data.promotions.map((promotion) => ({
|
|
10875
|
+
label: promotion.code,
|
|
10876
|
+
value: promotion.code
|
|
10877
|
+
}));
|
|
10878
|
+
}
|
|
10692
10879
|
});
|
|
10693
|
-
const
|
|
10694
|
-
|
|
10695
|
-
|
|
10880
|
+
const add = async (value) => {
|
|
10881
|
+
if (!value) {
|
|
10882
|
+
return;
|
|
10883
|
+
}
|
|
10884
|
+
addPromotions(
|
|
10696
10885
|
{
|
|
10697
|
-
|
|
10886
|
+
promo_codes: [value]
|
|
10698
10887
|
},
|
|
10699
10888
|
{
|
|
10700
|
-
|
|
10701
|
-
toast.
|
|
10702
|
-
|
|
10889
|
+
onError: (e) => {
|
|
10890
|
+
toast.error(e.message);
|
|
10891
|
+
comboboxData.onSearchValueChange("");
|
|
10892
|
+
setComboboxValue("");
|
|
10703
10893
|
},
|
|
10704
|
-
|
|
10705
|
-
|
|
10894
|
+
onSuccess: () => {
|
|
10895
|
+
comboboxData.onSearchValueChange("");
|
|
10896
|
+
setComboboxValue("");
|
|
10706
10897
|
}
|
|
10707
10898
|
}
|
|
10708
10899
|
);
|
|
10709
|
-
}
|
|
10710
|
-
const {
|
|
10711
|
-
|
|
10712
|
-
|
|
10713
|
-
|
|
10714
|
-
|
|
10715
|
-
|
|
10716
|
-
|
|
10717
|
-
|
|
10718
|
-
|
|
10719
|
-
|
|
10720
|
-
|
|
10721
|
-
}
|
|
10900
|
+
};
|
|
10901
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
10902
|
+
const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
|
|
10903
|
+
const onSubmit = async () => {
|
|
10904
|
+
setIsSubmitting(true);
|
|
10905
|
+
let requestSucceeded = false;
|
|
10906
|
+
await requestOrderEdit(void 0, {
|
|
10907
|
+
onError: (e) => {
|
|
10908
|
+
toast.error(e.message);
|
|
10909
|
+
},
|
|
10910
|
+
onSuccess: () => {
|
|
10911
|
+
requestSucceeded = true;
|
|
10912
|
+
}
|
|
10913
|
+
});
|
|
10914
|
+
if (!requestSucceeded) {
|
|
10915
|
+
setIsSubmitting(false);
|
|
10916
|
+
return;
|
|
10722
10917
|
}
|
|
10723
|
-
|
|
10724
|
-
|
|
10725
|
-
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10918
|
+
await confirmOrderEdit(void 0, {
|
|
10919
|
+
onError: (e) => {
|
|
10920
|
+
toast.error(e.message);
|
|
10921
|
+
},
|
|
10922
|
+
onSuccess: () => {
|
|
10923
|
+
handleSuccess();
|
|
10924
|
+
},
|
|
10925
|
+
onSettled: () => {
|
|
10926
|
+
setIsSubmitting(false);
|
|
10927
|
+
}
|
|
10729
10928
|
});
|
|
10929
|
+
};
|
|
10930
|
+
if (isError) {
|
|
10931
|
+
throw error;
|
|
10730
10932
|
}
|
|
10731
|
-
return /* @__PURE__ */
|
|
10732
|
-
|
|
10933
|
+
return /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
|
|
10934
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
10935
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
10936
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
10937
|
+
/* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
|
|
10938
|
+
/* @__PURE__ */ jsx(Hint$1, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
|
|
10939
|
+
] }),
|
|
10940
|
+
/* @__PURE__ */ jsx(
|
|
10941
|
+
Combobox,
|
|
10942
|
+
{
|
|
10943
|
+
id: "promotion-combobox",
|
|
10944
|
+
"aria-describedby": "promotion-combobox-hint",
|
|
10945
|
+
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
10946
|
+
fetchNextPage: comboboxData.fetchNextPage,
|
|
10947
|
+
options: comboboxData.options,
|
|
10948
|
+
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
10949
|
+
searchValue: comboboxData.searchValue,
|
|
10950
|
+
disabled: comboboxData.disabled || isAddingPromotions,
|
|
10951
|
+
onChange: add,
|
|
10952
|
+
value: comboboxValue
|
|
10953
|
+
}
|
|
10954
|
+
)
|
|
10955
|
+
] }),
|
|
10956
|
+
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
10957
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsx(
|
|
10958
|
+
PromotionItem,
|
|
10959
|
+
{
|
|
10960
|
+
promotion,
|
|
10961
|
+
orderId: preview.id,
|
|
10962
|
+
isLoading: isPending
|
|
10963
|
+
},
|
|
10964
|
+
promotion.id
|
|
10965
|
+
)) })
|
|
10966
|
+
] }) }),
|
|
10967
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10968
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10969
|
+
/* @__PURE__ */ jsx(
|
|
10970
|
+
Button,
|
|
10971
|
+
{
|
|
10972
|
+
size: "small",
|
|
10973
|
+
type: "submit",
|
|
10974
|
+
isLoading: isSubmitting || isAddingPromotions,
|
|
10975
|
+
children: "Save"
|
|
10976
|
+
}
|
|
10977
|
+
)
|
|
10978
|
+
] }) })
|
|
10979
|
+
] });
|
|
10980
|
+
};
|
|
10981
|
+
const PromotionItem = ({
|
|
10982
|
+
promotion,
|
|
10983
|
+
orderId,
|
|
10984
|
+
isLoading
|
|
10985
|
+
}) => {
|
|
10986
|
+
var _a;
|
|
10987
|
+
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
10988
|
+
const onRemove = async () => {
|
|
10989
|
+
removePromotions(
|
|
10990
|
+
{
|
|
10991
|
+
promo_codes: [promotion.code]
|
|
10992
|
+
},
|
|
10993
|
+
{
|
|
10994
|
+
onError: (e) => {
|
|
10995
|
+
toast.error(e.message);
|
|
10996
|
+
}
|
|
10997
|
+
}
|
|
10998
|
+
);
|
|
10999
|
+
};
|
|
11000
|
+
const displayValue = getDisplayValue(promotion);
|
|
11001
|
+
return /* @__PURE__ */ jsxs(
|
|
11002
|
+
"div",
|
|
10733
11003
|
{
|
|
10734
|
-
|
|
10735
|
-
|
|
11004
|
+
className: clx(
|
|
11005
|
+
"px-3 py-2 rounded-lg bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between",
|
|
11006
|
+
{
|
|
11007
|
+
"animate-pulse": isLoading
|
|
11008
|
+
}
|
|
11009
|
+
),
|
|
10736
11010
|
children: [
|
|
10737
|
-
/* @__PURE__ */ jsxs(
|
|
10738
|
-
/* @__PURE__ */
|
|
10739
|
-
|
|
10740
|
-
|
|
10741
|
-
/* @__PURE__ */ jsx(
|
|
11011
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
11012
|
+
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
11013
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 text-ui-fg-subtle", children: [
|
|
11014
|
+
displayValue && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
11015
|
+
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: displayValue }),
|
|
11016
|
+
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: "·" })
|
|
10742
11017
|
] }),
|
|
10743
|
-
|
|
10744
|
-
|
|
10745
|
-
|
|
10746
|
-
|
|
10747
|
-
|
|
10748
|
-
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
|
|
10756
|
-
|
|
10757
|
-
|
|
10758
|
-
|
|
10759
|
-
|
|
10760
|
-
|
|
10761
|
-
|
|
11018
|
+
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
|
|
11019
|
+
] })
|
|
11020
|
+
] }),
|
|
11021
|
+
/* @__PURE__ */ jsx(
|
|
11022
|
+
IconButton,
|
|
11023
|
+
{
|
|
11024
|
+
size: "small",
|
|
11025
|
+
type: "button",
|
|
11026
|
+
variant: "transparent",
|
|
11027
|
+
onClick: onRemove,
|
|
11028
|
+
isLoading: isPending || isLoading,
|
|
11029
|
+
children: /* @__PURE__ */ jsx(XMark, {})
|
|
11030
|
+
}
|
|
11031
|
+
)
|
|
11032
|
+
]
|
|
11033
|
+
},
|
|
11034
|
+
promotion.id
|
|
11035
|
+
);
|
|
11036
|
+
};
|
|
11037
|
+
function getDisplayValue(promotion) {
|
|
11038
|
+
var _a, _b, _c, _d;
|
|
11039
|
+
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
11040
|
+
if (!value) {
|
|
11041
|
+
return null;
|
|
11042
|
+
}
|
|
11043
|
+
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
11044
|
+
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
11045
|
+
if (!currency) {
|
|
11046
|
+
return null;
|
|
11047
|
+
}
|
|
11048
|
+
return getLocaleAmount(value, currency);
|
|
11049
|
+
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
11050
|
+
return formatPercentage(value);
|
|
11051
|
+
}
|
|
11052
|
+
return null;
|
|
11053
|
+
}
|
|
11054
|
+
const formatter = new Intl.NumberFormat([], {
|
|
11055
|
+
style: "percent",
|
|
11056
|
+
minimumFractionDigits: 2
|
|
11057
|
+
});
|
|
11058
|
+
const formatPercentage = (value, isPercentageValue = false) => {
|
|
11059
|
+
let val = value || 0;
|
|
11060
|
+
if (!isPercentageValue) {
|
|
11061
|
+
val = val / 100;
|
|
11062
|
+
}
|
|
11063
|
+
return formatter.format(val);
|
|
11064
|
+
};
|
|
11065
|
+
function getPromotionCodes(items, shippingMethods) {
|
|
11066
|
+
const codes = /* @__PURE__ */ new Set();
|
|
11067
|
+
for (const item of items) {
|
|
11068
|
+
if (item.adjustments) {
|
|
11069
|
+
for (const adjustment of item.adjustments) {
|
|
11070
|
+
if (adjustment.code) {
|
|
11071
|
+
codes.add(adjustment.code);
|
|
11072
|
+
}
|
|
11073
|
+
}
|
|
11074
|
+
}
|
|
11075
|
+
}
|
|
11076
|
+
for (const shippingMethod of shippingMethods) {
|
|
11077
|
+
if (shippingMethod.adjustments) {
|
|
11078
|
+
for (const adjustment of shippingMethod.adjustments) {
|
|
11079
|
+
if (adjustment.code) {
|
|
11080
|
+
codes.add(adjustment.code);
|
|
11081
|
+
}
|
|
11082
|
+
}
|
|
11083
|
+
}
|
|
11084
|
+
}
|
|
11085
|
+
return Array.from(codes);
|
|
11086
|
+
}
|
|
11087
|
+
const InlineTip = forwardRef(
|
|
11088
|
+
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
11089
|
+
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
11090
|
+
return /* @__PURE__ */ jsxs(
|
|
11091
|
+
"div",
|
|
11092
|
+
{
|
|
11093
|
+
ref,
|
|
11094
|
+
className: clx(
|
|
11095
|
+
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
11096
|
+
className
|
|
11097
|
+
),
|
|
11098
|
+
...props,
|
|
11099
|
+
children: [
|
|
11100
|
+
/* @__PURE__ */ jsx(
|
|
11101
|
+
"div",
|
|
11102
|
+
{
|
|
11103
|
+
role: "presentation",
|
|
11104
|
+
className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
11105
|
+
"bg-ui-tag-orange-icon": variant === "warning"
|
|
11106
|
+
})
|
|
11107
|
+
}
|
|
11108
|
+
),
|
|
11109
|
+
/* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
|
|
11110
|
+
/* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
11111
|
+
labelValue,
|
|
11112
|
+
":"
|
|
11113
|
+
] }),
|
|
11114
|
+
" ",
|
|
11115
|
+
children
|
|
11116
|
+
] })
|
|
11117
|
+
]
|
|
11118
|
+
}
|
|
11119
|
+
);
|
|
11120
|
+
}
|
|
11121
|
+
);
|
|
11122
|
+
InlineTip.displayName = "InlineTip";
|
|
11123
|
+
const MetadataFieldSchema = objectType({
|
|
11124
|
+
key: stringType(),
|
|
11125
|
+
disabled: booleanType().optional(),
|
|
11126
|
+
value: anyType()
|
|
11127
|
+
});
|
|
11128
|
+
const MetadataSchema = objectType({
|
|
11129
|
+
metadata: arrayType(MetadataFieldSchema)
|
|
11130
|
+
});
|
|
11131
|
+
const Metadata = () => {
|
|
11132
|
+
const { id } = useParams();
|
|
11133
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11134
|
+
fields: "metadata"
|
|
11135
|
+
});
|
|
11136
|
+
if (isError) {
|
|
11137
|
+
throw error;
|
|
11138
|
+
}
|
|
11139
|
+
const isReady = !isPending && !!order;
|
|
11140
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11141
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11142
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Metadata" }) }),
|
|
11143
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
11144
|
+
] }),
|
|
11145
|
+
!isReady ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
11146
|
+
] });
|
|
11147
|
+
};
|
|
11148
|
+
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
11149
|
+
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
11150
|
+
const MetadataForm = ({ orderId, metadata }) => {
|
|
11151
|
+
const { handleSuccess } = useRouteModal();
|
|
11152
|
+
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
11153
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
11154
|
+
const form = useForm({
|
|
11155
|
+
defaultValues: {
|
|
11156
|
+
metadata: getDefaultValues(metadata)
|
|
11157
|
+
},
|
|
11158
|
+
resolver: zodResolver(MetadataSchema)
|
|
11159
|
+
});
|
|
11160
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
11161
|
+
const parsedData = parseValues(data);
|
|
11162
|
+
await mutateAsync(
|
|
11163
|
+
{
|
|
11164
|
+
metadata: parsedData
|
|
11165
|
+
},
|
|
11166
|
+
{
|
|
11167
|
+
onSuccess: () => {
|
|
11168
|
+
toast.success("Metadata updated");
|
|
11169
|
+
handleSuccess();
|
|
11170
|
+
},
|
|
11171
|
+
onError: (error) => {
|
|
11172
|
+
toast.error(error.message);
|
|
11173
|
+
}
|
|
11174
|
+
}
|
|
11175
|
+
);
|
|
11176
|
+
});
|
|
11177
|
+
const { fields, insert, remove } = useFieldArray({
|
|
11178
|
+
control: form.control,
|
|
11179
|
+
name: "metadata"
|
|
11180
|
+
});
|
|
11181
|
+
function deleteRow(index) {
|
|
11182
|
+
remove(index);
|
|
11183
|
+
if (fields.length === 1) {
|
|
11184
|
+
insert(0, {
|
|
11185
|
+
key: "",
|
|
11186
|
+
value: "",
|
|
11187
|
+
disabled: false
|
|
11188
|
+
});
|
|
11189
|
+
}
|
|
11190
|
+
}
|
|
11191
|
+
function insertRow(index, position) {
|
|
11192
|
+
insert(index + (position === "above" ? 0 : 1), {
|
|
11193
|
+
key: "",
|
|
11194
|
+
value: "",
|
|
11195
|
+
disabled: false
|
|
11196
|
+
});
|
|
11197
|
+
}
|
|
11198
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11199
|
+
KeyboundForm,
|
|
11200
|
+
{
|
|
11201
|
+
onSubmit: handleSubmit,
|
|
11202
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11203
|
+
children: [
|
|
11204
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
11205
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
11206
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
11207
|
+
/* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsx("label", { id: METADATA_KEY_LABEL_ID, children: "Key" }) }),
|
|
11208
|
+
/* @__PURE__ */ jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsx("label", { id: METADATA_VALUE_LABEL_ID, children: "Value" }) })
|
|
11209
|
+
] }),
|
|
11210
|
+
fields.map((field, index) => {
|
|
11211
|
+
const isDisabled = field.disabled || false;
|
|
11212
|
+
let placeholder = "-";
|
|
11213
|
+
if (typeof field.value === "object") {
|
|
11214
|
+
placeholder = "{ ... }";
|
|
11215
|
+
}
|
|
11216
|
+
if (Array.isArray(field.value)) {
|
|
11217
|
+
placeholder = "[ ... ]";
|
|
11218
|
+
}
|
|
11219
|
+
return /* @__PURE__ */ jsx(
|
|
11220
|
+
ConditionalTooltip,
|
|
11221
|
+
{
|
|
11222
|
+
showTooltip: isDisabled,
|
|
11223
|
+
content: "This row is disabled because it contains non-primitive data.",
|
|
11224
|
+
children: /* @__PURE__ */ jsxs("div", { className: "group/table relative", children: [
|
|
11225
|
+
/* @__PURE__ */ jsxs(
|
|
11226
|
+
"div",
|
|
11227
|
+
{
|
|
11228
|
+
className: clx("grid grid-cols-2 divide-x", {
|
|
10762
11229
|
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
10763
11230
|
}),
|
|
10764
11231
|
children: [
|
|
@@ -10925,324 +11392,47 @@ function getDefaultValues(metadata) {
|
|
|
10925
11392
|
});
|
|
10926
11393
|
}
|
|
10927
11394
|
function parseValues(values) {
|
|
10928
|
-
const metadata = values.metadata;
|
|
10929
|
-
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
10930
|
-
if (isEmpty) {
|
|
10931
|
-
return null;
|
|
10932
|
-
}
|
|
10933
|
-
const update = {};
|
|
10934
|
-
metadata.forEach((field) => {
|
|
10935
|
-
let key = field.key;
|
|
10936
|
-
let value = field.value;
|
|
10937
|
-
const disabled = field.disabled;
|
|
10938
|
-
if (!key || !value) {
|
|
10939
|
-
return;
|
|
10940
|
-
}
|
|
10941
|
-
if (disabled) {
|
|
10942
|
-
update[key] = value;
|
|
10943
|
-
return;
|
|
10944
|
-
}
|
|
10945
|
-
key = key.trim();
|
|
10946
|
-
value = value.trim();
|
|
10947
|
-
if (value === "true") {
|
|
10948
|
-
update[key] = true;
|
|
10949
|
-
} else if (value === "false") {
|
|
10950
|
-
update[key] = false;
|
|
10951
|
-
} else {
|
|
10952
|
-
const parsedNumber = parseFloat(value);
|
|
10953
|
-
if (!isNaN(parsedNumber)) {
|
|
10954
|
-
update[key] = parsedNumber;
|
|
10955
|
-
} else {
|
|
10956
|
-
update[key] = value;
|
|
10957
|
-
}
|
|
10958
|
-
}
|
|
10959
|
-
});
|
|
10960
|
-
return update;
|
|
10961
|
-
}
|
|
10962
|
-
function getHasUneditableRows(metadata) {
|
|
10963
|
-
if (!metadata) {
|
|
10964
|
-
return false;
|
|
10965
|
-
}
|
|
10966
|
-
return Object.values(metadata).some(
|
|
10967
|
-
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
10968
|
-
);
|
|
10969
|
-
}
|
|
10970
|
-
const PROMOTION_QUERY_KEY = "promotions";
|
|
10971
|
-
const promotionsQueryKeys = {
|
|
10972
|
-
list: (query2) => [
|
|
10973
|
-
PROMOTION_QUERY_KEY,
|
|
10974
|
-
query2 ? query2 : void 0
|
|
10975
|
-
],
|
|
10976
|
-
detail: (id, query2) => [
|
|
10977
|
-
PROMOTION_QUERY_KEY,
|
|
10978
|
-
id,
|
|
10979
|
-
query2 ? query2 : void 0
|
|
10980
|
-
]
|
|
10981
|
-
};
|
|
10982
|
-
const usePromotions = (query2, options) => {
|
|
10983
|
-
const { data, ...rest } = useQuery({
|
|
10984
|
-
queryKey: promotionsQueryKeys.list(query2),
|
|
10985
|
-
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
10986
|
-
...options
|
|
10987
|
-
});
|
|
10988
|
-
return { ...data, ...rest };
|
|
10989
|
-
};
|
|
10990
|
-
const Promotions = () => {
|
|
10991
|
-
const { id } = useParams();
|
|
10992
|
-
const {
|
|
10993
|
-
order: preview,
|
|
10994
|
-
isError: isPreviewError,
|
|
10995
|
-
error: previewError
|
|
10996
|
-
} = useOrderPreview(id, void 0);
|
|
10997
|
-
useInitiateOrderEdit({ preview });
|
|
10998
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
10999
|
-
if (isPreviewError) {
|
|
11000
|
-
throw previewError;
|
|
11001
|
-
}
|
|
11002
|
-
const isReady = !!preview;
|
|
11003
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
11004
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Promotions" }) }) }),
|
|
11005
|
-
isReady && /* @__PURE__ */ jsx(PromotionForm, { preview })
|
|
11006
|
-
] });
|
|
11007
|
-
};
|
|
11008
|
-
const PromotionForm = ({ preview }) => {
|
|
11009
|
-
const { items, shipping_methods } = preview;
|
|
11010
|
-
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
11011
|
-
const [comboboxValue, setComboboxValue] = useState("");
|
|
11012
|
-
const { handleSuccess } = useRouteModal();
|
|
11013
|
-
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
11014
|
-
const promoCodes = getPromotionCodes(items, shipping_methods);
|
|
11015
|
-
const { promotions, isPending, isError, error } = usePromotions(
|
|
11016
|
-
{
|
|
11017
|
-
code: promoCodes
|
|
11018
|
-
},
|
|
11019
|
-
{
|
|
11020
|
-
enabled: !!promoCodes.length
|
|
11021
|
-
}
|
|
11022
|
-
);
|
|
11023
|
-
const comboboxData = useComboboxData({
|
|
11024
|
-
queryKey: ["promotions", "combobox", promoCodes],
|
|
11025
|
-
queryFn: async (params) => {
|
|
11026
|
-
return await sdk.admin.promotion.list({
|
|
11027
|
-
...params,
|
|
11028
|
-
code: {
|
|
11029
|
-
$nin: promoCodes
|
|
11030
|
-
}
|
|
11031
|
-
});
|
|
11032
|
-
},
|
|
11033
|
-
getOptions: (data) => {
|
|
11034
|
-
return data.promotions.map((promotion) => ({
|
|
11035
|
-
label: promotion.code,
|
|
11036
|
-
value: promotion.code
|
|
11037
|
-
}));
|
|
11038
|
-
}
|
|
11039
|
-
});
|
|
11040
|
-
const add = async (value) => {
|
|
11041
|
-
if (!value) {
|
|
11042
|
-
return;
|
|
11043
|
-
}
|
|
11044
|
-
addPromotions(
|
|
11045
|
-
{
|
|
11046
|
-
promo_codes: [value]
|
|
11047
|
-
},
|
|
11048
|
-
{
|
|
11049
|
-
onError: (e) => {
|
|
11050
|
-
toast.error(e.message);
|
|
11051
|
-
comboboxData.onSearchValueChange("");
|
|
11052
|
-
setComboboxValue("");
|
|
11053
|
-
},
|
|
11054
|
-
onSuccess: () => {
|
|
11055
|
-
comboboxData.onSearchValueChange("");
|
|
11056
|
-
setComboboxValue("");
|
|
11057
|
-
}
|
|
11058
|
-
}
|
|
11059
|
-
);
|
|
11060
|
-
};
|
|
11061
|
-
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11062
|
-
const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
|
|
11063
|
-
const onSubmit = async () => {
|
|
11064
|
-
setIsSubmitting(true);
|
|
11065
|
-
let requestSucceeded = false;
|
|
11066
|
-
await requestOrderEdit(void 0, {
|
|
11067
|
-
onError: (e) => {
|
|
11068
|
-
toast.error(e.message);
|
|
11069
|
-
},
|
|
11070
|
-
onSuccess: () => {
|
|
11071
|
-
requestSucceeded = true;
|
|
11072
|
-
}
|
|
11073
|
-
});
|
|
11074
|
-
if (!requestSucceeded) {
|
|
11075
|
-
setIsSubmitting(false);
|
|
11076
|
-
return;
|
|
11077
|
-
}
|
|
11078
|
-
await confirmOrderEdit(void 0, {
|
|
11079
|
-
onError: (e) => {
|
|
11080
|
-
toast.error(e.message);
|
|
11081
|
-
},
|
|
11082
|
-
onSuccess: () => {
|
|
11083
|
-
handleSuccess();
|
|
11084
|
-
},
|
|
11085
|
-
onSettled: () => {
|
|
11086
|
-
setIsSubmitting(false);
|
|
11087
|
-
}
|
|
11088
|
-
});
|
|
11089
|
-
};
|
|
11090
|
-
if (isError) {
|
|
11091
|
-
throw error;
|
|
11092
|
-
}
|
|
11093
|
-
return /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
|
|
11094
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
11095
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
11096
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
11097
|
-
/* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
|
|
11098
|
-
/* @__PURE__ */ jsx(Hint$1, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
|
|
11099
|
-
] }),
|
|
11100
|
-
/* @__PURE__ */ jsx(
|
|
11101
|
-
Combobox,
|
|
11102
|
-
{
|
|
11103
|
-
id: "promotion-combobox",
|
|
11104
|
-
"aria-describedby": "promotion-combobox-hint",
|
|
11105
|
-
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
11106
|
-
fetchNextPage: comboboxData.fetchNextPage,
|
|
11107
|
-
options: comboboxData.options,
|
|
11108
|
-
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
11109
|
-
searchValue: comboboxData.searchValue,
|
|
11110
|
-
disabled: comboboxData.disabled || isAddingPromotions,
|
|
11111
|
-
onChange: add,
|
|
11112
|
-
value: comboboxValue
|
|
11113
|
-
}
|
|
11114
|
-
)
|
|
11115
|
-
] }),
|
|
11116
|
-
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
11117
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsx(
|
|
11118
|
-
PromotionItem,
|
|
11119
|
-
{
|
|
11120
|
-
promotion,
|
|
11121
|
-
orderId: preview.id,
|
|
11122
|
-
isLoading: isPending
|
|
11123
|
-
},
|
|
11124
|
-
promotion.id
|
|
11125
|
-
)) })
|
|
11126
|
-
] }) }),
|
|
11127
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11128
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11129
|
-
/* @__PURE__ */ jsx(
|
|
11130
|
-
Button,
|
|
11131
|
-
{
|
|
11132
|
-
size: "small",
|
|
11133
|
-
type: "submit",
|
|
11134
|
-
isLoading: isSubmitting || isAddingPromotions,
|
|
11135
|
-
children: "Save"
|
|
11136
|
-
}
|
|
11137
|
-
)
|
|
11138
|
-
] }) })
|
|
11139
|
-
] });
|
|
11140
|
-
};
|
|
11141
|
-
const PromotionItem = ({
|
|
11142
|
-
promotion,
|
|
11143
|
-
orderId,
|
|
11144
|
-
isLoading
|
|
11145
|
-
}) => {
|
|
11146
|
-
var _a;
|
|
11147
|
-
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
11148
|
-
const onRemove = async () => {
|
|
11149
|
-
removePromotions(
|
|
11150
|
-
{
|
|
11151
|
-
promo_codes: [promotion.code]
|
|
11152
|
-
},
|
|
11153
|
-
{
|
|
11154
|
-
onError: (e) => {
|
|
11155
|
-
toast.error(e.message);
|
|
11156
|
-
}
|
|
11157
|
-
}
|
|
11158
|
-
);
|
|
11159
|
-
};
|
|
11160
|
-
const displayValue = getDisplayValue(promotion);
|
|
11161
|
-
return /* @__PURE__ */ jsxs(
|
|
11162
|
-
"div",
|
|
11163
|
-
{
|
|
11164
|
-
className: clx(
|
|
11165
|
-
"px-3 py-2 rounded-lg bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between",
|
|
11166
|
-
{
|
|
11167
|
-
"animate-pulse": isLoading
|
|
11168
|
-
}
|
|
11169
|
-
),
|
|
11170
|
-
children: [
|
|
11171
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
11172
|
-
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
11173
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 text-ui-fg-subtle", children: [
|
|
11174
|
-
displayValue && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
11175
|
-
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: displayValue }),
|
|
11176
|
-
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: "·" })
|
|
11177
|
-
] }),
|
|
11178
|
-
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
|
|
11179
|
-
] })
|
|
11180
|
-
] }),
|
|
11181
|
-
/* @__PURE__ */ jsx(
|
|
11182
|
-
IconButton,
|
|
11183
|
-
{
|
|
11184
|
-
size: "small",
|
|
11185
|
-
type: "button",
|
|
11186
|
-
variant: "transparent",
|
|
11187
|
-
onClick: onRemove,
|
|
11188
|
-
isLoading: isPending || isLoading,
|
|
11189
|
-
children: /* @__PURE__ */ jsx(XMark, {})
|
|
11190
|
-
}
|
|
11191
|
-
)
|
|
11192
|
-
]
|
|
11193
|
-
},
|
|
11194
|
-
promotion.id
|
|
11195
|
-
);
|
|
11196
|
-
};
|
|
11197
|
-
function getDisplayValue(promotion) {
|
|
11198
|
-
var _a, _b, _c, _d;
|
|
11199
|
-
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
11200
|
-
if (!value) {
|
|
11201
|
-
return null;
|
|
11202
|
-
}
|
|
11203
|
-
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
11204
|
-
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
11205
|
-
if (!currency) {
|
|
11206
|
-
return null;
|
|
11207
|
-
}
|
|
11208
|
-
return getLocaleAmount(value, currency);
|
|
11209
|
-
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
11210
|
-
return formatPercentage(value);
|
|
11211
|
-
}
|
|
11212
|
-
return null;
|
|
11213
|
-
}
|
|
11214
|
-
const formatter = new Intl.NumberFormat([], {
|
|
11215
|
-
style: "percent",
|
|
11216
|
-
minimumFractionDigits: 2
|
|
11217
|
-
});
|
|
11218
|
-
const formatPercentage = (value, isPercentageValue = false) => {
|
|
11219
|
-
let val = value || 0;
|
|
11220
|
-
if (!isPercentageValue) {
|
|
11221
|
-
val = val / 100;
|
|
11222
|
-
}
|
|
11223
|
-
return formatter.format(val);
|
|
11224
|
-
};
|
|
11225
|
-
function getPromotionCodes(items, shippingMethods) {
|
|
11226
|
-
const codes = /* @__PURE__ */ new Set();
|
|
11227
|
-
for (const item of items) {
|
|
11228
|
-
if (item.adjustments) {
|
|
11229
|
-
for (const adjustment of item.adjustments) {
|
|
11230
|
-
if (adjustment.code) {
|
|
11231
|
-
codes.add(adjustment.code);
|
|
11232
|
-
}
|
|
11233
|
-
}
|
|
11234
|
-
}
|
|
11395
|
+
const metadata = values.metadata;
|
|
11396
|
+
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
11397
|
+
if (isEmpty) {
|
|
11398
|
+
return null;
|
|
11235
11399
|
}
|
|
11236
|
-
|
|
11237
|
-
|
|
11238
|
-
|
|
11239
|
-
|
|
11240
|
-
|
|
11241
|
-
|
|
11400
|
+
const update = {};
|
|
11401
|
+
metadata.forEach((field) => {
|
|
11402
|
+
let key = field.key;
|
|
11403
|
+
let value = field.value;
|
|
11404
|
+
const disabled = field.disabled;
|
|
11405
|
+
if (!key || !value) {
|
|
11406
|
+
return;
|
|
11407
|
+
}
|
|
11408
|
+
if (disabled) {
|
|
11409
|
+
update[key] = value;
|
|
11410
|
+
return;
|
|
11411
|
+
}
|
|
11412
|
+
key = key.trim();
|
|
11413
|
+
value = value.trim();
|
|
11414
|
+
if (value === "true") {
|
|
11415
|
+
update[key] = true;
|
|
11416
|
+
} else if (value === "false") {
|
|
11417
|
+
update[key] = false;
|
|
11418
|
+
} else {
|
|
11419
|
+
const parsedNumber = parseFloat(value);
|
|
11420
|
+
if (!isNaN(parsedNumber)) {
|
|
11421
|
+
update[key] = parsedNumber;
|
|
11422
|
+
} else {
|
|
11423
|
+
update[key] = value;
|
|
11242
11424
|
}
|
|
11243
11425
|
}
|
|
11426
|
+
});
|
|
11427
|
+
return update;
|
|
11428
|
+
}
|
|
11429
|
+
function getHasUneditableRows(metadata) {
|
|
11430
|
+
if (!metadata) {
|
|
11431
|
+
return false;
|
|
11244
11432
|
}
|
|
11245
|
-
return
|
|
11433
|
+
return Object.values(metadata).some(
|
|
11434
|
+
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11435
|
+
);
|
|
11246
11436
|
}
|
|
11247
11437
|
const SalesChannel = () => {
|
|
11248
11438
|
const { id } = useParams();
|
|
@@ -11272,7 +11462,7 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11272
11462
|
defaultValues: {
|
|
11273
11463
|
sales_channel_id: order.sales_channel_id || ""
|
|
11274
11464
|
},
|
|
11275
|
-
resolver: zodResolver(schema$
|
|
11465
|
+
resolver: zodResolver(schema$2)
|
|
11276
11466
|
});
|
|
11277
11467
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11278
11468
|
const { handleSuccess } = useRouteModal();
|
|
@@ -11347,7 +11537,7 @@ const SalesChannelField = ({ control, order }) => {
|
|
|
11347
11537
|
}
|
|
11348
11538
|
);
|
|
11349
11539
|
};
|
|
11350
|
-
const schema$
|
|
11540
|
+
const schema$2 = objectType({
|
|
11351
11541
|
sales_channel_id: stringType().min(1)
|
|
11352
11542
|
});
|
|
11353
11543
|
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
@@ -12189,7 +12379,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12189
12379
|
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12190
12380
|
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12191
12381
|
},
|
|
12192
|
-
resolver: zodResolver(schema$
|
|
12382
|
+
resolver: zodResolver(schema$1)
|
|
12193
12383
|
});
|
|
12194
12384
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12195
12385
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12359,7 +12549,7 @@ const ShippingAddressForm = ({ order }) => {
|
|
|
12359
12549
|
}
|
|
12360
12550
|
) });
|
|
12361
12551
|
};
|
|
12362
|
-
const schema$
|
|
12552
|
+
const schema$1 = addressSchema;
|
|
12363
12553
|
const TransferOwnership = () => {
|
|
12364
12554
|
const { id } = useParams();
|
|
12365
12555
|
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
@@ -12383,7 +12573,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12383
12573
|
defaultValues: {
|
|
12384
12574
|
customer_id: order.customer_id || ""
|
|
12385
12575
|
},
|
|
12386
|
-
resolver: zodResolver(schema
|
|
12576
|
+
resolver: zodResolver(schema)
|
|
12387
12577
|
});
|
|
12388
12578
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12389
12579
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12833,199 +13023,9 @@ const Illustration = () => {
|
|
|
12833
13023
|
}
|
|
12834
13024
|
);
|
|
12835
13025
|
};
|
|
12836
|
-
const schema
|
|
13026
|
+
const schema = objectType({
|
|
12837
13027
|
customer_id: stringType().min(1)
|
|
12838
13028
|
});
|
|
12839
|
-
const BillingAddress = () => {
|
|
12840
|
-
const { id } = useParams();
|
|
12841
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12842
|
-
fields: "+billing_address"
|
|
12843
|
-
});
|
|
12844
|
-
if (isError) {
|
|
12845
|
-
throw error;
|
|
12846
|
-
}
|
|
12847
|
-
const isReady = !isPending && !!order;
|
|
12848
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12849
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12850
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
|
|
12851
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
|
|
12852
|
-
] }),
|
|
12853
|
-
isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
|
|
12854
|
-
] });
|
|
12855
|
-
};
|
|
12856
|
-
const BillingAddressForm = ({ order }) => {
|
|
12857
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12858
|
-
const form = useForm({
|
|
12859
|
-
defaultValues: {
|
|
12860
|
-
first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12861
|
-
last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12862
|
-
company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
|
|
12863
|
-
address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12864
|
-
address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12865
|
-
city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
|
|
12866
|
-
province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
|
|
12867
|
-
country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12868
|
-
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12869
|
-
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
12870
|
-
},
|
|
12871
|
-
resolver: zodResolver(schema)
|
|
12872
|
-
});
|
|
12873
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12874
|
-
const { handleSuccess } = useRouteModal();
|
|
12875
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
12876
|
-
await mutateAsync(
|
|
12877
|
-
{ billing_address: data },
|
|
12878
|
-
{
|
|
12879
|
-
onSuccess: () => {
|
|
12880
|
-
handleSuccess();
|
|
12881
|
-
},
|
|
12882
|
-
onError: (error) => {
|
|
12883
|
-
toast.error(error.message);
|
|
12884
|
-
}
|
|
12885
|
-
}
|
|
12886
|
-
);
|
|
12887
|
-
});
|
|
12888
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12889
|
-
KeyboundForm,
|
|
12890
|
-
{
|
|
12891
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
12892
|
-
onSubmit,
|
|
12893
|
-
children: [
|
|
12894
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
12895
|
-
/* @__PURE__ */ jsx(
|
|
12896
|
-
Form$2.Field,
|
|
12897
|
-
{
|
|
12898
|
-
control: form.control,
|
|
12899
|
-
name: "country_code",
|
|
12900
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12901
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12902
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12903
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12904
|
-
] })
|
|
12905
|
-
}
|
|
12906
|
-
),
|
|
12907
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12908
|
-
/* @__PURE__ */ jsx(
|
|
12909
|
-
Form$2.Field,
|
|
12910
|
-
{
|
|
12911
|
-
control: form.control,
|
|
12912
|
-
name: "first_name",
|
|
12913
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12914
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12915
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12916
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12917
|
-
] })
|
|
12918
|
-
}
|
|
12919
|
-
),
|
|
12920
|
-
/* @__PURE__ */ jsx(
|
|
12921
|
-
Form$2.Field,
|
|
12922
|
-
{
|
|
12923
|
-
control: form.control,
|
|
12924
|
-
name: "last_name",
|
|
12925
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12926
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12927
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12928
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12929
|
-
] })
|
|
12930
|
-
}
|
|
12931
|
-
)
|
|
12932
|
-
] }),
|
|
12933
|
-
/* @__PURE__ */ jsx(
|
|
12934
|
-
Form$2.Field,
|
|
12935
|
-
{
|
|
12936
|
-
control: form.control,
|
|
12937
|
-
name: "company",
|
|
12938
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12939
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12940
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12941
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12942
|
-
] })
|
|
12943
|
-
}
|
|
12944
|
-
),
|
|
12945
|
-
/* @__PURE__ */ jsx(
|
|
12946
|
-
Form$2.Field,
|
|
12947
|
-
{
|
|
12948
|
-
control: form.control,
|
|
12949
|
-
name: "address_1",
|
|
12950
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12951
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12952
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12953
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12954
|
-
] })
|
|
12955
|
-
}
|
|
12956
|
-
),
|
|
12957
|
-
/* @__PURE__ */ jsx(
|
|
12958
|
-
Form$2.Field,
|
|
12959
|
-
{
|
|
12960
|
-
control: form.control,
|
|
12961
|
-
name: "address_2",
|
|
12962
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12963
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12964
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12965
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12966
|
-
] })
|
|
12967
|
-
}
|
|
12968
|
-
),
|
|
12969
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12970
|
-
/* @__PURE__ */ jsx(
|
|
12971
|
-
Form$2.Field,
|
|
12972
|
-
{
|
|
12973
|
-
control: form.control,
|
|
12974
|
-
name: "postal_code",
|
|
12975
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12976
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12977
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12978
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12979
|
-
] })
|
|
12980
|
-
}
|
|
12981
|
-
),
|
|
12982
|
-
/* @__PURE__ */ jsx(
|
|
12983
|
-
Form$2.Field,
|
|
12984
|
-
{
|
|
12985
|
-
control: form.control,
|
|
12986
|
-
name: "city",
|
|
12987
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12988
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
12989
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12990
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12991
|
-
] })
|
|
12992
|
-
}
|
|
12993
|
-
)
|
|
12994
|
-
] }),
|
|
12995
|
-
/* @__PURE__ */ jsx(
|
|
12996
|
-
Form$2.Field,
|
|
12997
|
-
{
|
|
12998
|
-
control: form.control,
|
|
12999
|
-
name: "province",
|
|
13000
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13001
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13002
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13003
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13004
|
-
] })
|
|
13005
|
-
}
|
|
13006
|
-
),
|
|
13007
|
-
/* @__PURE__ */ jsx(
|
|
13008
|
-
Form$2.Field,
|
|
13009
|
-
{
|
|
13010
|
-
control: form.control,
|
|
13011
|
-
name: "phone",
|
|
13012
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13013
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13014
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13015
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13016
|
-
] })
|
|
13017
|
-
}
|
|
13018
|
-
)
|
|
13019
|
-
] }) }),
|
|
13020
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13021
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13022
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13023
|
-
] }) })
|
|
13024
|
-
]
|
|
13025
|
-
}
|
|
13026
|
-
) });
|
|
13027
|
-
};
|
|
13028
|
-
const schema = addressSchema;
|
|
13029
13029
|
const widgetModule = { widgets: [] };
|
|
13030
13030
|
const routeModule = {
|
|
13031
13031
|
routes: [
|
|
@@ -13046,6 +13046,10 @@ const routeModule = {
|
|
|
13046
13046
|
handle,
|
|
13047
13047
|
loader,
|
|
13048
13048
|
children: [
|
|
13049
|
+
{
|
|
13050
|
+
Component: BillingAddress,
|
|
13051
|
+
path: "/draft-orders/:id/billing-address"
|
|
13052
|
+
},
|
|
13049
13053
|
{
|
|
13050
13054
|
Component: CustomItems,
|
|
13051
13055
|
path: "/draft-orders/:id/custom-items"
|
|
@@ -13058,14 +13062,14 @@ const routeModule = {
|
|
|
13058
13062
|
Component: Items,
|
|
13059
13063
|
path: "/draft-orders/:id/items"
|
|
13060
13064
|
},
|
|
13061
|
-
{
|
|
13062
|
-
Component: Metadata,
|
|
13063
|
-
path: "/draft-orders/:id/metadata"
|
|
13064
|
-
},
|
|
13065
13065
|
{
|
|
13066
13066
|
Component: Promotions,
|
|
13067
13067
|
path: "/draft-orders/:id/promotions"
|
|
13068
13068
|
},
|
|
13069
|
+
{
|
|
13070
|
+
Component: Metadata,
|
|
13071
|
+
path: "/draft-orders/:id/metadata"
|
|
13072
|
+
},
|
|
13069
13073
|
{
|
|
13070
13074
|
Component: SalesChannel,
|
|
13071
13075
|
path: "/draft-orders/:id/sales-channel"
|
|
@@ -13081,10 +13085,6 @@ const routeModule = {
|
|
|
13081
13085
|
{
|
|
13082
13086
|
Component: TransferOwnership,
|
|
13083
13087
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13084
|
-
},
|
|
13085
|
-
{
|
|
13086
|
-
Component: BillingAddress,
|
|
13087
|
-
path: "/draft-orders/:id/billing-address"
|
|
13088
13088
|
}
|
|
13089
13089
|
]
|
|
13090
13090
|
}
|