@medusajs/draft-order 2.14.0 → 2.14.1-preview-20260423121526

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.
@@ -9899,6 +9899,196 @@ const ID = () => {
9899
9899
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9900
9900
  ] });
9901
9901
  };
9902
+ const BillingAddress = () => {
9903
+ const { id } = reactRouterDom.useParams();
9904
+ const { order, isPending, isError, error } = useOrder(id, {
9905
+ fields: "+billing_address"
9906
+ });
9907
+ if (isError) {
9908
+ throw error;
9909
+ }
9910
+ const isReady = !isPending && !!order;
9911
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9912
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9913
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9914
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9915
+ ] }),
9916
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9917
+ ] });
9918
+ };
9919
+ const BillingAddressForm = ({ order }) => {
9920
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9921
+ const form = reactHookForm.useForm({
9922
+ defaultValues: {
9923
+ first_name: ((_a2 = order.billing_address) == null ? void 0 : _a2.first_name) ?? "",
9924
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9925
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9926
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9927
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9928
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9929
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9930
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9931
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9932
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9933
+ },
9934
+ resolver: zod.zodResolver(schema$5)
9935
+ });
9936
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9937
+ const { handleSuccess } = useRouteModal();
9938
+ const onSubmit = form.handleSubmit(async (data) => {
9939
+ await mutateAsync(
9940
+ { billing_address: data },
9941
+ {
9942
+ onSuccess: () => {
9943
+ handleSuccess();
9944
+ },
9945
+ onError: (error) => {
9946
+ ui.toast.error(error.message);
9947
+ }
9948
+ }
9949
+ );
9950
+ });
9951
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9952
+ KeyboundForm,
9953
+ {
9954
+ className: "flex flex-1 flex-col overflow-hidden",
9955
+ onSubmit,
9956
+ children: [
9957
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
9958
+ /* @__PURE__ */ jsxRuntime.jsx(
9959
+ Form$2.Field,
9960
+ {
9961
+ control: form.control,
9962
+ name: "country_code",
9963
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9964
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9965
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9966
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9967
+ ] })
9968
+ }
9969
+ ),
9970
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9971
+ /* @__PURE__ */ jsxRuntime.jsx(
9972
+ Form$2.Field,
9973
+ {
9974
+ control: form.control,
9975
+ name: "first_name",
9976
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9977
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9978
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9979
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9980
+ ] })
9981
+ }
9982
+ ),
9983
+ /* @__PURE__ */ jsxRuntime.jsx(
9984
+ Form$2.Field,
9985
+ {
9986
+ control: form.control,
9987
+ name: "last_name",
9988
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9989
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9990
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9991
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9992
+ ] })
9993
+ }
9994
+ )
9995
+ ] }),
9996
+ /* @__PURE__ */ jsxRuntime.jsx(
9997
+ Form$2.Field,
9998
+ {
9999
+ control: form.control,
10000
+ name: "company",
10001
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10002
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
10003
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10004
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10005
+ ] })
10006
+ }
10007
+ ),
10008
+ /* @__PURE__ */ jsxRuntime.jsx(
10009
+ Form$2.Field,
10010
+ {
10011
+ control: form.control,
10012
+ name: "address_1",
10013
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10014
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
10015
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10016
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10017
+ ] })
10018
+ }
10019
+ ),
10020
+ /* @__PURE__ */ jsxRuntime.jsx(
10021
+ Form$2.Field,
10022
+ {
10023
+ control: form.control,
10024
+ name: "address_2",
10025
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10026
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
10027
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10028
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10029
+ ] })
10030
+ }
10031
+ ),
10032
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10033
+ /* @__PURE__ */ jsxRuntime.jsx(
10034
+ Form$2.Field,
10035
+ {
10036
+ control: form.control,
10037
+ name: "postal_code",
10038
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10039
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
10040
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10041
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10042
+ ] })
10043
+ }
10044
+ ),
10045
+ /* @__PURE__ */ jsxRuntime.jsx(
10046
+ Form$2.Field,
10047
+ {
10048
+ control: form.control,
10049
+ name: "city",
10050
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10051
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
10052
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10053
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10054
+ ] })
10055
+ }
10056
+ )
10057
+ ] }),
10058
+ /* @__PURE__ */ jsxRuntime.jsx(
10059
+ Form$2.Field,
10060
+ {
10061
+ control: form.control,
10062
+ name: "province",
10063
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10064
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
10065
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10066
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10067
+ ] })
10068
+ }
10069
+ ),
10070
+ /* @__PURE__ */ jsxRuntime.jsx(
10071
+ Form$2.Field,
10072
+ {
10073
+ control: form.control,
10074
+ name: "phone",
10075
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10076
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
10077
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10078
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10079
+ ] })
10080
+ }
10081
+ )
10082
+ ] }) }),
10083
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10084
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10085
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10086
+ ] }) })
10087
+ ]
10088
+ }
10089
+ ) });
10090
+ };
10091
+ const schema$5 = addressSchema;
9902
10092
  const CustomItems = () => {
9903
10093
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9904
10094
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
@@ -9907,7 +10097,7 @@ const CustomItems = () => {
9907
10097
  };
9908
10098
  const CustomItemsForm = () => {
9909
10099
  const form = reactHookForm.useForm({
9910
- resolver: zod.zodResolver(schema$5)
10100
+ resolver: zod.zodResolver(schema$4)
9911
10101
  });
9912
10102
  return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9913
10103
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
@@ -9917,46 +10107,114 @@ const CustomItemsForm = () => {
9917
10107
  ] }) })
9918
10108
  ] }) });
9919
10109
  };
9920
- const schema$5 = object({
10110
+ const schema$4 = object({
9921
10111
  email: string().email()
9922
10112
  });
9923
- const NumberInput = React.forwardRef(
9924
- ({
9925
- value,
9926
- onChange,
9927
- size = "base",
9928
- min = 0,
9929
- max = 100,
9930
- step = 1,
9931
- className,
9932
- disabled,
9933
- ...props
9934
- }, ref) => {
9935
- const handleChange = (event) => {
9936
- const newValue = event.target.value === "" ? min : Number(event.target.value);
9937
- if (!isNaN(newValue) && (max === void 0 || newValue <= max) && (min === void 0 || newValue >= min)) {
9938
- onChange(newValue);
9939
- }
9940
- };
9941
- const handleIncrement = () => {
9942
- const newValue = value + step;
9943
- if (max === void 0 || newValue <= max) {
9944
- onChange(newValue);
9945
- }
9946
- };
9947
- const handleDecrement = () => {
9948
- const newValue = value - step;
9949
- if (min === void 0 || newValue >= min) {
9950
- onChange(newValue);
9951
- }
9952
- };
9953
- return /* @__PURE__ */ jsxRuntime.jsxs(
9954
- "div",
10113
+ const Email = () => {
10114
+ const { id } = reactRouterDom.useParams();
10115
+ const { order, isPending, isError, error } = useOrder(id, {
10116
+ fields: "+email"
10117
+ });
10118
+ if (isError) {
10119
+ throw error;
10120
+ }
10121
+ const isReady = !isPending && !!order;
10122
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10123
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10124
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
10125
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
10126
+ ] }),
10127
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
10128
+ ] });
10129
+ };
10130
+ const EmailForm = ({ order }) => {
10131
+ const form = reactHookForm.useForm({
10132
+ defaultValues: {
10133
+ email: order.email ?? ""
10134
+ },
10135
+ resolver: zod.zodResolver(schema$3)
10136
+ });
10137
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10138
+ const { handleSuccess } = useRouteModal();
10139
+ const onSubmit = form.handleSubmit(async (data) => {
10140
+ await mutateAsync(
10141
+ { email: data.email },
9955
10142
  {
9956
- className: ui.clx(
9957
- "inline-flex rounded-md bg-ui-bg-field shadow-borders-base overflow-hidden divide-x transition-fg",
9958
- "[&:has(input:focus)]:shadow-borders-interactive-with-active",
9959
- {
10143
+ onSuccess: () => {
10144
+ handleSuccess();
10145
+ },
10146
+ onError: (error) => {
10147
+ ui.toast.error(error.message);
10148
+ }
10149
+ }
10150
+ );
10151
+ });
10152
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
10153
+ KeyboundForm,
10154
+ {
10155
+ className: "flex flex-1 flex-col overflow-hidden",
10156
+ onSubmit,
10157
+ children: [
10158
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
10159
+ Form$2.Field,
10160
+ {
10161
+ control: form.control,
10162
+ name: "email",
10163
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10164
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
10165
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10166
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10167
+ ] })
10168
+ }
10169
+ ) }),
10170
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10171
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10172
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10173
+ ] }) })
10174
+ ]
10175
+ }
10176
+ ) });
10177
+ };
10178
+ const schema$3 = object({
10179
+ email: string().email()
10180
+ });
10181
+ const NumberInput = React.forwardRef(
10182
+ ({
10183
+ value,
10184
+ onChange,
10185
+ size = "base",
10186
+ min = 0,
10187
+ max = 100,
10188
+ step = 1,
10189
+ className,
10190
+ disabled,
10191
+ ...props
10192
+ }, ref) => {
10193
+ const handleChange = (event) => {
10194
+ const newValue = event.target.value === "" ? min : Number(event.target.value);
10195
+ if (!isNaN(newValue) && (max === void 0 || newValue <= max) && (min === void 0 || newValue >= min)) {
10196
+ onChange(newValue);
10197
+ }
10198
+ };
10199
+ const handleIncrement = () => {
10200
+ const newValue = value + step;
10201
+ if (max === void 0 || newValue <= max) {
10202
+ onChange(newValue);
10203
+ }
10204
+ };
10205
+ const handleDecrement = () => {
10206
+ const newValue = value - step;
10207
+ if (min === void 0 || newValue >= min) {
10208
+ onChange(newValue);
10209
+ }
10210
+ };
10211
+ return /* @__PURE__ */ jsxRuntime.jsxs(
10212
+ "div",
10213
+ {
10214
+ className: ui.clx(
10215
+ "inline-flex rounded-md bg-ui-bg-field shadow-borders-base overflow-hidden divide-x transition-fg",
10216
+ "[&:has(input:focus)]:shadow-borders-interactive-with-active",
10217
+ {
9960
10218
  "h-7": size === "small",
9961
10219
  "h-8": size === "base"
9962
10220
  },
@@ -10718,439 +10976,181 @@ const ExistingItemsForm = ({ orderId, items }) => {
10718
10976
  const columnHelper = ui.createDataTableColumnHelper();
10719
10977
  const useColumns = () => {
10720
10978
  return React.useMemo(() => {
10721
- return [
10722
- columnHelper.select(),
10723
- columnHelper.accessor("product.title", {
10724
- header: "Product",
10725
- cell: ({ row }) => {
10726
- var _a2, _b, _c;
10727
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2", children: [
10728
- /* @__PURE__ */ jsxRuntime.jsx(
10729
- Thumbnail,
10730
- {
10731
- thumbnail: (_a2 = row.original.product) == null ? void 0 : _a2.thumbnail,
10732
- alt: (_b = row.original.product) == null ? void 0 : _b.title
10733
- }
10734
- ),
10735
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: (_c = row.original.product) == null ? void 0 : _c.title })
10736
- ] });
10737
- },
10738
- enableSorting: true
10739
- }),
10740
- columnHelper.accessor("title", {
10741
- header: "Variant",
10742
- enableSorting: true
10743
- }),
10744
- columnHelper.accessor("sku", {
10745
- header: "SKU",
10746
- cell: ({ getValue }) => {
10747
- return getValue() ?? "-";
10748
- },
10749
- enableSorting: true
10750
- }),
10751
- columnHelper.accessor("updated_at", {
10752
- header: "Updated",
10753
- cell: ({ getValue }) => {
10754
- return /* @__PURE__ */ jsxRuntime.jsx(
10755
- ui.Tooltip,
10756
- {
10757
- content: getFullDate({ date: getValue(), includeTime: true }),
10758
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: getFullDate({ date: getValue() }) })
10759
- }
10760
- );
10761
- },
10762
- enableSorting: true,
10763
- sortAscLabel: "Oldest first",
10764
- sortDescLabel: "Newest first"
10765
- }),
10766
- columnHelper.accessor("created_at", {
10767
- header: "Created",
10768
- cell: ({ getValue }) => {
10769
- return /* @__PURE__ */ jsxRuntime.jsx(
10770
- ui.Tooltip,
10771
- {
10772
- content: getFullDate({ date: getValue(), includeTime: true }),
10773
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: getFullDate({ date: getValue() }) })
10774
- }
10775
- );
10776
- },
10777
- enableSorting: true,
10778
- sortAscLabel: "Oldest first",
10779
- sortDescLabel: "Newest first"
10780
- })
10781
- ];
10782
- }, []);
10783
- };
10784
- const CustomItemForm = ({ orderId, currencyCode }) => {
10785
- const { setIsOpen } = useStackedModal();
10786
- const { mutateAsync: addItems } = useDraftOrderAddItems(orderId);
10787
- const form = reactHookForm.useForm({
10788
- defaultValues: {
10789
- title: "",
10790
- quantity: 1,
10791
- unit_price: ""
10792
- },
10793
- resolver: zod.zodResolver(customItemSchema)
10794
- });
10795
- const onSubmit = form.handleSubmit(async (data) => {
10796
- await addItems(
10797
- {
10798
- items: [
10799
- {
10800
- title: data.title,
10801
- quantity: data.quantity,
10802
- unit_price: convertNumber(data.unit_price)
10803
- }
10804
- ]
10805
- },
10806
- {
10807
- onSuccess: () => {
10808
- setIsOpen(STACKED_MODAL_ID, false);
10809
- },
10810
- onError: (e) => {
10811
- ui.toast.error(e.message);
10812
- }
10813
- }
10814
- );
10815
- });
10816
- return /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx(KeyboundForm, { onSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs(StackedFocusModal.Content, { children: [
10817
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Header, {}),
10818
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-2 py-16", children: [
10819
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10820
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Add custom item" }) }),
10821
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a custom item to the order. This will add a new line item that is not associated with an existing product." }) })
10822
- ] }),
10823
- /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
10824
- /* @__PURE__ */ jsxRuntime.jsx(
10825
- Form$2.Field,
10826
- {
10827
- control: form.control,
10828
- name: "title",
10829
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
10830
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10831
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Title" }),
10832
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the title of the item" })
10833
- ] }),
10834
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10835
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10836
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10837
- ] })
10838
- ] }) })
10839
- }
10840
- ),
10841
- /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
10842
- /* @__PURE__ */ jsxRuntime.jsx(
10843
- Form$2.Field,
10844
- {
10845
- control: form.control,
10846
- name: "unit_price",
10847
- render: ({ field: { onChange, ...field } }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
10848
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10849
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Unit price" }),
10850
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the unit price of the item" })
10851
- ] }),
10852
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10853
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
10854
- ui.CurrencyInput,
10855
- {
10856
- symbol: getNativeSymbol(currencyCode),
10857
- code: currencyCode,
10858
- onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value),
10859
- ...field
10860
- }
10861
- ) }),
10862
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10863
- ] })
10864
- ] }) })
10865
- }
10866
- ),
10867
- /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
10868
- /* @__PURE__ */ jsxRuntime.jsx(
10869
- Form$2.Field,
10870
- {
10871
- control: form.control,
10872
- name: "quantity",
10873
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
10874
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10875
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Quantity" }),
10876
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
10877
- ] }),
10878
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full flex-1", children: [
10879
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field, className: "w-full" }) }) }),
10880
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10881
- ] })
10882
- ] }) })
10883
- }
10884
- )
10885
- ] }) }) }),
10886
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
10887
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
10888
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
10889
- ] }) })
10890
- ] }) }) });
10891
- };
10892
- const customItemSchema = object({
10893
- title: string().min(1),
10894
- quantity: number(),
10895
- unit_price: union([number(), string()])
10896
- });
10897
- const BillingAddress = () => {
10898
- const { id } = reactRouterDom.useParams();
10899
- const { order, isPending, isError, error } = useOrder(id, {
10900
- fields: "+billing_address"
10901
- });
10902
- if (isError) {
10903
- throw error;
10904
- }
10905
- const isReady = !isPending && !!order;
10906
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10907
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10908
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
10909
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
10910
- ] }),
10911
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
10912
- ] });
10913
- };
10914
- const BillingAddressForm = ({ order }) => {
10915
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
10916
- const form = reactHookForm.useForm({
10917
- defaultValues: {
10918
- first_name: ((_a2 = order.billing_address) == null ? void 0 : _a2.first_name) ?? "",
10919
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
10920
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
10921
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
10922
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
10923
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
10924
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
10925
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
10926
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
10927
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
10928
- },
10929
- resolver: zod.zodResolver(schema$4)
10930
- });
10931
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10932
- const { handleSuccess } = useRouteModal();
10933
- const onSubmit = form.handleSubmit(async (data) => {
10934
- await mutateAsync(
10935
- { billing_address: data },
10936
- {
10937
- onSuccess: () => {
10938
- handleSuccess();
10939
- },
10940
- onError: (error) => {
10941
- ui.toast.error(error.message);
10942
- }
10943
- }
10944
- );
10945
- });
10946
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
10947
- KeyboundForm,
10948
- {
10949
- className: "flex flex-1 flex-col overflow-hidden",
10950
- onSubmit,
10951
- children: [
10952
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
10953
- /* @__PURE__ */ jsxRuntime.jsx(
10954
- Form$2.Field,
10955
- {
10956
- control: form.control,
10957
- name: "country_code",
10958
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10959
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
10960
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
10961
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10962
- ] })
10963
- }
10964
- ),
10965
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10966
- /* @__PURE__ */ jsxRuntime.jsx(
10967
- Form$2.Field,
10968
- {
10969
- control: form.control,
10970
- name: "first_name",
10971
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10972
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
10973
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10974
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10975
- ] })
10976
- }
10977
- ),
10978
- /* @__PURE__ */ jsxRuntime.jsx(
10979
- Form$2.Field,
10980
- {
10981
- control: form.control,
10982
- name: "last_name",
10983
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10984
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
10985
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10986
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10987
- ] })
10988
- }
10989
- )
10990
- ] }),
10991
- /* @__PURE__ */ jsxRuntime.jsx(
10992
- Form$2.Field,
10993
- {
10994
- control: form.control,
10995
- name: "company",
10996
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10997
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
10998
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10999
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11000
- ] })
11001
- }
11002
- ),
11003
- /* @__PURE__ */ jsxRuntime.jsx(
11004
- Form$2.Field,
11005
- {
11006
- control: form.control,
11007
- name: "address_1",
11008
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11009
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
11010
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11011
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11012
- ] })
11013
- }
11014
- ),
11015
- /* @__PURE__ */ jsxRuntime.jsx(
11016
- Form$2.Field,
11017
- {
11018
- control: form.control,
11019
- name: "address_2",
11020
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11021
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11022
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11023
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11024
- ] })
11025
- }
11026
- ),
11027
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11028
- /* @__PURE__ */ jsxRuntime.jsx(
11029
- Form$2.Field,
11030
- {
11031
- control: form.control,
11032
- name: "postal_code",
11033
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11034
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
11035
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11036
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11037
- ] })
11038
- }
11039
- ),
10979
+ return [
10980
+ columnHelper.select(),
10981
+ columnHelper.accessor("product.title", {
10982
+ header: "Product",
10983
+ cell: ({ row }) => {
10984
+ var _a2, _b, _c;
10985
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2", children: [
11040
10986
  /* @__PURE__ */ jsxRuntime.jsx(
11041
- Form$2.Field,
10987
+ Thumbnail,
11042
10988
  {
11043
- control: form.control,
11044
- name: "city",
11045
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11046
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
11047
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11048
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11049
- ] })
10989
+ thumbnail: (_a2 = row.original.product) == null ? void 0 : _a2.thumbnail,
10990
+ alt: (_b = row.original.product) == null ? void 0 : _b.title
11050
10991
  }
11051
- )
11052
- ] }),
11053
- /* @__PURE__ */ jsxRuntime.jsx(
11054
- Form$2.Field,
10992
+ ),
10993
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: (_c = row.original.product) == null ? void 0 : _c.title })
10994
+ ] });
10995
+ },
10996
+ enableSorting: true
10997
+ }),
10998
+ columnHelper.accessor("title", {
10999
+ header: "Variant",
11000
+ enableSorting: true
11001
+ }),
11002
+ columnHelper.accessor("sku", {
11003
+ header: "SKU",
11004
+ cell: ({ getValue }) => {
11005
+ return getValue() ?? "-";
11006
+ },
11007
+ enableSorting: true
11008
+ }),
11009
+ columnHelper.accessor("updated_at", {
11010
+ header: "Updated",
11011
+ cell: ({ getValue }) => {
11012
+ return /* @__PURE__ */ jsxRuntime.jsx(
11013
+ ui.Tooltip,
11055
11014
  {
11056
- control: form.control,
11057
- name: "province",
11058
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11059
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11060
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11061
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11062
- ] })
11015
+ content: getFullDate({ date: getValue(), includeTime: true }),
11016
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: getFullDate({ date: getValue() }) })
11063
11017
  }
11064
- ),
11065
- /* @__PURE__ */ jsxRuntime.jsx(
11066
- Form$2.Field,
11018
+ );
11019
+ },
11020
+ enableSorting: true,
11021
+ sortAscLabel: "Oldest first",
11022
+ sortDescLabel: "Newest first"
11023
+ }),
11024
+ columnHelper.accessor("created_at", {
11025
+ header: "Created",
11026
+ cell: ({ getValue }) => {
11027
+ return /* @__PURE__ */ jsxRuntime.jsx(
11028
+ ui.Tooltip,
11067
11029
  {
11068
- control: form.control,
11069
- name: "phone",
11070
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11071
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
11072
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11073
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11074
- ] })
11030
+ content: getFullDate({ date: getValue(), includeTime: true }),
11031
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: getFullDate({ date: getValue() }) })
11075
11032
  }
11076
- )
11077
- ] }) }),
11078
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11079
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11080
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11081
- ] }) })
11082
- ]
11083
- }
11084
- ) });
11085
- };
11086
- const schema$4 = addressSchema;
11087
- const Email = () => {
11088
- const { id } = reactRouterDom.useParams();
11089
- const { order, isPending, isError, error } = useOrder(id, {
11090
- fields: "+email"
11091
- });
11092
- if (isError) {
11093
- throw error;
11094
- }
11095
- const isReady = !isPending && !!order;
11096
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11097
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11098
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
11099
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
11100
- ] }),
11101
- isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
11102
- ] });
11033
+ );
11034
+ },
11035
+ enableSorting: true,
11036
+ sortAscLabel: "Oldest first",
11037
+ sortDescLabel: "Newest first"
11038
+ })
11039
+ ];
11040
+ }, []);
11103
11041
  };
11104
- const EmailForm = ({ order }) => {
11042
+ const CustomItemForm = ({ orderId, currencyCode }) => {
11043
+ const { setIsOpen } = useStackedModal();
11044
+ const { mutateAsync: addItems } = useDraftOrderAddItems(orderId);
11105
11045
  const form = reactHookForm.useForm({
11106
11046
  defaultValues: {
11107
- email: order.email ?? ""
11047
+ title: "",
11048
+ quantity: 1,
11049
+ unit_price: ""
11108
11050
  },
11109
- resolver: zod.zodResolver(schema$3)
11051
+ resolver: zod.zodResolver(customItemSchema)
11110
11052
  });
11111
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11112
- const { handleSuccess } = useRouteModal();
11113
11053
  const onSubmit = form.handleSubmit(async (data) => {
11114
- await mutateAsync(
11115
- { email: data.email },
11054
+ await addItems(
11055
+ {
11056
+ items: [
11057
+ {
11058
+ title: data.title,
11059
+ quantity: data.quantity,
11060
+ unit_price: convertNumber(data.unit_price)
11061
+ }
11062
+ ]
11063
+ },
11116
11064
  {
11117
11065
  onSuccess: () => {
11118
- handleSuccess();
11066
+ setIsOpen(STACKED_MODAL_ID, false);
11119
11067
  },
11120
- onError: (error) => {
11121
- ui.toast.error(error.message);
11068
+ onError: (e) => {
11069
+ ui.toast.error(e.message);
11122
11070
  }
11123
11071
  }
11124
11072
  );
11125
11073
  });
11126
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11127
- KeyboundForm,
11128
- {
11129
- className: "flex flex-1 flex-col overflow-hidden",
11130
- onSubmit,
11131
- children: [
11132
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
11133
- Form$2.Field,
11134
- {
11135
- control: form.control,
11136
- name: "email",
11137
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11138
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
11074
+ return /* @__PURE__ */ jsxRuntime.jsx(Form$2, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx(KeyboundForm, { onSubmit, children: /* @__PURE__ */ jsxRuntime.jsxs(StackedFocusModal.Content, { children: [
11075
+ /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Header, {}),
11076
+ /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Body, { className: "flex flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 flex-col items-center overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-6 px-2 py-16", children: [
11077
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11078
+ /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Add custom item" }) }),
11079
+ /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Add a custom item to the order. This will add a new line item that is not associated with an existing product." }) })
11080
+ ] }),
11081
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
11082
+ /* @__PURE__ */ jsxRuntime.jsx(
11083
+ Form$2.Field,
11084
+ {
11085
+ control: form.control,
11086
+ name: "title",
11087
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
11088
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11089
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Title" }),
11090
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the title of the item" })
11091
+ ] }),
11092
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11139
11093
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11140
11094
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11141
11095
  ] })
11142
- }
11143
- ) }),
11144
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11145
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11146
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11147
- ] }) })
11148
- ]
11149
- }
11150
- ) });
11096
+ ] }) })
11097
+ }
11098
+ ),
11099
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
11100
+ /* @__PURE__ */ jsxRuntime.jsx(
11101
+ Form$2.Field,
11102
+ {
11103
+ control: form.control,
11104
+ name: "unit_price",
11105
+ render: ({ field: { onChange, ...field } }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
11106
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11107
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Unit price" }),
11108
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the unit price of the item" })
11109
+ ] }),
11110
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11111
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11112
+ ui.CurrencyInput,
11113
+ {
11114
+ symbol: getNativeSymbol(currencyCode),
11115
+ code: currencyCode,
11116
+ onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value),
11117
+ ...field
11118
+ }
11119
+ ) }),
11120
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11121
+ ] })
11122
+ ] }) })
11123
+ }
11124
+ ),
11125
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
11126
+ /* @__PURE__ */ jsxRuntime.jsx(
11127
+ Form$2.Field,
11128
+ {
11129
+ control: form.control,
11130
+ name: "quantity",
11131
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
11132
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11133
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Quantity" }),
11134
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
11135
+ ] }),
11136
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full flex-1", children: [
11137
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full flex-1", children: /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { ...field, className: "w-full" }) }) }),
11138
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11139
+ ] })
11140
+ ] }) })
11141
+ }
11142
+ )
11143
+ ] }) }) }),
11144
+ /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
11145
+ /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
11146
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
11147
+ ] }) })
11148
+ ] }) }) });
11151
11149
  };
11152
- const schema$3 = object({
11153
- email: string().email()
11150
+ const customItemSchema = object({
11151
+ title: string().min(1),
11152
+ quantity: number(),
11153
+ unit_price: union([number(), string()])
11154
11154
  });
11155
11155
  const InlineTip = React.forwardRef(
11156
11156
  ({ variant = "tip", label, className, children, ...props }, ref) => {
@@ -13391,22 +13391,22 @@ const routeModule = {
13391
13391
  handle,
13392
13392
  loader,
13393
13393
  children: [
13394
- {
13395
- Component: CustomItems,
13396
- path: "/draft-orders/:id/custom-items"
13397
- },
13398
- {
13399
- Component: Items,
13400
- path: "/draft-orders/:id/items"
13401
- },
13402
13394
  {
13403
13395
  Component: BillingAddress,
13404
13396
  path: "/draft-orders/:id/billing-address"
13405
13397
  },
13398
+ {
13399
+ Component: CustomItems,
13400
+ path: "/draft-orders/:id/custom-items"
13401
+ },
13406
13402
  {
13407
13403
  Component: Email,
13408
13404
  path: "/draft-orders/:id/email"
13409
13405
  },
13406
+ {
13407
+ Component: Items,
13408
+ path: "/draft-orders/:id/items"
13409
+ },
13410
13410
  {
13411
13411
  Component: Metadata,
13412
13412
  path: "/draft-orders/:id/metadata"