@medusajs/draft-order 2.11.3-snapshot-20251103115905 → 2.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/index.js +733 -733
- package/.medusa/server/src/admin/index.mjs +733 -733
- package/package.json +16 -16
|
@@ -9758,6 +9758,27 @@ const BillingAddressForm = ({ order }) => {
|
|
|
9758
9758
|
) });
|
|
9759
9759
|
};
|
|
9760
9760
|
const schema$5 = addressSchema;
|
|
9761
|
+
const CustomItems = () => {
|
|
9762
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9763
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9764
|
+
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9765
|
+
] });
|
|
9766
|
+
};
|
|
9767
|
+
const CustomItemsForm = () => {
|
|
9768
|
+
const form = reactHookForm.useForm({
|
|
9769
|
+
resolver: zod.zodResolver(schema$4)
|
|
9770
|
+
});
|
|
9771
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9772
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9773
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9774
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9775
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9776
|
+
] }) })
|
|
9777
|
+
] }) });
|
|
9778
|
+
};
|
|
9779
|
+
const schema$4 = objectType({
|
|
9780
|
+
email: stringType().email()
|
|
9781
|
+
});
|
|
9761
9782
|
const Email = () => {
|
|
9762
9783
|
const { id } = reactRouterDom.useParams();
|
|
9763
9784
|
const { order, isPending, isError, error } = useOrder(id, {
|
|
@@ -9780,7 +9801,7 @@ const EmailForm = ({ order }) => {
|
|
|
9780
9801
|
defaultValues: {
|
|
9781
9802
|
email: order.email ?? ""
|
|
9782
9803
|
},
|
|
9783
|
-
resolver: zod.zodResolver(schema$
|
|
9804
|
+
resolver: zod.zodResolver(schema$3)
|
|
9784
9805
|
});
|
|
9785
9806
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
9786
9807
|
const { handleSuccess } = useRouteModal();
|
|
@@ -9823,27 +9844,6 @@ const EmailForm = ({ order }) => {
|
|
|
9823
9844
|
}
|
|
9824
9845
|
) });
|
|
9825
9846
|
};
|
|
9826
|
-
const schema$4 = objectType({
|
|
9827
|
-
email: stringType().email()
|
|
9828
|
-
});
|
|
9829
|
-
const CustomItems = () => {
|
|
9830
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
9831
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
|
|
9832
|
-
/* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
|
|
9833
|
-
] });
|
|
9834
|
-
};
|
|
9835
|
-
const CustomItemsForm = () => {
|
|
9836
|
-
const form = reactHookForm.useForm({
|
|
9837
|
-
resolver: zod.zodResolver(schema$3)
|
|
9838
|
-
});
|
|
9839
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
|
|
9840
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
|
|
9841
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
9842
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
9843
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
|
|
9844
|
-
] }) })
|
|
9845
|
-
] }) });
|
|
9846
|
-
};
|
|
9847
9847
|
const schema$3 = objectType({
|
|
9848
9848
|
email: stringType().email()
|
|
9849
9849
|
});
|
|
@@ -11171,105 +11171,77 @@ function getHasUneditableRows(metadata) {
|
|
|
11171
11171
|
(value) => !EDITABLE_TYPES.includes(typeof value)
|
|
11172
11172
|
);
|
|
11173
11173
|
}
|
|
11174
|
-
const
|
|
11175
|
-
const
|
|
11176
|
-
|
|
11177
|
-
PROMOTION_QUERY_KEY,
|
|
11178
|
-
query2 ? query2 : void 0
|
|
11179
|
-
],
|
|
11180
|
-
detail: (id, query2) => [
|
|
11181
|
-
PROMOTION_QUERY_KEY,
|
|
11182
|
-
id,
|
|
11183
|
-
query2 ? query2 : void 0
|
|
11184
|
-
]
|
|
11185
|
-
};
|
|
11186
|
-
const usePromotions = (query2, options) => {
|
|
11187
|
-
const { data, ...rest } = reactQuery.useQuery({
|
|
11188
|
-
queryKey: promotionsQueryKeys.list(query2),
|
|
11189
|
-
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
11190
|
-
...options
|
|
11191
|
-
});
|
|
11192
|
-
return { ...data, ...rest };
|
|
11193
|
-
};
|
|
11194
|
-
const Promotions = () => {
|
|
11174
|
+
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11175
|
+
const Shipping = () => {
|
|
11176
|
+
var _a;
|
|
11195
11177
|
const { id } = reactRouterDom.useParams();
|
|
11178
|
+
const { order, isPending, isError, error } = useOrder(id, {
|
|
11179
|
+
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11180
|
+
});
|
|
11196
11181
|
const {
|
|
11197
11182
|
order: preview,
|
|
11183
|
+
isPending: isPreviewPending,
|
|
11198
11184
|
isError: isPreviewError,
|
|
11199
11185
|
error: previewError
|
|
11200
|
-
} = useOrderPreview(id
|
|
11186
|
+
} = useOrderPreview(id);
|
|
11201
11187
|
useInitiateOrderEdit({ preview });
|
|
11202
11188
|
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11189
|
+
if (isError) {
|
|
11190
|
+
throw error;
|
|
11191
|
+
}
|
|
11203
11192
|
if (isPreviewError) {
|
|
11204
11193
|
throw previewError;
|
|
11205
11194
|
}
|
|
11206
|
-
const
|
|
11207
|
-
|
|
11208
|
-
|
|
11209
|
-
|
|
11210
|
-
|
|
11195
|
+
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11196
|
+
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11197
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11198
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
11199
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.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-6 py-16", children: [
|
|
11200
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11201
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
11202
|
+
] }) }) }),
|
|
11203
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11204
|
+
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11205
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11206
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11207
|
+
] }) });
|
|
11211
11208
|
};
|
|
11212
|
-
const
|
|
11213
|
-
|
|
11209
|
+
const ShippingForm = ({ preview, order }) => {
|
|
11210
|
+
var _a;
|
|
11211
|
+
const { setIsOpen } = useStackedModal();
|
|
11214
11212
|
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11215
|
-
const [
|
|
11216
|
-
const
|
|
11217
|
-
const {
|
|
11218
|
-
const promoIds = getPromotionIds(items, shipping_methods);
|
|
11219
|
-
const { promotions, isPending, isError, error } = usePromotions(
|
|
11213
|
+
const [data, setData] = React.useState(null);
|
|
11214
|
+
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11215
|
+
const { shipping_options } = useShippingOptions(
|
|
11220
11216
|
{
|
|
11221
|
-
id:
|
|
11217
|
+
id: appliedShippingOptionIds,
|
|
11218
|
+
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11222
11219
|
},
|
|
11223
11220
|
{
|
|
11224
|
-
enabled:
|
|
11221
|
+
enabled: appliedShippingOptionIds.length > 0
|
|
11225
11222
|
}
|
|
11226
11223
|
);
|
|
11227
|
-
const
|
|
11228
|
-
|
|
11229
|
-
|
|
11230
|
-
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
|
|
11238
|
-
return data.promotions.map((promotion) => ({
|
|
11239
|
-
label: promotion.code,
|
|
11240
|
-
value: promotion.code
|
|
11241
|
-
}));
|
|
11242
|
-
}
|
|
11243
|
-
});
|
|
11244
|
-
const add = async (value) => {
|
|
11245
|
-
if (!value) {
|
|
11246
|
-
return;
|
|
11247
|
-
}
|
|
11248
|
-
addPromotions(
|
|
11249
|
-
{
|
|
11250
|
-
promo_codes: [value]
|
|
11251
|
-
},
|
|
11252
|
-
{
|
|
11253
|
-
onError: (e) => {
|
|
11254
|
-
ui.toast.error(e.message);
|
|
11255
|
-
comboboxData.onSearchValueChange("");
|
|
11256
|
-
setComboboxValue("");
|
|
11257
|
-
},
|
|
11258
|
-
onSuccess: () => {
|
|
11259
|
-
comboboxData.onSearchValueChange("");
|
|
11260
|
-
setComboboxValue("");
|
|
11261
|
-
}
|
|
11262
|
-
}
|
|
11263
|
-
);
|
|
11264
|
-
};
|
|
11224
|
+
const uniqueShippingProfiles = React.useMemo(() => {
|
|
11225
|
+
const profiles = /* @__PURE__ */ new Map();
|
|
11226
|
+
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
11227
|
+
profiles.set(profile.id, profile);
|
|
11228
|
+
});
|
|
11229
|
+
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
11230
|
+
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
11231
|
+
});
|
|
11232
|
+
return Array.from(profiles.values());
|
|
11233
|
+
}, [order.items, shipping_options]);
|
|
11234
|
+
const { handleSuccess } = useRouteModal();
|
|
11265
11235
|
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11266
|
-
const { mutateAsync: requestOrderEdit } =
|
|
11236
|
+
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
11237
|
+
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
11238
|
+
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
11267
11239
|
const onSubmit = async () => {
|
|
11268
11240
|
setIsSubmitting(true);
|
|
11269
11241
|
let requestSucceeded = false;
|
|
11270
11242
|
await requestOrderEdit(void 0, {
|
|
11271
11243
|
onError: (e) => {
|
|
11272
|
-
ui.toast.error(e.message);
|
|
11244
|
+
ui.toast.error(`Failed to request order edit: ${e.message}`);
|
|
11273
11245
|
},
|
|
11274
11246
|
onSuccess: () => {
|
|
11275
11247
|
requestSucceeded = true;
|
|
@@ -11281,7 +11253,7 @@ const PromotionForm = ({ preview }) => {
|
|
|
11281
11253
|
}
|
|
11282
11254
|
await confirmOrderEdit(void 0, {
|
|
11283
11255
|
onError: (e) => {
|
|
11284
|
-
ui.toast.error(e.message);
|
|
11256
|
+
ui.toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
11285
11257
|
},
|
|
11286
11258
|
onSuccess: () => {
|
|
11287
11259
|
handleSuccess();
|
|
@@ -11291,571 +11263,13 @@ const PromotionForm = ({ preview }) => {
|
|
|
11291
11263
|
}
|
|
11292
11264
|
});
|
|
11293
11265
|
};
|
|
11294
|
-
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
11300
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
11301
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
|
|
11302
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
|
|
11303
|
-
] }),
|
|
11304
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11305
|
-
Combobox,
|
|
11306
|
-
{
|
|
11307
|
-
id: "promotion-combobox",
|
|
11308
|
-
"aria-describedby": "promotion-combobox-hint",
|
|
11309
|
-
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
11310
|
-
fetchNextPage: comboboxData.fetchNextPage,
|
|
11311
|
-
options: comboboxData.options,
|
|
11312
|
-
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
11313
|
-
searchValue: comboboxData.searchValue,
|
|
11314
|
-
disabled: comboboxData.disabled || isAddingPromotions,
|
|
11315
|
-
onChange: add,
|
|
11316
|
-
value: comboboxValue
|
|
11317
|
-
}
|
|
11318
|
-
)
|
|
11319
|
-
] }),
|
|
11320
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
11321
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
11322
|
-
PromotionItem,
|
|
11323
|
-
{
|
|
11324
|
-
promotion,
|
|
11325
|
-
orderId: preview.id,
|
|
11326
|
-
isLoading: isPending
|
|
11327
|
-
},
|
|
11328
|
-
promotion.id
|
|
11329
|
-
)) })
|
|
11330
|
-
] }) }),
|
|
11331
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11332
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11333
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11334
|
-
ui.Button,
|
|
11335
|
-
{
|
|
11336
|
-
size: "small",
|
|
11337
|
-
type: "submit",
|
|
11338
|
-
isLoading: isSubmitting || isAddingPromotions,
|
|
11339
|
-
children: "Save"
|
|
11340
|
-
}
|
|
11341
|
-
)
|
|
11342
|
-
] }) })
|
|
11343
|
-
] });
|
|
11344
|
-
};
|
|
11345
|
-
const PromotionItem = ({
|
|
11346
|
-
promotion,
|
|
11347
|
-
orderId,
|
|
11348
|
-
isLoading
|
|
11349
|
-
}) => {
|
|
11350
|
-
var _a;
|
|
11351
|
-
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
11352
|
-
const onRemove = async () => {
|
|
11353
|
-
removePromotions(
|
|
11354
|
-
{
|
|
11355
|
-
promo_codes: [promotion.code]
|
|
11356
|
-
},
|
|
11357
|
-
{
|
|
11358
|
-
onError: (e) => {
|
|
11359
|
-
ui.toast.error(e.message);
|
|
11266
|
+
const onKeydown = React.useCallback(
|
|
11267
|
+
(e) => {
|
|
11268
|
+
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
11269
|
+
if (data || isSubmitting) {
|
|
11270
|
+
return;
|
|
11360
11271
|
}
|
|
11361
|
-
|
|
11362
|
-
);
|
|
11363
|
-
};
|
|
11364
|
-
const displayValue = getDisplayValue(promotion);
|
|
11365
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11366
|
-
"div",
|
|
11367
|
-
{
|
|
11368
|
-
className: ui.clx(
|
|
11369
|
-
"bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
|
|
11370
|
-
{
|
|
11371
|
-
"animate-pulse": isLoading
|
|
11372
|
-
}
|
|
11373
|
-
),
|
|
11374
|
-
children: [
|
|
11375
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11376
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
11377
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
|
|
11378
|
-
displayValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
11379
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: displayValue }),
|
|
11380
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: "·" })
|
|
11381
|
-
] }),
|
|
11382
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
|
|
11383
|
-
] })
|
|
11384
|
-
] }),
|
|
11385
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11386
|
-
ui.IconButton,
|
|
11387
|
-
{
|
|
11388
|
-
size: "small",
|
|
11389
|
-
type: "button",
|
|
11390
|
-
variant: "transparent",
|
|
11391
|
-
onClick: onRemove,
|
|
11392
|
-
isLoading: isPending || isLoading,
|
|
11393
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XMark, {})
|
|
11394
|
-
}
|
|
11395
|
-
)
|
|
11396
|
-
]
|
|
11397
|
-
},
|
|
11398
|
-
promotion.id
|
|
11399
|
-
);
|
|
11400
|
-
};
|
|
11401
|
-
function getDisplayValue(promotion) {
|
|
11402
|
-
var _a, _b, _c, _d;
|
|
11403
|
-
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
11404
|
-
if (!value) {
|
|
11405
|
-
return null;
|
|
11406
|
-
}
|
|
11407
|
-
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
11408
|
-
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
11409
|
-
if (!currency) {
|
|
11410
|
-
return null;
|
|
11411
|
-
}
|
|
11412
|
-
return getLocaleAmount(value, currency);
|
|
11413
|
-
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
11414
|
-
return formatPercentage(value);
|
|
11415
|
-
}
|
|
11416
|
-
return null;
|
|
11417
|
-
}
|
|
11418
|
-
const formatter = new Intl.NumberFormat([], {
|
|
11419
|
-
style: "percent",
|
|
11420
|
-
minimumFractionDigits: 2
|
|
11421
|
-
});
|
|
11422
|
-
const formatPercentage = (value, isPercentageValue = false) => {
|
|
11423
|
-
let val = value || 0;
|
|
11424
|
-
if (!isPercentageValue) {
|
|
11425
|
-
val = val / 100;
|
|
11426
|
-
}
|
|
11427
|
-
return formatter.format(val);
|
|
11428
|
-
};
|
|
11429
|
-
function getPromotionIds(items, shippingMethods) {
|
|
11430
|
-
const promotionIds = /* @__PURE__ */ new Set();
|
|
11431
|
-
for (const item of items) {
|
|
11432
|
-
if (item.adjustments) {
|
|
11433
|
-
for (const adjustment of item.adjustments) {
|
|
11434
|
-
if (adjustment.promotion_id) {
|
|
11435
|
-
promotionIds.add(adjustment.promotion_id);
|
|
11436
|
-
}
|
|
11437
|
-
}
|
|
11438
|
-
}
|
|
11439
|
-
}
|
|
11440
|
-
for (const shippingMethod of shippingMethods) {
|
|
11441
|
-
if (shippingMethod.adjustments) {
|
|
11442
|
-
for (const adjustment of shippingMethod.adjustments) {
|
|
11443
|
-
if (adjustment.promotion_id) {
|
|
11444
|
-
promotionIds.add(adjustment.promotion_id);
|
|
11445
|
-
}
|
|
11446
|
-
}
|
|
11447
|
-
}
|
|
11448
|
-
}
|
|
11449
|
-
return Array.from(promotionIds);
|
|
11450
|
-
}
|
|
11451
|
-
const SalesChannel = () => {
|
|
11452
|
-
const { id } = reactRouterDom.useParams();
|
|
11453
|
-
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
11454
|
-
id,
|
|
11455
|
-
{
|
|
11456
|
-
fields: "+sales_channel_id"
|
|
11457
|
-
},
|
|
11458
|
-
{
|
|
11459
|
-
enabled: !!id
|
|
11460
|
-
}
|
|
11461
|
-
);
|
|
11462
|
-
if (isError) {
|
|
11463
|
-
throw error;
|
|
11464
|
-
}
|
|
11465
|
-
const ISrEADY = !!draft_order && !isPending;
|
|
11466
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11467
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11468
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
11469
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
11470
|
-
] }),
|
|
11471
|
-
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
11472
|
-
] });
|
|
11473
|
-
};
|
|
11474
|
-
const SalesChannelForm = ({ order }) => {
|
|
11475
|
-
const form = reactHookForm.useForm({
|
|
11476
|
-
defaultValues: {
|
|
11477
|
-
sales_channel_id: order.sales_channel_id || ""
|
|
11478
|
-
},
|
|
11479
|
-
resolver: zod.zodResolver(schema$2)
|
|
11480
|
-
});
|
|
11481
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11482
|
-
const { handleSuccess } = useRouteModal();
|
|
11483
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11484
|
-
await mutateAsync(
|
|
11485
|
-
{
|
|
11486
|
-
sales_channel_id: data.sales_channel_id
|
|
11487
|
-
},
|
|
11488
|
-
{
|
|
11489
|
-
onSuccess: () => {
|
|
11490
|
-
ui.toast.success("Sales channel updated");
|
|
11491
|
-
handleSuccess();
|
|
11492
|
-
},
|
|
11493
|
-
onError: (error) => {
|
|
11494
|
-
ui.toast.error(error.message);
|
|
11495
|
-
}
|
|
11496
|
-
}
|
|
11497
|
-
);
|
|
11498
|
-
});
|
|
11499
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11500
|
-
KeyboundForm,
|
|
11501
|
-
{
|
|
11502
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11503
|
-
onSubmit,
|
|
11504
|
-
children: [
|
|
11505
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
11506
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11507
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11508
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11509
|
-
] }) })
|
|
11510
|
-
]
|
|
11511
|
-
}
|
|
11512
|
-
) });
|
|
11513
|
-
};
|
|
11514
|
-
const SalesChannelField = ({ control, order }) => {
|
|
11515
|
-
const salesChannels = useComboboxData({
|
|
11516
|
-
queryFn: async (params) => {
|
|
11517
|
-
return await sdk.admin.salesChannel.list(params);
|
|
11518
|
-
},
|
|
11519
|
-
queryKey: ["sales-channels"],
|
|
11520
|
-
getOptions: (data) => {
|
|
11521
|
-
return data.sales_channels.map((salesChannel) => ({
|
|
11522
|
-
label: salesChannel.name,
|
|
11523
|
-
value: salesChannel.id
|
|
11524
|
-
}));
|
|
11525
|
-
},
|
|
11526
|
-
defaultValue: order.sales_channel_id || void 0
|
|
11527
|
-
});
|
|
11528
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11529
|
-
Form$2.Field,
|
|
11530
|
-
{
|
|
11531
|
-
control,
|
|
11532
|
-
name: "sales_channel_id",
|
|
11533
|
-
render: ({ field }) => {
|
|
11534
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11535
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
11536
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11537
|
-
Combobox,
|
|
11538
|
-
{
|
|
11539
|
-
options: salesChannels.options,
|
|
11540
|
-
fetchNextPage: salesChannels.fetchNextPage,
|
|
11541
|
-
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
11542
|
-
searchValue: salesChannels.searchValue,
|
|
11543
|
-
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
11544
|
-
placeholder: "Select sales channel",
|
|
11545
|
-
...field
|
|
11546
|
-
}
|
|
11547
|
-
) }),
|
|
11548
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11549
|
-
] });
|
|
11550
|
-
}
|
|
11551
|
-
}
|
|
11552
|
-
);
|
|
11553
|
-
};
|
|
11554
|
-
const schema$2 = objectType({
|
|
11555
|
-
sales_channel_id: stringType().min(1)
|
|
11556
|
-
});
|
|
11557
|
-
const ShippingAddress = () => {
|
|
11558
|
-
const { id } = reactRouterDom.useParams();
|
|
11559
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
11560
|
-
fields: "+shipping_address"
|
|
11561
|
-
});
|
|
11562
|
-
if (isError) {
|
|
11563
|
-
throw error;
|
|
11564
|
-
}
|
|
11565
|
-
const isReady = !isPending && !!order;
|
|
11566
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
11567
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
11568
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
|
|
11569
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
|
|
11570
|
-
] }),
|
|
11571
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
|
|
11572
|
-
] });
|
|
11573
|
-
};
|
|
11574
|
-
const ShippingAddressForm = ({ order }) => {
|
|
11575
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
11576
|
-
const form = reactHookForm.useForm({
|
|
11577
|
-
defaultValues: {
|
|
11578
|
-
first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
|
|
11579
|
-
last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
|
|
11580
|
-
company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
|
|
11581
|
-
address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
|
|
11582
|
-
address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
|
|
11583
|
-
city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
|
|
11584
|
-
province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
|
|
11585
|
-
country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
|
|
11586
|
-
postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
|
|
11587
|
-
phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
|
|
11588
|
-
},
|
|
11589
|
-
resolver: zod.zodResolver(schema$1)
|
|
11590
|
-
});
|
|
11591
|
-
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
11592
|
-
const { handleSuccess } = useRouteModal();
|
|
11593
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
11594
|
-
await mutateAsync(
|
|
11595
|
-
{
|
|
11596
|
-
shipping_address: {
|
|
11597
|
-
first_name: data.first_name,
|
|
11598
|
-
last_name: data.last_name,
|
|
11599
|
-
company: data.company,
|
|
11600
|
-
address_1: data.address_1,
|
|
11601
|
-
address_2: data.address_2,
|
|
11602
|
-
city: data.city,
|
|
11603
|
-
province: data.province,
|
|
11604
|
-
country_code: data.country_code,
|
|
11605
|
-
postal_code: data.postal_code,
|
|
11606
|
-
phone: data.phone
|
|
11607
|
-
}
|
|
11608
|
-
},
|
|
11609
|
-
{
|
|
11610
|
-
onSuccess: () => {
|
|
11611
|
-
handleSuccess();
|
|
11612
|
-
},
|
|
11613
|
-
onError: (error) => {
|
|
11614
|
-
ui.toast.error(error.message);
|
|
11615
|
-
}
|
|
11616
|
-
}
|
|
11617
|
-
);
|
|
11618
|
-
});
|
|
11619
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11620
|
-
KeyboundForm,
|
|
11621
|
-
{
|
|
11622
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
11623
|
-
onSubmit,
|
|
11624
|
-
children: [
|
|
11625
|
-
/* @__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: [
|
|
11626
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11627
|
-
Form$2.Field,
|
|
11628
|
-
{
|
|
11629
|
-
control: form.control,
|
|
11630
|
-
name: "country_code",
|
|
11631
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11632
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
|
|
11633
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
|
|
11634
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11635
|
-
] })
|
|
11636
|
-
}
|
|
11637
|
-
),
|
|
11638
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11639
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11640
|
-
Form$2.Field,
|
|
11641
|
-
{
|
|
11642
|
-
control: form.control,
|
|
11643
|
-
name: "first_name",
|
|
11644
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11645
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
|
|
11646
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11647
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11648
|
-
] })
|
|
11649
|
-
}
|
|
11650
|
-
),
|
|
11651
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11652
|
-
Form$2.Field,
|
|
11653
|
-
{
|
|
11654
|
-
control: form.control,
|
|
11655
|
-
name: "last_name",
|
|
11656
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11657
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
|
|
11658
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11659
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11660
|
-
] })
|
|
11661
|
-
}
|
|
11662
|
-
)
|
|
11663
|
-
] }),
|
|
11664
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11665
|
-
Form$2.Field,
|
|
11666
|
-
{
|
|
11667
|
-
control: form.control,
|
|
11668
|
-
name: "company",
|
|
11669
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11670
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
|
|
11671
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11672
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11673
|
-
] })
|
|
11674
|
-
}
|
|
11675
|
-
),
|
|
11676
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11677
|
-
Form$2.Field,
|
|
11678
|
-
{
|
|
11679
|
-
control: form.control,
|
|
11680
|
-
name: "address_1",
|
|
11681
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11682
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
|
|
11683
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11684
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11685
|
-
] })
|
|
11686
|
-
}
|
|
11687
|
-
),
|
|
11688
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11689
|
-
Form$2.Field,
|
|
11690
|
-
{
|
|
11691
|
-
control: form.control,
|
|
11692
|
-
name: "address_2",
|
|
11693
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11694
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
|
|
11695
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11696
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11697
|
-
] })
|
|
11698
|
-
}
|
|
11699
|
-
),
|
|
11700
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
11701
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11702
|
-
Form$2.Field,
|
|
11703
|
-
{
|
|
11704
|
-
control: form.control,
|
|
11705
|
-
name: "postal_code",
|
|
11706
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11707
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
|
|
11708
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11709
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11710
|
-
] })
|
|
11711
|
-
}
|
|
11712
|
-
),
|
|
11713
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11714
|
-
Form$2.Field,
|
|
11715
|
-
{
|
|
11716
|
-
control: form.control,
|
|
11717
|
-
name: "city",
|
|
11718
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11719
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
|
|
11720
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11721
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11722
|
-
] })
|
|
11723
|
-
}
|
|
11724
|
-
)
|
|
11725
|
-
] }),
|
|
11726
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11727
|
-
Form$2.Field,
|
|
11728
|
-
{
|
|
11729
|
-
control: form.control,
|
|
11730
|
-
name: "province",
|
|
11731
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11732
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
|
|
11733
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11734
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11735
|
-
] })
|
|
11736
|
-
}
|
|
11737
|
-
),
|
|
11738
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11739
|
-
Form$2.Field,
|
|
11740
|
-
{
|
|
11741
|
-
control: form.control,
|
|
11742
|
-
name: "phone",
|
|
11743
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
11744
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
|
|
11745
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
|
|
11746
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
11747
|
-
] })
|
|
11748
|
-
}
|
|
11749
|
-
)
|
|
11750
|
-
] }) }),
|
|
11751
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
11752
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
11753
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
11754
|
-
] }) })
|
|
11755
|
-
]
|
|
11756
|
-
}
|
|
11757
|
-
) });
|
|
11758
|
-
};
|
|
11759
|
-
const schema$1 = addressSchema;
|
|
11760
|
-
const STACKED_FOCUS_MODAL_ID = "shipping-form";
|
|
11761
|
-
const Shipping = () => {
|
|
11762
|
-
var _a;
|
|
11763
|
-
const { id } = reactRouterDom.useParams();
|
|
11764
|
-
const { order, isPending, isError, error } = useOrder(id, {
|
|
11765
|
-
fields: "+items.*,+items.variant.*,+items.variant.product.*,+items.variant.product.shipping_profile.*,+currency_code"
|
|
11766
|
-
});
|
|
11767
|
-
const {
|
|
11768
|
-
order: preview,
|
|
11769
|
-
isPending: isPreviewPending,
|
|
11770
|
-
isError: isPreviewError,
|
|
11771
|
-
error: previewError
|
|
11772
|
-
} = useOrderPreview(id);
|
|
11773
|
-
useInitiateOrderEdit({ preview });
|
|
11774
|
-
const { onCancel } = useCancelOrderEdit({ preview });
|
|
11775
|
-
if (isError) {
|
|
11776
|
-
throw error;
|
|
11777
|
-
}
|
|
11778
|
-
if (isPreviewError) {
|
|
11779
|
-
throw previewError;
|
|
11780
|
-
}
|
|
11781
|
-
const orderHasItems = (((_a = order == null ? void 0 : order.items) == null ? void 0 : _a.length) || 0) > 0;
|
|
11782
|
-
const isReady = preview && !isPreviewPending && order && !isPending;
|
|
11783
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { onClose: onCancel, children: !orderHasItems ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden ", children: [
|
|
11784
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
11785
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.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-6 py-16", children: [
|
|
11786
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Shipping" }) }),
|
|
11787
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "This draft order currently has no items. Add items to the order before adding shipping." }) })
|
|
11788
|
-
] }) }) }),
|
|
11789
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", type: "button", children: "Cancel" }) }) })
|
|
11790
|
-
] }) : isReady ? /* @__PURE__ */ jsxRuntime.jsx(ShippingForm, { preview, order }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
11791
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit Shipping" }) }),
|
|
11792
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Loading data for the draft order, please wait..." }) })
|
|
11793
|
-
] }) });
|
|
11794
|
-
};
|
|
11795
|
-
const ShippingForm = ({ preview, order }) => {
|
|
11796
|
-
var _a;
|
|
11797
|
-
const { setIsOpen } = useStackedModal();
|
|
11798
|
-
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
11799
|
-
const [data, setData] = React.useState(null);
|
|
11800
|
-
const appliedShippingOptionIds = (_a = preview.shipping_methods) == null ? void 0 : _a.map((method) => method.shipping_option_id).filter(Boolean);
|
|
11801
|
-
const { shipping_options } = useShippingOptions(
|
|
11802
|
-
{
|
|
11803
|
-
id: appliedShippingOptionIds,
|
|
11804
|
-
fields: "+service_zone.*,+service_zone.fulfillment_set.*,+service_zone.fulfillment_set.location.*"
|
|
11805
|
-
},
|
|
11806
|
-
{
|
|
11807
|
-
enabled: appliedShippingOptionIds.length > 0
|
|
11808
|
-
}
|
|
11809
|
-
);
|
|
11810
|
-
const uniqueShippingProfiles = React.useMemo(() => {
|
|
11811
|
-
const profiles = /* @__PURE__ */ new Map();
|
|
11812
|
-
getUniqueShippingProfiles(order.items).forEach((profile) => {
|
|
11813
|
-
profiles.set(profile.id, profile);
|
|
11814
|
-
});
|
|
11815
|
-
shipping_options == null ? void 0 : shipping_options.forEach((option) => {
|
|
11816
|
-
profiles.set(option.shipping_profile_id, option.shipping_profile);
|
|
11817
|
-
});
|
|
11818
|
-
return Array.from(profiles.values());
|
|
11819
|
-
}, [order.items, shipping_options]);
|
|
11820
|
-
const { handleSuccess } = useRouteModal();
|
|
11821
|
-
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
11822
|
-
const { mutateAsync: requestOrderEdit } = useDraftOrderRequestEdit(preview.id);
|
|
11823
|
-
const { mutateAsync: removeShippingMethod } = useDraftOrderRemoveShippingMethod(preview.id);
|
|
11824
|
-
const { mutateAsync: removeActionShippingMethod } = useDraftOrderRemoveActionShippingMethod(preview.id);
|
|
11825
|
-
const onSubmit = async () => {
|
|
11826
|
-
setIsSubmitting(true);
|
|
11827
|
-
let requestSucceeded = false;
|
|
11828
|
-
await requestOrderEdit(void 0, {
|
|
11829
|
-
onError: (e) => {
|
|
11830
|
-
ui.toast.error(`Failed to request order edit: ${e.message}`);
|
|
11831
|
-
},
|
|
11832
|
-
onSuccess: () => {
|
|
11833
|
-
requestSucceeded = true;
|
|
11834
|
-
}
|
|
11835
|
-
});
|
|
11836
|
-
if (!requestSucceeded) {
|
|
11837
|
-
setIsSubmitting(false);
|
|
11838
|
-
return;
|
|
11839
|
-
}
|
|
11840
|
-
await confirmOrderEdit(void 0, {
|
|
11841
|
-
onError: (e) => {
|
|
11842
|
-
ui.toast.error(`Failed to confirm order edit: ${e.message}`);
|
|
11843
|
-
},
|
|
11844
|
-
onSuccess: () => {
|
|
11845
|
-
handleSuccess();
|
|
11846
|
-
},
|
|
11847
|
-
onSettled: () => {
|
|
11848
|
-
setIsSubmitting(false);
|
|
11849
|
-
}
|
|
11850
|
-
});
|
|
11851
|
-
};
|
|
11852
|
-
const onKeydown = React.useCallback(
|
|
11853
|
-
(e) => {
|
|
11854
|
-
if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
11855
|
-
if (data || isSubmitting) {
|
|
11856
|
-
return;
|
|
11857
|
-
}
|
|
11858
|
-
onSubmit();
|
|
11272
|
+
onSubmit();
|
|
11859
11273
|
}
|
|
11860
11274
|
},
|
|
11861
11275
|
[data, isSubmitting, onSubmit]
|
|
@@ -12587,7 +12001,7 @@ const TransferOwnershipForm = ({ order }) => {
|
|
|
12587
12001
|
defaultValues: {
|
|
12588
12002
|
customer_id: order.customer_id || ""
|
|
12589
12003
|
},
|
|
12590
|
-
resolver: zod.zodResolver(schema)
|
|
12004
|
+
resolver: zod.zodResolver(schema$2)
|
|
12591
12005
|
});
|
|
12592
12006
|
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12593
12007
|
const { handleSuccess } = useRouteModal();
|
|
@@ -12966,80 +12380,666 @@ const Illustration = () => {
|
|
|
12966
12380
|
strokeLinecap: "round",
|
|
12967
12381
|
strokeLinejoin: "round"
|
|
12968
12382
|
}
|
|
12969
|
-
) }),
|
|
12970
|
-
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12971
|
-
"path",
|
|
12383
|
+
) }),
|
|
12384
|
+
/* @__PURE__ */ jsxRuntime.jsx("g", { clipPath: "url(#clip5_20915_38670)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12385
|
+
"path",
|
|
12386
|
+
{
|
|
12387
|
+
d: "M146.894 101.198L139.51 101.155L139.486 105.365",
|
|
12388
|
+
stroke: "#A1A1AA",
|
|
12389
|
+
strokeWidth: "1.5",
|
|
12390
|
+
strokeLinecap: "round",
|
|
12391
|
+
strokeLinejoin: "round"
|
|
12392
|
+
}
|
|
12393
|
+
) }),
|
|
12394
|
+
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
12395
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12396
|
+
"rect",
|
|
12397
|
+
{
|
|
12398
|
+
width: "12",
|
|
12399
|
+
height: "12",
|
|
12400
|
+
fill: "white",
|
|
12401
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 138.36 74.6508)"
|
|
12402
|
+
}
|
|
12403
|
+
) }),
|
|
12404
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip1_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12405
|
+
"rect",
|
|
12406
|
+
{
|
|
12407
|
+
width: "12",
|
|
12408
|
+
height: "12",
|
|
12409
|
+
fill: "white",
|
|
12410
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 148.75 80.6541)"
|
|
12411
|
+
}
|
|
12412
|
+
) }),
|
|
12413
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip2_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12414
|
+
"rect",
|
|
12415
|
+
{
|
|
12416
|
+
width: "12",
|
|
12417
|
+
height: "12",
|
|
12418
|
+
fill: "white",
|
|
12419
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 159.141 86.6575)"
|
|
12420
|
+
}
|
|
12421
|
+
) }),
|
|
12422
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip3_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12423
|
+
"rect",
|
|
12424
|
+
{
|
|
12425
|
+
width: "12",
|
|
12426
|
+
height: "12",
|
|
12427
|
+
fill: "white",
|
|
12428
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 120.928 84.4561)"
|
|
12429
|
+
}
|
|
12430
|
+
) }),
|
|
12431
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip4_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12432
|
+
"rect",
|
|
12433
|
+
{
|
|
12434
|
+
width: "12",
|
|
12435
|
+
height: "12",
|
|
12436
|
+
fill: "white",
|
|
12437
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 131.318 90.4594)"
|
|
12438
|
+
}
|
|
12439
|
+
) }),
|
|
12440
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip5_20915_38670", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12441
|
+
"rect",
|
|
12442
|
+
{
|
|
12443
|
+
width: "12",
|
|
12444
|
+
height: "12",
|
|
12445
|
+
fill: "white",
|
|
12446
|
+
transform: "matrix(0.865865 0.500278 -0.871576 0.490261 141.709 96.4627)"
|
|
12447
|
+
}
|
|
12448
|
+
) })
|
|
12449
|
+
] })
|
|
12450
|
+
]
|
|
12451
|
+
}
|
|
12452
|
+
);
|
|
12453
|
+
};
|
|
12454
|
+
const schema$2 = objectType({
|
|
12455
|
+
customer_id: stringType().min(1)
|
|
12456
|
+
});
|
|
12457
|
+
const PROMOTION_QUERY_KEY = "promotions";
|
|
12458
|
+
const promotionsQueryKeys = {
|
|
12459
|
+
list: (query2) => [
|
|
12460
|
+
PROMOTION_QUERY_KEY,
|
|
12461
|
+
query2 ? query2 : void 0
|
|
12462
|
+
],
|
|
12463
|
+
detail: (id, query2) => [
|
|
12464
|
+
PROMOTION_QUERY_KEY,
|
|
12465
|
+
id,
|
|
12466
|
+
query2 ? query2 : void 0
|
|
12467
|
+
]
|
|
12468
|
+
};
|
|
12469
|
+
const usePromotions = (query2, options) => {
|
|
12470
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
12471
|
+
queryKey: promotionsQueryKeys.list(query2),
|
|
12472
|
+
queryFn: async () => sdk.admin.promotion.list(query2),
|
|
12473
|
+
...options
|
|
12474
|
+
});
|
|
12475
|
+
return { ...data, ...rest };
|
|
12476
|
+
};
|
|
12477
|
+
const Promotions = () => {
|
|
12478
|
+
const { id } = reactRouterDom.useParams();
|
|
12479
|
+
const {
|
|
12480
|
+
order: preview,
|
|
12481
|
+
isError: isPreviewError,
|
|
12482
|
+
error: previewError
|
|
12483
|
+
} = useOrderPreview(id, void 0);
|
|
12484
|
+
useInitiateOrderEdit({ preview });
|
|
12485
|
+
const { onCancel } = useCancelOrderEdit({ preview });
|
|
12486
|
+
if (isPreviewError) {
|
|
12487
|
+
throw previewError;
|
|
12488
|
+
}
|
|
12489
|
+
const isReady = !!preview;
|
|
12490
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { onClose: onCancel, children: [
|
|
12491
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Promotions" }) }) }),
|
|
12492
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(PromotionForm, { preview })
|
|
12493
|
+
] });
|
|
12494
|
+
};
|
|
12495
|
+
const PromotionForm = ({ preview }) => {
|
|
12496
|
+
const { items, shipping_methods } = preview;
|
|
12497
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
12498
|
+
const [comboboxValue, setComboboxValue] = React.useState("");
|
|
12499
|
+
const { handleSuccess } = useRouteModal();
|
|
12500
|
+
const { mutateAsync: addPromotions, isPending: isAddingPromotions } = useDraftOrderAddPromotions(preview.id);
|
|
12501
|
+
const promoIds = getPromotionIds(items, shipping_methods);
|
|
12502
|
+
const { promotions, isPending, isError, error } = usePromotions(
|
|
12503
|
+
{
|
|
12504
|
+
id: promoIds
|
|
12505
|
+
},
|
|
12506
|
+
{
|
|
12507
|
+
enabled: !!promoIds.length
|
|
12508
|
+
}
|
|
12509
|
+
);
|
|
12510
|
+
const comboboxData = useComboboxData({
|
|
12511
|
+
queryKey: ["promotions", "combobox", promoIds],
|
|
12512
|
+
queryFn: async (params) => {
|
|
12513
|
+
return await sdk.admin.promotion.list({
|
|
12514
|
+
...params,
|
|
12515
|
+
id: {
|
|
12516
|
+
$nin: promoIds
|
|
12517
|
+
}
|
|
12518
|
+
});
|
|
12519
|
+
},
|
|
12520
|
+
getOptions: (data) => {
|
|
12521
|
+
return data.promotions.map((promotion) => ({
|
|
12522
|
+
label: promotion.code,
|
|
12523
|
+
value: promotion.code
|
|
12524
|
+
}));
|
|
12525
|
+
}
|
|
12526
|
+
});
|
|
12527
|
+
const add = async (value) => {
|
|
12528
|
+
if (!value) {
|
|
12529
|
+
return;
|
|
12530
|
+
}
|
|
12531
|
+
addPromotions(
|
|
12532
|
+
{
|
|
12533
|
+
promo_codes: [value]
|
|
12534
|
+
},
|
|
12535
|
+
{
|
|
12536
|
+
onError: (e) => {
|
|
12537
|
+
ui.toast.error(e.message);
|
|
12538
|
+
comboboxData.onSearchValueChange("");
|
|
12539
|
+
setComboboxValue("");
|
|
12540
|
+
},
|
|
12541
|
+
onSuccess: () => {
|
|
12542
|
+
comboboxData.onSearchValueChange("");
|
|
12543
|
+
setComboboxValue("");
|
|
12544
|
+
}
|
|
12545
|
+
}
|
|
12546
|
+
);
|
|
12547
|
+
};
|
|
12548
|
+
const { mutateAsync: confirmOrderEdit } = useDraftOrderConfirmEdit(preview.id);
|
|
12549
|
+
const { mutateAsync: requestOrderEdit } = useOrderEditRequest(preview.id);
|
|
12550
|
+
const onSubmit = async () => {
|
|
12551
|
+
setIsSubmitting(true);
|
|
12552
|
+
let requestSucceeded = false;
|
|
12553
|
+
await requestOrderEdit(void 0, {
|
|
12554
|
+
onError: (e) => {
|
|
12555
|
+
ui.toast.error(e.message);
|
|
12556
|
+
},
|
|
12557
|
+
onSuccess: () => {
|
|
12558
|
+
requestSucceeded = true;
|
|
12559
|
+
}
|
|
12560
|
+
});
|
|
12561
|
+
if (!requestSucceeded) {
|
|
12562
|
+
setIsSubmitting(false);
|
|
12563
|
+
return;
|
|
12564
|
+
}
|
|
12565
|
+
await confirmOrderEdit(void 0, {
|
|
12566
|
+
onError: (e) => {
|
|
12567
|
+
ui.toast.error(e.message);
|
|
12568
|
+
},
|
|
12569
|
+
onSuccess: () => {
|
|
12570
|
+
handleSuccess();
|
|
12571
|
+
},
|
|
12572
|
+
onSettled: () => {
|
|
12573
|
+
setIsSubmitting(false);
|
|
12574
|
+
}
|
|
12575
|
+
});
|
|
12576
|
+
};
|
|
12577
|
+
if (isError) {
|
|
12578
|
+
throw error;
|
|
12579
|
+
}
|
|
12580
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", onSubmit, children: [
|
|
12581
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
12582
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
12583
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
12584
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "promotion-combobox", children: "Apply promotions" }),
|
|
12585
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { id: "promotion-combobox-hint", children: "Manage promotions that should be applied to the order." })
|
|
12586
|
+
] }),
|
|
12587
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12588
|
+
Combobox,
|
|
12589
|
+
{
|
|
12590
|
+
id: "promotion-combobox",
|
|
12591
|
+
"aria-describedby": "promotion-combobox-hint",
|
|
12592
|
+
isFetchingNextPage: comboboxData.isFetchingNextPage,
|
|
12593
|
+
fetchNextPage: comboboxData.fetchNextPage,
|
|
12594
|
+
options: comboboxData.options,
|
|
12595
|
+
onSearchValueChange: comboboxData.onSearchValueChange,
|
|
12596
|
+
searchValue: comboboxData.searchValue,
|
|
12597
|
+
disabled: comboboxData.disabled || isAddingPromotions,
|
|
12598
|
+
onChange: add,
|
|
12599
|
+
value: comboboxValue
|
|
12600
|
+
}
|
|
12601
|
+
)
|
|
12602
|
+
] }),
|
|
12603
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Divider, { variant: "dashed" }),
|
|
12604
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: promotions == null ? void 0 : promotions.map((promotion) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
12605
|
+
PromotionItem,
|
|
12606
|
+
{
|
|
12607
|
+
promotion,
|
|
12608
|
+
orderId: preview.id,
|
|
12609
|
+
isLoading: isPending
|
|
12610
|
+
},
|
|
12611
|
+
promotion.id
|
|
12612
|
+
)) })
|
|
12613
|
+
] }) }),
|
|
12614
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12615
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12616
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12617
|
+
ui.Button,
|
|
12618
|
+
{
|
|
12619
|
+
size: "small",
|
|
12620
|
+
type: "submit",
|
|
12621
|
+
isLoading: isSubmitting || isAddingPromotions,
|
|
12622
|
+
children: "Save"
|
|
12623
|
+
}
|
|
12624
|
+
)
|
|
12625
|
+
] }) })
|
|
12626
|
+
] });
|
|
12627
|
+
};
|
|
12628
|
+
const PromotionItem = ({
|
|
12629
|
+
promotion,
|
|
12630
|
+
orderId,
|
|
12631
|
+
isLoading
|
|
12632
|
+
}) => {
|
|
12633
|
+
var _a;
|
|
12634
|
+
const { mutateAsync: removePromotions, isPending } = useDraftOrderRemovePromotions(orderId);
|
|
12635
|
+
const onRemove = async () => {
|
|
12636
|
+
removePromotions(
|
|
12637
|
+
{
|
|
12638
|
+
promo_codes: [promotion.code]
|
|
12639
|
+
},
|
|
12640
|
+
{
|
|
12641
|
+
onError: (e) => {
|
|
12642
|
+
ui.toast.error(e.message);
|
|
12643
|
+
}
|
|
12644
|
+
}
|
|
12645
|
+
);
|
|
12646
|
+
};
|
|
12647
|
+
const displayValue = getDisplayValue(promotion);
|
|
12648
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12649
|
+
"div",
|
|
12650
|
+
{
|
|
12651
|
+
className: ui.clx(
|
|
12652
|
+
"bg-ui-bg-component shadow-elevation-card-rest flex items-center justify-between rounded-lg px-3 py-2",
|
|
12653
|
+
{
|
|
12654
|
+
"animate-pulse": isLoading
|
|
12655
|
+
}
|
|
12656
|
+
),
|
|
12657
|
+
children: [
|
|
12658
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
12659
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", weight: "plus", leading: "compact", children: promotion.code }),
|
|
12660
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-1.5", children: [
|
|
12661
|
+
displayValue && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
12662
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: displayValue }),
|
|
12663
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", children: "·" })
|
|
12664
|
+
] }),
|
|
12665
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", leading: "compact", className: "capitalize", children: (_a = promotion.application_method) == null ? void 0 : _a.allocation })
|
|
12666
|
+
] })
|
|
12667
|
+
] }),
|
|
12668
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12669
|
+
ui.IconButton,
|
|
12972
12670
|
{
|
|
12973
|
-
|
|
12974
|
-
|
|
12975
|
-
|
|
12976
|
-
|
|
12977
|
-
|
|
12671
|
+
size: "small",
|
|
12672
|
+
type: "button",
|
|
12673
|
+
variant: "transparent",
|
|
12674
|
+
onClick: onRemove,
|
|
12675
|
+
isLoading: isPending || isLoading,
|
|
12676
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XMark, {})
|
|
12978
12677
|
}
|
|
12979
|
-
)
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
|
|
12678
|
+
)
|
|
12679
|
+
]
|
|
12680
|
+
},
|
|
12681
|
+
promotion.id
|
|
12682
|
+
);
|
|
12683
|
+
};
|
|
12684
|
+
function getDisplayValue(promotion) {
|
|
12685
|
+
var _a, _b, _c, _d;
|
|
12686
|
+
const value = (_a = promotion.application_method) == null ? void 0 : _a.value;
|
|
12687
|
+
if (!value) {
|
|
12688
|
+
return null;
|
|
12689
|
+
}
|
|
12690
|
+
if (((_b = promotion.application_method) == null ? void 0 : _b.type) === "fixed") {
|
|
12691
|
+
const currency = (_c = promotion.application_method) == null ? void 0 : _c.currency_code;
|
|
12692
|
+
if (!currency) {
|
|
12693
|
+
return null;
|
|
12694
|
+
}
|
|
12695
|
+
return getLocaleAmount(value, currency);
|
|
12696
|
+
} else if (((_d = promotion.application_method) == null ? void 0 : _d.type) === "percentage") {
|
|
12697
|
+
return formatPercentage(value);
|
|
12698
|
+
}
|
|
12699
|
+
return null;
|
|
12700
|
+
}
|
|
12701
|
+
const formatter = new Intl.NumberFormat([], {
|
|
12702
|
+
style: "percent",
|
|
12703
|
+
minimumFractionDigits: 2
|
|
12704
|
+
});
|
|
12705
|
+
const formatPercentage = (value, isPercentageValue = false) => {
|
|
12706
|
+
let val = value || 0;
|
|
12707
|
+
if (!isPercentageValue) {
|
|
12708
|
+
val = val / 100;
|
|
12709
|
+
}
|
|
12710
|
+
return formatter.format(val);
|
|
12711
|
+
};
|
|
12712
|
+
function getPromotionIds(items, shippingMethods) {
|
|
12713
|
+
const promotionIds = /* @__PURE__ */ new Set();
|
|
12714
|
+
for (const item of items) {
|
|
12715
|
+
if (item.adjustments) {
|
|
12716
|
+
for (const adjustment of item.adjustments) {
|
|
12717
|
+
if (adjustment.promotion_id) {
|
|
12718
|
+
promotionIds.add(adjustment.promotion_id);
|
|
12719
|
+
}
|
|
12720
|
+
}
|
|
12721
|
+
}
|
|
12722
|
+
}
|
|
12723
|
+
for (const shippingMethod of shippingMethods) {
|
|
12724
|
+
if (shippingMethod.adjustments) {
|
|
12725
|
+
for (const adjustment of shippingMethod.adjustments) {
|
|
12726
|
+
if (adjustment.promotion_id) {
|
|
12727
|
+
promotionIds.add(adjustment.promotion_id);
|
|
12728
|
+
}
|
|
12729
|
+
}
|
|
12730
|
+
}
|
|
12731
|
+
}
|
|
12732
|
+
return Array.from(promotionIds);
|
|
12733
|
+
}
|
|
12734
|
+
const SalesChannel = () => {
|
|
12735
|
+
const { id } = reactRouterDom.useParams();
|
|
12736
|
+
const { draft_order, isPending, isError, error } = useDraftOrder(
|
|
12737
|
+
id,
|
|
12738
|
+
{
|
|
12739
|
+
fields: "+sales_channel_id"
|
|
12740
|
+
},
|
|
12741
|
+
{
|
|
12742
|
+
enabled: !!id
|
|
12743
|
+
}
|
|
12744
|
+
);
|
|
12745
|
+
if (isError) {
|
|
12746
|
+
throw error;
|
|
12747
|
+
}
|
|
12748
|
+
const ISrEADY = !!draft_order && !isPending;
|
|
12749
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
12750
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
12751
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
|
|
12752
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
|
|
12753
|
+
] }),
|
|
12754
|
+
ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
|
|
12755
|
+
] });
|
|
12756
|
+
};
|
|
12757
|
+
const SalesChannelForm = ({ order }) => {
|
|
12758
|
+
const form = reactHookForm.useForm({
|
|
12759
|
+
defaultValues: {
|
|
12760
|
+
sales_channel_id: order.sales_channel_id || ""
|
|
12761
|
+
},
|
|
12762
|
+
resolver: zod.zodResolver(schema$1)
|
|
12763
|
+
});
|
|
12764
|
+
const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
|
|
12765
|
+
const { handleSuccess } = useRouteModal();
|
|
12766
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
12767
|
+
await mutateAsync(
|
|
12768
|
+
{
|
|
12769
|
+
sales_channel_id: data.sales_channel_id
|
|
12770
|
+
},
|
|
12771
|
+
{
|
|
12772
|
+
onSuccess: () => {
|
|
12773
|
+
ui.toast.success("Sales channel updated");
|
|
12774
|
+
handleSuccess();
|
|
12775
|
+
},
|
|
12776
|
+
onError: (error) => {
|
|
12777
|
+
ui.toast.error(error.message);
|
|
12778
|
+
}
|
|
12779
|
+
}
|
|
12780
|
+
);
|
|
12781
|
+
});
|
|
12782
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
12783
|
+
KeyboundForm,
|
|
12784
|
+
{
|
|
12785
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
12786
|
+
onSubmit,
|
|
12787
|
+
children: [
|
|
12788
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
|
|
12789
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
12790
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
12791
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
12792
|
+
] }) })
|
|
12793
|
+
]
|
|
12794
|
+
}
|
|
12795
|
+
) });
|
|
12796
|
+
};
|
|
12797
|
+
const SalesChannelField = ({ control, order }) => {
|
|
12798
|
+
const salesChannels = useComboboxData({
|
|
12799
|
+
queryFn: async (params) => {
|
|
12800
|
+
return await sdk.admin.salesChannel.list(params);
|
|
12801
|
+
},
|
|
12802
|
+
queryKey: ["sales-channels"],
|
|
12803
|
+
getOptions: (data) => {
|
|
12804
|
+
return data.sales_channels.map((salesChannel) => ({
|
|
12805
|
+
label: salesChannel.name,
|
|
12806
|
+
value: salesChannel.id
|
|
12807
|
+
}));
|
|
12808
|
+
},
|
|
12809
|
+
defaultValue: order.sales_channel_id || void 0
|
|
12810
|
+
});
|
|
12811
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12812
|
+
Form$2.Field,
|
|
12813
|
+
{
|
|
12814
|
+
control,
|
|
12815
|
+
name: "sales_channel_id",
|
|
12816
|
+
render: ({ field }) => {
|
|
12817
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
12818
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
|
|
12819
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12820
|
+
Combobox,
|
|
12821
|
+
{
|
|
12822
|
+
options: salesChannels.options,
|
|
12823
|
+
fetchNextPage: salesChannels.fetchNextPage,
|
|
12824
|
+
isFetchingNextPage: salesChannels.isFetchingNextPage,
|
|
12825
|
+
searchValue: salesChannels.searchValue,
|
|
12826
|
+
onSearchValueChange: salesChannels.onSearchValueChange,
|
|
12827
|
+
placeholder: "Select sales channel",
|
|
12828
|
+
...field
|
|
12829
|
+
}
|
|
12830
|
+
) }),
|
|
12831
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
12832
|
+
] });
|
|
12833
|
+
}
|
|
12834
|
+
}
|
|
12835
|
+
);
|
|
12836
|
+
};
|
|
12837
|
+
const schema$1 = objectType({
|
|
12838
|
+
sales_channel_id: stringType().min(1)
|
|
12839
|
+
});
|
|
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,
|
|
12983
12911
|
{
|
|
12984
|
-
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
|
|
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
|
+
] })
|
|
12988
12919
|
}
|
|
12989
|
-
)
|
|
12990
|
-
/* @__PURE__ */ jsxRuntime.
|
|
12991
|
-
|
|
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,
|
|
12992
12949
|
{
|
|
12993
|
-
|
|
12994
|
-
|
|
12995
|
-
|
|
12996
|
-
|
|
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
|
+
] })
|
|
12997
12957
|
}
|
|
12998
|
-
)
|
|
12999
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13000
|
-
|
|
12958
|
+
),
|
|
12959
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12960
|
+
Form$2.Field,
|
|
13001
12961
|
{
|
|
13002
|
-
|
|
13003
|
-
|
|
13004
|
-
|
|
13005
|
-
|
|
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
|
+
] })
|
|
13006
12969
|
}
|
|
13007
|
-
)
|
|
13008
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13009
|
-
|
|
12970
|
+
),
|
|
12971
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12972
|
+
Form$2.Field,
|
|
13010
12973
|
{
|
|
13011
|
-
|
|
13012
|
-
|
|
13013
|
-
|
|
13014
|
-
|
|
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
|
+
] })
|
|
13015
12981
|
}
|
|
13016
|
-
)
|
|
13017
|
-
/* @__PURE__ */ jsxRuntime.
|
|
13018
|
-
|
|
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,
|
|
13019
13011
|
{
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
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
|
+
] })
|
|
13024
13019
|
}
|
|
13025
|
-
)
|
|
13026
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13027
|
-
|
|
13020
|
+
),
|
|
13021
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13022
|
+
Form$2.Field,
|
|
13028
13023
|
{
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
|
|
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
|
+
] })
|
|
13033
13031
|
}
|
|
13034
|
-
)
|
|
13035
|
-
] })
|
|
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
|
+
] }) })
|
|
13036
13038
|
]
|
|
13037
13039
|
}
|
|
13038
|
-
);
|
|
13040
|
+
) });
|
|
13039
13041
|
};
|
|
13040
|
-
const schema =
|
|
13041
|
-
customer_id: stringType().min(1)
|
|
13042
|
-
});
|
|
13042
|
+
const schema = addressSchema;
|
|
13043
13043
|
const widgetModule = { widgets: [] };
|
|
13044
13044
|
const routeModule = {
|
|
13045
13045
|
routes: [
|
|
@@ -13064,14 +13064,14 @@ const routeModule = {
|
|
|
13064
13064
|
Component: BillingAddress,
|
|
13065
13065
|
path: "/draft-orders/:id/billing-address"
|
|
13066
13066
|
},
|
|
13067
|
-
{
|
|
13068
|
-
Component: Email,
|
|
13069
|
-
path: "/draft-orders/:id/email"
|
|
13070
|
-
},
|
|
13071
13067
|
{
|
|
13072
13068
|
Component: CustomItems,
|
|
13073
13069
|
path: "/draft-orders/:id/custom-items"
|
|
13074
13070
|
},
|
|
13071
|
+
{
|
|
13072
|
+
Component: Email,
|
|
13073
|
+
path: "/draft-orders/:id/email"
|
|
13074
|
+
},
|
|
13075
13075
|
{
|
|
13076
13076
|
Component: Items,
|
|
13077
13077
|
path: "/draft-orders/:id/items"
|
|
@@ -13080,6 +13080,14 @@ const routeModule = {
|
|
|
13080
13080
|
Component: Metadata,
|
|
13081
13081
|
path: "/draft-orders/:id/metadata"
|
|
13082
13082
|
},
|
|
13083
|
+
{
|
|
13084
|
+
Component: Shipping,
|
|
13085
|
+
path: "/draft-orders/:id/shipping"
|
|
13086
|
+
},
|
|
13087
|
+
{
|
|
13088
|
+
Component: TransferOwnership,
|
|
13089
|
+
path: "/draft-orders/:id/transfer-ownership"
|
|
13090
|
+
},
|
|
13083
13091
|
{
|
|
13084
13092
|
Component: Promotions,
|
|
13085
13093
|
path: "/draft-orders/:id/promotions"
|
|
@@ -13091,14 +13099,6 @@ const routeModule = {
|
|
|
13091
13099
|
{
|
|
13092
13100
|
Component: ShippingAddress,
|
|
13093
13101
|
path: "/draft-orders/:id/shipping-address"
|
|
13094
|
-
},
|
|
13095
|
-
{
|
|
13096
|
-
Component: Shipping,
|
|
13097
|
-
path: "/draft-orders/:id/shipping"
|
|
13098
|
-
},
|
|
13099
|
-
{
|
|
13100
|
-
Component: TransferOwnership,
|
|
13101
|
-
path: "/draft-orders/:id/transfer-ownership"
|
|
13102
13102
|
}
|
|
13103
13103
|
]
|
|
13104
13104
|
}
|