@medusajs/draft-order 2.11.4-snapshot-20251105174837 → 2.11.4-snapshot-20251106121614

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.
@@ -9779,10 +9779,54 @@ const CustomItemsForm = () => {
9779
9779
  const schema$4 = objectType({
9780
9780
  email: stringType().email()
9781
9781
  });
9782
- const Email = () => {
9782
+ const InlineTip = React.forwardRef(
9783
+ ({ variant = "tip", label, className, children, ...props }, ref) => {
9784
+ const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
9785
+ return /* @__PURE__ */ jsxRuntime.jsxs(
9786
+ "div",
9787
+ {
9788
+ ref,
9789
+ className: ui.clx(
9790
+ "bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
9791
+ className
9792
+ ),
9793
+ ...props,
9794
+ children: [
9795
+ /* @__PURE__ */ jsxRuntime.jsx(
9796
+ "div",
9797
+ {
9798
+ role: "presentation",
9799
+ className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
9800
+ "bg-ui-tag-orange-icon": variant === "warning"
9801
+ })
9802
+ }
9803
+ ),
9804
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
9805
+ /* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
9806
+ labelValue,
9807
+ ":"
9808
+ ] }),
9809
+ " ",
9810
+ children
9811
+ ] })
9812
+ ]
9813
+ }
9814
+ );
9815
+ }
9816
+ );
9817
+ InlineTip.displayName = "InlineTip";
9818
+ const MetadataFieldSchema = objectType({
9819
+ key: stringType(),
9820
+ disabled: booleanType().optional(),
9821
+ value: anyType()
9822
+ });
9823
+ const MetadataSchema = objectType({
9824
+ metadata: arrayType(MetadataFieldSchema)
9825
+ });
9826
+ const Metadata = () => {
9783
9827
  const { id } = reactRouterDom.useParams();
9784
9828
  const { order, isPending, isError, error } = useOrder(id, {
9785
- fields: "+email"
9829
+ fields: "metadata"
9786
9830
  });
9787
9831
  if (isError) {
9788
9832
  throw error;
@@ -9790,26 +9834,33 @@ const Email = () => {
9790
9834
  const isReady = !isPending && !!order;
9791
9835
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9792
9836
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9793
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
9794
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
9837
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
9838
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
9795
9839
  ] }),
9796
- isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
9840
+ !isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
9797
9841
  ] });
9798
9842
  };
9799
- const EmailForm = ({ order }) => {
9843
+ const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
9844
+ const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
9845
+ const MetadataForm = ({ orderId, metadata }) => {
9846
+ const { handleSuccess } = useRouteModal();
9847
+ const hasUneditableRows = getHasUneditableRows(metadata);
9848
+ const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
9800
9849
  const form = reactHookForm.useForm({
9801
9850
  defaultValues: {
9802
- email: order.email ?? ""
9851
+ metadata: getDefaultValues(metadata)
9803
9852
  },
9804
- resolver: zod.zodResolver(schema$3)
9853
+ resolver: zod.zodResolver(MetadataSchema)
9805
9854
  });
9806
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9807
- const { handleSuccess } = useRouteModal();
9808
- const onSubmit = form.handleSubmit(async (data) => {
9855
+ const handleSubmit = form.handleSubmit(async (data) => {
9856
+ const parsedData = parseValues(data);
9809
9857
  await mutateAsync(
9810
- { email: data.email },
9858
+ {
9859
+ metadata: parsedData
9860
+ },
9811
9861
  {
9812
9862
  onSuccess: () => {
9863
+ ui.toast.success("Metadata updated");
9813
9864
  handleSuccess();
9814
9865
  },
9815
9866
  onError: (error) => {
@@ -9818,46 +9869,345 @@ const EmailForm = ({ order }) => {
9818
9869
  }
9819
9870
  );
9820
9871
  });
9872
+ const { fields, insert, remove } = reactHookForm.useFieldArray({
9873
+ control: form.control,
9874
+ name: "metadata"
9875
+ });
9876
+ function deleteRow(index) {
9877
+ remove(index);
9878
+ if (fields.length === 1) {
9879
+ insert(0, {
9880
+ key: "",
9881
+ value: "",
9882
+ disabled: false
9883
+ });
9884
+ }
9885
+ }
9886
+ function insertRow(index, position) {
9887
+ insert(index + (position === "above" ? 0 : 1), {
9888
+ key: "",
9889
+ value: "",
9890
+ disabled: false
9891
+ });
9892
+ }
9821
9893
  return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9822
9894
  KeyboundForm,
9823
9895
  {
9896
+ onSubmit: handleSubmit,
9824
9897
  className: "flex flex-1 flex-col overflow-hidden",
9825
- onSubmit,
9826
9898
  children: [
9827
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
9828
- Form$2.Field,
9829
- {
9830
- control: form.control,
9831
- name: "email",
9832
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9833
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
9834
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9835
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9836
- ] })
9837
- }
9838
- ) }),
9839
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9840
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9899
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
9900
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
9901
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
9902
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_KEY_LABEL_ID, children: "Key" }) }),
9903
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_VALUE_LABEL_ID, children: "Value" }) })
9904
+ ] }),
9905
+ fields.map((field, index) => {
9906
+ const isDisabled = field.disabled || false;
9907
+ let placeholder = "-";
9908
+ if (typeof field.value === "object") {
9909
+ placeholder = "{ ... }";
9910
+ }
9911
+ if (Array.isArray(field.value)) {
9912
+ placeholder = "[ ... ]";
9913
+ }
9914
+ return /* @__PURE__ */ jsxRuntime.jsx(
9915
+ ConditionalTooltip,
9916
+ {
9917
+ showTooltip: isDisabled,
9918
+ content: "This row is disabled because it contains non-primitive data.",
9919
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
9920
+ /* @__PURE__ */ jsxRuntime.jsxs(
9921
+ "div",
9922
+ {
9923
+ className: ui.clx("grid grid-cols-2 divide-x", {
9924
+ "overflow-hidden rounded-b-lg": index === fields.length - 1
9925
+ }),
9926
+ children: [
9927
+ /* @__PURE__ */ jsxRuntime.jsx(
9928
+ Form$2.Field,
9929
+ {
9930
+ control: form.control,
9931
+ name: `metadata.${index}.key`,
9932
+ render: ({ field: field2 }) => {
9933
+ return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
9934
+ GridInput,
9935
+ {
9936
+ "aria-labelledby": METADATA_KEY_LABEL_ID,
9937
+ ...field2,
9938
+ disabled: isDisabled,
9939
+ placeholder: "Key"
9940
+ }
9941
+ ) }) });
9942
+ }
9943
+ }
9944
+ ),
9945
+ /* @__PURE__ */ jsxRuntime.jsx(
9946
+ Form$2.Field,
9947
+ {
9948
+ control: form.control,
9949
+ name: `metadata.${index}.value`,
9950
+ render: ({ field: { value, ...field2 } }) => {
9951
+ return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
9952
+ GridInput,
9953
+ {
9954
+ "aria-labelledby": METADATA_VALUE_LABEL_ID,
9955
+ ...field2,
9956
+ value: isDisabled ? placeholder : value,
9957
+ disabled: isDisabled,
9958
+ placeholder: "Value"
9959
+ }
9960
+ ) }) });
9961
+ }
9962
+ }
9963
+ )
9964
+ ]
9965
+ }
9966
+ ),
9967
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
9968
+ /* @__PURE__ */ jsxRuntime.jsx(
9969
+ ui.DropdownMenu.Trigger,
9970
+ {
9971
+ className: ui.clx(
9972
+ "invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
9973
+ {
9974
+ hidden: isDisabled
9975
+ }
9976
+ ),
9977
+ disabled: isDisabled,
9978
+ asChild: true,
9979
+ children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
9980
+ }
9981
+ ),
9982
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
9983
+ /* @__PURE__ */ jsxRuntime.jsxs(
9984
+ ui.DropdownMenu.Item,
9985
+ {
9986
+ className: "gap-x-2",
9987
+ onClick: () => insertRow(index, "above"),
9988
+ children: [
9989
+ /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
9990
+ "Insert row above"
9991
+ ]
9992
+ }
9993
+ ),
9994
+ /* @__PURE__ */ jsxRuntime.jsxs(
9995
+ ui.DropdownMenu.Item,
9996
+ {
9997
+ className: "gap-x-2",
9998
+ onClick: () => insertRow(index, "below"),
9999
+ children: [
10000
+ /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
10001
+ "Insert row below"
10002
+ ]
10003
+ }
10004
+ ),
10005
+ /* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
10006
+ /* @__PURE__ */ jsxRuntime.jsxs(
10007
+ ui.DropdownMenu.Item,
10008
+ {
10009
+ className: "gap-x-2",
10010
+ onClick: () => deleteRow(index),
10011
+ children: [
10012
+ /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
10013
+ "Delete row"
10014
+ ]
10015
+ }
10016
+ )
10017
+ ] })
10018
+ ] })
10019
+ ] })
10020
+ },
10021
+ field.id
10022
+ );
10023
+ })
10024
+ ] }),
10025
+ hasUneditableRows && /* @__PURE__ */ jsxRuntime.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." })
10026
+ ] }),
10027
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
10028
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
9841
10029
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9842
10030
  ] }) })
9843
10031
  ]
9844
10032
  }
9845
10033
  ) });
9846
10034
  };
9847
- const schema$3 = objectType({
9848
- email: stringType().email()
9849
- });
9850
- const NumberInput = React.forwardRef(
9851
- ({
9852
- value,
9853
- onChange,
9854
- size = "base",
9855
- min = 0,
9856
- max = 100,
9857
- step = 1,
9858
- className,
9859
- disabled,
9860
- ...props
10035
+ const GridInput = React.forwardRef(({ className, ...props }, ref) => {
10036
+ return /* @__PURE__ */ jsxRuntime.jsx(
10037
+ "input",
10038
+ {
10039
+ ref,
10040
+ ...props,
10041
+ autoComplete: "off",
10042
+ className: ui.clx(
10043
+ "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",
10044
+ className
10045
+ )
10046
+ }
10047
+ );
10048
+ });
10049
+ GridInput.displayName = "MetadataForm.GridInput";
10050
+ const PlaceholderInner = () => {
10051
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
10052
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
10053
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
10054
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
10055
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
10056
+ ] }) })
10057
+ ] });
10058
+ };
10059
+ const EDITABLE_TYPES = ["string", "number", "boolean"];
10060
+ function getDefaultValues(metadata) {
10061
+ if (!metadata || !Object.keys(metadata).length) {
10062
+ return [
10063
+ {
10064
+ key: "",
10065
+ value: "",
10066
+ disabled: false
10067
+ }
10068
+ ];
10069
+ }
10070
+ return Object.entries(metadata).map(([key, value]) => {
10071
+ if (!EDITABLE_TYPES.includes(typeof value)) {
10072
+ return {
10073
+ key,
10074
+ value,
10075
+ disabled: true
10076
+ };
10077
+ }
10078
+ let stringValue = value;
10079
+ if (typeof value !== "string") {
10080
+ stringValue = JSON.stringify(value);
10081
+ }
10082
+ return {
10083
+ key,
10084
+ value: stringValue,
10085
+ original_key: key
10086
+ };
10087
+ });
10088
+ }
10089
+ function parseValues(values) {
10090
+ const metadata = values.metadata;
10091
+ const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
10092
+ if (isEmpty) {
10093
+ return null;
10094
+ }
10095
+ const update = {};
10096
+ metadata.forEach((field) => {
10097
+ let key = field.key;
10098
+ let value = field.value;
10099
+ const disabled = field.disabled;
10100
+ if (!key || !value) {
10101
+ return;
10102
+ }
10103
+ if (disabled) {
10104
+ update[key] = value;
10105
+ return;
10106
+ }
10107
+ key = key.trim();
10108
+ value = value.trim();
10109
+ if (value === "true") {
10110
+ update[key] = true;
10111
+ } else if (value === "false") {
10112
+ update[key] = false;
10113
+ } else {
10114
+ const parsedNumber = parseFloat(value);
10115
+ if (!isNaN(parsedNumber)) {
10116
+ update[key] = parsedNumber;
10117
+ } else {
10118
+ update[key] = value;
10119
+ }
10120
+ }
10121
+ });
10122
+ return update;
10123
+ }
10124
+ function getHasUneditableRows(metadata) {
10125
+ if (!metadata) {
10126
+ return false;
10127
+ }
10128
+ return Object.values(metadata).some(
10129
+ (value) => !EDITABLE_TYPES.includes(typeof value)
10130
+ );
10131
+ }
10132
+ const Email = () => {
10133
+ const { id } = reactRouterDom.useParams();
10134
+ const { order, isPending, isError, error } = useOrder(id, {
10135
+ fields: "+email"
10136
+ });
10137
+ if (isError) {
10138
+ throw error;
10139
+ }
10140
+ const isReady = !isPending && !!order;
10141
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10142
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10143
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Email" }) }),
10144
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the email for the draft order" }) })
10145
+ ] }),
10146
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(EmailForm, { order })
10147
+ ] });
10148
+ };
10149
+ const EmailForm = ({ order }) => {
10150
+ const form = reactHookForm.useForm({
10151
+ defaultValues: {
10152
+ email: order.email ?? ""
10153
+ },
10154
+ resolver: zod.zodResolver(schema$3)
10155
+ });
10156
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
10157
+ const { handleSuccess } = useRouteModal();
10158
+ const onSubmit = form.handleSubmit(async (data) => {
10159
+ await mutateAsync(
10160
+ { email: data.email },
10161
+ {
10162
+ onSuccess: () => {
10163
+ handleSuccess();
10164
+ },
10165
+ onError: (error) => {
10166
+ ui.toast.error(error.message);
10167
+ }
10168
+ }
10169
+ );
10170
+ });
10171
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
10172
+ KeyboundForm,
10173
+ {
10174
+ className: "flex flex-1 flex-col overflow-hidden",
10175
+ onSubmit,
10176
+ children: [
10177
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
10178
+ Form$2.Field,
10179
+ {
10180
+ control: form.control,
10181
+ name: "email",
10182
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10183
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Email" }),
10184
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10185
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10186
+ ] })
10187
+ }
10188
+ ) }),
10189
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10190
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10191
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10192
+ ] }) })
10193
+ ]
10194
+ }
10195
+ ) });
10196
+ };
10197
+ const schema$3 = objectType({
10198
+ email: stringType().email()
10199
+ });
10200
+ const NumberInput = React.forwardRef(
10201
+ ({
10202
+ value,
10203
+ onChange,
10204
+ size = "base",
10205
+ min = 0,
10206
+ max = 100,
10207
+ step = 1,
10208
+ className,
10209
+ disabled,
10210
+ ...props
9861
10211
  }, ref) => {
9862
10212
  const handleChange = (event) => {
9863
10213
  const newValue = event.target.value === "" ? min : Number(event.target.value);
@@ -10747,430 +11097,80 @@ const CustomItemForm = ({ orderId, currencyCode }) => {
10747
11097
  /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Add custom item" }) }),
10748
11098
  /* @__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." }) })
10749
11099
  ] }),
10750
- /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
10751
- /* @__PURE__ */ jsxRuntime.jsx(
10752
- Form$2.Field,
10753
- {
10754
- control: form.control,
10755
- name: "title",
10756
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
10757
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10758
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Title" }),
10759
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the title of the item" })
10760
- ] }),
10761
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10762
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10763
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10764
- ] })
10765
- ] }) })
10766
- }
10767
- ),
10768
- /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
10769
- /* @__PURE__ */ jsxRuntime.jsx(
10770
- Form$2.Field,
10771
- {
10772
- control: form.control,
10773
- name: "unit_price",
10774
- render: ({ field: { onChange, ...field } }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
10775
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10776
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Unit price" }),
10777
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the unit price of the item" })
10778
- ] }),
10779
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10780
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
10781
- ui.CurrencyInput,
10782
- {
10783
- symbol: getNativeSymbol(currencyCode),
10784
- code: currencyCode,
10785
- onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value),
10786
- ...field
10787
- }
10788
- ) }),
10789
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10790
- ] })
10791
- ] }) })
10792
- }
10793
- ),
10794
- /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
10795
- /* @__PURE__ */ jsxRuntime.jsx(
10796
- Form$2.Field,
10797
- {
10798
- control: form.control,
10799
- name: "quantity",
10800
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
10801
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
10802
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Quantity" }),
10803
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
10804
- ] }),
10805
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full flex-1", children: [
10806
- /* @__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" }) }) }),
10807
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10808
- ] })
10809
- ] }) })
10810
- }
10811
- )
10812
- ] }) }) }),
10813
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
10814
- /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
10815
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
10816
- ] }) })
10817
- ] }) }) });
10818
- };
10819
- const customItemSchema = objectType({
10820
- title: stringType().min(1),
10821
- quantity: numberType(),
10822
- unit_price: unionType([numberType(), stringType()])
10823
- });
10824
- const InlineTip = React.forwardRef(
10825
- ({ variant = "tip", label, className, children, ...props }, ref) => {
10826
- const labelValue = label || (variant === "warning" ? "Warning" : "Tip");
10827
- return /* @__PURE__ */ jsxRuntime.jsxs(
10828
- "div",
10829
- {
10830
- ref,
10831
- className: ui.clx(
10832
- "bg-ui-bg-component txt-small text-ui-fg-subtle grid grid-cols-[4px_1fr] items-start gap-3 rounded-lg border p-3",
10833
- className
10834
- ),
10835
- ...props,
10836
- children: [
10837
- /* @__PURE__ */ jsxRuntime.jsx(
10838
- "div",
10839
- {
10840
- role: "presentation",
10841
- className: ui.clx("w-4px bg-ui-tag-neutral-icon h-full rounded-full", {
10842
- "bg-ui-tag-orange-icon": variant === "warning"
10843
- })
10844
- }
10845
- ),
10846
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-pretty", children: [
10847
- /* @__PURE__ */ jsxRuntime.jsxs("strong", { className: "txt-small-plus text-ui-fg-base", children: [
10848
- labelValue,
10849
- ":"
10850
- ] }),
10851
- " ",
10852
- children
10853
- ] })
10854
- ]
10855
- }
10856
- );
10857
- }
10858
- );
10859
- InlineTip.displayName = "InlineTip";
10860
- const MetadataFieldSchema = objectType({
10861
- key: stringType(),
10862
- disabled: booleanType().optional(),
10863
- value: anyType()
10864
- });
10865
- const MetadataSchema = objectType({
10866
- metadata: arrayType(MetadataFieldSchema)
10867
- });
10868
- const Metadata = () => {
10869
- const { id } = reactRouterDom.useParams();
10870
- const { order, isPending, isError, error } = useOrder(id, {
10871
- fields: "metadata"
10872
- });
10873
- if (isError) {
10874
- throw error;
10875
- }
10876
- const isReady = !isPending && !!order;
10877
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10878
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10879
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Metadata" }) }),
10880
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Add metadata to the draft order." }) })
10881
- ] }),
10882
- !isReady ? /* @__PURE__ */ jsxRuntime.jsx(PlaceholderInner, {}) : /* @__PURE__ */ jsxRuntime.jsx(MetadataForm, { orderId: id, metadata: order == null ? void 0 : order.metadata })
10883
- ] });
10884
- };
10885
- const METADATA_KEY_LABEL_ID = "metadata-form-key-label";
10886
- const METADATA_VALUE_LABEL_ID = "metadata-form-value-label";
10887
- const MetadataForm = ({ orderId, metadata }) => {
10888
- const { handleSuccess } = useRouteModal();
10889
- const hasUneditableRows = getHasUneditableRows(metadata);
10890
- const { mutateAsync, isPending } = useUpdateDraftOrder(orderId);
10891
- const form = reactHookForm.useForm({
10892
- defaultValues: {
10893
- metadata: getDefaultValues(metadata)
10894
- },
10895
- resolver: zod.zodResolver(MetadataSchema)
10896
- });
10897
- const handleSubmit = form.handleSubmit(async (data) => {
10898
- const parsedData = parseValues(data);
10899
- await mutateAsync(
10900
- {
10901
- metadata: parsedData
10902
- },
10903
- {
10904
- onSuccess: () => {
10905
- ui.toast.success("Metadata updated");
10906
- handleSuccess();
10907
- },
10908
- onError: (error) => {
10909
- ui.toast.error(error.message);
10910
- }
10911
- }
10912
- );
10913
- });
10914
- const { fields, insert, remove } = reactHookForm.useFieldArray({
10915
- control: form.control,
10916
- name: "metadata"
10917
- });
10918
- function deleteRow(index) {
10919
- remove(index);
10920
- if (fields.length === 1) {
10921
- insert(0, {
10922
- key: "",
10923
- value: "",
10924
- disabled: false
10925
- });
10926
- }
10927
- }
10928
- function insertRow(index, position) {
10929
- insert(index + (position === "above" ? 0 : 1), {
10930
- key: "",
10931
- value: "",
10932
- disabled: false
10933
- });
10934
- }
10935
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
10936
- KeyboundForm,
10937
- {
10938
- onSubmit: handleSubmit,
10939
- className: "flex flex-1 flex-col overflow-hidden",
10940
- children: [
10941
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: [
10942
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-base shadow-elevation-card-rest grid grid-cols-1 divide-y rounded-lg", children: [
10943
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-ui-bg-subtle grid grid-cols-2 divide-x rounded-t-lg", children: [
10944
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_KEY_LABEL_ID, children: "Key" }) }),
10945
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "txt-compact-small-plus text-ui-fg-subtle px-2 py-1.5", children: /* @__PURE__ */ jsxRuntime.jsx("label", { id: METADATA_VALUE_LABEL_ID, children: "Value" }) })
10946
- ] }),
10947
- fields.map((field, index) => {
10948
- const isDisabled = field.disabled || false;
10949
- let placeholder = "-";
10950
- if (typeof field.value === "object") {
10951
- placeholder = "{ ... }";
10952
- }
10953
- if (Array.isArray(field.value)) {
10954
- placeholder = "[ ... ]";
10955
- }
10956
- return /* @__PURE__ */ jsxRuntime.jsx(
10957
- ConditionalTooltip,
10958
- {
10959
- showTooltip: isDisabled,
10960
- content: "This row is disabled because it contains non-primitive data.",
10961
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group/table relative", children: [
10962
- /* @__PURE__ */ jsxRuntime.jsxs(
10963
- "div",
10964
- {
10965
- className: ui.clx("grid grid-cols-2 divide-x", {
10966
- "overflow-hidden rounded-b-lg": index === fields.length - 1
10967
- }),
10968
- children: [
10969
- /* @__PURE__ */ jsxRuntime.jsx(
10970
- Form$2.Field,
10971
- {
10972
- control: form.control,
10973
- name: `metadata.${index}.key`,
10974
- render: ({ field: field2 }) => {
10975
- return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
10976
- GridInput,
10977
- {
10978
- "aria-labelledby": METADATA_KEY_LABEL_ID,
10979
- ...field2,
10980
- disabled: isDisabled,
10981
- placeholder: "Key"
10982
- }
10983
- ) }) });
10984
- }
10985
- }
10986
- ),
10987
- /* @__PURE__ */ jsxRuntime.jsx(
10988
- Form$2.Field,
10989
- {
10990
- control: form.control,
10991
- name: `metadata.${index}.value`,
10992
- render: ({ field: { value, ...field2 } }) => {
10993
- return /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
10994
- GridInput,
10995
- {
10996
- "aria-labelledby": METADATA_VALUE_LABEL_ID,
10997
- ...field2,
10998
- value: isDisabled ? placeholder : value,
10999
- disabled: isDisabled,
11000
- placeholder: "Value"
11001
- }
11002
- ) }) });
11003
- }
11004
- }
11005
- )
11006
- ]
11007
- }
11008
- ),
11009
- /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
11010
- /* @__PURE__ */ jsxRuntime.jsx(
11011
- ui.DropdownMenu.Trigger,
11012
- {
11013
- className: ui.clx(
11014
- "invisible absolute inset-y-0 -right-2.5 my-auto group-hover/table:visible data-[state='open']:visible",
11015
- {
11016
- hidden: isDisabled
11017
- }
11018
- ),
11019
- disabled: isDisabled,
11020
- asChild: true,
11021
- children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: "2xsmall", children: /* @__PURE__ */ jsxRuntime.jsx(icons.EllipsisVertical, {}) })
11022
- }
11023
- ),
11024
- /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu.Content, { children: [
11025
- /* @__PURE__ */ jsxRuntime.jsxs(
11026
- ui.DropdownMenu.Item,
11027
- {
11028
- className: "gap-x-2",
11029
- onClick: () => insertRow(index, "above"),
11030
- children: [
11031
- /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowUpMini, { className: "text-ui-fg-subtle" }),
11032
- "Insert row above"
11033
- ]
11034
- }
11035
- ),
11036
- /* @__PURE__ */ jsxRuntime.jsxs(
11037
- ui.DropdownMenu.Item,
11038
- {
11039
- className: "gap-x-2",
11040
- onClick: () => insertRow(index, "below"),
11041
- children: [
11042
- /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowDownMini, { className: "text-ui-fg-subtle" }),
11043
- "Insert row below"
11044
- ]
11045
- }
11046
- ),
11047
- /* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenu.Separator, {}),
11048
- /* @__PURE__ */ jsxRuntime.jsxs(
11049
- ui.DropdownMenu.Item,
11050
- {
11051
- className: "gap-x-2",
11052
- onClick: () => deleteRow(index),
11053
- children: [
11054
- /* @__PURE__ */ jsxRuntime.jsx(icons.Trash, { className: "text-ui-fg-subtle" }),
11055
- "Delete row"
11056
- ]
11057
- }
11058
- )
11059
- ] })
11060
- ] })
11061
- ] })
11062
- },
11063
- field.id
11064
- );
11065
- })
11066
- ] }),
11067
- hasUneditableRows && /* @__PURE__ */ jsxRuntime.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." })
11068
- ] }),
11069
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
11070
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
11071
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11072
- ] }) })
11073
- ]
11074
- }
11075
- ) });
11076
- };
11077
- const GridInput = React.forwardRef(({ className, ...props }, ref) => {
11078
- return /* @__PURE__ */ jsxRuntime.jsx(
11079
- "input",
11080
- {
11081
- ref,
11082
- ...props,
11083
- autoComplete: "off",
11084
- className: ui.clx(
11085
- "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",
11086
- className
11087
- )
11088
- }
11089
- );
11090
- });
11091
- GridInput.displayName = "MetadataForm.GridInput";
11092
- const PlaceholderInner = () => {
11093
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
11094
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-[148ox] w-full rounded-lg" }) }),
11095
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
11096
- /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" }),
11097
- /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-7 w-12 rounded-md" })
11098
- ] }) })
11099
- ] });
11100
- };
11101
- const EDITABLE_TYPES = ["string", "number", "boolean"];
11102
- function getDefaultValues(metadata) {
11103
- if (!metadata || !Object.keys(metadata).length) {
11104
- return [
11105
- {
11106
- key: "",
11107
- value: "",
11108
- disabled: false
11109
- }
11110
- ];
11111
- }
11112
- return Object.entries(metadata).map(([key, value]) => {
11113
- if (!EDITABLE_TYPES.includes(typeof value)) {
11114
- return {
11115
- key,
11116
- value,
11117
- disabled: true
11118
- };
11119
- }
11120
- let stringValue = value;
11121
- if (typeof value !== "string") {
11122
- stringValue = JSON.stringify(value);
11123
- }
11124
- return {
11125
- key,
11126
- value: stringValue,
11127
- original_key: key
11128
- };
11129
- });
11130
- }
11131
- function parseValues(values) {
11132
- const metadata = values.metadata;
11133
- const isEmpty = !metadata.length || metadata.length === 1 && !metadata[0].key && !metadata[0].value;
11134
- if (isEmpty) {
11135
- return null;
11136
- }
11137
- const update = {};
11138
- metadata.forEach((field) => {
11139
- let key = field.key;
11140
- let value = field.value;
11141
- const disabled = field.disabled;
11142
- if (!key || !value) {
11143
- return;
11144
- }
11145
- if (disabled) {
11146
- update[key] = value;
11147
- return;
11148
- }
11149
- key = key.trim();
11150
- value = value.trim();
11151
- if (value === "true") {
11152
- update[key] = true;
11153
- } else if (value === "false") {
11154
- update[key] = false;
11155
- } else {
11156
- const parsedNumber = parseFloat(value);
11157
- if (!isNaN(parsedNumber)) {
11158
- update[key] = parsedNumber;
11159
- } else {
11160
- update[key] = value;
11161
- }
11162
- }
11163
- });
11164
- return update;
11165
- }
11166
- function getHasUneditableRows(metadata) {
11167
- if (!metadata) {
11168
- return false;
11169
- }
11170
- return Object.values(metadata).some(
11171
- (value) => !EDITABLE_TYPES.includes(typeof value)
11172
- );
11173
- }
11100
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
11101
+ /* @__PURE__ */ jsxRuntime.jsx(
11102
+ Form$2.Field,
11103
+ {
11104
+ control: form.control,
11105
+ name: "title",
11106
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
11107
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11108
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Title" }),
11109
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the title of the item" })
11110
+ ] }),
11111
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11112
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11113
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11114
+ ] })
11115
+ ] }) })
11116
+ }
11117
+ ),
11118
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
11119
+ /* @__PURE__ */ jsxRuntime.jsx(
11120
+ Form$2.Field,
11121
+ {
11122
+ control: form.control,
11123
+ name: "unit_price",
11124
+ render: ({ field: { onChange, ...field } }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
11125
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11126
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Unit price" }),
11127
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the unit price of the item" })
11128
+ ] }),
11129
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11130
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11131
+ ui.CurrencyInput,
11132
+ {
11133
+ symbol: getNativeSymbol(currencyCode),
11134
+ code: currencyCode,
11135
+ onValueChange: (_value, _name, values) => onChange(values == null ? void 0 : values.value),
11136
+ ...field
11137
+ }
11138
+ ) }),
11139
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11140
+ ] })
11141
+ ] }) })
11142
+ }
11143
+ ),
11144
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
11145
+ /* @__PURE__ */ jsxRuntime.jsx(
11146
+ Form$2.Field,
11147
+ {
11148
+ control: form.control,
11149
+ name: "quantity",
11150
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsx(Form$2.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
11151
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
11152
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Quantity" }),
11153
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Hint, { children: "Enter the quantity of the item" })
11154
+ ] }),
11155
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full flex-1", children: [
11156
+ /* @__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" }) }) }),
11157
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11158
+ ] })
11159
+ ] }) })
11160
+ }
11161
+ )
11162
+ ] }) }) }),
11163
+ /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
11164
+ /* @__PURE__ */ jsxRuntime.jsx(StackedFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }),
11165
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "button", onClick: onSubmit, children: "Add item" })
11166
+ ] }) })
11167
+ ] }) }) });
11168
+ };
11169
+ const customItemSchema = objectType({
11170
+ title: stringType().min(1),
11171
+ quantity: numberType(),
11172
+ unit_price: unionType([numberType(), stringType()])
11173
+ });
11174
11174
  const PROMOTION_QUERY_KEY = "promotions";
11175
11175
  const promotionsQueryKeys = {
11176
11176
  list: (query2) => [
@@ -12350,17 +12350,220 @@ const CustomAmountField = ({
12350
12350
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
12351
12351
  ui.CurrencyInput,
12352
12352
  {
12353
- ...field,
12354
- onValueChange: (value) => onChange(value),
12355
- symbol: getNativeSymbol(currencyCode),
12356
- code: currencyCode
12353
+ ...field,
12354
+ onValueChange: (value) => onChange(value),
12355
+ symbol: getNativeSymbol(currencyCode),
12356
+ code: currencyCode
12357
+ }
12358
+ ) })
12359
+ ] });
12360
+ }
12361
+ }
12362
+ );
12363
+ };
12364
+ const ShippingAddress = () => {
12365
+ const { id } = reactRouterDom.useParams();
12366
+ const { order, isPending, isError, error } = useOrder(id, {
12367
+ fields: "+shipping_address"
12368
+ });
12369
+ if (isError) {
12370
+ throw error;
12371
+ }
12372
+ const isReady = !isPending && !!order;
12373
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12374
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12375
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12376
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12377
+ ] }),
12378
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12379
+ ] });
12380
+ };
12381
+ const ShippingAddressForm = ({ order }) => {
12382
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12383
+ const form = reactHookForm.useForm({
12384
+ defaultValues: {
12385
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12386
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12387
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12388
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12389
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12390
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12391
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12392
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12393
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12394
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12395
+ },
12396
+ resolver: zod.zodResolver(schema$1)
12397
+ });
12398
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12399
+ const { handleSuccess } = useRouteModal();
12400
+ const onSubmit = form.handleSubmit(async (data) => {
12401
+ await mutateAsync(
12402
+ {
12403
+ shipping_address: {
12404
+ first_name: data.first_name,
12405
+ last_name: data.last_name,
12406
+ company: data.company,
12407
+ address_1: data.address_1,
12408
+ address_2: data.address_2,
12409
+ city: data.city,
12410
+ province: data.province,
12411
+ country_code: data.country_code,
12412
+ postal_code: data.postal_code,
12413
+ phone: data.phone
12414
+ }
12415
+ },
12416
+ {
12417
+ onSuccess: () => {
12418
+ handleSuccess();
12419
+ },
12420
+ onError: (error) => {
12421
+ ui.toast.error(error.message);
12422
+ }
12423
+ }
12424
+ );
12425
+ });
12426
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12427
+ KeyboundForm,
12428
+ {
12429
+ className: "flex flex-1 flex-col overflow-hidden",
12430
+ onSubmit,
12431
+ children: [
12432
+ /* @__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: [
12433
+ /* @__PURE__ */ jsxRuntime.jsx(
12434
+ Form$2.Field,
12435
+ {
12436
+ control: form.control,
12437
+ name: "country_code",
12438
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12439
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12440
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12441
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12442
+ ] })
12443
+ }
12444
+ ),
12445
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12446
+ /* @__PURE__ */ jsxRuntime.jsx(
12447
+ Form$2.Field,
12448
+ {
12449
+ control: form.control,
12450
+ name: "first_name",
12451
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12452
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12453
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12454
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12455
+ ] })
12456
+ }
12457
+ ),
12458
+ /* @__PURE__ */ jsxRuntime.jsx(
12459
+ Form$2.Field,
12460
+ {
12461
+ control: form.control,
12462
+ name: "last_name",
12463
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12464
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12465
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12466
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12467
+ ] })
12468
+ }
12469
+ )
12470
+ ] }),
12471
+ /* @__PURE__ */ jsxRuntime.jsx(
12472
+ Form$2.Field,
12473
+ {
12474
+ control: form.control,
12475
+ name: "company",
12476
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12477
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12478
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12479
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12480
+ ] })
12481
+ }
12482
+ ),
12483
+ /* @__PURE__ */ jsxRuntime.jsx(
12484
+ Form$2.Field,
12485
+ {
12486
+ control: form.control,
12487
+ name: "address_1",
12488
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12489
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12490
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12491
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12492
+ ] })
12493
+ }
12494
+ ),
12495
+ /* @__PURE__ */ jsxRuntime.jsx(
12496
+ Form$2.Field,
12497
+ {
12498
+ control: form.control,
12499
+ name: "address_2",
12500
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12501
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12502
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12503
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12504
+ ] })
12505
+ }
12506
+ ),
12507
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12508
+ /* @__PURE__ */ jsxRuntime.jsx(
12509
+ Form$2.Field,
12510
+ {
12511
+ control: form.control,
12512
+ name: "postal_code",
12513
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12514
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12515
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12516
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12517
+ ] })
12518
+ }
12519
+ ),
12520
+ /* @__PURE__ */ jsxRuntime.jsx(
12521
+ Form$2.Field,
12522
+ {
12523
+ control: form.control,
12524
+ name: "city",
12525
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12526
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12527
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12528
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12529
+ ] })
12530
+ }
12531
+ )
12532
+ ] }),
12533
+ /* @__PURE__ */ jsxRuntime.jsx(
12534
+ Form$2.Field,
12535
+ {
12536
+ control: form.control,
12537
+ name: "province",
12538
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12539
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12540
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12541
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12542
+ ] })
12357
12543
  }
12358
- ) })
12359
- ] });
12360
- }
12544
+ ),
12545
+ /* @__PURE__ */ jsxRuntime.jsx(
12546
+ Form$2.Field,
12547
+ {
12548
+ control: form.control,
12549
+ name: "phone",
12550
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12551
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12552
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12553
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12554
+ ] })
12555
+ }
12556
+ )
12557
+ ] }) }),
12558
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12559
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12560
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12561
+ ] }) })
12562
+ ]
12361
12563
  }
12362
- );
12564
+ ) });
12363
12565
  };
12566
+ const schema$1 = addressSchema;
12364
12567
  const TransferOwnership = () => {
12365
12568
  const { id } = reactRouterDom.useParams();
12366
12569
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12384,7 +12587,7 @@ const TransferOwnershipForm = ({ order }) => {
12384
12587
  defaultValues: {
12385
12588
  customer_id: order.customer_id || ""
12386
12589
  },
12387
- resolver: zod.zodResolver(schema$1)
12590
+ resolver: zod.zodResolver(schema)
12388
12591
  });
12389
12592
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12390
12593
  const { handleSuccess } = useRouteModal();
@@ -12834,212 +13037,9 @@ const Illustration = () => {
12834
13037
  }
12835
13038
  );
12836
13039
  };
12837
- const schema$1 = objectType({
13040
+ const schema = objectType({
12838
13041
  customer_id: stringType().min(1)
12839
13042
  });
12840
- const ShippingAddress = () => {
12841
- const { id } = reactRouterDom.useParams();
12842
- const { order, isPending, isError, error } = useOrder(id, {
12843
- fields: "+shipping_address"
12844
- });
12845
- if (isError) {
12846
- throw error;
12847
- }
12848
- const isReady = !isPending && !!order;
12849
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12850
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12851
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12852
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12853
- ] }),
12854
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12855
- ] });
12856
- };
12857
- const ShippingAddressForm = ({ order }) => {
12858
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12859
- const form = reactHookForm.useForm({
12860
- defaultValues: {
12861
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12862
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12863
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12864
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12865
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12866
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12867
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12868
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12869
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12870
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12871
- },
12872
- resolver: zod.zodResolver(schema)
12873
- });
12874
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12875
- const { handleSuccess } = useRouteModal();
12876
- const onSubmit = form.handleSubmit(async (data) => {
12877
- await mutateAsync(
12878
- {
12879
- shipping_address: {
12880
- first_name: data.first_name,
12881
- last_name: data.last_name,
12882
- company: data.company,
12883
- address_1: data.address_1,
12884
- address_2: data.address_2,
12885
- city: data.city,
12886
- province: data.province,
12887
- country_code: data.country_code,
12888
- postal_code: data.postal_code,
12889
- phone: data.phone
12890
- }
12891
- },
12892
- {
12893
- onSuccess: () => {
12894
- handleSuccess();
12895
- },
12896
- onError: (error) => {
12897
- ui.toast.error(error.message);
12898
- }
12899
- }
12900
- );
12901
- });
12902
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12903
- KeyboundForm,
12904
- {
12905
- className: "flex flex-1 flex-col overflow-hidden",
12906
- onSubmit,
12907
- children: [
12908
- /* @__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: [
12909
- /* @__PURE__ */ jsxRuntime.jsx(
12910
- Form$2.Field,
12911
- {
12912
- control: form.control,
12913
- name: "country_code",
12914
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12915
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12916
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12917
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12918
- ] })
12919
- }
12920
- ),
12921
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12922
- /* @__PURE__ */ jsxRuntime.jsx(
12923
- Form$2.Field,
12924
- {
12925
- control: form.control,
12926
- name: "first_name",
12927
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12928
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12929
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12930
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12931
- ] })
12932
- }
12933
- ),
12934
- /* @__PURE__ */ jsxRuntime.jsx(
12935
- Form$2.Field,
12936
- {
12937
- control: form.control,
12938
- name: "last_name",
12939
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12940
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12941
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12942
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12943
- ] })
12944
- }
12945
- )
12946
- ] }),
12947
- /* @__PURE__ */ jsxRuntime.jsx(
12948
- Form$2.Field,
12949
- {
12950
- control: form.control,
12951
- name: "company",
12952
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12953
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12954
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12955
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12956
- ] })
12957
- }
12958
- ),
12959
- /* @__PURE__ */ jsxRuntime.jsx(
12960
- Form$2.Field,
12961
- {
12962
- control: form.control,
12963
- name: "address_1",
12964
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12965
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12966
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12967
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12968
- ] })
12969
- }
12970
- ),
12971
- /* @__PURE__ */ jsxRuntime.jsx(
12972
- Form$2.Field,
12973
- {
12974
- control: form.control,
12975
- name: "address_2",
12976
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12977
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12978
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12979
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12980
- ] })
12981
- }
12982
- ),
12983
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12984
- /* @__PURE__ */ jsxRuntime.jsx(
12985
- Form$2.Field,
12986
- {
12987
- control: form.control,
12988
- name: "postal_code",
12989
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12990
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12991
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12992
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12993
- ] })
12994
- }
12995
- ),
12996
- /* @__PURE__ */ jsxRuntime.jsx(
12997
- Form$2.Field,
12998
- {
12999
- control: form.control,
13000
- name: "city",
13001
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13002
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
13003
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13004
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13005
- ] })
13006
- }
13007
- )
13008
- ] }),
13009
- /* @__PURE__ */ jsxRuntime.jsx(
13010
- Form$2.Field,
13011
- {
13012
- control: form.control,
13013
- name: "province",
13014
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13015
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13016
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13017
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13018
- ] })
13019
- }
13020
- ),
13021
- /* @__PURE__ */ jsxRuntime.jsx(
13022
- Form$2.Field,
13023
- {
13024
- control: form.control,
13025
- name: "phone",
13026
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13027
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13028
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13029
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13030
- ] })
13031
- }
13032
- )
13033
- ] }) }),
13034
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13035
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13036
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13037
- ] }) })
13038
- ]
13039
- }
13040
- ) });
13041
- };
13042
- const schema = addressSchema;
13043
13043
  const widgetModule = { widgets: [] };
13044
13044
  const routeModule = {
13045
13045
  routes: [
@@ -13068,6 +13068,10 @@ const routeModule = {
13068
13068
  Component: CustomItems,
13069
13069
  path: "/draft-orders/:id/custom-items"
13070
13070
  },
13071
+ {
13072
+ Component: Metadata,
13073
+ path: "/draft-orders/:id/metadata"
13074
+ },
13071
13075
  {
13072
13076
  Component: Email,
13073
13077
  path: "/draft-orders/:id/email"
@@ -13076,10 +13080,6 @@ const routeModule = {
13076
13080
  Component: Items,
13077
13081
  path: "/draft-orders/:id/items"
13078
13082
  },
13079
- {
13080
- Component: Metadata,
13081
- path: "/draft-orders/:id/metadata"
13082
- },
13083
13083
  {
13084
13084
  Component: Promotions,
13085
13085
  path: "/draft-orders/:id/promotions"
@@ -13092,13 +13092,13 @@ const routeModule = {
13092
13092
  Component: Shipping,
13093
13093
  path: "/draft-orders/:id/shipping"
13094
13094
  },
13095
- {
13096
- Component: TransferOwnership,
13097
- path: "/draft-orders/:id/transfer-ownership"
13098
- },
13099
13095
  {
13100
13096
  Component: ShippingAddress,
13101
13097
  path: "/draft-orders/:id/shipping-address"
13098
+ },
13099
+ {
13100
+ Component: TransferOwnership,
13101
+ path: "/draft-orders/:id/transfer-ownership"
13102
13102
  }
13103
13103
  ]
13104
13104
  }