@medusajs/draft-order 2.10.4-preview-20250926090153 → 2.10.4-preview-20250926150202
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 +1840 -1840
- package/.medusa/server/src/admin/index.mjs +1840 -1840
- package/package.json +16 -16
|
@@ -9567,6 +9567,27 @@ const ID = () => {
|
|
|
9567
9567
|
/* @__PURE__ */ jsx(Outlet, {})
|
|
9568
9568
|
] });
|
|
9569
9569
|
};
|
|
9570
|
+
const CustomItems = () => {
|
|
9571
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9572
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9573
|
+
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9574
|
+
] });
|
|
9575
|
+
};
|
|
9576
|
+
const CustomItemsForm = () => {
|
|
9577
|
+
const form = useForm({
|
|
9578
|
+
resolver: zodResolver(schema$5)
|
|
9579
|
+
});
|
|
9580
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9581
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9582
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9583
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9584
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9585
|
+
] }) })
|
|
9586
|
+
] }) });
|
|
9587
|
+
};
|
|
9588
|
+
const schema$5 = objectType({
|
|
9589
|
+
email: stringType().email()
|
|
9590
|
+
});
|
|
9570
9591
|
const BillingAddress = () => {
|
|
9571
9592
|
const { id } = useParams();
|
|
9572
9593
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9599,7 +9620,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9599
9620
|
postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
9600
9621
|
phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
|
|
9601
9622
|
},
|
|
9602
|
-
resolver: zodResolver(schema$
|
|
9623
|
+
resolver: zodResolver(schema$4)
|
|
9603
9624
|
});
|
|
9604
9625
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9605
9626
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9756,28 +9777,7 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9756
9777
|
}
|
|
9757
9778
|
) });
|
|
9758
9779
|
};
|
|
9759
|
-
const schema$
|
|
9760
|
-
const CustomItems = () => {
|
|
9761
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
9762
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
|
|
9763
|
-
/* @__PURE__ */ jsx(CustomItemsForm, {})
|
|
9764
|
-
] });
|
|
9765
|
-
};
|
|
9766
|
-
const CustomItemsForm = () => {
|
|
9767
|
-
const form = useForm({
|
|
9768
|
-
resolver: zodResolver(schema$4)
|
|
9769
|
-
});
|
|
9770
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9771
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, {}),
|
|
9772
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9773
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9774
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
|
|
9775
|
-
] }) })
|
|
9776
|
-
] }) });
|
|
9777
|
-
};
|
|
9778
|
-
const schema$4 = objectType({
|
|
9779
|
-
email: stringType().email()
|
|
9780
|
-
});
|
|
9780
|
+
const schema$4 = addressSchema;
|
|
9781
9781
|
const Email = () => {
|
|
9782
9782
|
const { id } = useParams();
|
|
9783
9783
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -10820,396 +10820,365 @@ const customItemSchema = objectType({
|
|
|
10820
10820
|
quantity: numberType(),
|
|
10821
10821
|
unit_price: unionType([numberType(), stringType()])
|
|
10822
10822
|
});
|
|
10823
|
-
const
|
|
10824
|
-
|
|
10825
|
-
|
|
10826
|
-
|
|
10827
|
-
|
|
10828
|
-
|
|
10829
|
-
|
|
10830
|
-
|
|
10831
|
-
|
|
10832
|
-
|
|
10833
|
-
|
|
10834
|
-
|
|
10835
|
-
|
|
10836
|
-
|
|
10837
|
-
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
10841
|
-
"bg-ui-tag-orange-icon": variant === "warning"
|
|
10842
|
-
})
|
|
10843
|
-
}
|
|
10844
|
-
),
|
|
10845
|
-
/* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
|
|
10846
|
-
/* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
10847
|
-
labelValue,
|
|
10848
|
-
":"
|
|
10849
|
-
] }),
|
|
10850
|
-
" ",
|
|
10851
|
-
children
|
|
10852
|
-
] })
|
|
10853
|
-
]
|
|
10854
|
-
}
|
|
10855
|
-
);
|
|
10856
|
-
}
|
|
10857
|
-
);
|
|
10858
|
-
InlineTip.displayName = "InlineTip";
|
|
10859
|
-
const MetadataFieldSchema = objectType({
|
|
10860
|
-
key: stringType(),
|
|
10861
|
-
disabled: booleanType().optional(),
|
|
10862
|
-
value: anyType()
|
|
10863
|
-
});
|
|
10864
|
-
const MetadataSchema = objectType({
|
|
10865
|
-
metadata: arrayType(MetadataFieldSchema)
|
|
10866
|
-
});
|
|
10867
|
-
const Metadata = () => {
|
|
10868
|
-
const { id } = useParams();
|
|
10869
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
10870
|
-
fields: "metadata"
|
|
10823
|
+
const PROMOTION_QUERY_KEY = "promotions";
|
|
10824
|
+
const promotionsQueryKeys = {
|
|
10825
|
+
list: (query2) => [
|
|
10826
|
+
PROMOTION_QUERY_KEY,
|
|
10827
|
+
query2 ? query2 : void 0
|
|
10828
|
+
],
|
|
10829
|
+
detail: (id, query2) => [
|
|
10830
|
+
PROMOTION_QUERY_KEY,
|
|
10831
|
+
id,
|
|
10832
|
+
query2 ? query2 : void 0
|
|
10833
|
+
]
|
|
10834
|
+
};
|
|
10835
|
+
const usePromotions = (query2, options) => {
|
|
10836
|
+
const { data, ...rest } = useQuery({
|
|
10837
|
+
queryKey: promotionsQueryKeys.list(query2),
|
|
10838
|
+
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
10839
|
+
...options
|
|
10871
10840
|
});
|
|
10872
|
-
|
|
10873
|
-
|
|
10841
|
+
return { ...data, ...rest };
|
|
10842
|
+
};
|
|
10843
|
+
const Promotions = () => {
|
|
10844
|
+
const { id } = useParams();
|
|
10845
|
+
const {
|
|
10846
|
+
order: preview,
|
|
10847
|
+
isError: isPreviewError,
|
|
10848
|
+
error: previewError
|
|
10849
|
+
} = useOrderPreview(id, void 0);
|
|
10850
|
+
useInitiateOrderEdit({ preview });
|
|
10851
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
10852
|
+
if (isPreviewError) {
|
|
10853
|
+
throw previewError;
|
|
10874
10854
|
}
|
|
10875
|
-
const isReady =
|
|
10876
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
10877
|
-
/* @__PURE__ */
|
|
10878
|
-
|
|
10879
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
10880
|
-
] }),
|
|
10881
|
-
!isReady ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
10855
|
+
const isReady = !!preview;
|
|
10856
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
10857
|
+
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Promotions" }) }) }),
|
|
10858
|
+
isReady && /* @__PURE__ */ jsx(PromotionForm, { preview })
|
|
10882
10859
|
] });
|
|
10883
10860
|
};
|
|
10884
|
-
const
|
|
10885
|
-
const
|
|
10886
|
-
const
|
|
10861
|
+
const PromotionForm = ({ preview }) => {
|
|
10862
|
+
const { items, shipping_methods } = preview;
|
|
10863
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
10864
|
+
const [comboboxValue, setComboboxValue] = useState("");
|
|
10887
10865
|
const { handleSuccess } = useRouteModal();
|
|
10888
|
-
const
|
|
10889
|
-
const
|
|
10890
|
-
const
|
|
10891
|
-
|
|
10892
|
-
|
|
10866
|
+
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
10867
|
+
const promoIds = getPromotionIds(items, shipping_methods);
|
|
10868
|
+
const { promotions, isPending, isError, error } = usePromotions(
|
|
10869
|
+
{
|
|
10870
|
+
id: promoIds
|
|
10893
10871
|
},
|
|
10894
|
-
|
|
10872
|
+
{
|
|
10873
|
+
enabled: !!promoIds.length
|
|
10874
|
+
}
|
|
10875
|
+
);
|
|
10876
|
+
const comboboxData = useComboboxData({
|
|
10877
|
+
queryKey: ["promotions", "combobox", promoIds],
|
|
10878
|
+
queryFn: async (params) => {
|
|
10879
|
+
return await sdk.admin.promotion.list({
|
|
10880
|
+
...params,
|
|
10881
|
+
id: {
|
|
10882
|
+
$nin: promoIds
|
|
10883
|
+
}
|
|
10884
|
+
});
|
|
10885
|
+
},
|
|
10886
|
+
getOptions: (data) => {
|
|
10887
|
+
return data.promotions.map((promotion) => ({
|
|
10888
|
+
label: promotion.code,
|
|
10889
|
+
value: promotion.code
|
|
10890
|
+
}));
|
|
10891
|
+
}
|
|
10895
10892
|
});
|
|
10896
|
-
const
|
|
10897
|
-
|
|
10898
|
-
|
|
10893
|
+
const add = async (value) => {
|
|
10894
|
+
if (!value) {
|
|
10895
|
+
return;
|
|
10896
|
+
}
|
|
10897
|
+
addPromotions(
|
|
10899
10898
|
{
|
|
10900
|
-
|
|
10899
|
+
promo_codes: [value]
|
|
10901
10900
|
},
|
|
10902
10901
|
{
|
|
10903
|
-
|
|
10904
|
-
toast.
|
|
10905
|
-
|
|
10902
|
+
onError: (e) => {
|
|
10903
|
+
toast.error(e.message);
|
|
10904
|
+
comboboxData.onSearchValueChange("");
|
|
10905
|
+
setComboboxValue("");
|
|
10906
10906
|
},
|
|
10907
|
-
|
|
10908
|
-
|
|
10907
|
+
onSuccess: () => {
|
|
10908
|
+
comboboxData.onSearchValueChange("");
|
|
10909
|
+
setComboboxValue("");
|
|
10909
10910
|
}
|
|
10910
10911
|
}
|
|
10911
10912
|
);
|
|
10912
|
-
}
|
|
10913
|
-
const {
|
|
10914
|
-
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
|
|
10918
|
-
|
|
10919
|
-
|
|
10920
|
-
|
|
10921
|
-
|
|
10922
|
-
|
|
10923
|
-
|
|
10924
|
-
}
|
|
10913
|
+
};
|
|
10914
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
10915
|
+
const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
|
|
10916
|
+
const onSubmit = async () => {
|
|
10917
|
+
setIsSubmitting(true);
|
|
10918
|
+
let requestSucceeded = false;
|
|
10919
|
+
await requestOrderEdit(void 0, {
|
|
10920
|
+
onError: (e) => {
|
|
10921
|
+
toast.error(e.message);
|
|
10922
|
+
},
|
|
10923
|
+
onSuccess: () => {
|
|
10924
|
+
requestSucceeded = true;
|
|
10925
|
+
}
|
|
10926
|
+
});
|
|
10927
|
+
if (!requestSucceeded) {
|
|
10928
|
+
setIsSubmitting(false);
|
|
10929
|
+
return;
|
|
10925
10930
|
}
|
|
10926
|
-
|
|
10927
|
-
|
|
10928
|
-
|
|
10929
|
-
|
|
10930
|
-
|
|
10931
|
-
|
|
10931
|
+
await confirmOrderEdit(void 0, {
|
|
10932
|
+
onError: (e) => {
|
|
10933
|
+
toast.error(e.message);
|
|
10934
|
+
},
|
|
10935
|
+
onSuccess: () => {
|
|
10936
|
+
handleSuccess();
|
|
10937
|
+
},
|
|
10938
|
+
onSettled: () => {
|
|
10939
|
+
setIsSubmitting(false);
|
|
10940
|
+
}
|
|
10932
10941
|
});
|
|
10942
|
+
};
|
|
10943
|
+
if (isError) {
|
|
10944
|
+
throw error;
|
|
10933
10945
|
}
|
|
10934
|
-
return /* @__PURE__ */
|
|
10935
|
-
|
|
10936
|
-
|
|
10937
|
-
|
|
10938
|
-
|
|
10939
|
-
|
|
10940
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
10941
|
-
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
10942
|
-
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
10943
|
-
/* @__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" }) }),
|
|
10944
|
-
/* @__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" }) })
|
|
10945
|
-
] }),
|
|
10946
|
-
fields.map((field, index) => {
|
|
10947
|
-
const isDisabled = field.disabled || false;
|
|
10948
|
-
let placeholder = "-";
|
|
10949
|
-
if (typeof field.value === "object") {
|
|
10950
|
-
placeholder = "{ ... }";
|
|
10951
|
-
}
|
|
10952
|
-
if (Array.isArray(field.value)) {
|
|
10953
|
-
placeholder = "[ ... ]";
|
|
10954
|
-
}
|
|
10955
|
-
return /* @__PURE__ */ jsx(
|
|
10956
|
-
ConditionalTooltip,
|
|
10957
|
-
{
|
|
10958
|
-
showTooltip: isDisabled,
|
|
10959
|
-
content: "This row is disabled because it contains non-primitive data.",
|
|
10960
|
-
children: /* @__PURE__ */ jsxs("div", { className: "group/table relative", children: [
|
|
10961
|
-
/* @__PURE__ */ jsxs(
|
|
10962
|
-
"div",
|
|
10963
|
-
{
|
|
10964
|
-
className: clx("grid grid-cols-2 divide-x", {
|
|
10965
|
-
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
10966
|
-
}),
|
|
10967
|
-
children: [
|
|
10968
|
-
/* @__PURE__ */ jsx(
|
|
10969
|
-
Form$2.Field,
|
|
10970
|
-
{
|
|
10971
|
-
control: form.control,
|
|
10972
|
-
name: `metadata.${index}.key`,
|
|
10973
|
-
render: ({ field: field2 }) => {
|
|
10974
|
-
return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
10975
|
-
GridInput,
|
|
10976
|
-
{
|
|
10977
|
-
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
10978
|
-
...field2,
|
|
10979
|
-
disabled: isDisabled,
|
|
10980
|
-
placeholder: "Key"
|
|
10981
|
-
}
|
|
10982
|
-
) }) });
|
|
10983
|
-
}
|
|
10984
|
-
}
|
|
10985
|
-
),
|
|
10986
|
-
/* @__PURE__ */ jsx(
|
|
10987
|
-
Form$2.Field,
|
|
10988
|
-
{
|
|
10989
|
-
control: form.control,
|
|
10990
|
-
name: `metadata.${index}.value`,
|
|
10991
|
-
render: ({ field: { value, ...field2 } }) => {
|
|
10992
|
-
return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
10993
|
-
GridInput,
|
|
10994
|
-
{
|
|
10995
|
-
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
10996
|
-
...field2,
|
|
10997
|
-
value: isDisabled ? placeholder : value,
|
|
10998
|
-
disabled: isDisabled,
|
|
10999
|
-
placeholder: "Value"
|
|
11000
|
-
}
|
|
11001
|
-
) }) });
|
|
11002
|
-
}
|
|
11003
|
-
}
|
|
11004
|
-
)
|
|
11005
|
-
]
|
|
11006
|
-
}
|
|
11007
|
-
),
|
|
11008
|
-
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
11009
|
-
/* @__PURE__ */ jsx(
|
|
11010
|
-
DropdownMenu.Trigger,
|
|
11011
|
-
{
|
|
11012
|
-
className: clx(
|
|
11013
|
-
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
11014
|
-
{
|
|
11015
|
-
hidden: isDisabled
|
|
11016
|
-
}
|
|
11017
|
-
),
|
|
11018
|
-
disabled: isDisabled,
|
|
11019
|
-
asChild: true,
|
|
11020
|
-
children: /* @__PURE__ */ jsx(IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsx(EllipsisVertical, {}) })
|
|
11021
|
-
}
|
|
11022
|
-
),
|
|
11023
|
-
/* @__PURE__ */ jsxs(DropdownMenu.Content, { children: [
|
|
11024
|
-
/* @__PURE__ */ jsxs(
|
|
11025
|
-
DropdownMenu.Item,
|
|
11026
|
-
{
|
|
11027
|
-
className: "gap-x-2",
|
|
11028
|
-
onClick: () => insertRow(index, "above"),
|
|
11029
|
-
children: [
|
|
11030
|
-
/* @__PURE__ */ jsx(ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
11031
|
-
"Insert row above"
|
|
11032
|
-
]
|
|
11033
|
-
}
|
|
11034
|
-
),
|
|
11035
|
-
/* @__PURE__ */ jsxs(
|
|
11036
|
-
DropdownMenu.Item,
|
|
11037
|
-
{
|
|
11038
|
-
className: "gap-x-2",
|
|
11039
|
-
onClick: () => insertRow(index, "below"),
|
|
11040
|
-
children: [
|
|
11041
|
-
/* @__PURE__ */ jsx(ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
11042
|
-
"Insert row below"
|
|
11043
|
-
]
|
|
11044
|
-
}
|
|
11045
|
-
),
|
|
11046
|
-
/* @__PURE__ */ jsx(DropdownMenu.Separator, {}),
|
|
11047
|
-
/* @__PURE__ */ jsxs(
|
|
11048
|
-
DropdownMenu.Item,
|
|
11049
|
-
{
|
|
11050
|
-
className: "gap-x-2",
|
|
11051
|
-
onClick: () => deleteRow(index),
|
|
11052
|
-
children: [
|
|
11053
|
-
/* @__PURE__ */ jsx(Trash, { className: "text-ui-fg-subtle" }),
|
|
11054
|
-
"Delete row"
|
|
11055
|
-
]
|
|
11056
|
-
}
|
|
11057
|
-
)
|
|
11058
|
-
] })
|
|
11059
|
-
] })
|
|
11060
|
-
] })
|
|
11061
|
-
},
|
|
11062
|
-
field.id
|
|
11063
|
-
);
|
|
11064
|
-
})
|
|
11065
|
-
] }),
|
|
11066
|
-
hasUneditableRows && /* @__PURE__ */ jsx(InlineTip, { variant: "warning", label: "Some rows are disabled", children: "This object contains non-primitive metadata, such as arrays or objects, that can't be edited here. To edit the disabled rows, use the API directly." })
|
|
10946
|
+
return /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
|
|
10947
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
10948
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
10949
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
10950
|
+
/* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
|
|
10951
|
+
/* @__PURE__ */ jsx(Hint$1, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
|
|
11067
10952
|
] }),
|
|
11068
|
-
/* @__PURE__ */ jsx(
|
|
11069
|
-
|
|
11070
|
-
|
|
11071
|
-
|
|
11072
|
-
|
|
11073
|
-
|
|
11074
|
-
|
|
11075
|
-
|
|
11076
|
-
|
|
11077
|
-
|
|
11078
|
-
|
|
11079
|
-
|
|
11080
|
-
|
|
11081
|
-
|
|
11082
|
-
|
|
11083
|
-
|
|
11084
|
-
|
|
11085
|
-
|
|
10953
|
+
/* @__PURE__ */ jsx(
|
|
10954
|
+
Combobox,
|
|
10955
|
+
{
|
|
10956
|
+
id: "promotion-combobox",
|
|
10957
|
+
"aria-describedby": "promotion-combobox-hint",
|
|
10958
|
+
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
10959
|
+
fetchNextPage: comboboxData.fetchNextPage,
|
|
10960
|
+
options: comboboxData.options,
|
|
10961
|
+
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
10962
|
+
searchValue: comboboxData.searchValue,
|
|
10963
|
+
disabled: comboboxData.disabled || isAddingPromotions,
|
|
10964
|
+
onChange: add,
|
|
10965
|
+
value: comboboxValue
|
|
10966
|
+
}
|
|
10967
|
+
)
|
|
10968
|
+
] }),
|
|
10969
|
+
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
10970
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsx(
|
|
10971
|
+
PromotionItem,
|
|
10972
|
+
{
|
|
10973
|
+
promotion,
|
|
10974
|
+
orderId: preview.id,
|
|
10975
|
+
isLoading: isPending
|
|
10976
|
+
},
|
|
10977
|
+
promotion.id
|
|
10978
|
+
)) })
|
|
10979
|
+
] }) }),
|
|
10980
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
10981
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
10982
|
+
/* @__PURE__ */ jsx(
|
|
10983
|
+
Button,
|
|
10984
|
+
{
|
|
10985
|
+
size: "small",
|
|
10986
|
+
type: "submit",
|
|
10987
|
+
isLoading: isSubmitting || isAddingPromotions,
|
|
10988
|
+
children: "Save"
|
|
10989
|
+
}
|
|
11086
10990
|
)
|
|
11087
|
-
}
|
|
11088
|
-
);
|
|
11089
|
-
});
|
|
11090
|
-
GridInput.displayName = "MetadataForm.GridInput";
|
|
11091
|
-
const PlaceholderInner = () => {
|
|
11092
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11093
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
11094
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11095
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
11096
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
11097
10991
|
] }) })
|
|
11098
10992
|
] });
|
|
11099
10993
|
};
|
|
11100
|
-
const
|
|
11101
|
-
|
|
11102
|
-
|
|
11103
|
-
|
|
10994
|
+
const PromotionItem = ({
|
|
10995
|
+
promotion,
|
|
10996
|
+
orderId,
|
|
10997
|
+
isLoading
|
|
10998
|
+
}) => {
|
|
10999
|
+
var _a;
|
|
11000
|
+
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
11001
|
+
const onRemove = async () => {
|
|
11002
|
+
removePromotions(
|
|
11104
11003
|
{
|
|
11105
|
-
|
|
11106
|
-
|
|
11107
|
-
|
|
11108
|
-
|
|
11109
|
-
|
|
11110
|
-
|
|
11111
|
-
return Object.entries(metadata).map(([key, value]) => {
|
|
11112
|
-
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
11113
|
-
return {
|
|
11114
|
-
key,
|
|
11115
|
-
value,
|
|
11116
|
-
disabled: true
|
|
11117
|
-
};
|
|
11118
|
-
}
|
|
11119
|
-
let stringValue = value;
|
|
11120
|
-
if (typeof value !== "string") {
|
|
11121
|
-
stringValue = JSON.stringify(value);
|
|
11122
|
-
}
|
|
11123
|
-
return {
|
|
11124
|
-
key,
|
|
11125
|
-
value: stringValue,
|
|
11126
|
-
original_key: key
|
|
11127
|
-
};
|
|
11128
|
-
});
|
|
11129
|
-
}
|
|
11130
|
-
function parseValues(values) {
|
|
11131
|
-
const metadata = values.metadata;
|
|
11132
|
-
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
11133
|
-
if (isEmpty) {
|
|
11134
|
-
return null;
|
|
11135
|
-
}
|
|
11136
|
-
const update = {};
|
|
11137
|
-
metadata.forEach((field) => {
|
|
11138
|
-
let key = field.key;
|
|
11139
|
-
let value = field.value;
|
|
11140
|
-
const disabled = field.disabled;
|
|
11141
|
-
if (!key || !value) {
|
|
11142
|
-
return;
|
|
11143
|
-
}
|
|
11144
|
-
if (disabled) {
|
|
11145
|
-
update[key] = value;
|
|
11146
|
-
return;
|
|
11147
|
-
}
|
|
11148
|
-
key = key.trim();
|
|
11149
|
-
value = value.trim();
|
|
11150
|
-
if (value === "true") {
|
|
11151
|
-
update[key] = true;
|
|
11152
|
-
} else if (value === "false") {
|
|
11153
|
-
update[key] = false;
|
|
11154
|
-
} else {
|
|
11155
|
-
const parsedNumber = parseFloat(value);
|
|
11156
|
-
if (!isNaN(parsedNumber)) {
|
|
11157
|
-
update[key] = parsedNumber;
|
|
11158
|
-
} else {
|
|
11159
|
-
update[key] = value;
|
|
11004
|
+
promo_codes: [promotion.code]
|
|
11005
|
+
},
|
|
11006
|
+
{
|
|
11007
|
+
onError: (e) => {
|
|
11008
|
+
toast.error(e.message);
|
|
11009
|
+
}
|
|
11160
11010
|
}
|
|
11011
|
+
);
|
|
11012
|
+
};
|
|
11013
|
+
const displayValue = getDisplayValue(promotion);
|
|
11014
|
+
return /* @__PURE__ */ jsxs(
|
|
11015
|
+
"div",
|
|
11016
|
+
{
|
|
11017
|
+
className: clx(
|
|
11018
|
+
"bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
|
|
11019
|
+
{
|
|
11020
|
+
"animate-pulse": isLoading
|
|
11021
|
+
}
|
|
11022
|
+
),
|
|
11023
|
+
children: [
|
|
11024
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
11025
|
+
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
11026
|
+
/* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
|
|
11027
|
+
displayValue && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
11028
|
+
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: displayValue }),
|
|
11029
|
+
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: "·" })
|
|
11030
|
+
] }),
|
|
11031
|
+
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
|
|
11032
|
+
] })
|
|
11033
|
+
] }),
|
|
11034
|
+
/* @__PURE__ */ jsx(
|
|
11035
|
+
IconButton,
|
|
11036
|
+
{
|
|
11037
|
+
size: "small",
|
|
11038
|
+
type: "button",
|
|
11039
|
+
variant: "transparent",
|
|
11040
|
+
onClick: onRemove,
|
|
11041
|
+
isLoading: isPending || isLoading,
|
|
11042
|
+
children: /* @__PURE__ */ jsx(XMark, {})
|
|
11043
|
+
}
|
|
11044
|
+
)
|
|
11045
|
+
]
|
|
11046
|
+
},
|
|
11047
|
+
promotion.id
|
|
11048
|
+
);
|
|
11049
|
+
};
|
|
11050
|
+
function getDisplayValue(promotion) {
|
|
11051
|
+
var _a, _b, _c, _d;
|
|
11052
|
+
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
11053
|
+
if (!value) {
|
|
11054
|
+
return null;
|
|
11055
|
+
}
|
|
11056
|
+
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
11057
|
+
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
11058
|
+
if (!currency) {
|
|
11059
|
+
return null;
|
|
11161
11060
|
}
|
|
11162
|
-
|
|
11163
|
-
|
|
11061
|
+
return getLocaleAmount(value, currency);
|
|
11062
|
+
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
11063
|
+
return formatPercentage(value);
|
|
11064
|
+
}
|
|
11065
|
+
return null;
|
|
11164
11066
|
}
|
|
11165
|
-
|
|
11166
|
-
|
|
11167
|
-
|
|
11067
|
+
const formatter = new Intl.NumberFormat([], {
|
|
11068
|
+
style: "percent",
|
|
11069
|
+
minimumFractionDigits: 2
|
|
11070
|
+
});
|
|
11071
|
+
const formatPercentage = (value, isPercentageValue = false) => {
|
|
11072
|
+
let val = value || 0;
|
|
11073
|
+
if (!isPercentageValue) {
|
|
11074
|
+
val = val / 100;
|
|
11168
11075
|
}
|
|
11169
|
-
return
|
|
11170
|
-
|
|
11171
|
-
|
|
11076
|
+
return formatter.format(val);
|
|
11077
|
+
};
|
|
11078
|
+
function getPromotionIds(items, shippingMethods) {
|
|
11079
|
+
const promotionIds = /* @__PURE__ */ new Set();
|
|
11080
|
+
for (const item of items) {
|
|
11081
|
+
if (item.adjustments) {
|
|
11082
|
+
for (const adjustment of item.adjustments) {
|
|
11083
|
+
if (adjustment.promotion_id) {
|
|
11084
|
+
promotionIds.add(adjustment.promotion_id);
|
|
11085
|
+
}
|
|
11086
|
+
}
|
|
11087
|
+
}
|
|
11088
|
+
}
|
|
11089
|
+
for (const shippingMethod of shippingMethods) {
|
|
11090
|
+
if (shippingMethod.adjustments) {
|
|
11091
|
+
for (const adjustment of shippingMethod.adjustments) {
|
|
11092
|
+
if (adjustment.promotion_id) {
|
|
11093
|
+
promotionIds.add(adjustment.promotion_id);
|
|
11094
|
+
}
|
|
11095
|
+
}
|
|
11096
|
+
}
|
|
11097
|
+
}
|
|
11098
|
+
return Array.from(promotionIds);
|
|
11172
11099
|
}
|
|
11173
|
-
const
|
|
11100
|
+
const InlineTip = forwardRef(
|
|
11101
|
+
({ variant = "tip", label, className, children, ...props }, ref) => {
|
|
11102
|
+
const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
|
|
11103
|
+
return /* @__PURE__ */ jsxs(
|
|
11104
|
+
"div",
|
|
11105
|
+
{
|
|
11106
|
+
ref,
|
|
11107
|
+
className: clx(
|
|
11108
|
+
"bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
|
|
11109
|
+
className
|
|
11110
|
+
),
|
|
11111
|
+
...props,
|
|
11112
|
+
children: [
|
|
11113
|
+
/* @__PURE__ */ jsx(
|
|
11114
|
+
"div",
|
|
11115
|
+
{
|
|
11116
|
+
role: "presentation",
|
|
11117
|
+
className: clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
|
|
11118
|
+
"bg-ui-tag-orange-icon": variant === "warning"
|
|
11119
|
+
})
|
|
11120
|
+
}
|
|
11121
|
+
),
|
|
11122
|
+
/* @__PURE__ */ jsxs("div", { className: "text-pretty", children: [
|
|
11123
|
+
/* @__PURE__ */ jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
|
|
11124
|
+
labelValue,
|
|
11125
|
+
":"
|
|
11126
|
+
] }),
|
|
11127
|
+
" ",
|
|
11128
|
+
children
|
|
11129
|
+
] })
|
|
11130
|
+
]
|
|
11131
|
+
}
|
|
11132
|
+
);
|
|
11133
|
+
}
|
|
11134
|
+
);
|
|
11135
|
+
InlineTip.displayName = "InlineTip";
|
|
11136
|
+
const MetadataFieldSchema = objectType({
|
|
11137
|
+
key: stringType(),
|
|
11138
|
+
disabled: booleanType().optional(),
|
|
11139
|
+
value: anyType()
|
|
11140
|
+
});
|
|
11141
|
+
const MetadataSchema = objectType({
|
|
11142
|
+
metadata: arrayType(MetadataFieldSchema)
|
|
11143
|
+
});
|
|
11144
|
+
const Metadata = () => {
|
|
11174
11145
|
const { id } = useParams();
|
|
11175
|
-
const {
|
|
11176
|
-
|
|
11177
|
-
|
|
11178
|
-
fields: "+sales_channel_id"
|
|
11179
|
-
},
|
|
11180
|
-
{
|
|
11181
|
-
enabled: !!id
|
|
11182
|
-
}
|
|
11183
|
-
);
|
|
11146
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11147
|
+
fields: "metadata"
|
|
11148
|
+
});
|
|
11184
11149
|
if (isError) {
|
|
11185
11150
|
throw error;
|
|
11186
11151
|
}
|
|
11187
|
-
const
|
|
11152
|
+
const isReady = !isPending && !!order;
|
|
11188
11153
|
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11189
11154
|
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11190
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "
|
|
11191
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "
|
|
11155
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Metadata" }) }),
|
|
11156
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
|
|
11192
11157
|
] }),
|
|
11193
|
-
|
|
11158
|
+
!isReady ? /* @__PURE__ */ jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
|
|
11194
11159
|
] });
|
|
11195
11160
|
};
|
|
11196
|
-
const
|
|
11161
|
+
const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
|
|
11162
|
+
const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
|
|
11163
|
+
const MetadataForm = ({ orderId, metadata }) => {
|
|
11164
|
+
const { handleSuccess } = useRouteModal();
|
|
11165
|
+
const hasUneditableRows = getHasUneditableRows(metadata);
|
|
11166
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
|
|
11197
11167
|
const form = useForm({
|
|
11198
11168
|
defaultValues: {
|
|
11199
|
-
|
|
11169
|
+
metadata: getDefaultValues(metadata)
|
|
11200
11170
|
},
|
|
11201
|
-
resolver: zodResolver(
|
|
11171
|
+
resolver: zodResolver(MetadataSchema)
|
|
11202
11172
|
});
|
|
11203
|
-
const
|
|
11204
|
-
|
|
11205
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11173
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
11174
|
+
const parsedData = parseValues(data);
|
|
11206
11175
|
await mutateAsync(
|
|
11207
11176
|
{
|
|
11208
|
-
|
|
11177
|
+
metadata: parsedData
|
|
11209
11178
|
},
|
|
11210
11179
|
{
|
|
11211
11180
|
onSuccess: () => {
|
|
11212
|
-
toast.success("
|
|
11181
|
+
toast.success("Metadata updated");
|
|
11213
11182
|
handleSuccess();
|
|
11214
11183
|
},
|
|
11215
11184
|
onError: (error) => {
|
|
@@ -11218,163 +11187,443 @@ const SalesChannelForm = ({ order }) => {
|
|
|
11218
11187
|
}
|
|
11219
11188
|
);
|
|
11220
11189
|
});
|
|
11190
|
+
const { fields, insert, remove } = useFieldArray({
|
|
11191
|
+
control: form.control,
|
|
11192
|
+
name: "metadata"
|
|
11193
|
+
});
|
|
11194
|
+
function deleteRow(index) {
|
|
11195
|
+
remove(index);
|
|
11196
|
+
if (fields.length === 1) {
|
|
11197
|
+
insert(0, {
|
|
11198
|
+
key: "",
|
|
11199
|
+
value: "",
|
|
11200
|
+
disabled: false
|
|
11201
|
+
});
|
|
11202
|
+
}
|
|
11203
|
+
}
|
|
11204
|
+
function insertRow(index, position) {
|
|
11205
|
+
insert(index + (position === "above" ? 0 : 1), {
|
|
11206
|
+
key: "",
|
|
11207
|
+
value: "",
|
|
11208
|
+
disabled: false
|
|
11209
|
+
});
|
|
11210
|
+
}
|
|
11221
11211
|
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11222
11212
|
KeyboundForm,
|
|
11223
11213
|
{
|
|
11214
|
+
onSubmit: handleSubmit,
|
|
11224
11215
|
className: "flex flex-1 flex-col overflow-hidden",
|
|
11225
|
-
onSubmit,
|
|
11226
11216
|
children: [
|
|
11227
|
-
/* @__PURE__ */
|
|
11228
|
-
|
|
11229
|
-
|
|
11230
|
-
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
|
|
11238
|
-
|
|
11239
|
-
|
|
11240
|
-
|
|
11241
|
-
|
|
11242
|
-
|
|
11243
|
-
|
|
11244
|
-
|
|
11245
|
-
|
|
11246
|
-
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11255
|
-
|
|
11256
|
-
|
|
11257
|
-
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
|
|
11217
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
|
|
11218
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
|
|
11219
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
|
|
11220
|
+
/* @__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" }) }),
|
|
11221
|
+
/* @__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" }) })
|
|
11222
|
+
] }),
|
|
11223
|
+
fields.map((field, index) => {
|
|
11224
|
+
const isDisabled = field.disabled || false;
|
|
11225
|
+
let placeholder = "-";
|
|
11226
|
+
if (typeof field.value === "object") {
|
|
11227
|
+
placeholder = "{ ... }";
|
|
11228
|
+
}
|
|
11229
|
+
if (Array.isArray(field.value)) {
|
|
11230
|
+
placeholder = "[ ... ]";
|
|
11231
|
+
}
|
|
11232
|
+
return /* @__PURE__ */ jsx(
|
|
11233
|
+
ConditionalTooltip,
|
|
11234
|
+
{
|
|
11235
|
+
showTooltip: isDisabled,
|
|
11236
|
+
content: "This row is disabled because it contains non-primitive data.",
|
|
11237
|
+
children: /* @__PURE__ */ jsxs("div", { className: "group/table relative", children: [
|
|
11238
|
+
/* @__PURE__ */ jsxs(
|
|
11239
|
+
"div",
|
|
11240
|
+
{
|
|
11241
|
+
className: clx("grid grid-cols-2 divide-x", {
|
|
11242
|
+
"overflow-hidden rounded-b-lg": index === fields.length - 1
|
|
11243
|
+
}),
|
|
11244
|
+
children: [
|
|
11245
|
+
/* @__PURE__ */ jsx(
|
|
11246
|
+
Form$2.Field,
|
|
11247
|
+
{
|
|
11248
|
+
control: form.control,
|
|
11249
|
+
name: `metadata.${index}.key`,
|
|
11250
|
+
render: ({ field: field2 }) => {
|
|
11251
|
+
return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11252
|
+
GridInput,
|
|
11253
|
+
{
|
|
11254
|
+
"aria-labelledby": METADATA_KEY_LABEL_ID,
|
|
11255
|
+
...field2,
|
|
11256
|
+
disabled: isDisabled,
|
|
11257
|
+
placeholder: "Key"
|
|
11258
|
+
}
|
|
11259
|
+
) }) });
|
|
11260
|
+
}
|
|
11261
|
+
}
|
|
11262
|
+
),
|
|
11263
|
+
/* @__PURE__ */ jsx(
|
|
11264
|
+
Form$2.Field,
|
|
11265
|
+
{
|
|
11266
|
+
control: form.control,
|
|
11267
|
+
name: `metadata.${index}.value`,
|
|
11268
|
+
render: ({ field: { value, ...field2 } }) => {
|
|
11269
|
+
return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11270
|
+
GridInput,
|
|
11271
|
+
{
|
|
11272
|
+
"aria-labelledby": METADATA_VALUE_LABEL_ID,
|
|
11273
|
+
...field2,
|
|
11274
|
+
value: isDisabled ? placeholder : value,
|
|
11275
|
+
disabled: isDisabled,
|
|
11276
|
+
placeholder: "Value"
|
|
11277
|
+
}
|
|
11278
|
+
) }) });
|
|
11279
|
+
}
|
|
11280
|
+
}
|
|
11281
|
+
)
|
|
11282
|
+
]
|
|
11283
|
+
}
|
|
11284
|
+
),
|
|
11285
|
+
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
11286
|
+
/* @__PURE__ */ jsx(
|
|
11287
|
+
DropdownMenu.Trigger,
|
|
11288
|
+
{
|
|
11289
|
+
className: clx(
|
|
11290
|
+
"invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
|
|
11291
|
+
{
|
|
11292
|
+
hidden: isDisabled
|
|
11293
|
+
}
|
|
11294
|
+
),
|
|
11295
|
+
disabled: isDisabled,
|
|
11296
|
+
asChild: true,
|
|
11297
|
+
children: /* @__PURE__ */ jsx(IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsx(EllipsisVertical, {}) })
|
|
11298
|
+
}
|
|
11299
|
+
),
|
|
11300
|
+
/* @__PURE__ */ jsxs(DropdownMenu.Content, { children: [
|
|
11301
|
+
/* @__PURE__ */ jsxs(
|
|
11302
|
+
DropdownMenu.Item,
|
|
11303
|
+
{
|
|
11304
|
+
className: "gap-x-2",
|
|
11305
|
+
onClick: () => insertRow(index, "above"),
|
|
11306
|
+
children: [
|
|
11307
|
+
/* @__PURE__ */ jsx(ArrowUpMini, { className: "text-ui-fg-subtle" }),
|
|
11308
|
+
"Insert row above"
|
|
11309
|
+
]
|
|
11310
|
+
}
|
|
11311
|
+
),
|
|
11312
|
+
/* @__PURE__ */ jsxs(
|
|
11313
|
+
DropdownMenu.Item,
|
|
11314
|
+
{
|
|
11315
|
+
className: "gap-x-2",
|
|
11316
|
+
onClick: () => insertRow(index, "below"),
|
|
11317
|
+
children: [
|
|
11318
|
+
/* @__PURE__ */ jsx(ArrowDownMini, { className: "text-ui-fg-subtle" }),
|
|
11319
|
+
"Insert row below"
|
|
11320
|
+
]
|
|
11321
|
+
}
|
|
11322
|
+
),
|
|
11323
|
+
/* @__PURE__ */ jsx(DropdownMenu.Separator, {}),
|
|
11324
|
+
/* @__PURE__ */ jsxs(
|
|
11325
|
+
DropdownMenu.Item,
|
|
11326
|
+
{
|
|
11327
|
+
className: "gap-x-2",
|
|
11328
|
+
onClick: () => deleteRow(index),
|
|
11329
|
+
children: [
|
|
11330
|
+
/* @__PURE__ */ jsx(Trash, { className: "text-ui-fg-subtle" }),
|
|
11331
|
+
"Delete row"
|
|
11332
|
+
]
|
|
11333
|
+
}
|
|
11334
|
+
)
|
|
11335
|
+
] })
|
|
11336
|
+
] })
|
|
11337
|
+
] })
|
|
11338
|
+
},
|
|
11339
|
+
field.id
|
|
11340
|
+
);
|
|
11341
|
+
})
|
|
11342
|
+
] }),
|
|
11343
|
+
hasUneditableRows && /* @__PURE__ */ jsx(InlineTip, { variant: "warning", label: "Some rows are disabled", children: "This object contains non-primitive metadata, such as arrays or objects, that can't be edited here. To edit the disabled rows, use the API directly." })
|
|
11344
|
+
] }),
|
|
11345
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11346
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
11347
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11348
|
+
] }) })
|
|
11349
|
+
]
|
|
11273
11350
|
}
|
|
11274
|
-
);
|
|
11351
|
+
) });
|
|
11275
11352
|
};
|
|
11276
|
-
const
|
|
11277
|
-
|
|
11353
|
+
const GridInput = forwardRef(({ className, ...props }, ref) => {
|
|
11354
|
+
return /* @__PURE__ */ jsx(
|
|
11355
|
+
"input",
|
|
11356
|
+
{
|
|
11357
|
+
ref,
|
|
11358
|
+
...props,
|
|
11359
|
+
autoComplete: "off",
|
|
11360
|
+
className: clx(
|
|
11361
|
+
"txt-compact-small text-ui-fg-base placeholder:text-ui-fg-muted disabled:text-ui-fg-disabled disabled:bg-ui-bg-base bg-transparent px-2 py-1.5 outline-none",
|
|
11362
|
+
className
|
|
11363
|
+
)
|
|
11364
|
+
}
|
|
11365
|
+
);
|
|
11278
11366
|
});
|
|
11279
|
-
|
|
11280
|
-
const
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
11284
|
-
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
id,
|
|
11288
|
-
query2 ? query2 : void 0
|
|
11289
|
-
]
|
|
11290
|
-
};
|
|
11291
|
-
const usePromotions = (query2, options) => {
|
|
11292
|
-
const { data, ...rest } = useQuery({
|
|
11293
|
-
queryKey: promotionsQueryKeys.list(query2),
|
|
11294
|
-
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
11295
|
-
...options
|
|
11296
|
-
});
|
|
11297
|
-
return { ...data, ...rest };
|
|
11298
|
-
};
|
|
11299
|
-
const Promotions = () => {
|
|
11300
|
-
const { id } = useParams();
|
|
11301
|
-
const {
|
|
11302
|
-
order: preview,
|
|
11303
|
-
isError: isPreviewError,
|
|
11304
|
-
error: previewError
|
|
11305
|
-
} = useOrderPreview(id, void 0);
|
|
11306
|
-
useInitiateOrderEdit({ preview });
|
|
11307
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11308
|
-
if (isPreviewError) {
|
|
11309
|
-
throw previewError;
|
|
11310
|
-
}
|
|
11311
|
-
const isReady = !!preview;
|
|
11312
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
11313
|
-
/* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Promotions" }) }) }),
|
|
11314
|
-
isReady && /* @__PURE__ */ jsx(PromotionForm, { preview })
|
|
11367
|
+
GridInput.displayName = "MetadataForm.GridInput";
|
|
11368
|
+
const PlaceholderInner = () => {
|
|
11369
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11370
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
|
|
11371
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11372
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" }),
|
|
11373
|
+
/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-12 rounded-md" })
|
|
11374
|
+
] }) })
|
|
11315
11375
|
] });
|
|
11316
11376
|
};
|
|
11317
|
-
const
|
|
11318
|
-
|
|
11319
|
-
|
|
11320
|
-
|
|
11321
|
-
|
|
11322
|
-
|
|
11323
|
-
|
|
11324
|
-
|
|
11325
|
-
|
|
11326
|
-
|
|
11327
|
-
|
|
11328
|
-
|
|
11329
|
-
|
|
11377
|
+
const EDITABLE_TYPES = ["string", "number", "boolean"];
|
|
11378
|
+
function getDefaultValues(metadata) {
|
|
11379
|
+
if (!metadata || !Object.keys(metadata).length) {
|
|
11380
|
+
return [
|
|
11381
|
+
{
|
|
11382
|
+
key: "",
|
|
11383
|
+
value: "",
|
|
11384
|
+
disabled: false
|
|
11385
|
+
}
|
|
11386
|
+
];
|
|
11387
|
+
}
|
|
11388
|
+
return Object.entries(metadata).map(([key, value]) => {
|
|
11389
|
+
if (!EDITABLE_TYPES.includes(typeof value)) {
|
|
11390
|
+
return {
|
|
11391
|
+
key,
|
|
11392
|
+
value,
|
|
11393
|
+
disabled: true
|
|
11394
|
+
};
|
|
11330
11395
|
}
|
|
11331
|
-
|
|
11332
|
-
|
|
11333
|
-
|
|
11334
|
-
queryFn: async (params) => {
|
|
11335
|
-
return await sdk.admin.promotion.list({
|
|
11336
|
-
...params,
|
|
11337
|
-
id: {
|
|
11338
|
-
$nin: promoIds
|
|
11339
|
-
}
|
|
11340
|
-
});
|
|
11341
|
-
},
|
|
11342
|
-
getOptions: (data) => {
|
|
11343
|
-
return data.promotions.map((promotion) => ({
|
|
11344
|
-
label: promotion.code,
|
|
11345
|
-
value: promotion.code
|
|
11346
|
-
}));
|
|
11396
|
+
let stringValue = value;
|
|
11397
|
+
if (typeof value !== "string") {
|
|
11398
|
+
stringValue = JSON.stringify(value);
|
|
11347
11399
|
}
|
|
11400
|
+
return {
|
|
11401
|
+
key,
|
|
11402
|
+
value: stringValue,
|
|
11403
|
+
original_key: key
|
|
11404
|
+
};
|
|
11348
11405
|
});
|
|
11349
|
-
|
|
11350
|
-
|
|
11351
|
-
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
11406
|
+
}
|
|
11407
|
+
function parseValues(values) {
|
|
11408
|
+
const metadata = values.metadata;
|
|
11409
|
+
const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
|
|
11410
|
+
if (isEmpty) {
|
|
11411
|
+
return null;
|
|
11412
|
+
}
|
|
11413
|
+
const update = {};
|
|
11414
|
+
metadata.forEach((field) => {
|
|
11415
|
+
let key = field.key;
|
|
11416
|
+
let value = field.value;
|
|
11417
|
+
const disabled = field.disabled;
|
|
11418
|
+
if (!key || !value) {
|
|
11419
|
+
return;
|
|
11420
|
+
}
|
|
11421
|
+
if (disabled) {
|
|
11422
|
+
update[key] = value;
|
|
11423
|
+
return;
|
|
11424
|
+
}
|
|
11425
|
+
key = key.trim();
|
|
11426
|
+
value = value.trim();
|
|
11427
|
+
if (value === "true") {
|
|
11428
|
+
update[key] = true;
|
|
11429
|
+
} else if (value === "false") {
|
|
11430
|
+
update[key] = false;
|
|
11431
|
+
} else {
|
|
11432
|
+
const parsedNumber = parseFloat(value);
|
|
11433
|
+
if (!isNaN(parsedNumber)) {
|
|
11434
|
+
update[key] = parsedNumber;
|
|
11435
|
+
} else {
|
|
11436
|
+
update[key] = value;
|
|
11437
|
+
}
|
|
11438
|
+
}
|
|
11439
|
+
});
|
|
11440
|
+
return update;
|
|
11441
|
+
}
|
|
11442
|
+
function getHasUneditableRows(metadata) {
|
|
11443
|
+
if (!metadata) {
|
|
11444
|
+
return false;
|
|
11445
|
+
}
|
|
11446
|
+
return Object.values(metadata).some(
|
|
11447
|
+
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11448
|
+
);
|
|
11449
|
+
}
|
|
11450
|
+
const SalesChannel = () => {
|
|
11451
|
+
const { id } = useParams();
|
|
11452
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11453
|
+
id,
|
|
11454
|
+
{
|
|
11455
|
+
fields: "+sales_channel_id"
|
|
11456
|
+
},
|
|
11457
|
+
{
|
|
11458
|
+
enabled: !!id
|
|
11459
|
+
}
|
|
11460
|
+
);
|
|
11461
|
+
if (isError) {
|
|
11462
|
+
throw error;
|
|
11463
|
+
}
|
|
11464
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
11465
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11466
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11467
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
|
|
11468
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11469
|
+
] }),
|
|
11470
|
+
ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
|
|
11471
|
+
] });
|
|
11472
|
+
};
|
|
11473
|
+
const SalesChannelForm = ({ order }) => {
|
|
11474
|
+
const form = useForm({
|
|
11475
|
+
defaultValues: {
|
|
11476
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
11477
|
+
},
|
|
11478
|
+
resolver: zodResolver(schema$2)
|
|
11479
|
+
});
|
|
11480
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11481
|
+
const { handleSuccess } = useRouteModal();
|
|
11482
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
11483
|
+
await mutateAsync(
|
|
11484
|
+
{
|
|
11485
|
+
sales_channel_id: data.sales_channel_id
|
|
11356
11486
|
},
|
|
11357
11487
|
{
|
|
11358
|
-
onError: (e) => {
|
|
11359
|
-
toast.error(e.message);
|
|
11360
|
-
comboboxData.onSearchValueChange("");
|
|
11361
|
-
setComboboxValue("");
|
|
11362
|
-
},
|
|
11363
11488
|
onSuccess: () => {
|
|
11364
|
-
|
|
11365
|
-
|
|
11489
|
+
toast.success("Sales channel updated");
|
|
11490
|
+
handleSuccess();
|
|
11491
|
+
},
|
|
11492
|
+
onError: (error) => {
|
|
11493
|
+
toast.error(error.message);
|
|
11366
11494
|
}
|
|
11367
11495
|
}
|
|
11368
11496
|
);
|
|
11369
|
-
};
|
|
11497
|
+
});
|
|
11498
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11499
|
+
KeyboundForm,
|
|
11500
|
+
{
|
|
11501
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
11502
|
+
onSubmit,
|
|
11503
|
+
children: [
|
|
11504
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11505
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11506
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11507
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11508
|
+
] }) })
|
|
11509
|
+
]
|
|
11510
|
+
}
|
|
11511
|
+
) });
|
|
11512
|
+
};
|
|
11513
|
+
const SalesChannelField = ({ control, order }) => {
|
|
11514
|
+
const salesChannels = useComboboxData({
|
|
11515
|
+
queryFn: async (params) => {
|
|
11516
|
+
return await sdk.admin.salesChannel.list(params);
|
|
11517
|
+
},
|
|
11518
|
+
queryKey: ["sales-channels"],
|
|
11519
|
+
getOptions: (data) => {
|
|
11520
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
11521
|
+
label: salesChannel.name,
|
|
11522
|
+
value: salesChannel.id
|
|
11523
|
+
}));
|
|
11524
|
+
},
|
|
11525
|
+
defaultValue: order.sales_channel_id || void 0
|
|
11526
|
+
});
|
|
11527
|
+
return /* @__PURE__ */ jsx(
|
|
11528
|
+
Form$2.Field,
|
|
11529
|
+
{
|
|
11530
|
+
control,
|
|
11531
|
+
name: "sales_channel_id",
|
|
11532
|
+
render: ({ field }) => {
|
|
11533
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11534
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11535
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11536
|
+
Combobox,
|
|
11537
|
+
{
|
|
11538
|
+
options: salesChannels.options,
|
|
11539
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
11540
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11541
|
+
searchValue: salesChannels.searchValue,
|
|
11542
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11543
|
+
placeholder: "Select sales channel",
|
|
11544
|
+
...field
|
|
11545
|
+
}
|
|
11546
|
+
) }),
|
|
11547
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11548
|
+
] });
|
|
11549
|
+
}
|
|
11550
|
+
}
|
|
11551
|
+
);
|
|
11552
|
+
};
|
|
11553
|
+
const schema$2 = objectType({
|
|
11554
|
+
sales_channel_id: stringType().min(1)
|
|
11555
|
+
});
|
|
11556
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11557
|
+
const Shipping = () => {
|
|
11558
|
+
var _a;
|
|
11559
|
+
const { id } = useParams();
|
|
11560
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11561
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11562
|
+
});
|
|
11563
|
+
const {
|
|
11564
|
+
order: preview,
|
|
11565
|
+
isPending: isPreviewPending,
|
|
11566
|
+
isError: isPreviewError,
|
|
11567
|
+
error: previewError
|
|
11568
|
+
} = useOrderPreview(id);
|
|
11569
|
+
useInitiateOrderEdit({ preview });
|
|
11570
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11571
|
+
if (isError) {
|
|
11572
|
+
throw error;
|
|
11573
|
+
}
|
|
11574
|
+
if (isPreviewError) {
|
|
11575
|
+
throw previewError;
|
|
11576
|
+
}
|
|
11577
|
+
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11578
|
+
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11579
|
+
return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11580
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11581
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
|
|
11582
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11583
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
11584
|
+
] }) }) }),
|
|
11585
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11586
|
+
] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
11587
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11588
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11589
|
+
] }) });
|
|
11590
|
+
};
|
|
11591
|
+
const ShippingForm = ({ preview, order }) => {
|
|
11592
|
+
var _a;
|
|
11593
|
+
const { setIsOpen } = useStackedModal();
|
|
11594
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
11595
|
+
const [data, setData] = useState(null);
|
|
11596
|
+
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11597
|
+
const { shipping_options } = useShippingOptions(
|
|
11598
|
+
{
|
|
11599
|
+
id: appliedShippingOptionIds,
|
|
11600
|
+
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11601
|
+
},
|
|
11602
|
+
{
|
|
11603
|
+
enabled: appliedShippingOptionIds.length > 0
|
|
11604
|
+
}
|
|
11605
|
+
);
|
|
11606
|
+
const uniqueShippingProfiles = useMemo(() => {
|
|
11607
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
11608
|
+
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
11609
|
+
profiles.set(profile.id, profile);
|
|
11610
|
+
});
|
|
11611
|
+
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
11612
|
+
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
11613
|
+
});
|
|
11614
|
+
return Array.from(profiles.values());
|
|
11615
|
+
}, [order.items, shipping_options]);
|
|
11616
|
+
const { handleSuccess } = useRouteModal();
|
|
11370
11617
|
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11371
|
-
const { mutateAsync: requestOrderEdit } =
|
|
11618
|
+
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
11619
|
+
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
11620
|
+
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
11372
11621
|
const onSubmit = async () => {
|
|
11373
11622
|
setIsSubmitting(true);
|
|
11374
11623
|
let requestSucceeded = false;
|
|
11375
11624
|
await requestOrderEdit(void 0, {
|
|
11376
11625
|
onError: (e) => {
|
|
11377
|
-
toast.error(e.message);
|
|
11626
|
+
toast.error(`Failed to request order edit: ${e.message}`);
|
|
11378
11627
|
},
|
|
11379
11628
|
onSuccess: () => {
|
|
11380
11629
|
requestSucceeded = true;
|
|
@@ -11386,7 +11635,7 @@ const PromotionForm = ({ preview }) => {
|
|
|
11386
11635
|
}
|
|
11387
11636
|
await confirmOrderEdit(void 0, {
|
|
11388
11637
|
onError: (e) => {
|
|
11389
|
-
toast.error(e.message);
|
|
11638
|
+
toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
11390
11639
|
},
|
|
11391
11640
|
onSuccess: () => {
|
|
11392
11641
|
handleSuccess();
|
|
@@ -11396,978 +11645,50 @@ const PromotionForm = ({ preview }) => {
|
|
|
11396
11645
|
}
|
|
11397
11646
|
});
|
|
11398
11647
|
};
|
|
11399
|
-
|
|
11400
|
-
|
|
11401
|
-
|
|
11402
|
-
|
|
11403
|
-
|
|
11404
|
-
|
|
11405
|
-
|
|
11406
|
-
|
|
11407
|
-
|
|
11648
|
+
const onKeydown = useCallback(
|
|
11649
|
+
(e) => {
|
|
11650
|
+
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
11651
|
+
if (data || isSubmitting) {
|
|
11652
|
+
return;
|
|
11653
|
+
}
|
|
11654
|
+
onSubmit();
|
|
11655
|
+
}
|
|
11656
|
+
},
|
|
11657
|
+
[data, isSubmitting, onSubmit]
|
|
11658
|
+
);
|
|
11659
|
+
useEffect(() => {
|
|
11660
|
+
document.addEventListener("keydown", onKeydown);
|
|
11661
|
+
return () => {
|
|
11662
|
+
document.removeEventListener("keydown", onKeydown);
|
|
11663
|
+
};
|
|
11664
|
+
}, [onKeydown]);
|
|
11665
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
11666
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
11667
|
+
/* @__PURE__ */ jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
11668
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
|
|
11669
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
11670
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
11671
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
|
|
11408
11672
|
] }),
|
|
11409
|
-
/* @__PURE__ */ jsx(
|
|
11410
|
-
|
|
11411
|
-
{
|
|
11412
|
-
id: "promotion-combobox",
|
|
11413
|
-
"aria-describedby": "promotion-combobox-hint",
|
|
11414
|
-
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
11415
|
-
fetchNextPage: comboboxData.fetchNextPage,
|
|
11416
|
-
options: comboboxData.options,
|
|
11417
|
-
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
11418
|
-
searchValue: comboboxData.searchValue,
|
|
11419
|
-
disabled: comboboxData.disabled || isAddingPromotions,
|
|
11420
|
-
onChange: add,
|
|
11421
|
-
value: comboboxValue
|
|
11422
|
-
}
|
|
11423
|
-
)
|
|
11424
|
-
] }),
|
|
11425
|
-
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
11426
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsx(
|
|
11427
|
-
PromotionItem,
|
|
11428
|
-
{
|
|
11429
|
-
promotion,
|
|
11430
|
-
orderId: preview.id,
|
|
11431
|
-
isLoading: isPending
|
|
11432
|
-
},
|
|
11433
|
-
promotion.id
|
|
11434
|
-
)) })
|
|
11435
|
-
] }) }),
|
|
11436
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11437
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11438
|
-
/* @__PURE__ */ jsx(
|
|
11439
|
-
Button,
|
|
11440
|
-
{
|
|
11441
|
-
size: "small",
|
|
11442
|
-
type: "submit",
|
|
11443
|
-
isLoading: isSubmitting || isAddingPromotions,
|
|
11444
|
-
children: "Save"
|
|
11445
|
-
}
|
|
11446
|
-
)
|
|
11447
|
-
] }) })
|
|
11448
|
-
] });
|
|
11449
|
-
};
|
|
11450
|
-
const PromotionItem = ({
|
|
11451
|
-
promotion,
|
|
11452
|
-
orderId,
|
|
11453
|
-
isLoading
|
|
11454
|
-
}) => {
|
|
11455
|
-
var _a;
|
|
11456
|
-
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
11457
|
-
const onRemove = async () => {
|
|
11458
|
-
removePromotions(
|
|
11459
|
-
{
|
|
11460
|
-
promo_codes: [promotion.code]
|
|
11461
|
-
},
|
|
11462
|
-
{
|
|
11463
|
-
onError: (e) => {
|
|
11464
|
-
toast.error(e.message);
|
|
11465
|
-
}
|
|
11466
|
-
}
|
|
11467
|
-
);
|
|
11468
|
-
};
|
|
11469
|
-
const displayValue = getDisplayValue(promotion);
|
|
11470
|
-
return /* @__PURE__ */ jsxs(
|
|
11471
|
-
"div",
|
|
11472
|
-
{
|
|
11473
|
-
className: clx(
|
|
11474
|
-
"bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
|
|
11475
|
-
{
|
|
11476
|
-
"animate-pulse": isLoading
|
|
11477
|
-
}
|
|
11478
|
-
),
|
|
11479
|
-
children: [
|
|
11480
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
11481
|
-
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
11482
|
-
/* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
|
|
11483
|
-
displayValue && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
11484
|
-
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: displayValue }),
|
|
11485
|
-
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", children: "·" })
|
|
11486
|
-
] }),
|
|
11487
|
-
/* @__PURE__ */ jsx(Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
|
|
11488
|
-
] })
|
|
11489
|
-
] }),
|
|
11490
|
-
/* @__PURE__ */ jsx(
|
|
11491
|
-
IconButton,
|
|
11492
|
-
{
|
|
11493
|
-
size: "small",
|
|
11494
|
-
type: "button",
|
|
11495
|
-
variant: "transparent",
|
|
11496
|
-
onClick: onRemove,
|
|
11497
|
-
isLoading: isPending || isLoading,
|
|
11498
|
-
children: /* @__PURE__ */ jsx(XMark, {})
|
|
11499
|
-
}
|
|
11500
|
-
)
|
|
11501
|
-
]
|
|
11502
|
-
},
|
|
11503
|
-
promotion.id
|
|
11504
|
-
);
|
|
11505
|
-
};
|
|
11506
|
-
function getDisplayValue(promotion) {
|
|
11507
|
-
var _a, _b, _c, _d;
|
|
11508
|
-
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
11509
|
-
if (!value) {
|
|
11510
|
-
return null;
|
|
11511
|
-
}
|
|
11512
|
-
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
11513
|
-
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
11514
|
-
if (!currency) {
|
|
11515
|
-
return null;
|
|
11516
|
-
}
|
|
11517
|
-
return getLocaleAmount(value, currency);
|
|
11518
|
-
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
11519
|
-
return formatPercentage(value);
|
|
11520
|
-
}
|
|
11521
|
-
return null;
|
|
11522
|
-
}
|
|
11523
|
-
const formatter = new Intl.NumberFormat([], {
|
|
11524
|
-
style: "percent",
|
|
11525
|
-
minimumFractionDigits: 2
|
|
11526
|
-
});
|
|
11527
|
-
const formatPercentage = (value, isPercentageValue = false) => {
|
|
11528
|
-
let val = value || 0;
|
|
11529
|
-
if (!isPercentageValue) {
|
|
11530
|
-
val = val / 100;
|
|
11531
|
-
}
|
|
11532
|
-
return formatter.format(val);
|
|
11533
|
-
};
|
|
11534
|
-
function getPromotionIds(items, shippingMethods) {
|
|
11535
|
-
const promotionIds = /* @__PURE__ */ new Set();
|
|
11536
|
-
for (const item of items) {
|
|
11537
|
-
if (item.adjustments) {
|
|
11538
|
-
for (const adjustment of item.adjustments) {
|
|
11539
|
-
if (adjustment.promotion_id) {
|
|
11540
|
-
promotionIds.add(adjustment.promotion_id);
|
|
11541
|
-
}
|
|
11542
|
-
}
|
|
11543
|
-
}
|
|
11544
|
-
}
|
|
11545
|
-
for (const shippingMethod of shippingMethods) {
|
|
11546
|
-
if (shippingMethod.adjustments) {
|
|
11547
|
-
for (const adjustment of shippingMethod.adjustments) {
|
|
11548
|
-
if (adjustment.promotion_id) {
|
|
11549
|
-
promotionIds.add(adjustment.promotion_id);
|
|
11550
|
-
}
|
|
11551
|
-
}
|
|
11552
|
-
}
|
|
11553
|
-
}
|
|
11554
|
-
return Array.from(promotionIds);
|
|
11555
|
-
}
|
|
11556
|
-
const ShippingAddress = () => {
|
|
11557
|
-
const { id } = useParams();
|
|
11558
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
11559
|
-
fields: "+shipping_address"
|
|
11560
|
-
});
|
|
11561
|
-
if (isError) {
|
|
11562
|
-
throw error;
|
|
11563
|
-
}
|
|
11564
|
-
const isReady = !isPending && !!order;
|
|
11565
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11566
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11567
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
|
|
11568
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
11569
|
-
] }),
|
|
11570
|
-
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
11571
|
-
] });
|
|
11572
|
-
};
|
|
11573
|
-
const ShippingAddressForm = ({ order }) => {
|
|
11574
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
11575
|
-
const form = useForm({
|
|
11576
|
-
defaultValues: {
|
|
11577
|
-
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
11578
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
11579
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
11580
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
11581
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
11582
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
11583
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
11584
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
11585
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11586
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11587
|
-
},
|
|
11588
|
-
resolver: zodResolver(schema$1)
|
|
11589
|
-
});
|
|
11590
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11591
|
-
const { handleSuccess } = useRouteModal();
|
|
11592
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11593
|
-
await mutateAsync(
|
|
11594
|
-
{
|
|
11595
|
-
shipping_address: {
|
|
11596
|
-
first_name: data.first_name,
|
|
11597
|
-
last_name: data.last_name,
|
|
11598
|
-
company: data.company,
|
|
11599
|
-
address_1: data.address_1,
|
|
11600
|
-
address_2: data.address_2,
|
|
11601
|
-
city: data.city,
|
|
11602
|
-
province: data.province,
|
|
11603
|
-
country_code: data.country_code,
|
|
11604
|
-
postal_code: data.postal_code,
|
|
11605
|
-
phone: data.phone
|
|
11606
|
-
}
|
|
11607
|
-
},
|
|
11608
|
-
{
|
|
11609
|
-
onSuccess: () => {
|
|
11610
|
-
handleSuccess();
|
|
11611
|
-
},
|
|
11612
|
-
onError: (error) => {
|
|
11613
|
-
toast.error(error.message);
|
|
11614
|
-
}
|
|
11615
|
-
}
|
|
11616
|
-
);
|
|
11617
|
-
});
|
|
11618
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11619
|
-
KeyboundForm,
|
|
11620
|
-
{
|
|
11621
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11622
|
-
onSubmit,
|
|
11623
|
-
children: [
|
|
11624
|
-
/* @__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: [
|
|
11625
|
-
/* @__PURE__ */ jsx(
|
|
11626
|
-
Form$2.Field,
|
|
11627
|
-
{
|
|
11628
|
-
control: form.control,
|
|
11629
|
-
name: "country_code",
|
|
11630
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11631
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
11632
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
11633
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11634
|
-
] })
|
|
11635
|
-
}
|
|
11636
|
-
),
|
|
11637
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11673
|
+
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
11674
|
+
/* @__PURE__ */ jsx(Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle rounded-xl shadow-elevation-card-rest", children: [
|
|
11675
|
+
/* @__PURE__ */ jsxs("div", { className: "px-4 py-2 flex items-center justify-between", children: [
|
|
11638
11676
|
/* @__PURE__ */ jsx(
|
|
11639
|
-
|
|
11677
|
+
Text,
|
|
11640
11678
|
{
|
|
11641
|
-
|
|
11642
|
-
|
|
11643
|
-
|
|
11644
|
-
|
|
11645
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11646
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11647
|
-
] })
|
|
11679
|
+
size: "xsmall",
|
|
11680
|
+
weight: "plus",
|
|
11681
|
+
className: "text-ui-fg-muted",
|
|
11682
|
+
children: "Shipping profile"
|
|
11648
11683
|
}
|
|
11649
11684
|
),
|
|
11650
11685
|
/* @__PURE__ */ jsx(
|
|
11651
|
-
|
|
11686
|
+
Text,
|
|
11652
11687
|
{
|
|
11653
|
-
|
|
11654
|
-
|
|
11655
|
-
|
|
11656
|
-
|
|
11657
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11658
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11659
|
-
] })
|
|
11660
|
-
}
|
|
11661
|
-
)
|
|
11662
|
-
] }),
|
|
11663
|
-
/* @__PURE__ */ jsx(
|
|
11664
|
-
Form$2.Field,
|
|
11665
|
-
{
|
|
11666
|
-
control: form.control,
|
|
11667
|
-
name: "company",
|
|
11668
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11669
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
11670
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11671
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11672
|
-
] })
|
|
11673
|
-
}
|
|
11674
|
-
),
|
|
11675
|
-
/* @__PURE__ */ jsx(
|
|
11676
|
-
Form$2.Field,
|
|
11677
|
-
{
|
|
11678
|
-
control: form.control,
|
|
11679
|
-
name: "address_1",
|
|
11680
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11681
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
11682
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11683
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11684
|
-
] })
|
|
11685
|
-
}
|
|
11686
|
-
),
|
|
11687
|
-
/* @__PURE__ */ jsx(
|
|
11688
|
-
Form$2.Field,
|
|
11689
|
-
{
|
|
11690
|
-
control: form.control,
|
|
11691
|
-
name: "address_2",
|
|
11692
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11693
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11694
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11695
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11696
|
-
] })
|
|
11697
|
-
}
|
|
11698
|
-
),
|
|
11699
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11700
|
-
/* @__PURE__ */ jsx(
|
|
11701
|
-
Form$2.Field,
|
|
11702
|
-
{
|
|
11703
|
-
control: form.control,
|
|
11704
|
-
name: "postal_code",
|
|
11705
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11706
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
11707
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11708
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11709
|
-
] })
|
|
11710
|
-
}
|
|
11711
|
-
),
|
|
11712
|
-
/* @__PURE__ */ jsx(
|
|
11713
|
-
Form$2.Field,
|
|
11714
|
-
{
|
|
11715
|
-
control: form.control,
|
|
11716
|
-
name: "city",
|
|
11717
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11718
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
11719
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11720
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11721
|
-
] })
|
|
11722
|
-
}
|
|
11723
|
-
)
|
|
11724
|
-
] }),
|
|
11725
|
-
/* @__PURE__ */ jsx(
|
|
11726
|
-
Form$2.Field,
|
|
11727
|
-
{
|
|
11728
|
-
control: form.control,
|
|
11729
|
-
name: "province",
|
|
11730
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11731
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11732
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11733
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11734
|
-
] })
|
|
11735
|
-
}
|
|
11736
|
-
),
|
|
11737
|
-
/* @__PURE__ */ jsx(
|
|
11738
|
-
Form$2.Field,
|
|
11739
|
-
{
|
|
11740
|
-
control: form.control,
|
|
11741
|
-
name: "phone",
|
|
11742
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
11743
|
-
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11744
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
11745
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11746
|
-
] })
|
|
11747
|
-
}
|
|
11748
|
-
)
|
|
11749
|
-
] }) }),
|
|
11750
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11751
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11752
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11753
|
-
] }) })
|
|
11754
|
-
]
|
|
11755
|
-
}
|
|
11756
|
-
) });
|
|
11757
|
-
};
|
|
11758
|
-
const schema$1 = addressSchema;
|
|
11759
|
-
const TransferOwnership = () => {
|
|
11760
|
-
const { id } = useParams();
|
|
11761
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
11762
|
-
fields: "id,customer_id,customer.*"
|
|
11763
|
-
});
|
|
11764
|
-
if (isError) {
|
|
11765
|
-
throw error;
|
|
11766
|
-
}
|
|
11767
|
-
const isReady = !isPending && !!draft_order;
|
|
11768
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
11769
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
11770
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
11771
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
|
|
11772
|
-
] }),
|
|
11773
|
-
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
11774
|
-
] });
|
|
11775
|
-
};
|
|
11776
|
-
const TransferOwnershipForm = ({ order }) => {
|
|
11777
|
-
var _a, _b;
|
|
11778
|
-
const form = useForm({
|
|
11779
|
-
defaultValues: {
|
|
11780
|
-
customer_id: order.customer_id || ""
|
|
11781
|
-
},
|
|
11782
|
-
resolver: zodResolver(schema)
|
|
11783
|
-
});
|
|
11784
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11785
|
-
const { handleSuccess } = useRouteModal();
|
|
11786
|
-
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
11787
|
-
const currentCustomer = order.customer ? {
|
|
11788
|
-
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
11789
|
-
value: order.customer.id
|
|
11790
|
-
} : null;
|
|
11791
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11792
|
-
await mutateAsync(
|
|
11793
|
-
{ customer_id: data.customer_id },
|
|
11794
|
-
{
|
|
11795
|
-
onSuccess: () => {
|
|
11796
|
-
toast.success("Customer updated");
|
|
11797
|
-
handleSuccess();
|
|
11798
|
-
},
|
|
11799
|
-
onError: (error) => {
|
|
11800
|
-
toast.error(error.message);
|
|
11801
|
-
}
|
|
11802
|
-
}
|
|
11803
|
-
);
|
|
11804
|
-
});
|
|
11805
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
11806
|
-
KeyboundForm,
|
|
11807
|
-
{
|
|
11808
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11809
|
-
onSubmit,
|
|
11810
|
-
children: [
|
|
11811
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
11812
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsx(Illustration, {}) }),
|
|
11813
|
-
currentCustomer && /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
11814
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
11815
|
-
/* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
11816
|
-
/* @__PURE__ */ jsx(Hint$1, { children: "The customer that is currently associated with this draft order." })
|
|
11817
|
-
] }),
|
|
11818
|
-
/* @__PURE__ */ jsxs(Select, { disabled: true, value: currentCustomer.value, children: [
|
|
11819
|
-
/* @__PURE__ */ jsx(Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
11820
|
-
/* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
11821
|
-
] })
|
|
11822
|
-
] }),
|
|
11823
|
-
/* @__PURE__ */ jsx(
|
|
11824
|
-
CustomerField,
|
|
11825
|
-
{
|
|
11826
|
-
control: form.control,
|
|
11827
|
-
currentCustomerId: order.customer_id
|
|
11828
|
-
}
|
|
11829
|
-
)
|
|
11830
|
-
] }),
|
|
11831
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
11832
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
11833
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11834
|
-
] }) })
|
|
11835
|
-
]
|
|
11836
|
-
}
|
|
11837
|
-
) });
|
|
11838
|
-
};
|
|
11839
|
-
const CustomerField = ({ control, currentCustomerId }) => {
|
|
11840
|
-
const customers = useComboboxData({
|
|
11841
|
-
queryFn: async (params) => {
|
|
11842
|
-
return await sdk.admin.customer.list({
|
|
11843
|
-
...params,
|
|
11844
|
-
id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
|
|
11845
|
-
});
|
|
11846
|
-
},
|
|
11847
|
-
queryKey: ["customers"],
|
|
11848
|
-
getOptions: (data) => {
|
|
11849
|
-
return data.customers.map((customer) => {
|
|
11850
|
-
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
11851
|
-
return {
|
|
11852
|
-
label: name ? `${name} (${customer.email})` : customer.email,
|
|
11853
|
-
value: customer.id
|
|
11854
|
-
};
|
|
11855
|
-
});
|
|
11856
|
-
}
|
|
11857
|
-
});
|
|
11858
|
-
return /* @__PURE__ */ jsx(
|
|
11859
|
-
Form$2.Field,
|
|
11860
|
-
{
|
|
11861
|
-
name: "customer_id",
|
|
11862
|
-
control,
|
|
11863
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { className: "space-y-3", children: [
|
|
11864
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
11865
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "New customer" }),
|
|
11866
|
-
/* @__PURE__ */ jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
|
|
11867
|
-
] }),
|
|
11868
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
11869
|
-
Combobox,
|
|
11870
|
-
{
|
|
11871
|
-
options: customers.options,
|
|
11872
|
-
fetchNextPage: customers.fetchNextPage,
|
|
11873
|
-
isFetchingNextPage: customers.isFetchingNextPage,
|
|
11874
|
-
searchValue: customers.searchValue,
|
|
11875
|
-
onSearchValueChange: customers.onSearchValueChange,
|
|
11876
|
-
placeholder: "Select customer",
|
|
11877
|
-
...field
|
|
11878
|
-
}
|
|
11879
|
-
) }),
|
|
11880
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
11881
|
-
] })
|
|
11882
|
-
}
|
|
11883
|
-
);
|
|
11884
|
-
};
|
|
11885
|
-
const Illustration = () => {
|
|
11886
|
-
return /* @__PURE__ */ jsxs(
|
|
11887
|
-
"svg",
|
|
11888
|
-
{
|
|
11889
|
-
width: "280",
|
|
11890
|
-
height: "180",
|
|
11891
|
-
viewBox: "0 0 280 180",
|
|
11892
|
-
fill: "none",
|
|
11893
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
11894
|
-
children: [
|
|
11895
|
-
/* @__PURE__ */ jsx(
|
|
11896
|
-
"rect",
|
|
11897
|
-
{
|
|
11898
|
-
x: "0.00428286",
|
|
11899
|
-
y: "-0.742904",
|
|
11900
|
-
width: "33.5",
|
|
11901
|
-
height: "65.5",
|
|
11902
|
-
rx: "6.75",
|
|
11903
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
|
|
11904
|
-
fill: "#D4D4D8",
|
|
11905
|
-
stroke: "#52525B",
|
|
11906
|
-
strokeWidth: "1.5"
|
|
11907
|
-
}
|
|
11908
|
-
),
|
|
11909
|
-
/* @__PURE__ */ jsx(
|
|
11910
|
-
"rect",
|
|
11911
|
-
{
|
|
11912
|
-
x: "0.00428286",
|
|
11913
|
-
y: "-0.742904",
|
|
11914
|
-
width: "33.5",
|
|
11915
|
-
height: "65.5",
|
|
11916
|
-
rx: "6.75",
|
|
11917
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
|
|
11918
|
-
fill: "white",
|
|
11919
|
-
stroke: "#52525B",
|
|
11920
|
-
strokeWidth: "1.5"
|
|
11921
|
-
}
|
|
11922
|
-
),
|
|
11923
|
-
/* @__PURE__ */ jsx(
|
|
11924
|
-
"path",
|
|
11925
|
-
{
|
|
11926
|
-
d: "M180.579 107.142L179.126 107.959",
|
|
11927
|
-
stroke: "#52525B",
|
|
11928
|
-
strokeWidth: "1.5",
|
|
11929
|
-
strokeLinecap: "round",
|
|
11930
|
-
strokeLinejoin: "round"
|
|
11931
|
-
}
|
|
11932
|
-
),
|
|
11933
|
-
/* @__PURE__ */ jsx(
|
|
11934
|
-
"path",
|
|
11935
|
-
{
|
|
11936
|
-
opacity: "0.88",
|
|
11937
|
-
d: "M182.305 109.546L180.257 109.534",
|
|
11938
|
-
stroke: "#52525B",
|
|
11939
|
-
strokeWidth: "1.5",
|
|
11940
|
-
strokeLinecap: "round",
|
|
11941
|
-
strokeLinejoin: "round"
|
|
11942
|
-
}
|
|
11943
|
-
),
|
|
11944
|
-
/* @__PURE__ */ jsx(
|
|
11945
|
-
"path",
|
|
11946
|
-
{
|
|
11947
|
-
opacity: "0.75",
|
|
11948
|
-
d: "M180.551 111.93L179.108 111.096",
|
|
11949
|
-
stroke: "#52525B",
|
|
11950
|
-
strokeWidth: "1.5",
|
|
11951
|
-
strokeLinecap: "round",
|
|
11952
|
-
strokeLinejoin: "round"
|
|
11953
|
-
}
|
|
11954
|
-
),
|
|
11955
|
-
/* @__PURE__ */ jsx(
|
|
11956
|
-
"path",
|
|
11957
|
-
{
|
|
11958
|
-
opacity: "0.63",
|
|
11959
|
-
d: "M176.347 112.897L176.354 111.73",
|
|
11960
|
-
stroke: "#52525B",
|
|
11961
|
-
strokeWidth: "1.5",
|
|
11962
|
-
strokeLinecap: "round",
|
|
11963
|
-
strokeLinejoin: "round"
|
|
11964
|
-
}
|
|
11965
|
-
),
|
|
11966
|
-
/* @__PURE__ */ jsx(
|
|
11967
|
-
"path",
|
|
11968
|
-
{
|
|
11969
|
-
opacity: "0.5",
|
|
11970
|
-
d: "M172.153 111.881L173.606 111.064",
|
|
11971
|
-
stroke: "#52525B",
|
|
11972
|
-
strokeWidth: "1.5",
|
|
11973
|
-
strokeLinecap: "round",
|
|
11974
|
-
strokeLinejoin: "round"
|
|
11975
|
-
}
|
|
11976
|
-
),
|
|
11977
|
-
/* @__PURE__ */ jsx(
|
|
11978
|
-
"path",
|
|
11979
|
-
{
|
|
11980
|
-
opacity: "0.38",
|
|
11981
|
-
d: "M170.428 109.478L172.476 109.489",
|
|
11982
|
-
stroke: "#52525B",
|
|
11983
|
-
strokeWidth: "1.5",
|
|
11984
|
-
strokeLinecap: "round",
|
|
11985
|
-
strokeLinejoin: "round"
|
|
11986
|
-
}
|
|
11987
|
-
),
|
|
11988
|
-
/* @__PURE__ */ jsx(
|
|
11989
|
-
"path",
|
|
11990
|
-
{
|
|
11991
|
-
opacity: "0.25",
|
|
11992
|
-
d: "M172.181 107.094L173.624 107.928",
|
|
11993
|
-
stroke: "#52525B",
|
|
11994
|
-
strokeWidth: "1.5",
|
|
11995
|
-
strokeLinecap: "round",
|
|
11996
|
-
strokeLinejoin: "round"
|
|
11997
|
-
}
|
|
11998
|
-
),
|
|
11999
|
-
/* @__PURE__ */ jsx(
|
|
12000
|
-
"path",
|
|
12001
|
-
{
|
|
12002
|
-
opacity: "0.13",
|
|
12003
|
-
d: "M176.386 106.126L176.379 107.294",
|
|
12004
|
-
stroke: "#52525B",
|
|
12005
|
-
strokeWidth: "1.5",
|
|
12006
|
-
strokeLinecap: "round",
|
|
12007
|
-
strokeLinejoin: "round"
|
|
12008
|
-
}
|
|
12009
|
-
),
|
|
12010
|
-
/* @__PURE__ */ jsx(
|
|
12011
|
-
"rect",
|
|
12012
|
-
{
|
|
12013
|
-
width: "12",
|
|
12014
|
-
height: "3",
|
|
12015
|
-
rx: "1.5",
|
|
12016
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
|
|
12017
|
-
fill: "#D4D4D8"
|
|
12018
|
-
}
|
|
12019
|
-
),
|
|
12020
|
-
/* @__PURE__ */ jsx(
|
|
12021
|
-
"rect",
|
|
12022
|
-
{
|
|
12023
|
-
x: "0.00428286",
|
|
12024
|
-
y: "-0.742904",
|
|
12025
|
-
width: "33.5",
|
|
12026
|
-
height: "65.5",
|
|
12027
|
-
rx: "6.75",
|
|
12028
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
|
|
12029
|
-
fill: "#D4D4D8",
|
|
12030
|
-
stroke: "#52525B",
|
|
12031
|
-
strokeWidth: "1.5"
|
|
12032
|
-
}
|
|
12033
|
-
),
|
|
12034
|
-
/* @__PURE__ */ jsx(
|
|
12035
|
-
"rect",
|
|
12036
|
-
{
|
|
12037
|
-
x: "0.00428286",
|
|
12038
|
-
y: "-0.742904",
|
|
12039
|
-
width: "33.5",
|
|
12040
|
-
height: "65.5",
|
|
12041
|
-
rx: "6.75",
|
|
12042
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
|
|
12043
|
-
fill: "white",
|
|
12044
|
-
stroke: "#52525B",
|
|
12045
|
-
strokeWidth: "1.5"
|
|
12046
|
-
}
|
|
12047
|
-
),
|
|
12048
|
-
/* @__PURE__ */ jsx(
|
|
12049
|
-
"rect",
|
|
12050
|
-
{
|
|
12051
|
-
width: "12",
|
|
12052
|
-
height: "3",
|
|
12053
|
-
rx: "1.5",
|
|
12054
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
|
|
12055
|
-
fill: "#D4D4D8"
|
|
12056
|
-
}
|
|
12057
|
-
),
|
|
12058
|
-
/* @__PURE__ */ jsx(
|
|
12059
|
-
"rect",
|
|
12060
|
-
{
|
|
12061
|
-
width: "17",
|
|
12062
|
-
height: "3",
|
|
12063
|
-
rx: "1.5",
|
|
12064
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
|
|
12065
|
-
fill: "#D4D4D8"
|
|
12066
|
-
}
|
|
12067
|
-
),
|
|
12068
|
-
/* @__PURE__ */ jsx(
|
|
12069
|
-
"rect",
|
|
12070
|
-
{
|
|
12071
|
-
width: "12",
|
|
12072
|
-
height: "3",
|
|
12073
|
-
rx: "1.5",
|
|
12074
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
|
|
12075
|
-
fill: "#D4D4D8"
|
|
12076
|
-
}
|
|
12077
|
-
),
|
|
12078
|
-
/* @__PURE__ */ jsx(
|
|
12079
|
-
"path",
|
|
12080
|
-
{
|
|
12081
|
-
d: "M92.3603 63.9563C90.9277 63.1286 88.59 63.1152 87.148 63.9263C85.7059 64.7374 85.6983 66.0702 87.1308 66.8979C88.5634 67.7256 90.9011 67.7391 92.3432 66.928C93.7852 66.1168 93.7929 64.784 92.3603 63.9563ZM88.4382 66.1625C87.7221 65.7488 87.726 65.0822 88.4468 64.6767C89.1676 64.2713 90.3369 64.278 91.0529 64.6917C91.769 65.1055 91.7652 65.7721 91.0444 66.1775C90.3236 66.583 89.1543 66.5762 88.4382 66.1625Z",
|
|
12082
|
-
fill: "#A1A1AA"
|
|
12083
|
-
}
|
|
12084
|
-
),
|
|
12085
|
-
/* @__PURE__ */ jsx(
|
|
12086
|
-
"rect",
|
|
12087
|
-
{
|
|
12088
|
-
width: "17",
|
|
12089
|
-
height: "3",
|
|
12090
|
-
rx: "1.5",
|
|
12091
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
|
|
12092
|
-
fill: "#A1A1AA"
|
|
12093
|
-
}
|
|
12094
|
-
),
|
|
12095
|
-
/* @__PURE__ */ jsx(
|
|
12096
|
-
"rect",
|
|
12097
|
-
{
|
|
12098
|
-
width: "12",
|
|
12099
|
-
height: "3",
|
|
12100
|
-
rx: "1.5",
|
|
12101
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
|
|
12102
|
-
fill: "#A1A1AA"
|
|
12103
|
-
}
|
|
12104
|
-
),
|
|
12105
|
-
/* @__PURE__ */ jsx(
|
|
12106
|
-
"path",
|
|
12107
|
-
{
|
|
12108
|
-
d: "M104.562 57.0927C103.13 56.265 100.792 56.2515 99.3501 57.0626C97.9081 57.8738 97.9004 59.2065 99.333 60.0343C100.766 60.862 103.103 60.8754 104.545 60.0643C105.987 59.2532 105.995 57.9204 104.562 57.0927ZM103.858 58.8972L100.815 59.1265C100.683 59.1367 100.55 59.1134 100.449 59.063C100.44 59.0585 100.432 59.0545 100.425 59.05C100.339 59.0005 100.29 58.9336 100.291 58.8637L100.294 58.1201C100.294 57.9752 100.501 57.8585 100.756 57.86C101.01 57.8615 101.217 57.98 101.216 58.1256L101.214 58.5669L103.732 58.3769C103.984 58.3578 104.217 58.4584 104.251 58.603C104.286 58.7468 104.11 58.8788 103.858 58.8977L103.858 58.8972Z",
|
|
12109
|
-
fill: "#52525B"
|
|
12110
|
-
}
|
|
12111
|
-
),
|
|
12112
|
-
/* @__PURE__ */ jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsx(
|
|
12113
|
-
"path",
|
|
12114
|
-
{
|
|
12115
|
-
d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
|
|
12116
|
-
stroke: "#A1A1AA",
|
|
12117
|
-
strokeWidth: "1.5",
|
|
12118
|
-
strokeLinecap: "round",
|
|
12119
|
-
strokeLinejoin: "round"
|
|
12120
|
-
}
|
|
12121
|
-
) }),
|
|
12122
|
-
/* @__PURE__ */ jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsx(
|
|
12123
|
-
"path",
|
|
12124
|
-
{
|
|
12125
|
-
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
12126
|
-
stroke: "#A1A1AA",
|
|
12127
|
-
strokeWidth: "1.5",
|
|
12128
|
-
strokeLinecap: "round",
|
|
12129
|
-
strokeLinejoin: "round"
|
|
12130
|
-
}
|
|
12131
|
-
) }),
|
|
12132
|
-
/* @__PURE__ */ jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsx(
|
|
12133
|
-
"path",
|
|
12134
|
-
{
|
|
12135
|
-
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
12136
|
-
stroke: "#A1A1AA",
|
|
12137
|
-
strokeWidth: "1.5",
|
|
12138
|
-
strokeLinecap: "round",
|
|
12139
|
-
strokeLinejoin: "round"
|
|
12140
|
-
}
|
|
12141
|
-
) }),
|
|
12142
|
-
/* @__PURE__ */ jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsx(
|
|
12143
|
-
"path",
|
|
12144
|
-
{
|
|
12145
|
-
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
12146
|
-
stroke: "#A1A1AA",
|
|
12147
|
-
strokeWidth: "1.5",
|
|
12148
|
-
strokeLinecap: "round",
|
|
12149
|
-
strokeLinejoin: "round"
|
|
12150
|
-
}
|
|
12151
|
-
) }),
|
|
12152
|
-
/* @__PURE__ */ jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsx(
|
|
12153
|
-
"path",
|
|
12154
|
-
{
|
|
12155
|
-
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
12156
|
-
stroke: "#A1A1AA",
|
|
12157
|
-
strokeWidth: "1.5",
|
|
12158
|
-
strokeLinecap: "round",
|
|
12159
|
-
strokeLinejoin: "round"
|
|
12160
|
-
}
|
|
12161
|
-
) }),
|
|
12162
|
-
/* @__PURE__ */ jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsx(
|
|
12163
|
-
"path",
|
|
12164
|
-
{
|
|
12165
|
-
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
12166
|
-
stroke: "#A1A1AA",
|
|
12167
|
-
strokeWidth: "1.5",
|
|
12168
|
-
strokeLinecap: "round",
|
|
12169
|
-
strokeLinejoin: "round"
|
|
12170
|
-
}
|
|
12171
|
-
) }),
|
|
12172
|
-
/* @__PURE__ */ jsxs("defs", { children: [
|
|
12173
|
-
/* @__PURE__ */ jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsx(
|
|
12174
|
-
"rect",
|
|
12175
|
-
{
|
|
12176
|
-
width: "12",
|
|
12177
|
-
height: "12",
|
|
12178
|
-
fill: "white",
|
|
12179
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12180
|
-
}
|
|
12181
|
-
) }),
|
|
12182
|
-
/* @__PURE__ */ jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsx(
|
|
12183
|
-
"rect",
|
|
12184
|
-
{
|
|
12185
|
-
width: "12",
|
|
12186
|
-
height: "12",
|
|
12187
|
-
fill: "white",
|
|
12188
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
12189
|
-
}
|
|
12190
|
-
) }),
|
|
12191
|
-
/* @__PURE__ */ jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsx(
|
|
12192
|
-
"rect",
|
|
12193
|
-
{
|
|
12194
|
-
width: "12",
|
|
12195
|
-
height: "12",
|
|
12196
|
-
fill: "white",
|
|
12197
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
12198
|
-
}
|
|
12199
|
-
) }),
|
|
12200
|
-
/* @__PURE__ */ jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsx(
|
|
12201
|
-
"rect",
|
|
12202
|
-
{
|
|
12203
|
-
width: "12",
|
|
12204
|
-
height: "12",
|
|
12205
|
-
fill: "white",
|
|
12206
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
12207
|
-
}
|
|
12208
|
-
) }),
|
|
12209
|
-
/* @__PURE__ */ jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsx(
|
|
12210
|
-
"rect",
|
|
12211
|
-
{
|
|
12212
|
-
width: "12",
|
|
12213
|
-
height: "12",
|
|
12214
|
-
fill: "white",
|
|
12215
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
12216
|
-
}
|
|
12217
|
-
) }),
|
|
12218
|
-
/* @__PURE__ */ jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsx(
|
|
12219
|
-
"rect",
|
|
12220
|
-
{
|
|
12221
|
-
width: "12",
|
|
12222
|
-
height: "12",
|
|
12223
|
-
fill: "white",
|
|
12224
|
-
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
12225
|
-
}
|
|
12226
|
-
) })
|
|
12227
|
-
] })
|
|
12228
|
-
]
|
|
12229
|
-
}
|
|
12230
|
-
);
|
|
12231
|
-
};
|
|
12232
|
-
const schema = objectType({
|
|
12233
|
-
customer_id: stringType().min(1)
|
|
12234
|
-
});
|
|
12235
|
-
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
12236
|
-
const Shipping = () => {
|
|
12237
|
-
var _a;
|
|
12238
|
-
const { id } = useParams();
|
|
12239
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
12240
|
-
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
12241
|
-
});
|
|
12242
|
-
const {
|
|
12243
|
-
order: preview,
|
|
12244
|
-
isPending: isPreviewPending,
|
|
12245
|
-
isError: isPreviewError,
|
|
12246
|
-
error: previewError
|
|
12247
|
-
} = useOrderPreview(id);
|
|
12248
|
-
useInitiateOrderEdit({ preview });
|
|
12249
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
12250
|
-
if (isError) {
|
|
12251
|
-
throw error;
|
|
12252
|
-
}
|
|
12253
|
-
if (isPreviewError) {
|
|
12254
|
-
throw previewError;
|
|
12255
|
-
}
|
|
12256
|
-
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
12257
|
-
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
12258
|
-
return /* @__PURE__ */ jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
12259
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
12260
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
|
|
12261
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
12262
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
12263
|
-
] }) }) }),
|
|
12264
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
12265
|
-
] }) : isReady ? /* @__PURE__ */ jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
12266
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
12267
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
12268
|
-
] }) });
|
|
12269
|
-
};
|
|
12270
|
-
const ShippingForm = ({ preview, order }) => {
|
|
12271
|
-
var _a;
|
|
12272
|
-
const { setIsOpen } = useStackedModal();
|
|
12273
|
-
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
12274
|
-
const [data, setData] = useState(null);
|
|
12275
|
-
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
12276
|
-
const { shipping_options } = useShippingOptions(
|
|
12277
|
-
{
|
|
12278
|
-
id: appliedShippingOptionIds,
|
|
12279
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
12280
|
-
},
|
|
12281
|
-
{
|
|
12282
|
-
enabled: appliedShippingOptionIds.length > 0
|
|
12283
|
-
}
|
|
12284
|
-
);
|
|
12285
|
-
const uniqueShippingProfiles = useMemo(() => {
|
|
12286
|
-
const profiles = /* @__PURE__ */ new Map();
|
|
12287
|
-
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
12288
|
-
profiles.set(profile.id, profile);
|
|
12289
|
-
});
|
|
12290
|
-
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
12291
|
-
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
12292
|
-
});
|
|
12293
|
-
return Array.from(profiles.values());
|
|
12294
|
-
}, [order.items, shipping_options]);
|
|
12295
|
-
const { handleSuccess } = useRouteModal();
|
|
12296
|
-
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
12297
|
-
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
12298
|
-
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
12299
|
-
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
12300
|
-
const onSubmit = async () => {
|
|
12301
|
-
setIsSubmitting(true);
|
|
12302
|
-
let requestSucceeded = false;
|
|
12303
|
-
await requestOrderEdit(void 0, {
|
|
12304
|
-
onError: (e) => {
|
|
12305
|
-
toast.error(`Failed to request order edit: ${e.message}`);
|
|
12306
|
-
},
|
|
12307
|
-
onSuccess: () => {
|
|
12308
|
-
requestSucceeded = true;
|
|
12309
|
-
}
|
|
12310
|
-
});
|
|
12311
|
-
if (!requestSucceeded) {
|
|
12312
|
-
setIsSubmitting(false);
|
|
12313
|
-
return;
|
|
12314
|
-
}
|
|
12315
|
-
await confirmOrderEdit(void 0, {
|
|
12316
|
-
onError: (e) => {
|
|
12317
|
-
toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
12318
|
-
},
|
|
12319
|
-
onSuccess: () => {
|
|
12320
|
-
handleSuccess();
|
|
12321
|
-
},
|
|
12322
|
-
onSettled: () => {
|
|
12323
|
-
setIsSubmitting(false);
|
|
12324
|
-
}
|
|
12325
|
-
});
|
|
12326
|
-
};
|
|
12327
|
-
const onKeydown = useCallback(
|
|
12328
|
-
(e) => {
|
|
12329
|
-
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
12330
|
-
if (data || isSubmitting) {
|
|
12331
|
-
return;
|
|
12332
|
-
}
|
|
12333
|
-
onSubmit();
|
|
12334
|
-
}
|
|
12335
|
-
},
|
|
12336
|
-
[data, isSubmitting, onSubmit]
|
|
12337
|
-
);
|
|
12338
|
-
useEffect(() => {
|
|
12339
|
-
document.addEventListener("keydown", onKeydown);
|
|
12340
|
-
return () => {
|
|
12341
|
-
document.removeEventListener("keydown", onKeydown);
|
|
12342
|
-
};
|
|
12343
|
-
}, [onKeydown]);
|
|
12344
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
12345
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
12346
|
-
/* @__PURE__ */ jsxs(RouteFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: [
|
|
12347
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
|
|
12348
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
12349
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
12350
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Choose which shipping method(s) to use for the items in the order." }) })
|
|
12351
|
-
] }),
|
|
12352
|
-
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
12353
|
-
/* @__PURE__ */ jsx(Accordion.Root, { type: "multiple", children: /* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle rounded-xl shadow-elevation-card-rest", children: [
|
|
12354
|
-
/* @__PURE__ */ jsxs("div", { className: "px-4 py-2 flex items-center justify-between", children: [
|
|
12355
|
-
/* @__PURE__ */ jsx(
|
|
12356
|
-
Text,
|
|
12357
|
-
{
|
|
12358
|
-
size: "xsmall",
|
|
12359
|
-
weight: "plus",
|
|
12360
|
-
className: "text-ui-fg-muted",
|
|
12361
|
-
children: "Shipping profile"
|
|
12362
|
-
}
|
|
12363
|
-
),
|
|
12364
|
-
/* @__PURE__ */ jsx(
|
|
12365
|
-
Text,
|
|
12366
|
-
{
|
|
12367
|
-
size: "xsmall",
|
|
12368
|
-
weight: "plus",
|
|
12369
|
-
className: "text-ui-fg-muted",
|
|
12370
|
-
children: "Action"
|
|
11688
|
+
size: "xsmall",
|
|
11689
|
+
weight: "plus",
|
|
11690
|
+
className: "text-ui-fg-muted",
|
|
11691
|
+
children: "Action"
|
|
12371
11692
|
}
|
|
12372
11693
|
)
|
|
12373
11694
|
] }),
|
|
@@ -12629,416 +11950,1095 @@ const ShippingForm = ({ preview, order }) => {
|
|
|
12629
11950
|
if (!open) {
|
|
12630
11951
|
setData(null);
|
|
12631
11952
|
}
|
|
12632
|
-
return open;
|
|
12633
|
-
},
|
|
12634
|
-
children: data && /* @__PURE__ */ jsx(ShippingProfileForm, { data, order, preview })
|
|
12635
|
-
}
|
|
12636
|
-
)
|
|
12637
|
-
] }),
|
|
12638
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-x-2", children: [
|
|
12639
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
12640
|
-
/* @__PURE__ */ jsx(
|
|
12641
|
-
Button,
|
|
11953
|
+
return open;
|
|
11954
|
+
},
|
|
11955
|
+
children: data && /* @__PURE__ */ jsx(ShippingProfileForm, { data, order, preview })
|
|
11956
|
+
}
|
|
11957
|
+
)
|
|
11958
|
+
] }),
|
|
11959
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-x-2", children: [
|
|
11960
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
11961
|
+
/* @__PURE__ */ jsx(
|
|
11962
|
+
Button,
|
|
11963
|
+
{
|
|
11964
|
+
size: "small",
|
|
11965
|
+
type: "button",
|
|
11966
|
+
isLoading: isSubmitting,
|
|
11967
|
+
onClick: onSubmit,
|
|
11968
|
+
children: "Save"
|
|
11969
|
+
}
|
|
11970
|
+
)
|
|
11971
|
+
] }) })
|
|
11972
|
+
] });
|
|
11973
|
+
};
|
|
11974
|
+
const StackedModalTrigger = ({
|
|
11975
|
+
shippingProfileId,
|
|
11976
|
+
shippingOption,
|
|
11977
|
+
shippingMethod,
|
|
11978
|
+
setData,
|
|
11979
|
+
children
|
|
11980
|
+
}) => {
|
|
11981
|
+
const { setIsOpen, getIsOpen } = useStackedModal();
|
|
11982
|
+
const isOpen = getIsOpen(STACKED_FOCUS_MODAL_ID);
|
|
11983
|
+
const onToggle = () => {
|
|
11984
|
+
if (isOpen) {
|
|
11985
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
11986
|
+
setData(null);
|
|
11987
|
+
} else {
|
|
11988
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, true);
|
|
11989
|
+
setData({
|
|
11990
|
+
shippingProfileId,
|
|
11991
|
+
shippingOption,
|
|
11992
|
+
shippingMethod
|
|
11993
|
+
});
|
|
11994
|
+
}
|
|
11995
|
+
};
|
|
11996
|
+
return /* @__PURE__ */ jsx(
|
|
11997
|
+
Button,
|
|
11998
|
+
{
|
|
11999
|
+
size: "small",
|
|
12000
|
+
variant: "secondary",
|
|
12001
|
+
onClick: onToggle,
|
|
12002
|
+
className: "text-ui-fg-primary shrink-0",
|
|
12003
|
+
children
|
|
12004
|
+
}
|
|
12005
|
+
);
|
|
12006
|
+
};
|
|
12007
|
+
const ShippingProfileForm = ({
|
|
12008
|
+
data,
|
|
12009
|
+
order,
|
|
12010
|
+
preview
|
|
12011
|
+
}) => {
|
|
12012
|
+
var _a, _b, _c, _d, _e, _f;
|
|
12013
|
+
const { setIsOpen } = useStackedModal();
|
|
12014
|
+
const form = useForm({
|
|
12015
|
+
resolver: zodResolver(shippingMethodSchema),
|
|
12016
|
+
defaultValues: {
|
|
12017
|
+
location_id: (_d = (_c = (_b = (_a = data.shippingOption) == null ? void 0 : _a.service_zone) == null ? void 0 : _b.fulfillment_set) == null ? void 0 : _c.location) == null ? void 0 : _d.id,
|
|
12018
|
+
shipping_option_id: (_e = data.shippingOption) == null ? void 0 : _e.id,
|
|
12019
|
+
custom_amount: (_f = data.shippingMethod) == null ? void 0 : _f.amount
|
|
12020
|
+
}
|
|
12021
|
+
});
|
|
12022
|
+
const { mutateAsync: addShippingMethod, isPending } = useDraftOrderAddShippingMethod(order.id);
|
|
12023
|
+
const {
|
|
12024
|
+
mutateAsync: updateShippingMethod,
|
|
12025
|
+
isPending: isUpdatingShippingMethod
|
|
12026
|
+
} = useDraftOrderUpdateShippingMethod(order.id);
|
|
12027
|
+
const onSubmit = form.handleSubmit(async (values) => {
|
|
12028
|
+
if (isEqual(values, form.formState.defaultValues)) {
|
|
12029
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
12030
|
+
return;
|
|
12031
|
+
}
|
|
12032
|
+
if (data.shippingMethod) {
|
|
12033
|
+
await updateShippingMethod(
|
|
12034
|
+
{
|
|
12035
|
+
method_id: data.shippingMethod.id,
|
|
12036
|
+
shipping_option_id: values.shipping_option_id,
|
|
12037
|
+
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
12038
|
+
},
|
|
12039
|
+
{
|
|
12040
|
+
onError: (e) => {
|
|
12041
|
+
toast.error(e.message);
|
|
12042
|
+
},
|
|
12043
|
+
onSuccess: () => {
|
|
12044
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
12045
|
+
}
|
|
12046
|
+
}
|
|
12047
|
+
);
|
|
12048
|
+
return;
|
|
12049
|
+
}
|
|
12050
|
+
await addShippingMethod(
|
|
12051
|
+
{
|
|
12052
|
+
shipping_option_id: values.shipping_option_id,
|
|
12053
|
+
custom_amount: values.custom_amount ? convertNumber(values.custom_amount) : void 0
|
|
12054
|
+
},
|
|
12055
|
+
{
|
|
12056
|
+
onError: (e) => {
|
|
12057
|
+
toast.error(e.message);
|
|
12058
|
+
},
|
|
12059
|
+
onSuccess: () => {
|
|
12060
|
+
setIsOpen(STACKED_FOCUS_MODAL_ID, false);
|
|
12061
|
+
}
|
|
12062
|
+
}
|
|
12063
|
+
);
|
|
12064
|
+
});
|
|
12065
|
+
return /* @__PURE__ */ jsx(StackedFocusModal.Content, { children: /* @__PURE__ */ jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxs(
|
|
12066
|
+
KeyboundForm,
|
|
12067
|
+
{
|
|
12068
|
+
className: "flex h-full flex-col overflow-hidden",
|
|
12069
|
+
onSubmit,
|
|
12070
|
+
children: [
|
|
12071
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Header, {}),
|
|
12072
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 py-16 px-6", children: [
|
|
12073
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
12074
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Shipping" }) }),
|
|
12075
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a shipping method for the selected shipping profile. You can see the items that will be shipped using this method in the preview below." }) })
|
|
12076
|
+
] }),
|
|
12077
|
+
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
12078
|
+
/* @__PURE__ */ jsx(
|
|
12079
|
+
LocationField,
|
|
12080
|
+
{
|
|
12081
|
+
control: form.control,
|
|
12082
|
+
setValue: form.setValue
|
|
12083
|
+
}
|
|
12084
|
+
),
|
|
12085
|
+
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
12086
|
+
/* @__PURE__ */ jsx(
|
|
12087
|
+
ShippingOptionField,
|
|
12088
|
+
{
|
|
12089
|
+
shippingProfileId: data.shippingProfileId,
|
|
12090
|
+
preview,
|
|
12091
|
+
control: form.control
|
|
12092
|
+
}
|
|
12093
|
+
),
|
|
12094
|
+
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
12095
|
+
/* @__PURE__ */ jsx(
|
|
12096
|
+
CustomAmountField,
|
|
12097
|
+
{
|
|
12098
|
+
control: form.control,
|
|
12099
|
+
currencyCode: order.currency_code
|
|
12100
|
+
}
|
|
12101
|
+
),
|
|
12102
|
+
/* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
|
|
12103
|
+
/* @__PURE__ */ jsx(
|
|
12104
|
+
ItemsPreview,
|
|
12105
|
+
{
|
|
12106
|
+
order,
|
|
12107
|
+
shippingProfileId: data.shippingProfileId
|
|
12108
|
+
}
|
|
12109
|
+
)
|
|
12110
|
+
] }) }) }),
|
|
12111
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-x-2", children: [
|
|
12112
|
+
/* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
12113
|
+
/* @__PURE__ */ jsx(
|
|
12114
|
+
Button,
|
|
12115
|
+
{
|
|
12116
|
+
size: "small",
|
|
12117
|
+
type: "submit",
|
|
12118
|
+
isLoading: isPending || isUpdatingShippingMethod,
|
|
12119
|
+
children: data.shippingMethod ? "Update" : "Add"
|
|
12120
|
+
}
|
|
12121
|
+
)
|
|
12122
|
+
] }) })
|
|
12123
|
+
]
|
|
12124
|
+
}
|
|
12125
|
+
) }) });
|
|
12126
|
+
};
|
|
12127
|
+
const shippingMethodSchema = objectType({
|
|
12128
|
+
location_id: stringType(),
|
|
12129
|
+
shipping_option_id: stringType(),
|
|
12130
|
+
custom_amount: unionType([numberType(), stringType()]).optional()
|
|
12131
|
+
});
|
|
12132
|
+
const ItemsPreview = ({ order, shippingProfileId }) => {
|
|
12133
|
+
const matches = order.items.filter(
|
|
12134
|
+
(item) => {
|
|
12135
|
+
var _a, _b, _c;
|
|
12136
|
+
return ((_c = (_b = (_a = item.variant) == null ? void 0 : _a.product) == null ? void 0 : _b.shipping_profile) == null ? void 0 : _c.id) === shippingProfileId;
|
|
12137
|
+
}
|
|
12138
|
+
);
|
|
12139
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-6", children: [
|
|
12140
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 items-center gap-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12141
|
+
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "Items to ship" }),
|
|
12142
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
|
|
12143
|
+
] }) }),
|
|
12144
|
+
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
12145
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-3 px-4 py-2 text-ui-fg-muted", children: [
|
|
12146
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Item" }) }),
|
|
12147
|
+
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Quantity" }) })
|
|
12148
|
+
] }),
|
|
12149
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsxs(
|
|
12150
|
+
"div",
|
|
12642
12151
|
{
|
|
12643
|
-
|
|
12644
|
-
|
|
12645
|
-
|
|
12646
|
-
|
|
12647
|
-
|
|
12648
|
-
|
|
12649
|
-
|
|
12650
|
-
|
|
12152
|
+
className: "grid grid-cols-2 gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center",
|
|
12153
|
+
children: [
|
|
12154
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
12155
|
+
/* @__PURE__ */ jsx(
|
|
12156
|
+
Thumbnail,
|
|
12157
|
+
{
|
|
12158
|
+
thumbnail: item.thumbnail,
|
|
12159
|
+
alt: item.product_title ?? void 0
|
|
12160
|
+
}
|
|
12161
|
+
),
|
|
12162
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12163
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
12164
|
+
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
|
|
12165
|
+
/* @__PURE__ */ jsxs(
|
|
12166
|
+
Text,
|
|
12167
|
+
{
|
|
12168
|
+
size: "small",
|
|
12169
|
+
leading: "compact",
|
|
12170
|
+
className: "text-ui-fg-subtle",
|
|
12171
|
+
children: [
|
|
12172
|
+
"(",
|
|
12173
|
+
item.variant_title,
|
|
12174
|
+
")"
|
|
12175
|
+
]
|
|
12176
|
+
}
|
|
12177
|
+
)
|
|
12178
|
+
] }),
|
|
12179
|
+
/* @__PURE__ */ jsx(
|
|
12180
|
+
Text,
|
|
12181
|
+
{
|
|
12182
|
+
size: "small",
|
|
12183
|
+
leading: "compact",
|
|
12184
|
+
className: "text-ui-fg-subtle",
|
|
12185
|
+
children: item.variant_sku
|
|
12186
|
+
}
|
|
12187
|
+
)
|
|
12188
|
+
] })
|
|
12189
|
+
] }),
|
|
12190
|
+
/* @__PURE__ */ jsxs(
|
|
12191
|
+
Text,
|
|
12192
|
+
{
|
|
12193
|
+
size: "small",
|
|
12194
|
+
leading: "compact",
|
|
12195
|
+
className: "text-ui-fg-subtle",
|
|
12196
|
+
children: [
|
|
12197
|
+
item.quantity,
|
|
12198
|
+
"x"
|
|
12199
|
+
]
|
|
12200
|
+
}
|
|
12201
|
+
)
|
|
12202
|
+
]
|
|
12203
|
+
},
|
|
12204
|
+
item.id
|
|
12205
|
+
)) : /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
|
|
12206
|
+
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
|
|
12207
|
+
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
12208
|
+
'No items found for "',
|
|
12209
|
+
query,
|
|
12210
|
+
'".'
|
|
12211
|
+
] })
|
|
12212
|
+
] }) })
|
|
12213
|
+
] })
|
|
12651
12214
|
] });
|
|
12652
12215
|
};
|
|
12653
|
-
const
|
|
12216
|
+
const LocationField = ({ control, setValue }) => {
|
|
12217
|
+
const locations = useComboboxData({
|
|
12218
|
+
queryKey: ["locations"],
|
|
12219
|
+
queryFn: async (params) => {
|
|
12220
|
+
return await sdk.admin.stockLocation.list(params);
|
|
12221
|
+
},
|
|
12222
|
+
getOptions: (data) => {
|
|
12223
|
+
return data.stock_locations.map((location) => ({
|
|
12224
|
+
label: location.name,
|
|
12225
|
+
value: location.id
|
|
12226
|
+
}));
|
|
12227
|
+
}
|
|
12228
|
+
});
|
|
12229
|
+
return /* @__PURE__ */ jsx(
|
|
12230
|
+
Form$2.Field,
|
|
12231
|
+
{
|
|
12232
|
+
control,
|
|
12233
|
+
name: "location_id",
|
|
12234
|
+
render: ({ field: { onChange, ...field } }) => {
|
|
12235
|
+
return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12236
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
12237
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Location" }),
|
|
12238
|
+
/* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
|
|
12239
|
+
] }),
|
|
12240
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12241
|
+
Combobox,
|
|
12242
|
+
{
|
|
12243
|
+
options: locations.options,
|
|
12244
|
+
fetchNextPage: locations.fetchNextPage,
|
|
12245
|
+
isFetchingNextPage: locations.isFetchingNextPage,
|
|
12246
|
+
searchValue: locations.searchValue,
|
|
12247
|
+
onSearchValueChange: locations.onSearchValueChange,
|
|
12248
|
+
placeholder: "Select location",
|
|
12249
|
+
onChange: (value) => {
|
|
12250
|
+
setValue("shipping_option_id", "", {
|
|
12251
|
+
shouldDirty: true,
|
|
12252
|
+
shouldTouch: true
|
|
12253
|
+
});
|
|
12254
|
+
onChange(value);
|
|
12255
|
+
},
|
|
12256
|
+
...field
|
|
12257
|
+
}
|
|
12258
|
+
) })
|
|
12259
|
+
] }) });
|
|
12260
|
+
}
|
|
12261
|
+
}
|
|
12262
|
+
);
|
|
12263
|
+
};
|
|
12264
|
+
const ShippingOptionField = ({
|
|
12654
12265
|
shippingProfileId,
|
|
12655
|
-
|
|
12656
|
-
|
|
12657
|
-
setData,
|
|
12658
|
-
children
|
|
12266
|
+
preview,
|
|
12267
|
+
control
|
|
12659
12268
|
}) => {
|
|
12660
|
-
|
|
12661
|
-
const
|
|
12662
|
-
const
|
|
12663
|
-
|
|
12664
|
-
|
|
12665
|
-
|
|
12666
|
-
|
|
12667
|
-
|
|
12668
|
-
|
|
12669
|
-
shippingProfileId,
|
|
12670
|
-
shippingOption,
|
|
12671
|
-
shippingMethod
|
|
12269
|
+
var _a;
|
|
12270
|
+
const locationId = useWatch({ control, name: "location_id" });
|
|
12271
|
+
const shippingOptions = useComboboxData({
|
|
12272
|
+
queryKey: ["shipping_options", locationId, shippingProfileId],
|
|
12273
|
+
queryFn: async (params) => {
|
|
12274
|
+
return await sdk.admin.shippingOption.list({
|
|
12275
|
+
...params,
|
|
12276
|
+
stock_location_id: locationId,
|
|
12277
|
+
shipping_profile_id: shippingProfileId
|
|
12672
12278
|
});
|
|
12279
|
+
},
|
|
12280
|
+
getOptions: (data) => {
|
|
12281
|
+
return data.shipping_options.map((option) => {
|
|
12282
|
+
var _a2;
|
|
12283
|
+
if ((_a2 = option.rules) == null ? void 0 : _a2.find(
|
|
12284
|
+
(r) => r.attribute === "is_return" && r.value === "true"
|
|
12285
|
+
)) {
|
|
12286
|
+
return void 0;
|
|
12287
|
+
}
|
|
12288
|
+
return {
|
|
12289
|
+
label: option.name,
|
|
12290
|
+
value: option.id
|
|
12291
|
+
};
|
|
12292
|
+
}).filter(Boolean);
|
|
12293
|
+
},
|
|
12294
|
+
enabled: !!locationId && !!shippingProfileId,
|
|
12295
|
+
defaultValue: ((_a = preview.shipping_methods[0]) == null ? void 0 : _a.shipping_option_id) || void 0
|
|
12296
|
+
});
|
|
12297
|
+
const tooltipContent = !locationId && !shippingProfileId ? "Choose a location and shipping profile first." : !locationId ? "Choose a location first." : "Choose a shipping profile first.";
|
|
12298
|
+
return /* @__PURE__ */ jsx(
|
|
12299
|
+
Form$2.Field,
|
|
12300
|
+
{
|
|
12301
|
+
control,
|
|
12302
|
+
name: "shipping_option_id",
|
|
12303
|
+
render: ({ field }) => {
|
|
12304
|
+
return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12305
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12306
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Shipping option" }),
|
|
12307
|
+
/* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose the shipping option to use." })
|
|
12308
|
+
] }),
|
|
12309
|
+
/* @__PURE__ */ jsx(
|
|
12310
|
+
ConditionalTooltip,
|
|
12311
|
+
{
|
|
12312
|
+
content: tooltipContent,
|
|
12313
|
+
showTooltip: !locationId || !shippingProfileId,
|
|
12314
|
+
children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12315
|
+
Combobox,
|
|
12316
|
+
{
|
|
12317
|
+
options: shippingOptions.options,
|
|
12318
|
+
fetchNextPage: shippingOptions.fetchNextPage,
|
|
12319
|
+
isFetchingNextPage: shippingOptions.isFetchingNextPage,
|
|
12320
|
+
searchValue: shippingOptions.searchValue,
|
|
12321
|
+
onSearchValueChange: shippingOptions.onSearchValueChange,
|
|
12322
|
+
placeholder: "Select shipping option",
|
|
12323
|
+
...field,
|
|
12324
|
+
disabled: !locationId || !shippingProfileId
|
|
12325
|
+
}
|
|
12326
|
+
) }) })
|
|
12327
|
+
}
|
|
12328
|
+
)
|
|
12329
|
+
] }) });
|
|
12330
|
+
}
|
|
12673
12331
|
}
|
|
12674
|
-
|
|
12332
|
+
);
|
|
12333
|
+
};
|
|
12334
|
+
const CustomAmountField = ({
|
|
12335
|
+
control,
|
|
12336
|
+
currencyCode
|
|
12337
|
+
}) => {
|
|
12675
12338
|
return /* @__PURE__ */ jsx(
|
|
12676
|
-
|
|
12339
|
+
Form$2.Field,
|
|
12677
12340
|
{
|
|
12678
|
-
|
|
12679
|
-
|
|
12680
|
-
|
|
12681
|
-
|
|
12682
|
-
|
|
12341
|
+
control,
|
|
12342
|
+
name: "custom_amount",
|
|
12343
|
+
render: ({ field: { onChange, ...field } }) => {
|
|
12344
|
+
return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12345
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12346
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Custom amount" }),
|
|
12347
|
+
/* @__PURE__ */ jsx(Form$2.Hint, { children: "Set a custom amount for the shipping option." })
|
|
12348
|
+
] }),
|
|
12349
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12350
|
+
CurrencyInput,
|
|
12351
|
+
{
|
|
12352
|
+
...field,
|
|
12353
|
+
onValueChange: (value) => onChange(value),
|
|
12354
|
+
symbol: getNativeSymbol(currencyCode),
|
|
12355
|
+
code: currencyCode
|
|
12356
|
+
}
|
|
12357
|
+
) })
|
|
12358
|
+
] });
|
|
12359
|
+
}
|
|
12683
12360
|
}
|
|
12684
12361
|
);
|
|
12685
12362
|
};
|
|
12686
|
-
const
|
|
12687
|
-
|
|
12688
|
-
|
|
12689
|
-
|
|
12690
|
-
})
|
|
12691
|
-
|
|
12692
|
-
|
|
12363
|
+
const TransferOwnership = () => {
|
|
12364
|
+
const { id } = useParams();
|
|
12365
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(id, {
|
|
12366
|
+
fields: "id,customer_id,customer.*"
|
|
12367
|
+
});
|
|
12368
|
+
if (isError) {
|
|
12369
|
+
throw error;
|
|
12370
|
+
}
|
|
12371
|
+
const isReady = !isPending && !!draft_order;
|
|
12372
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
12373
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
12374
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Transfer Ownership" }) }),
|
|
12375
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
|
|
12376
|
+
] }),
|
|
12377
|
+
isReady && /* @__PURE__ */ jsx(TransferOwnershipForm, { order: draft_order })
|
|
12378
|
+
] });
|
|
12379
|
+
};
|
|
12380
|
+
const TransferOwnershipForm = ({ order }) => {
|
|
12381
|
+
var _a, _b;
|
|
12693
12382
|
const form = useForm({
|
|
12694
|
-
resolver: zodResolver(shippingMethodSchema),
|
|
12695
12383
|
defaultValues: {
|
|
12696
|
-
|
|
12697
|
-
|
|
12698
|
-
|
|
12384
|
+
customer_id: order.customer_id || ""
|
|
12385
|
+
},
|
|
12386
|
+
resolver: zodResolver(schema$1)
|
|
12387
|
+
});
|
|
12388
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12389
|
+
const { handleSuccess } = useRouteModal();
|
|
12390
|
+
const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
|
|
12391
|
+
const currentCustomer = order.customer ? {
|
|
12392
|
+
label: name ? `${name} (${order.customer.email})` : order.customer.email,
|
|
12393
|
+
value: order.customer.id
|
|
12394
|
+
} : null;
|
|
12395
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12396
|
+
await mutateAsync(
|
|
12397
|
+
{ customer_id: data.customer_id },
|
|
12398
|
+
{
|
|
12399
|
+
onSuccess: () => {
|
|
12400
|
+
toast.success("Customer updated");
|
|
12401
|
+
handleSuccess();
|
|
12402
|
+
},
|
|
12403
|
+
onError: (error) => {
|
|
12404
|
+
toast.error(error.message);
|
|
12405
|
+
}
|
|
12406
|
+
}
|
|
12407
|
+
);
|
|
12408
|
+
});
|
|
12409
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12410
|
+
KeyboundForm,
|
|
12411
|
+
{
|
|
12412
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12413
|
+
onSubmit,
|
|
12414
|
+
children: [
|
|
12415
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
12416
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsx(Illustration, {}) }),
|
|
12417
|
+
currentCustomer && /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3", children: [
|
|
12418
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12419
|
+
/* @__PURE__ */ jsx(Label$1, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
|
|
12420
|
+
/* @__PURE__ */ jsx(Hint$1, { children: "The customer that is currently associated with this draft order." })
|
|
12421
|
+
] }),
|
|
12422
|
+
/* @__PURE__ */ jsxs(Select, { disabled: true, value: currentCustomer.value, children: [
|
|
12423
|
+
/* @__PURE__ */ jsx(Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsx(Select.Value, {}) }),
|
|
12424
|
+
/* @__PURE__ */ jsx(Select.Content, { children: /* @__PURE__ */ jsx(Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
|
|
12425
|
+
] })
|
|
12426
|
+
] }),
|
|
12427
|
+
/* @__PURE__ */ jsx(
|
|
12428
|
+
CustomerField,
|
|
12429
|
+
{
|
|
12430
|
+
control: form.control,
|
|
12431
|
+
currentCustomerId: order.customer_id
|
|
12432
|
+
}
|
|
12433
|
+
)
|
|
12434
|
+
] }),
|
|
12435
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
12436
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
12437
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12438
|
+
] }) })
|
|
12439
|
+
]
|
|
12440
|
+
}
|
|
12441
|
+
) });
|
|
12442
|
+
};
|
|
12443
|
+
const CustomerField = ({ control, currentCustomerId }) => {
|
|
12444
|
+
const customers = useComboboxData({
|
|
12445
|
+
queryFn: async (params) => {
|
|
12446
|
+
return await sdk.admin.customer.list({
|
|
12447
|
+
...params,
|
|
12448
|
+
id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
|
|
12449
|
+
});
|
|
12450
|
+
},
|
|
12451
|
+
queryKey: ["customers"],
|
|
12452
|
+
getOptions: (data) => {
|
|
12453
|
+
return data.customers.map((customer) => {
|
|
12454
|
+
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
12455
|
+
return {
|
|
12456
|
+
label: name ? `${name} (${customer.email})` : customer.email,
|
|
12457
|
+
value: customer.id
|
|
12458
|
+
};
|
|
12459
|
+
});
|
|
12699
12460
|
}
|
|
12700
12461
|
});
|
|
12701
|
-
|
|
12702
|
-
|
|
12703
|
-
|
|
12704
|
-
|
|
12705
|
-
|
|
12706
|
-
|
|
12707
|
-
|
|
12708
|
-
|
|
12709
|
-
|
|
12462
|
+
return /* @__PURE__ */ jsx(
|
|
12463
|
+
Form$2.Field,
|
|
12464
|
+
{
|
|
12465
|
+
name: "customer_id",
|
|
12466
|
+
control,
|
|
12467
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { className: "space-y-3", children: [
|
|
12468
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12469
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "New customer" }),
|
|
12470
|
+
/* @__PURE__ */ jsx(Form$2.Hint, { children: "The customer to transfer this draft order to." })
|
|
12471
|
+
] }),
|
|
12472
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12473
|
+
Combobox,
|
|
12474
|
+
{
|
|
12475
|
+
options: customers.options,
|
|
12476
|
+
fetchNextPage: customers.fetchNextPage,
|
|
12477
|
+
isFetchingNextPage: customers.isFetchingNextPage,
|
|
12478
|
+
searchValue: customers.searchValue,
|
|
12479
|
+
onSearchValueChange: customers.onSearchValueChange,
|
|
12480
|
+
placeholder: "Select customer",
|
|
12481
|
+
...field
|
|
12482
|
+
}
|
|
12483
|
+
) }),
|
|
12484
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12485
|
+
] })
|
|
12710
12486
|
}
|
|
12711
|
-
|
|
12712
|
-
|
|
12713
|
-
|
|
12714
|
-
|
|
12715
|
-
|
|
12716
|
-
|
|
12717
|
-
|
|
12718
|
-
|
|
12719
|
-
|
|
12720
|
-
|
|
12721
|
-
|
|
12722
|
-
|
|
12723
|
-
|
|
12487
|
+
);
|
|
12488
|
+
};
|
|
12489
|
+
const Illustration = () => {
|
|
12490
|
+
return /* @__PURE__ */ jsxs(
|
|
12491
|
+
"svg",
|
|
12492
|
+
{
|
|
12493
|
+
width: "280",
|
|
12494
|
+
height: "180",
|
|
12495
|
+
viewBox: "0 0 280 180",
|
|
12496
|
+
fill: "none",
|
|
12497
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
12498
|
+
children: [
|
|
12499
|
+
/* @__PURE__ */ jsx(
|
|
12500
|
+
"rect",
|
|
12501
|
+
{
|
|
12502
|
+
x: "0.00428286",
|
|
12503
|
+
y: "-0.742904",
|
|
12504
|
+
width: "33.5",
|
|
12505
|
+
height: "65.5",
|
|
12506
|
+
rx: "6.75",
|
|
12507
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 88.438)",
|
|
12508
|
+
fill: "#D4D4D8",
|
|
12509
|
+
stroke: "#52525B",
|
|
12510
|
+
strokeWidth: "1.5"
|
|
12511
|
+
}
|
|
12512
|
+
),
|
|
12513
|
+
/* @__PURE__ */ jsx(
|
|
12514
|
+
"rect",
|
|
12515
|
+
{
|
|
12516
|
+
x: "0.00428286",
|
|
12517
|
+
y: "-0.742904",
|
|
12518
|
+
width: "33.5",
|
|
12519
|
+
height: "65.5",
|
|
12520
|
+
rx: "6.75",
|
|
12521
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 189.756 85.4381)",
|
|
12522
|
+
fill: "white",
|
|
12523
|
+
stroke: "#52525B",
|
|
12524
|
+
strokeWidth: "1.5"
|
|
12525
|
+
}
|
|
12526
|
+
),
|
|
12527
|
+
/* @__PURE__ */ jsx(
|
|
12528
|
+
"path",
|
|
12529
|
+
{
|
|
12530
|
+
d: "M180.579 107.142L179.126 107.959",
|
|
12531
|
+
stroke: "#52525B",
|
|
12532
|
+
strokeWidth: "1.5",
|
|
12533
|
+
strokeLinecap: "round",
|
|
12534
|
+
strokeLinejoin: "round"
|
|
12535
|
+
}
|
|
12536
|
+
),
|
|
12537
|
+
/* @__PURE__ */ jsx(
|
|
12538
|
+
"path",
|
|
12539
|
+
{
|
|
12540
|
+
opacity: "0.88",
|
|
12541
|
+
d: "M182.305 109.546L180.257 109.534",
|
|
12542
|
+
stroke: "#52525B",
|
|
12543
|
+
strokeWidth: "1.5",
|
|
12544
|
+
strokeLinecap: "round",
|
|
12545
|
+
strokeLinejoin: "round"
|
|
12546
|
+
}
|
|
12547
|
+
),
|
|
12548
|
+
/* @__PURE__ */ jsx(
|
|
12549
|
+
"path",
|
|
12550
|
+
{
|
|
12551
|
+
opacity: "0.75",
|
|
12552
|
+
d: "M180.551 111.93L179.108 111.096",
|
|
12553
|
+
stroke: "#52525B",
|
|
12554
|
+
strokeWidth: "1.5",
|
|
12555
|
+
strokeLinecap: "round",
|
|
12556
|
+
strokeLinejoin: "round"
|
|
12724
12557
|
}
|
|
12725
|
-
|
|
12726
|
-
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12738
|
-
|
|
12739
|
-
|
|
12740
|
-
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
|
|
12744
|
-
|
|
12745
|
-
|
|
12746
|
-
|
|
12747
|
-
|
|
12748
|
-
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
|
|
12558
|
+
),
|
|
12559
|
+
/* @__PURE__ */ jsx(
|
|
12560
|
+
"path",
|
|
12561
|
+
{
|
|
12562
|
+
opacity: "0.63",
|
|
12563
|
+
d: "M176.347 112.897L176.354 111.73",
|
|
12564
|
+
stroke: "#52525B",
|
|
12565
|
+
strokeWidth: "1.5",
|
|
12566
|
+
strokeLinecap: "round",
|
|
12567
|
+
strokeLinejoin: "round"
|
|
12568
|
+
}
|
|
12569
|
+
),
|
|
12570
|
+
/* @__PURE__ */ jsx(
|
|
12571
|
+
"path",
|
|
12572
|
+
{
|
|
12573
|
+
opacity: "0.5",
|
|
12574
|
+
d: "M172.153 111.881L173.606 111.064",
|
|
12575
|
+
stroke: "#52525B",
|
|
12576
|
+
strokeWidth: "1.5",
|
|
12577
|
+
strokeLinecap: "round",
|
|
12578
|
+
strokeLinejoin: "round"
|
|
12579
|
+
}
|
|
12580
|
+
),
|
|
12581
|
+
/* @__PURE__ */ jsx(
|
|
12582
|
+
"path",
|
|
12583
|
+
{
|
|
12584
|
+
opacity: "0.38",
|
|
12585
|
+
d: "M170.428 109.478L172.476 109.489",
|
|
12586
|
+
stroke: "#52525B",
|
|
12587
|
+
strokeWidth: "1.5",
|
|
12588
|
+
strokeLinecap: "round",
|
|
12589
|
+
strokeLinejoin: "round"
|
|
12590
|
+
}
|
|
12591
|
+
),
|
|
12592
|
+
/* @__PURE__ */ jsx(
|
|
12593
|
+
"path",
|
|
12594
|
+
{
|
|
12595
|
+
opacity: "0.25",
|
|
12596
|
+
d: "M172.181 107.094L173.624 107.928",
|
|
12597
|
+
stroke: "#52525B",
|
|
12598
|
+
strokeWidth: "1.5",
|
|
12599
|
+
strokeLinecap: "round",
|
|
12600
|
+
strokeLinejoin: "round"
|
|
12601
|
+
}
|
|
12602
|
+
),
|
|
12603
|
+
/* @__PURE__ */ jsx(
|
|
12604
|
+
"path",
|
|
12605
|
+
{
|
|
12606
|
+
opacity: "0.13",
|
|
12607
|
+
d: "M176.386 106.126L176.379 107.294",
|
|
12608
|
+
stroke: "#52525B",
|
|
12609
|
+
strokeWidth: "1.5",
|
|
12610
|
+
strokeLinecap: "round",
|
|
12611
|
+
strokeLinejoin: "round"
|
|
12612
|
+
}
|
|
12613
|
+
),
|
|
12614
|
+
/* @__PURE__ */ jsx(
|
|
12615
|
+
"rect",
|
|
12616
|
+
{
|
|
12617
|
+
width: "12",
|
|
12618
|
+
height: "3",
|
|
12619
|
+
rx: "1.5",
|
|
12620
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 196.447 92.2925)",
|
|
12621
|
+
fill: "#D4D4D8"
|
|
12622
|
+
}
|
|
12623
|
+
),
|
|
12624
|
+
/* @__PURE__ */ jsx(
|
|
12625
|
+
"rect",
|
|
12626
|
+
{
|
|
12627
|
+
x: "0.00428286",
|
|
12628
|
+
y: "-0.742904",
|
|
12629
|
+
width: "33.5",
|
|
12630
|
+
height: "65.5",
|
|
12631
|
+
rx: "6.75",
|
|
12632
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 46.4147)",
|
|
12633
|
+
fill: "#D4D4D8",
|
|
12634
|
+
stroke: "#52525B",
|
|
12635
|
+
strokeWidth: "1.5"
|
|
12636
|
+
}
|
|
12637
|
+
),
|
|
12638
|
+
/* @__PURE__ */ jsx(
|
|
12639
|
+
"rect",
|
|
12640
|
+
{
|
|
12641
|
+
x: "0.00428286",
|
|
12642
|
+
y: "-0.742904",
|
|
12643
|
+
width: "33.5",
|
|
12644
|
+
height: "65.5",
|
|
12645
|
+
rx: "6.75",
|
|
12646
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 117.023 43.4147)",
|
|
12647
|
+
fill: "white",
|
|
12648
|
+
stroke: "#52525B",
|
|
12649
|
+
strokeWidth: "1.5"
|
|
12650
|
+
}
|
|
12651
|
+
),
|
|
12652
|
+
/* @__PURE__ */ jsx(
|
|
12653
|
+
"rect",
|
|
12654
|
+
{
|
|
12655
|
+
width: "12",
|
|
12656
|
+
height: "3",
|
|
12657
|
+
rx: "1.5",
|
|
12658
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 123.714 50.2691)",
|
|
12659
|
+
fill: "#D4D4D8"
|
|
12660
|
+
}
|
|
12661
|
+
),
|
|
12662
|
+
/* @__PURE__ */ jsx(
|
|
12663
|
+
"rect",
|
|
12664
|
+
{
|
|
12665
|
+
width: "17",
|
|
12666
|
+
height: "3",
|
|
12667
|
+
rx: "1.5",
|
|
12668
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 97.5557 66.958)",
|
|
12669
|
+
fill: "#D4D4D8"
|
|
12670
|
+
}
|
|
12671
|
+
),
|
|
12672
|
+
/* @__PURE__ */ jsx(
|
|
12673
|
+
"rect",
|
|
12674
|
+
{
|
|
12675
|
+
width: "12",
|
|
12676
|
+
height: "3",
|
|
12677
|
+
rx: "1.5",
|
|
12678
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 93.1978 69.4093)",
|
|
12679
|
+
fill: "#D4D4D8"
|
|
12680
|
+
}
|
|
12681
|
+
),
|
|
12682
|
+
/* @__PURE__ */ jsx(
|
|
12683
|
+
"path",
|
|
12684
|
+
{
|
|
12685
|
+
d: "M92.3603 63.9563C90.9277 63.1286 88.59 63.1152 87.148 63.9263C85.7059 64.7374 85.6983 66.0702 87.1308 66.8979C88.5634 67.7256 90.9011 67.7391 92.3432 66.928C93.7852 66.1168 93.7929 64.784 92.3603 63.9563ZM88.4382 66.1625C87.7221 65.7488 87.726 65.0822 88.4468 64.6767C89.1676 64.2713 90.3369 64.278 91.0529 64.6917C91.769 65.1055 91.7652 65.7721 91.0444 66.1775C90.3236 66.583 89.1543 66.5762 88.4382 66.1625Z",
|
|
12686
|
+
fill: "#A1A1AA"
|
|
12687
|
+
}
|
|
12688
|
+
),
|
|
12689
|
+
/* @__PURE__ */ jsx(
|
|
12690
|
+
"rect",
|
|
12691
|
+
{
|
|
12692
|
+
width: "17",
|
|
12693
|
+
height: "3",
|
|
12694
|
+
rx: "1.5",
|
|
12695
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 109.758 60.0944)",
|
|
12696
|
+
fill: "#A1A1AA"
|
|
12697
|
+
}
|
|
12698
|
+
),
|
|
12699
|
+
/* @__PURE__ */ jsx(
|
|
12700
|
+
"rect",
|
|
12701
|
+
{
|
|
12702
|
+
width: "12",
|
|
12703
|
+
height: "3",
|
|
12704
|
+
rx: "1.5",
|
|
12705
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 105.4 62.5457)",
|
|
12706
|
+
fill: "#A1A1AA"
|
|
12707
|
+
}
|
|
12708
|
+
),
|
|
12709
|
+
/* @__PURE__ */ jsx(
|
|
12710
|
+
"path",
|
|
12711
|
+
{
|
|
12712
|
+
d: "M104.562 57.0927C103.13 56.265 100.792 56.2515 99.3501 57.0626C97.9081 57.8738 97.9004 59.2065 99.333 60.0343C100.766 60.862 103.103 60.8754 104.545 60.0643C105.987 59.2532 105.995 57.9204 104.562 57.0927ZM103.858 58.8972L100.815 59.1265C100.683 59.1367 100.55 59.1134 100.449 59.063C100.44 59.0585 100.432 59.0545 100.425 59.05C100.339 59.0005 100.29 58.9336 100.291 58.8637L100.294 58.1201C100.294 57.9752 100.501 57.8585 100.756 57.86C101.01 57.8615 101.217 57.98 101.216 58.1256L101.214 58.5669L103.732 58.3769C103.984 58.3578 104.217 58.4584 104.251 58.603C104.286 58.7468 104.11 58.8788 103.858 58.8977L103.858 58.8972Z",
|
|
12713
|
+
fill: "#52525B"
|
|
12714
|
+
}
|
|
12715
|
+
),
|
|
12716
|
+
/* @__PURE__ */ jsx("g", { clipPath: "url(#clip0_20915_38670)", children: /* @__PURE__ */ jsx(
|
|
12717
|
+
"path",
|
|
12718
|
+
{
|
|
12719
|
+
d: "M133.106 81.8022L140.49 81.8447L140.515 77.6349",
|
|
12720
|
+
stroke: "#A1A1AA",
|
|
12721
|
+
strokeWidth: "1.5",
|
|
12722
|
+
strokeLinecap: "round",
|
|
12723
|
+
strokeLinejoin: "round"
|
|
12724
|
+
}
|
|
12725
|
+
) }),
|
|
12726
|
+
/* @__PURE__ */ jsx("g", { clipPath: "url(#clip1_20915_38670)", children: /* @__PURE__ */ jsx(
|
|
12727
|
+
"path",
|
|
12728
|
+
{
|
|
12729
|
+
d: "M143.496 87.8055L150.881 87.8481L150.905 83.6383",
|
|
12730
|
+
stroke: "#A1A1AA",
|
|
12731
|
+
strokeWidth: "1.5",
|
|
12732
|
+
strokeLinecap: "round",
|
|
12733
|
+
strokeLinejoin: "round"
|
|
12734
|
+
}
|
|
12735
|
+
) }),
|
|
12736
|
+
/* @__PURE__ */ jsx("g", { clipPath: "url(#clip2_20915_38670)", children: /* @__PURE__ */ jsx(
|
|
12737
|
+
"path",
|
|
12738
|
+
{
|
|
12739
|
+
d: "M153.887 93.8088L161.271 93.8514L161.295 89.6416",
|
|
12740
|
+
stroke: "#A1A1AA",
|
|
12741
|
+
strokeWidth: "1.5",
|
|
12742
|
+
strokeLinecap: "round",
|
|
12743
|
+
strokeLinejoin: "round"
|
|
12744
|
+
}
|
|
12745
|
+
) }),
|
|
12746
|
+
/* @__PURE__ */ jsx("g", { clipPath: "url(#clip3_20915_38670)", children: /* @__PURE__ */ jsx(
|
|
12747
|
+
"path",
|
|
12748
|
+
{
|
|
12749
|
+
d: "M126.114 89.1912L118.729 89.1486L118.705 93.3584",
|
|
12750
|
+
stroke: "#A1A1AA",
|
|
12751
|
+
strokeWidth: "1.5",
|
|
12752
|
+
strokeLinecap: "round",
|
|
12753
|
+
strokeLinejoin: "round"
|
|
12754
|
+
}
|
|
12755
|
+
) }),
|
|
12756
|
+
/* @__PURE__ */ jsx("g", { clipPath: "url(#clip4_20915_38670)", children: /* @__PURE__ */ jsx(
|
|
12757
|
+
"path",
|
|
12758
|
+
{
|
|
12759
|
+
d: "M136.504 95.1945L129.12 95.1519L129.095 99.3617",
|
|
12760
|
+
stroke: "#A1A1AA",
|
|
12761
|
+
strokeWidth: "1.5",
|
|
12762
|
+
strokeLinecap: "round",
|
|
12763
|
+
strokeLinejoin: "round"
|
|
12764
|
+
}
|
|
12765
|
+
) }),
|
|
12766
|
+
/* @__PURE__ */ jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsx(
|
|
12767
|
+
"path",
|
|
12768
|
+
{
|
|
12769
|
+
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
12770
|
+
stroke: "#A1A1AA",
|
|
12771
|
+
strokeWidth: "1.5",
|
|
12772
|
+
strokeLinecap: "round",
|
|
12773
|
+
strokeLinejoin: "round"
|
|
12774
|
+
}
|
|
12775
|
+
) }),
|
|
12776
|
+
/* @__PURE__ */ jsxs("defs", { children: [
|
|
12777
|
+
/* @__PURE__ */ jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsx(
|
|
12778
|
+
"rect",
|
|
12759
12779
|
{
|
|
12760
|
-
|
|
12761
|
-
|
|
12780
|
+
width: "12",
|
|
12781
|
+
height: "12",
|
|
12782
|
+
fill: "white",
|
|
12783
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12762
12784
|
}
|
|
12763
|
-
),
|
|
12764
|
-
/* @__PURE__ */ jsx(
|
|
12765
|
-
|
|
12766
|
-
ShippingOptionField,
|
|
12785
|
+
) }),
|
|
12786
|
+
/* @__PURE__ */ jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsx(
|
|
12787
|
+
"rect",
|
|
12767
12788
|
{
|
|
12768
|
-
|
|
12769
|
-
|
|
12770
|
-
|
|
12789
|
+
width: "12",
|
|
12790
|
+
height: "12",
|
|
12791
|
+
fill: "white",
|
|
12792
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
12771
12793
|
}
|
|
12772
|
-
),
|
|
12773
|
-
/* @__PURE__ */ jsx(
|
|
12774
|
-
|
|
12775
|
-
CustomAmountField,
|
|
12794
|
+
) }),
|
|
12795
|
+
/* @__PURE__ */ jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsx(
|
|
12796
|
+
"rect",
|
|
12776
12797
|
{
|
|
12777
|
-
|
|
12778
|
-
|
|
12798
|
+
width: "12",
|
|
12799
|
+
height: "12",
|
|
12800
|
+
fill: "white",
|
|
12801
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
12779
12802
|
}
|
|
12780
|
-
),
|
|
12781
|
-
/* @__PURE__ */ jsx(
|
|
12782
|
-
|
|
12783
|
-
ItemsPreview,
|
|
12803
|
+
) }),
|
|
12804
|
+
/* @__PURE__ */ jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsx(
|
|
12805
|
+
"rect",
|
|
12784
12806
|
{
|
|
12785
|
-
|
|
12786
|
-
|
|
12807
|
+
width: "12",
|
|
12808
|
+
height: "12",
|
|
12809
|
+
fill: "white",
|
|
12810
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
12787
12811
|
}
|
|
12788
|
-
)
|
|
12789
|
-
|
|
12790
|
-
|
|
12791
|
-
/* @__PURE__ */ jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
|
|
12792
|
-
/* @__PURE__ */ jsx(
|
|
12793
|
-
Button,
|
|
12812
|
+
) }),
|
|
12813
|
+
/* @__PURE__ */ jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsx(
|
|
12814
|
+
"rect",
|
|
12794
12815
|
{
|
|
12795
|
-
|
|
12796
|
-
|
|
12797
|
-
|
|
12798
|
-
|
|
12816
|
+
width: "12",
|
|
12817
|
+
height: "12",
|
|
12818
|
+
fill: "white",
|
|
12819
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
12799
12820
|
}
|
|
12800
|
-
)
|
|
12801
|
-
|
|
12802
|
-
|
|
12803
|
-
}
|
|
12804
|
-
) }) });
|
|
12805
|
-
};
|
|
12806
|
-
const shippingMethodSchema = objectType({
|
|
12807
|
-
location_id: stringType(),
|
|
12808
|
-
shipping_option_id: stringType(),
|
|
12809
|
-
custom_amount: unionType([numberType(), stringType()]).optional()
|
|
12810
|
-
});
|
|
12811
|
-
const ItemsPreview = ({ order, shippingProfileId }) => {
|
|
12812
|
-
const matches = order.items.filter(
|
|
12813
|
-
(item) => {
|
|
12814
|
-
var _a, _b, _c;
|
|
12815
|
-
return ((_c = (_b = (_a = item.variant) == null ? void 0 : _a.product) == null ? void 0 : _b.shipping_profile) == null ? void 0 : _c.id) === shippingProfileId;
|
|
12816
|
-
}
|
|
12817
|
-
);
|
|
12818
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-6", children: [
|
|
12819
|
-
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 items-center gap-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12820
|
-
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "Items to ship" }),
|
|
12821
|
-
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Items with the selected shipping profile." })
|
|
12822
|
-
] }) }),
|
|
12823
|
-
/* @__PURE__ */ jsxs("div", { className: "bg-ui-bg-subtle shadow-elevation-card-rest rounded-xl", children: [
|
|
12824
|
-
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-3 px-4 py-2 text-ui-fg-muted", children: [
|
|
12825
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Item" }) }),
|
|
12826
|
-
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", children: "Quantity" }) })
|
|
12827
|
-
] }),
|
|
12828
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1.5 px-[5px] pb-[5px]", children: matches.length > 0 ? matches == null ? void 0 : matches.map((item) => /* @__PURE__ */ jsxs(
|
|
12829
|
-
"div",
|
|
12830
|
-
{
|
|
12831
|
-
className: "grid grid-cols-2 gap-3 px-4 py-2 bg-ui-bg-base shadow-elevation-card-rest rounded-lg items-center",
|
|
12832
|
-
children: [
|
|
12833
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-3", children: [
|
|
12834
|
-
/* @__PURE__ */ jsx(
|
|
12835
|
-
Thumbnail,
|
|
12836
|
-
{
|
|
12837
|
-
thumbnail: item.thumbnail,
|
|
12838
|
-
alt: item.product_title ?? void 0
|
|
12839
|
-
}
|
|
12840
|
-
),
|
|
12841
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
12842
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1", children: [
|
|
12843
|
-
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: item.product_title }),
|
|
12844
|
-
/* @__PURE__ */ jsxs(
|
|
12845
|
-
Text,
|
|
12846
|
-
{
|
|
12847
|
-
size: "small",
|
|
12848
|
-
leading: "compact",
|
|
12849
|
-
className: "text-ui-fg-subtle",
|
|
12850
|
-
children: [
|
|
12851
|
-
"(",
|
|
12852
|
-
item.variant_title,
|
|
12853
|
-
")"
|
|
12854
|
-
]
|
|
12855
|
-
}
|
|
12856
|
-
)
|
|
12857
|
-
] }),
|
|
12858
|
-
/* @__PURE__ */ jsx(
|
|
12859
|
-
Text,
|
|
12860
|
-
{
|
|
12861
|
-
size: "small",
|
|
12862
|
-
leading: "compact",
|
|
12863
|
-
className: "text-ui-fg-subtle",
|
|
12864
|
-
children: item.variant_sku
|
|
12865
|
-
}
|
|
12866
|
-
)
|
|
12867
|
-
] })
|
|
12868
|
-
] }),
|
|
12869
|
-
/* @__PURE__ */ jsxs(
|
|
12870
|
-
Text,
|
|
12871
|
-
{
|
|
12872
|
-
size: "small",
|
|
12873
|
-
leading: "compact",
|
|
12874
|
-
className: "text-ui-fg-subtle",
|
|
12875
|
-
children: [
|
|
12876
|
-
item.quantity,
|
|
12877
|
-
"x"
|
|
12878
|
-
]
|
|
12879
|
-
}
|
|
12880
|
-
)
|
|
12881
|
-
]
|
|
12882
|
-
},
|
|
12883
|
-
item.id
|
|
12884
|
-
)) : /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-x-3 bg-ui-bg-base rounded-lg p-4 shadow-elevation-card-rest flex-col gap-1", children: [
|
|
12885
|
-
/* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: "No items found" }),
|
|
12886
|
-
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
12887
|
-
'No items found for "',
|
|
12888
|
-
query,
|
|
12889
|
-
'".'
|
|
12890
|
-
] })
|
|
12891
|
-
] }) })
|
|
12892
|
-
] })
|
|
12893
|
-
] });
|
|
12894
|
-
};
|
|
12895
|
-
const LocationField = ({ control, setValue }) => {
|
|
12896
|
-
const locations = useComboboxData({
|
|
12897
|
-
queryKey: ["locations"],
|
|
12898
|
-
queryFn: async (params) => {
|
|
12899
|
-
return await sdk.admin.stockLocation.list(params);
|
|
12900
|
-
},
|
|
12901
|
-
getOptions: (data) => {
|
|
12902
|
-
return data.stock_locations.map((location) => ({
|
|
12903
|
-
label: location.name,
|
|
12904
|
-
value: location.id
|
|
12905
|
-
}));
|
|
12906
|
-
}
|
|
12907
|
-
});
|
|
12908
|
-
return /* @__PURE__ */ jsx(
|
|
12909
|
-
Form$2.Field,
|
|
12910
|
-
{
|
|
12911
|
-
control,
|
|
12912
|
-
name: "location_id",
|
|
12913
|
-
render: ({ field: { onChange, ...field } }) => {
|
|
12914
|
-
return /* @__PURE__ */ jsx(Form$2.Item, { children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
12915
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
12916
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Location" }),
|
|
12917
|
-
/* @__PURE__ */ jsx(Form$2.Hint, { children: "Choose where you want to ship the items from." })
|
|
12918
|
-
] }),
|
|
12919
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
12920
|
-
Combobox,
|
|
12821
|
+
) }),
|
|
12822
|
+
/* @__PURE__ */ jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsx(
|
|
12823
|
+
"rect",
|
|
12921
12824
|
{
|
|
12922
|
-
|
|
12923
|
-
|
|
12924
|
-
|
|
12925
|
-
|
|
12926
|
-
onSearchValueChange: locations.onSearchValueChange,
|
|
12927
|
-
placeholder: "Select location",
|
|
12928
|
-
onChange: (value) => {
|
|
12929
|
-
setValue("shipping_option_id", "", {
|
|
12930
|
-
shouldDirty: true,
|
|
12931
|
-
shouldTouch: true
|
|
12932
|
-
});
|
|
12933
|
-
onChange(value);
|
|
12934
|
-
},
|
|
12935
|
-
...field
|
|
12825
|
+
width: "12",
|
|
12826
|
+
height: "12",
|
|
12827
|
+
fill: "white",
|
|
12828
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
12936
12829
|
}
|
|
12937
12830
|
) })
|
|
12938
|
-
] })
|
|
12939
|
-
|
|
12831
|
+
] })
|
|
12832
|
+
]
|
|
12940
12833
|
}
|
|
12941
12834
|
);
|
|
12942
12835
|
};
|
|
12943
|
-
const
|
|
12944
|
-
|
|
12945
|
-
|
|
12946
|
-
|
|
12947
|
-
}
|
|
12948
|
-
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
|
|
12952
|
-
|
|
12953
|
-
|
|
12954
|
-
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
})
|
|
12836
|
+
const schema$1 = objectType({
|
|
12837
|
+
customer_id: stringType().min(1)
|
|
12838
|
+
});
|
|
12839
|
+
const ShippingAddress = () => {
|
|
12840
|
+
const { id } = useParams();
|
|
12841
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
12842
|
+
fields: "+shipping_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 Shipping Address" }) }),
|
|
12851
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
12852
|
+
] }),
|
|
12853
|
+
isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
|
|
12854
|
+
] });
|
|
12855
|
+
};
|
|
12856
|
+
const ShippingAddressForm = ({ order }) => {
|
|
12857
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12858
|
+
const form = useForm({
|
|
12859
|
+
defaultValues: {
|
|
12860
|
+
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
12861
|
+
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
12862
|
+
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
12863
|
+
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
12864
|
+
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
12865
|
+
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
12866
|
+
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
12867
|
+
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
12868
|
+
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
12869
|
+
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
12958
12870
|
},
|
|
12959
|
-
|
|
12960
|
-
|
|
12961
|
-
|
|
12962
|
-
|
|
12963
|
-
|
|
12964
|
-
|
|
12965
|
-
|
|
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
|
+
{
|
|
12878
|
+
shipping_address: {
|
|
12879
|
+
first_name: data.first_name,
|
|
12880
|
+
last_name: data.last_name,
|
|
12881
|
+
company: data.company,
|
|
12882
|
+
address_1: data.address_1,
|
|
12883
|
+
address_2: data.address_2,
|
|
12884
|
+
city: data.city,
|
|
12885
|
+
province: data.province,
|
|
12886
|
+
country_code: data.country_code,
|
|
12887
|
+
postal_code: data.postal_code,
|
|
12888
|
+
phone: data.phone
|
|
12966
12889
|
}
|
|
12967
|
-
|
|
12968
|
-
|
|
12969
|
-
|
|
12970
|
-
|
|
12971
|
-
|
|
12972
|
-
|
|
12973
|
-
|
|
12974
|
-
|
|
12890
|
+
},
|
|
12891
|
+
{
|
|
12892
|
+
onSuccess: () => {
|
|
12893
|
+
handleSuccess();
|
|
12894
|
+
},
|
|
12895
|
+
onError: (error) => {
|
|
12896
|
+
toast.error(error.message);
|
|
12897
|
+
}
|
|
12898
|
+
}
|
|
12899
|
+
);
|
|
12975
12900
|
});
|
|
12976
|
-
|
|
12977
|
-
|
|
12978
|
-
Form$2.Field,
|
|
12901
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
12902
|
+
KeyboundForm,
|
|
12979
12903
|
{
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
|
|
12983
|
-
|
|
12984
|
-
/* @__PURE__ */
|
|
12985
|
-
|
|
12986
|
-
|
|
12904
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12905
|
+
onSubmit,
|
|
12906
|
+
children: [
|
|
12907
|
+
/* @__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: [
|
|
12908
|
+
/* @__PURE__ */ jsx(
|
|
12909
|
+
Form$2.Field,
|
|
12910
|
+
{
|
|
12911
|
+
control: form.control,
|
|
12912
|
+
name: "country_code",
|
|
12913
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12914
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
|
|
12915
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
|
|
12916
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12917
|
+
] })
|
|
12918
|
+
}
|
|
12919
|
+
),
|
|
12920
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12921
|
+
/* @__PURE__ */ jsx(
|
|
12922
|
+
Form$2.Field,
|
|
12923
|
+
{
|
|
12924
|
+
control: form.control,
|
|
12925
|
+
name: "first_name",
|
|
12926
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12927
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
|
|
12928
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12929
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12930
|
+
] })
|
|
12931
|
+
}
|
|
12932
|
+
),
|
|
12933
|
+
/* @__PURE__ */ jsx(
|
|
12934
|
+
Form$2.Field,
|
|
12935
|
+
{
|
|
12936
|
+
control: form.control,
|
|
12937
|
+
name: "last_name",
|
|
12938
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12939
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
|
|
12940
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12941
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12942
|
+
] })
|
|
12943
|
+
}
|
|
12944
|
+
)
|
|
12987
12945
|
] }),
|
|
12988
12946
|
/* @__PURE__ */ jsx(
|
|
12989
|
-
|
|
12947
|
+
Form$2.Field,
|
|
12990
12948
|
{
|
|
12991
|
-
|
|
12992
|
-
|
|
12993
|
-
|
|
12994
|
-
|
|
12995
|
-
{
|
|
12996
|
-
|
|
12997
|
-
|
|
12998
|
-
isFetchingNextPage: shippingOptions.isFetchingNextPage,
|
|
12999
|
-
searchValue: shippingOptions.searchValue,
|
|
13000
|
-
onSearchValueChange: shippingOptions.onSearchValueChange,
|
|
13001
|
-
placeholder: "Select shipping option",
|
|
13002
|
-
...field,
|
|
13003
|
-
disabled: !locationId || !shippingProfileId
|
|
13004
|
-
}
|
|
13005
|
-
) }) })
|
|
12949
|
+
control: form.control,
|
|
12950
|
+
name: "company",
|
|
12951
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12952
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
12953
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12954
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12955
|
+
] })
|
|
13006
12956
|
}
|
|
13007
|
-
)
|
|
13008
|
-
|
|
13009
|
-
|
|
13010
|
-
|
|
13011
|
-
|
|
13012
|
-
|
|
13013
|
-
|
|
13014
|
-
|
|
13015
|
-
|
|
13016
|
-
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
13024
|
-
|
|
13025
|
-
|
|
13026
|
-
|
|
12957
|
+
),
|
|
12958
|
+
/* @__PURE__ */ jsx(
|
|
12959
|
+
Form$2.Field,
|
|
12960
|
+
{
|
|
12961
|
+
control: form.control,
|
|
12962
|
+
name: "address_1",
|
|
12963
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12964
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
|
|
12965
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12966
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12967
|
+
] })
|
|
12968
|
+
}
|
|
12969
|
+
),
|
|
12970
|
+
/* @__PURE__ */ jsx(
|
|
12971
|
+
Form$2.Field,
|
|
12972
|
+
{
|
|
12973
|
+
control: form.control,
|
|
12974
|
+
name: "address_2",
|
|
12975
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12976
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
12977
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12978
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12979
|
+
] })
|
|
12980
|
+
}
|
|
12981
|
+
),
|
|
12982
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
12983
|
+
/* @__PURE__ */ jsx(
|
|
12984
|
+
Form$2.Field,
|
|
12985
|
+
{
|
|
12986
|
+
control: form.control,
|
|
12987
|
+
name: "postal_code",
|
|
12988
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
12989
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
|
|
12990
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
12991
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
12992
|
+
] })
|
|
12993
|
+
}
|
|
12994
|
+
),
|
|
12995
|
+
/* @__PURE__ */ jsx(
|
|
12996
|
+
Form$2.Field,
|
|
12997
|
+
{
|
|
12998
|
+
control: form.control,
|
|
12999
|
+
name: "city",
|
|
13000
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13001
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
|
|
13002
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13003
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13004
|
+
] })
|
|
13005
|
+
}
|
|
13006
|
+
)
|
|
13027
13007
|
] }),
|
|
13028
|
-
/* @__PURE__ */ jsx(
|
|
13029
|
-
|
|
13008
|
+
/* @__PURE__ */ jsx(
|
|
13009
|
+
Form$2.Field,
|
|
13030
13010
|
{
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
13011
|
+
control: form.control,
|
|
13012
|
+
name: "province",
|
|
13013
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13014
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
13015
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13016
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13017
|
+
] })
|
|
13035
13018
|
}
|
|
13036
|
-
)
|
|
13037
|
-
|
|
13038
|
-
|
|
13019
|
+
),
|
|
13020
|
+
/* @__PURE__ */ jsx(
|
|
13021
|
+
Form$2.Field,
|
|
13022
|
+
{
|
|
13023
|
+
control: form.control,
|
|
13024
|
+
name: "phone",
|
|
13025
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
13026
|
+
/* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
13027
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
|
|
13028
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
13029
|
+
] })
|
|
13030
|
+
}
|
|
13031
|
+
)
|
|
13032
|
+
] }) }),
|
|
13033
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
13034
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
13035
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
13036
|
+
] }) })
|
|
13037
|
+
]
|
|
13039
13038
|
}
|
|
13040
|
-
);
|
|
13039
|
+
) });
|
|
13041
13040
|
};
|
|
13041
|
+
const schema = addressSchema;
|
|
13042
13042
|
const widgetModule = { widgets: [] };
|
|
13043
13043
|
const routeModule = {
|
|
13044
13044
|
routes: [
|
|
@@ -13059,14 +13059,14 @@ const routeModule = {
|
|
|
13059
13059
|
handle,
|
|
13060
13060
|
loader,
|
|
13061
13061
|
children: [
|
|
13062
|
-
{
|
|
13063
|
-
Component: BillingAddress,
|
|
13064
|
-
path: "/draft-orders/:id/billing-address"
|
|
13065
|
-
},
|
|
13066
13062
|
{
|
|
13067
13063
|
Component: CustomItems,
|
|
13068
13064
|
path: "/draft-orders/:id/custom-items"
|
|
13069
13065
|
},
|
|
13066
|
+
{
|
|
13067
|
+
Component: BillingAddress,
|
|
13068
|
+
path: "/draft-orders/:id/billing-address"
|
|
13069
|
+
},
|
|
13070
13070
|
{
|
|
13071
13071
|
Component: Email,
|
|
13072
13072
|
path: "/draft-orders/:id/email"
|
|
@@ -13075,6 +13075,10 @@ const routeModule = {
|
|
|
13075
13075
|
Component: Items,
|
|
13076
13076
|
path: "/draft-orders/:id/items"
|
|
13077
13077
|
},
|
|
13078
|
+
{
|
|
13079
|
+
Component: Promotions,
|
|
13080
|
+
path: "/draft-orders/:id/promotions"
|
|
13081
|
+
},
|
|
13078
13082
|
{
|
|
13079
13083
|
Component: Metadata,
|
|
13080
13084
|
path: "/draft-orders/:id/metadata"
|
|
@@ -13084,20 +13088,16 @@ const routeModule = {
|
|
|
13084
13088
|
path: "/draft-orders/:id/sales-channel"
|
|
13085
13089
|
},
|
|
13086
13090
|
{
|
|
13087
|
-
Component:
|
|
13088
|
-
path: "/draft-orders/:id/
|
|
13089
|
-
},
|
|
13090
|
-
{
|
|
13091
|
-
Component: ShippingAddress,
|
|
13092
|
-
path: "/draft-orders/:id/shipping-address"
|
|
13091
|
+
Component: Shipping,
|
|
13092
|
+
path: "/draft-orders/:id/shipping"
|
|
13093
13093
|
},
|
|
13094
13094
|
{
|
|
13095
13095
|
Component: TransferOwnership,
|
|
13096
13096
|
path: "/draft-orders/:id/transfer-ownership"
|
|
13097
13097
|
},
|
|
13098
13098
|
{
|
|
13099
|
-
Component:
|
|
13100
|
-
path: "/draft-orders/:id/shipping"
|
|
13099
|
+
Component: ShippingAddress,
|
|
13100
|
+
path: "/draft-orders/:id/shipping-address"
|
|
13101
13101
|
}
|
|
13102
13102
|
]
|
|
13103
13103
|
}
|