@medusajs/loyalty-plugin 0.0.7-preview.0 → 0.0.7-preview.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.
@@ -3,7 +3,7 @@ var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, {
3
3
  var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
4
4
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
5
5
  import { defineWidgetConfig, defineRouteConfig } from "@medusajs/admin-sdk";
6
- import { DropdownMenu, IconButton, clx, Heading, Text, Tooltip, Button, Container as Container$1, StatusBadge, useDataTable, DataTable as DataTable$1, createDataTableFilterHelper, usePrompt, Checkbox, toast, createDataTableColumnHelper, Badge, Toaster, Label as Label$1, Hint as Hint$1, Prompt, Drawer, FocusModal, Divider, CurrencyInput as CurrencyInput$1, Textarea, Kbd, Copy, RadioGroup, DatePicker, Skeleton, Input, Alert, ProgressTabs, CommandBar, Select } from "@medusajs/ui";
6
+ import { DropdownMenu, IconButton, clx, Heading, Text, Tooltip, Button, Container as Container$1, StatusBadge, useDataTable, DataTable as DataTable$1, createDataTableFilterHelper, usePrompt, Checkbox, toast, createDataTableColumnHelper, Badge, Toaster, Label as Label$1, Hint as Hint$1, Prompt, Drawer, FocusModal, Divider, CurrencyInput as CurrencyInput$1, DatePicker, Textarea, Kbd, Copy, RadioGroup, Skeleton, Input, Alert, ProgressTabs, CommandBar, Select } from "@medusajs/ui";
7
7
  import { Link, useParams, useSearchParams, useNavigate, Outlet, useBlocker, useLocation } from "react-router-dom";
8
8
  import * as React from "react";
9
9
  import React__default, { createElement as createElement$1, useState, useCallback, useMemo, Fragment as Fragment$1, createContext, forwardRef, useId as useId$1, useContext, useEffect, isValidElement as isValidElement$1, useLayoutEffect, useRef, useReducer, useTransition, useImperativeHandle, useDeferredValue, Suspense, memo as memo$2, cloneElement } from "react";
@@ -20350,7 +20350,11 @@ const GiftCardProductsSection = () => {
20350
20350
  )
20351
20351
  ] });
20352
20352
  };
20353
- const giftCardQueryKey = queryKeysFactory("gift-card");
20353
+ const _giftCardQueryKey = queryKeysFactory("gift-card");
20354
+ const giftCardQueryKey = {
20355
+ ..._giftCardQueryKey,
20356
+ orders: (id) => [..._giftCardQueryKey.detail(id), "orders"]
20357
+ };
20354
20358
  const useGiftCards = (query, options) => {
20355
20359
  const fetchGiftCards = (query2, headers) => sdk.client.fetch(`/admin/gift-cards`, {
20356
20360
  query: query2,
@@ -20375,6 +20379,18 @@ const useGiftCard = (id, query, options) => {
20375
20379
  });
20376
20380
  return { ...data, ...rest };
20377
20381
  };
20382
+ const useGiftCardOrders = (id, options) => {
20383
+ const fetchGiftCardOrders = (id2, query, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}/orders`, {
20384
+ query,
20385
+ headers
20386
+ });
20387
+ const { data, ...rest } = useQuery({
20388
+ queryFn: () => fetchGiftCardOrders(id),
20389
+ queryKey: giftCardQueryKey.orders(id),
20390
+ ...options
20391
+ });
20392
+ return { ...data, ...rest };
20393
+ };
20378
20394
  const useRedeemGiftCard = (id, options) => {
20379
20395
  const queryClient = useQueryClient();
20380
20396
  const redeemGiftCard = async (id2, body) => sdk.client.fetch(`/admin/gift-cards/${id2}/redeem`, {
@@ -20438,6 +20454,12 @@ const columnHelper$9 = createDataTableColumnHelper();
20438
20454
  const useGiftCardTableColumns = () => {
20439
20455
  return useMemo(() => {
20440
20456
  return [
20457
+ columnHelper$9.accessor("code", {
20458
+ header: "Code",
20459
+ cell: ({ row }) => {
20460
+ return row.original.code;
20461
+ }
20462
+ }),
20441
20463
  columnHelper$9.accessor("line_item.product.title", {
20442
20464
  header: "Product",
20443
20465
  cell: ({ row }) => {
@@ -20445,34 +20467,10 @@ const useGiftCardTableColumns = () => {
20445
20467
  return ((_b = (_a = row.original.line_item) == null ? void 0 : _a.product) == null ? void 0 : _b.title) || "Custom Gift Card";
20446
20468
  }
20447
20469
  }),
20448
- columnHelper$9.accessor("customer.first_name", {
20449
- header: "Owner",
20450
- cell: ({ row }) => {
20451
- if (!row.original.customer) {
20452
- return "N/A";
20453
- }
20454
- const fullName = [
20455
- row.original.customer.first_name,
20456
- row.original.customer.last_name
20457
- ];
20458
- if (fullName.join("").length > 0) {
20459
- return fullName.join(" ");
20460
- }
20461
- return row.original.customer.email;
20462
- }
20463
- }),
20464
20470
  columnHelper$9.accessor("created_at", {
20465
20471
  header: "Date issued",
20466
20472
  cell: ({ row }) => getRelativeDate(row.original.created_at)
20467
20473
  }),
20468
- columnHelper$9.accessor("status", {
20469
- header: "Status",
20470
- cell: ({ row }) => {
20471
- const status = getGiftCardStatus(row.original);
20472
- const color = getGiftCardStatusColor(status);
20473
- return /* @__PURE__ */ jsx(StatusBadge, { color, children: status });
20474
- }
20475
- }),
20476
20474
  columnHelper$9.accessor("value", {
20477
20475
  header: "Value",
20478
20476
  cell: ({ row }) => {
@@ -20603,9 +20601,6 @@ const GiftCardCreateSchema = z.object({
20603
20601
  currency_code: z.string({
20604
20602
  required_error: "Currency is required"
20605
20603
  }),
20606
- customer_id: z.string({
20607
- required_error: "Customer is required"
20608
- }),
20609
20604
  expires_at: z.date().nullable().optional(),
20610
20605
  note: z.string().optional(),
20611
20606
  metadata: z.record(z.string(), z.string()).optional()
@@ -20621,10 +20616,9 @@ const GiftCardCreateForm = ({
20621
20616
  defaultValues: {
20622
20617
  value: void 0,
20623
20618
  currency_code: (supportedCurrencies == null ? void 0 : supportedCurrencies[0]) ?? "eur",
20624
- customer_id: "",
20625
20619
  expires_at: null,
20626
- note: "",
20627
- metadata: {}
20620
+ metadata: {},
20621
+ note: ""
20628
20622
  },
20629
20623
  resolver: t(GiftCardCreateSchema)
20630
20624
  });
@@ -20653,30 +20647,6 @@ const GiftCardCreateForm = ({
20653
20647
  (option) => option.label.toLowerCase().includes(currencySearchValue.toLowerCase())
20654
20648
  );
20655
20649
  }, [currencySearchValue]);
20656
- const {
20657
- options: customerOptions,
20658
- fetchNextPage,
20659
- isFetchingNextPage,
20660
- searchValue,
20661
- onSearchValueChange,
20662
- isLoading
20663
- } = useComboboxData({
20664
- queryKey: customersQueryKeys.list(),
20665
- queryFn: async (params) => {
20666
- return sdk.admin.customer.list(params);
20667
- },
20668
- getOptions: (data) => {
20669
- var _a;
20670
- return ((_a = data.customers) == null ? void 0 : _a.map((customer) => {
20671
- const fullName = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
20672
- const label = fullName ? `${customer.email} (${fullName})` : customer.email;
20673
- return {
20674
- label,
20675
- value: customer.id
20676
- };
20677
- })) || [];
20678
- }
20679
- });
20680
20650
  const selectedCurrency = form.watch("currency_code");
20681
20651
  const currentCurrency = useMemo(() => {
20682
20652
  return currencies[selectedCurrency.toUpperCase()];
@@ -20689,7 +20659,7 @@ const GiftCardCreateForm = ({
20689
20659
  /* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "size-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center p-16", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children: [
20690
20660
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
20691
20661
  /* @__PURE__ */ jsx(Heading, { level: "h1", children: "Create Gift Card" }),
20692
- /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", size: "small", children: "Create a new gift card for a customer" })
20662
+ /* @__PURE__ */ jsx(Text, { className: "text-ui-fg-subtle", size: "small", children: "Create a new gift card" })
20693
20663
  ] }),
20694
20664
  /* @__PURE__ */ jsx(Divider, { variant: "dashed" }),
20695
20665
  /* @__PURE__ */ jsxs(
@@ -20738,14 +20708,21 @@ const GiftCardCreateForm = ({
20738
20708
  /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
20739
20709
  CurrencyInput$1,
20740
20710
  {
20741
- ...field,
20742
- formatValueOnBlur: true,
20743
- symbol: currentCurrency.symbol_native,
20711
+ value: field.value,
20744
20712
  code: currentCurrency.code,
20713
+ symbol: currentCurrency.symbol_native,
20745
20714
  decimalScale: currentCurrency.decimal_digits,
20746
20715
  decimalsLimit: currentCurrency.decimal_digits,
20716
+ allowDecimals: true,
20717
+ formatValueOnBlur: true,
20718
+ allowNegativeValue: false,
20747
20719
  autoComplete: "off",
20748
- tabIndex: -1
20720
+ tabIndex: -1,
20721
+ onValueChange: (_value, _name, values) => {
20722
+ field.onChange(
20723
+ (values == null ? void 0 : values.value) ? values == null ? void 0 : values.value : ""
20724
+ );
20725
+ }
20749
20726
  }
20750
20727
  ) }),
20751
20728
  /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
@@ -20757,22 +20734,17 @@ const GiftCardCreateForm = ({
20757
20734
  Form$2.Field,
20758
20735
  {
20759
20736
  control: form.control,
20760
- name: "customer_id",
20737
+ name: "expires_at",
20761
20738
  render: ({ field }) => {
20762
- return /* @__PURE__ */ jsxs(Form$2.Item, { className: "w-full", children: [
20763
- /* @__PURE__ */ jsx(Form$2.Label, { className: "font-normal", children: "Customer" }),
20739
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
20740
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Expires at" }),
20764
20741
  /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
20765
- Combobox,
20742
+ DatePicker,
20766
20743
  {
20767
- value: field.value,
20768
- onChange: field.onChange,
20769
- searchValue,
20770
- onSearchValueChange,
20771
- options: customerOptions,
20772
- placeholder: "Search for a customer...",
20773
- fetchNextPage,
20774
- isFetchingNextPage,
20775
- noResultsPlaceholder: isLoading ? "Loading customers..." : "No customers found"
20744
+ hourCycle: 24,
20745
+ granularity: "minute",
20746
+ shouldCloseOnSelect: false,
20747
+ ...field
20776
20748
  }
20777
20749
  ) }),
20778
20750
  /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
@@ -23716,8 +23688,7 @@ const GiftCardGeneralSection = ({ giftCard }) => {
23716
23688
  onError: (error) => toast.error(error.message)
23717
23689
  });
23718
23690
  };
23719
- const status = getGiftCardStatus(giftCard);
23720
- const statusColor = getGiftCardStatusColor(status);
23691
+ getGiftCardStatus(giftCard);
23721
23692
  return /* @__PURE__ */ jsxs(Container$1, { className: "divide-y p-0", children: [
23722
23693
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-6 py-4", children: [
23723
23694
  /* @__PURE__ */ jsxs("div", { children: [
@@ -23733,43 +23704,40 @@ const GiftCardGeneralSection = ({ giftCard }) => {
23733
23704
  includeTime: true
23734
23705
  }) })
23735
23706
  ] }),
23736
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-4", children: [
23737
- /* @__PURE__ */ jsx(StatusBadge, { color: statusColor, children: status }),
23738
- /* @__PURE__ */ jsx(
23739
- ActionMenu,
23740
- {
23741
- groups: [
23742
- {
23743
- actions: [
23744
- // TODO: revisit this - now GC doesn't have owner so redeeming would result in an anonymous account
23745
- // {
23746
- // icon: <Gift />,
23747
- // label: "Redeem gift card",
23748
- // onClick: () => handleRedeem(),
23749
- // disabled: isPending || giftCard.status === "redeemed",
23750
- // },
23751
- {
23752
- icon: /* @__PURE__ */ jsx(Calendar, {}),
23753
- label: "Edit expiration date",
23754
- to: "expiration",
23755
- disabled: isPending
23756
- }
23757
- ]
23758
- },
23759
- {
23760
- actions: [
23761
- {
23762
- icon: /* @__PURE__ */ jsx(Trash, {}),
23763
- label: "Delete",
23764
- onClick: handleDelete,
23765
- disabled: isDeleting || true
23766
- }
23767
- ]
23768
- }
23769
- ]
23770
- }
23771
- )
23772
- ] })
23707
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-x-4", children: /* @__PURE__ */ jsx(
23708
+ ActionMenu,
23709
+ {
23710
+ groups: [
23711
+ {
23712
+ actions: [
23713
+ // TODO: revisit this - now GC doesn't have owner so redeeming would result in an anonymous account
23714
+ // {
23715
+ // icon: <Gift />,
23716
+ // label: "Redeem gift card",
23717
+ // onClick: () => handleRedeem(),
23718
+ // disabled: isPending || giftCard.status === "redeemed",
23719
+ // },
23720
+ {
23721
+ icon: /* @__PURE__ */ jsx(Calendar, {}),
23722
+ label: "Edit expiration date",
23723
+ to: "expiration",
23724
+ disabled: isPending
23725
+ }
23726
+ ]
23727
+ },
23728
+ {
23729
+ actions: [
23730
+ {
23731
+ icon: /* @__PURE__ */ jsx(Trash, {}),
23732
+ label: "Delete",
23733
+ onClick: handleDelete,
23734
+ disabled: isDeleting || true
23735
+ }
23736
+ ]
23737
+ }
23738
+ ]
23739
+ }
23740
+ ) })
23773
23741
  ] }),
23774
23742
  ((_a = giftCard.line_item) == null ? void 0 : _a.product) && /* @__PURE__ */ jsx(
23775
23743
  SectionRow,
@@ -23852,19 +23820,21 @@ const GiftCardNoteSection = ({ giftCard }) => {
23852
23820
  ] });
23853
23821
  };
23854
23822
  const GiftCardOrderSection = ({ giftCard }) => {
23855
- if (!giftCard || giftCard.reference !== "order") {
23856
- return;
23857
- }
23858
- const { order, isLoading, isError, error } = useOrder(giftCard.reference_id);
23823
+ const { orders, isLoading, isError, error } = useGiftCardOrders(
23824
+ giftCard == null ? void 0 : giftCard.id
23825
+ );
23859
23826
  if (isError) {
23860
23827
  throw error;
23861
23828
  }
23862
- if (isLoading) {
23829
+ if (isLoading || !orders) {
23830
+ return null;
23831
+ }
23832
+ if (orders && orders.length === 0) {
23863
23833
  return null;
23864
23834
  }
23865
23835
  return /* @__PURE__ */ jsxs(Container$1, { className: "p-0", children: [
23866
23836
  /* @__PURE__ */ jsx(Header$5, { title: "Order" }),
23867
- /* @__PURE__ */ jsx(
23837
+ orders.map((order) => /* @__PURE__ */ jsx(
23868
23838
  SidebarLink,
23869
23839
  {
23870
23840
  to: `/orders/${order.id}`,
@@ -23872,7 +23842,7 @@ const GiftCardOrderSection = ({ giftCard }) => {
23872
23842
  icon: /* @__PURE__ */ jsx(ShoppingCart, {}),
23873
23843
  descriptionKey: `Order #${order.display_id}`
23874
23844
  }
23875
- )
23845
+ ))
23876
23846
  ] });
23877
23847
  };
23878
23848
  const GiftCardTransactionsSection = ({
@@ -23949,73 +23919,6 @@ const KeyboundForm = React__default.forwardRef(({ onSubmit, onKeyDown, ...rest }
23949
23919
  );
23950
23920
  });
23951
23921
  KeyboundForm.displayName = "KeyboundForm";
23952
- const Note = () => {
23953
- const { id } = useParams();
23954
- const {
23955
- gift_card: giftCard,
23956
- isPending,
23957
- isError,
23958
- error
23959
- } = useGiftCard(id, {});
23960
- if (isError) {
23961
- throw error;
23962
- }
23963
- const isReady = !isPending && !!giftCard;
23964
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
23965
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
23966
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit note" }) }),
23967
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
23968
- ] }),
23969
- isReady && /* @__PURE__ */ jsx(GiftCardNoteForm, { giftCard })
23970
- ] });
23971
- };
23972
- const GiftCardNoteForm = ({ giftCard }) => {
23973
- const form = useForm({
23974
- defaultValues: {
23975
- note: giftCard.note ?? ""
23976
- },
23977
- resolver: t(schema$1)
23978
- });
23979
- const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
23980
- const { handleSuccess } = useRouteModal();
23981
- const onSubmit = form.handleSubmit(async (data) => {
23982
- await mutateAsync(
23983
- { note: data.note },
23984
- {
23985
- onSuccess: () => handleSuccess(),
23986
- onError: (error) => toast.error(error.message)
23987
- }
23988
- );
23989
- });
23990
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
23991
- KeyboundForm,
23992
- {
23993
- className: "flex flex-1 flex-col overflow-hidden",
23994
- onSubmit,
23995
- children: [
23996
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
23997
- Form$2.Field,
23998
- {
23999
- control: form.control,
24000
- name: "note",
24001
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
24002
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Note" }),
24003
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
24004
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
24005
- ] })
24006
- }
24007
- ) }),
24008
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
24009
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
24010
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
24011
- ] }) })
24012
- ]
24013
- }
24014
- ) });
24015
- };
24016
- const schema$1 = z.object({
24017
- note: z.string().optional()
24018
- });
24019
23922
  const GiftCardExpiration = () => {
24020
23923
  const { id } = useParams();
24021
23924
  const {
@@ -24041,7 +23944,7 @@ const GiftCardExpirationForm = ({ giftCard }) => {
24041
23944
  defaultValues: {
24042
23945
  expires_at: giftCard.expires_at ? new Date(giftCard.expires_at) : null
24043
23946
  },
24044
- resolver: t(schema)
23947
+ resolver: t(schema$1)
24045
23948
  });
24046
23949
  const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
24047
23950
  const { handleSuccess } = useRouteModal();
@@ -24130,9 +24033,76 @@ const GiftCardExpirationForm = ({ giftCard }) => {
24130
24033
  }
24131
24034
  ) });
24132
24035
  };
24133
- const schema = z.object({
24036
+ const schema$1 = z.object({
24134
24037
  expires_at: z.date().nullish()
24135
24038
  });
24039
+ const Note = () => {
24040
+ const { id } = useParams();
24041
+ const {
24042
+ gift_card: giftCard,
24043
+ isPending,
24044
+ isError,
24045
+ error
24046
+ } = useGiftCard(id, {});
24047
+ if (isError) {
24048
+ throw error;
24049
+ }
24050
+ const isReady = !isPending && !!giftCard;
24051
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
24052
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
24053
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit note" }) }),
24054
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
24055
+ ] }),
24056
+ isReady && /* @__PURE__ */ jsx(GiftCardNoteForm, { giftCard })
24057
+ ] });
24058
+ };
24059
+ const GiftCardNoteForm = ({ giftCard }) => {
24060
+ const form = useForm({
24061
+ defaultValues: {
24062
+ note: giftCard.note ?? ""
24063
+ },
24064
+ resolver: t(schema)
24065
+ });
24066
+ const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
24067
+ const { handleSuccess } = useRouteModal();
24068
+ const onSubmit = form.handleSubmit(async (data) => {
24069
+ await mutateAsync(
24070
+ { note: data.note },
24071
+ {
24072
+ onSuccess: () => handleSuccess(),
24073
+ onError: (error) => toast.error(error.message)
24074
+ }
24075
+ );
24076
+ });
24077
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
24078
+ KeyboundForm,
24079
+ {
24080
+ className: "flex flex-1 flex-col overflow-hidden",
24081
+ onSubmit,
24082
+ children: [
24083
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
24084
+ Form$2.Field,
24085
+ {
24086
+ control: form.control,
24087
+ name: "note",
24088
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
24089
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Note" }),
24090
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
24091
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
24092
+ ] })
24093
+ }
24094
+ ) }),
24095
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
24096
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
24097
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
24098
+ ] }) })
24099
+ ]
24100
+ }
24101
+ ) });
24102
+ };
24103
+ const schema = z.object({
24104
+ note: z.string().optional()
24105
+ });
24136
24106
  const columnHelper$7 = createColumnHelper();
24137
24107
  const useGiftCardProductsTableColumns = () => {
24138
24108
  return useMemo(
@@ -37415,6 +37385,153 @@ const ProductDetail = () => {
37415
37385
  ] });
37416
37386
  };
37417
37387
  const EditProductSchema$1 = z.object({
37388
+ denominations: z.array(
37389
+ z.object({
37390
+ id: z.string().optional(),
37391
+ value: z.string().min(1),
37392
+ prices: z.record(z.string(), optionalFloat).optional()
37393
+ })
37394
+ ).min(1)
37395
+ });
37396
+ const GiftCardProductEditDenominationsForm = ({
37397
+ product
37398
+ }) => {
37399
+ var _a;
37400
+ const { handleSuccess } = useRouteModal();
37401
+ const form = useForm({
37402
+ defaultValues: {
37403
+ denominations: (_a = product.variants) == null ? void 0 : _a.map((variant) => ({
37404
+ id: variant.id,
37405
+ value: variant.title
37406
+ }))
37407
+ },
37408
+ resolver: t(EditProductSchema$1)
37409
+ });
37410
+ const { mutateAsync, isPending } = useUpdateProduct(product.id);
37411
+ const handleSubmit = form.handleSubmit(async (data) => {
37412
+ const optionValues = data.denominations.map(
37413
+ (denomination) => denomination.value
37414
+ );
37415
+ const options = [
37416
+ {
37417
+ title: "denomination",
37418
+ values: optionValues
37419
+ }
37420
+ ];
37421
+ await mutateAsync(
37422
+ {
37423
+ options,
37424
+ variants: data.denominations.map((denomination) => ({
37425
+ id: denomination.id,
37426
+ title: denomination.value,
37427
+ manage_inventory: false,
37428
+ options: {
37429
+ denomination: denomination.value
37430
+ }
37431
+ }))
37432
+ },
37433
+ {
37434
+ onSuccess: () => {
37435
+ toast.success(`Denominations updated successfully`);
37436
+ handleSuccess();
37437
+ },
37438
+ onError: (e2) => {
37439
+ toast.error(e2.message);
37440
+ }
37441
+ }
37442
+ );
37443
+ });
37444
+ const {
37445
+ fields: denominationsFields,
37446
+ append: addDenomination,
37447
+ remove: removeDenomination
37448
+ } = useFieldArray({
37449
+ name: "denominations",
37450
+ control: form.control
37451
+ });
37452
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
37453
+ KeyboundForm,
37454
+ {
37455
+ onSubmit: handleSubmit,
37456
+ className: "flex flex-1 flex-col overflow-hidden",
37457
+ children: [
37458
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
37459
+ denominationsFields.map((denominationField, index) => {
37460
+ return /* @__PURE__ */ jsxs(
37461
+ "div",
37462
+ {
37463
+ className: "flex items-center justify-between shadow-elevation-card-rest bg-ui-bg-component transition-fg rounded-md px-4 py-2",
37464
+ children: [
37465
+ /* @__PURE__ */ jsx(
37466
+ Form$2.Field,
37467
+ {
37468
+ control: form.control,
37469
+ name: `denominations.${index}.value`,
37470
+ render: ({ field }) => {
37471
+ return /* @__PURE__ */ jsxs(Form$2.Item, { className: "w-full", children: [
37472
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field, placeholder: "100" }) }),
37473
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
37474
+ ] });
37475
+ }
37476
+ },
37477
+ denominationField.id
37478
+ ),
37479
+ /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsx(
37480
+ Button,
37481
+ {
37482
+ size: "small",
37483
+ variant: "secondary",
37484
+ type: "button",
37485
+ className: "rounded-full p-0 ml-4",
37486
+ onClick: () => {
37487
+ removeDenomination(index);
37488
+ },
37489
+ children: /* @__PURE__ */ jsx(XCircleSolid, { className: "rounded-full" })
37490
+ }
37491
+ ) })
37492
+ ]
37493
+ },
37494
+ denominationField.id
37495
+ );
37496
+ }),
37497
+ /* @__PURE__ */ jsx(
37498
+ Button,
37499
+ {
37500
+ size: "small",
37501
+ variant: "secondary",
37502
+ type: "button",
37503
+ className: "w-full",
37504
+ onClick: () => {
37505
+ addDenomination({ value: "", prices: {} });
37506
+ },
37507
+ children: "Add denomination"
37508
+ }
37509
+ ),
37510
+ form.formState.errors.denominations && /* @__PURE__ */ jsx(Alert, { variant: "error", children: "Please add at least one denomination." })
37511
+ ] }) }) }) }),
37512
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
37513
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
37514
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
37515
+ ] }) })
37516
+ ]
37517
+ }
37518
+ ) });
37519
+ };
37520
+ const GiftCardProductEdit$1 = () => {
37521
+ const { id } = useParams();
37522
+ const { product, isLoading, isError, error } = useProduct(id, {});
37523
+ if (isError) {
37524
+ throw error;
37525
+ }
37526
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
37527
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
37528
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift cards denominations" }) }),
37529
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
37530
+ ] }),
37531
+ !isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditDenominationsForm, { product })
37532
+ ] });
37533
+ };
37534
+ const EditProductSchema = z.object({
37418
37535
  status: z.enum(["draft", "published", "proposed", "rejected"]),
37419
37536
  title: z.string().min(1),
37420
37537
  subtitle: z.string().optional(),
@@ -37433,7 +37550,7 @@ const GiftCardProductEditForm = ({
37433
37550
  handle: product.handle || "",
37434
37551
  description: product.description || ""
37435
37552
  },
37436
- resolver: t(EditProductSchema$1)
37553
+ resolver: t(EditProductSchema)
37437
37554
  });
37438
37555
  const { mutateAsync, isPending } = useUpdateProduct(product.id);
37439
37556
  const handleSubmit = form.handleSubmit(async (data) => {
@@ -37574,7 +37691,7 @@ const GiftCardProductEditForm = ({
37574
37691
  }
37575
37692
  ) });
37576
37693
  };
37577
- const GiftCardProductEdit$1 = () => {
37694
+ const GiftCardProductEdit = () => {
37578
37695
  const { id } = useParams();
37579
37696
  const { product, isLoading, isError, error } = useProduct(id, {});
37580
37697
  if (isError) {
@@ -37588,152 +37705,6 @@ const GiftCardProductEdit$1 = () => {
37588
37705
  !isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditForm, { product })
37589
37706
  ] });
37590
37707
  };
37591
- const EditProductSchema = z.object({
37592
- denominations: z.array(
37593
- z.object({
37594
- id: z.string().optional(),
37595
- value: z.string().min(1),
37596
- prices: z.record(z.string(), optionalFloat).optional()
37597
- })
37598
- ).min(1)
37599
- });
37600
- const GiftCardProductEditDenominationsForm = ({
37601
- product
37602
- }) => {
37603
- var _a;
37604
- const { handleSuccess } = useRouteModal();
37605
- const form = useForm({
37606
- defaultValues: {
37607
- denominations: (_a = product.variants) == null ? void 0 : _a.map((variant) => ({
37608
- id: variant.id,
37609
- value: variant.title
37610
- }))
37611
- },
37612
- resolver: t(EditProductSchema)
37613
- });
37614
- const { mutateAsync, isPending } = useUpdateProduct(product.id);
37615
- const handleSubmit = form.handleSubmit(async (data) => {
37616
- const optionValues = data.denominations.map(
37617
- (denomination) => denomination.value
37618
- );
37619
- const options = [
37620
- {
37621
- title: "denomination",
37622
- values: optionValues
37623
- }
37624
- ];
37625
- await mutateAsync(
37626
- {
37627
- options,
37628
- variants: data.denominations.map((denomination) => ({
37629
- id: denomination.id,
37630
- title: denomination.value,
37631
- options: {
37632
- denomination: denomination.value
37633
- }
37634
- }))
37635
- },
37636
- {
37637
- onSuccess: () => {
37638
- toast.success(`Denominations updated successfully`);
37639
- handleSuccess();
37640
- },
37641
- onError: (e2) => {
37642
- toast.error(e2.message);
37643
- }
37644
- }
37645
- );
37646
- });
37647
- const {
37648
- fields: denominationsFields,
37649
- append: addDenomination,
37650
- remove: removeDenomination
37651
- } = useFieldArray({
37652
- name: "denominations",
37653
- control: form.control
37654
- });
37655
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
37656
- KeyboundForm,
37657
- {
37658
- onSubmit: handleSubmit,
37659
- className: "flex flex-1 flex-col overflow-hidden",
37660
- children: [
37661
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
37662
- denominationsFields.map((denominationField, index) => {
37663
- return /* @__PURE__ */ jsxs(
37664
- "div",
37665
- {
37666
- className: "flex items-center justify-between shadow-elevation-card-rest bg-ui-bg-component transition-fg rounded-md px-4 py-2",
37667
- children: [
37668
- /* @__PURE__ */ jsx(
37669
- Form$2.Field,
37670
- {
37671
- control: form.control,
37672
- name: `denominations.${index}.value`,
37673
- render: ({ field }) => {
37674
- return /* @__PURE__ */ jsxs(Form$2.Item, { className: "w-full", children: [
37675
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field, placeholder: "100" }) }),
37676
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
37677
- ] });
37678
- }
37679
- },
37680
- denominationField.id
37681
- ),
37682
- /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsx(
37683
- Button,
37684
- {
37685
- size: "small",
37686
- variant: "secondary",
37687
- type: "button",
37688
- className: "rounded-full p-0 ml-4",
37689
- onClick: () => {
37690
- removeDenomination(index);
37691
- },
37692
- children: /* @__PURE__ */ jsx(XCircleSolid, { className: "rounded-full" })
37693
- }
37694
- ) })
37695
- ]
37696
- },
37697
- denominationField.id
37698
- );
37699
- }),
37700
- /* @__PURE__ */ jsx(
37701
- Button,
37702
- {
37703
- size: "small",
37704
- variant: "secondary",
37705
- type: "button",
37706
- className: "w-full",
37707
- onClick: () => {
37708
- addDenomination({ value: "", prices: {} });
37709
- },
37710
- children: "Add denomination"
37711
- }
37712
- ),
37713
- form.formState.errors.denominations && /* @__PURE__ */ jsx(Alert, { variant: "error", children: "Please add at least one denomination." })
37714
- ] }) }) }) }),
37715
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
37716
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
37717
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
37718
- ] }) })
37719
- ]
37720
- }
37721
- ) });
37722
- };
37723
- const GiftCardProductEdit = () => {
37724
- const { id } = useParams();
37725
- const { product, isLoading, isError, error } = useProduct(id, {});
37726
- if (isError) {
37727
- throw error;
37728
- }
37729
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
37730
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
37731
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift cards denominations" }) }),
37732
- /* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
37733
- ] }),
37734
- !isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditDenominationsForm, { product })
37735
- ] });
37736
- };
37737
37708
  const EditProductMediaForm = ({ product }) => {
37738
37709
  const [selection, setSelection] = useState({});
37739
37710
  const { handleSuccess } = useRouteModal();
@@ -38347,6 +38318,112 @@ const ProductMedia = () => {
38347
38318
  ready && /* @__PURE__ */ jsx(ProductMediaView, { product })
38348
38319
  ] });
38349
38320
  };
38321
+ const EditSalesChannelsSchema = objectType({
38322
+ sales_channels: arrayType(stringType()).optional()
38323
+ });
38324
+ const PAGE_SIZE = 50;
38325
+ const PREFIX = "sc";
38326
+ const EditSalesChannelsForm = ({
38327
+ product
38328
+ }) => {
38329
+ var _a, _b;
38330
+ const { handleSuccess } = useRouteModal();
38331
+ const form = useForm({
38332
+ defaultValues: {
38333
+ sales_channels: ((_a = product.sales_channels) == null ? void 0 : _a.map((sc) => sc.id)) ?? []
38334
+ },
38335
+ resolver: t(EditSalesChannelsSchema)
38336
+ });
38337
+ const { setValue: setValue2 } = form;
38338
+ const initialState2 = ((_b = product.sales_channels) == null ? void 0 : _b.reduce((acc, curr) => {
38339
+ acc[curr.id] = true;
38340
+ return acc;
38341
+ }, {})) ?? {};
38342
+ const [rowSelection, setRowSelection] = useState(initialState2);
38343
+ useEffect(() => {
38344
+ const ids2 = Object.keys(rowSelection);
38345
+ setValue2("sales_channels", ids2, {
38346
+ shouldDirty: true,
38347
+ shouldTouch: true
38348
+ });
38349
+ }, [rowSelection, setValue2]);
38350
+ const searchParams = useSalesChannelTableQuery({
38351
+ pageSize: PAGE_SIZE,
38352
+ prefix: PREFIX
38353
+ });
38354
+ const { sales_channels, count: count2, isLoading, isError, error } = useSalesChannels(
38355
+ {
38356
+ ...searchParams
38357
+ },
38358
+ {
38359
+ placeholderData: keepPreviousData
38360
+ }
38361
+ );
38362
+ const filters = useSalesChannelTableFilters();
38363
+ const emptyState = useSalesChannelTableEmptyState();
38364
+ const columns = useColumns();
38365
+ const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
38366
+ const handleSubmit = form.handleSubmit(async (data) => {
38367
+ const arr = data.sales_channels ?? [];
38368
+ const sales_channels2 = arr.map((id) => {
38369
+ return {
38370
+ id
38371
+ };
38372
+ });
38373
+ await mutateAsync(
38374
+ {
38375
+ sales_channels: sales_channels2
38376
+ },
38377
+ {
38378
+ onSuccess: () => {
38379
+ handleSuccess();
38380
+ }
38381
+ }
38382
+ );
38383
+ });
38384
+ if (isError) {
38385
+ throw error;
38386
+ }
38387
+ return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
38388
+ /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
38389
+ /* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(
38390
+ DataTable,
38391
+ {
38392
+ data: sales_channels,
38393
+ columns,
38394
+ getRowId: (row) => row.id,
38395
+ rowCount: count2,
38396
+ isLoading,
38397
+ filters,
38398
+ rowSelection: {
38399
+ state: rowSelection,
38400
+ onRowSelectionChange: setRowSelection
38401
+ },
38402
+ autoFocusSearch: true,
38403
+ layout: "fill",
38404
+ emptyState,
38405
+ prefix: PREFIX
38406
+ }
38407
+ ) }),
38408
+ /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
38409
+ /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
38410
+ /* @__PURE__ */ jsx(Button, { size: "small", isLoading: isMutating, onClick: handleSubmit, children: "Save" })
38411
+ ] }) })
38412
+ ] }) });
38413
+ };
38414
+ const columnHelper$1 = createDataTableColumnHelper();
38415
+ const useColumns = () => {
38416
+ const columns = useSalesChannelTableColumns();
38417
+ return useMemo(() => [columnHelper$1.select(), ...columns], [columns]);
38418
+ };
38419
+ const ProductSalesChannels = () => {
38420
+ const { id } = useParams();
38421
+ const { product, isLoading, isError, error } = useProduct(id);
38422
+ if (isError) {
38423
+ throw error;
38424
+ }
38425
+ return /* @__PURE__ */ jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsx(EditSalesChannelsForm, { product }) });
38426
+ };
38350
38427
  const VariantPricingForm = ({ form }) => {
38351
38428
  const { store } = useStore$1();
38352
38429
  const { regions } = useRegions({ limit: 9999 });
@@ -38371,7 +38448,7 @@ const VariantPricingForm = ({ form }) => {
38371
38448
  }
38372
38449
  );
38373
38450
  };
38374
- const columnHelper$1 = createDataGridHelper();
38451
+ const columnHelper = createDataGridHelper();
38375
38452
  const useVariantPriceGridColumns = ({
38376
38453
  currencies: currencies2 = [],
38377
38454
  regions = [],
@@ -38379,7 +38456,7 @@ const useVariantPriceGridColumns = ({
38379
38456
  }) => {
38380
38457
  return useMemo(() => {
38381
38458
  return [
38382
- columnHelper$1.column({
38459
+ columnHelper.column({
38383
38460
  id: "Title",
38384
38461
  header: "Title",
38385
38462
  cell: (context) => {
@@ -38505,112 +38582,6 @@ const ProductPrices = () => {
38505
38582
  }
38506
38583
  return /* @__PURE__ */ jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsx(PricingEdit, { product, variantId: variant_id }) });
38507
38584
  };
38508
- const EditSalesChannelsSchema = objectType({
38509
- sales_channels: arrayType(stringType()).optional()
38510
- });
38511
- const PAGE_SIZE = 50;
38512
- const PREFIX = "sc";
38513
- const EditSalesChannelsForm = ({
38514
- product
38515
- }) => {
38516
- var _a, _b;
38517
- const { handleSuccess } = useRouteModal();
38518
- const form = useForm({
38519
- defaultValues: {
38520
- sales_channels: ((_a = product.sales_channels) == null ? void 0 : _a.map((sc) => sc.id)) ?? []
38521
- },
38522
- resolver: t(EditSalesChannelsSchema)
38523
- });
38524
- const { setValue: setValue2 } = form;
38525
- const initialState2 = ((_b = product.sales_channels) == null ? void 0 : _b.reduce((acc, curr) => {
38526
- acc[curr.id] = true;
38527
- return acc;
38528
- }, {})) ?? {};
38529
- const [rowSelection, setRowSelection] = useState(initialState2);
38530
- useEffect(() => {
38531
- const ids2 = Object.keys(rowSelection);
38532
- setValue2("sales_channels", ids2, {
38533
- shouldDirty: true,
38534
- shouldTouch: true
38535
- });
38536
- }, [rowSelection, setValue2]);
38537
- const searchParams = useSalesChannelTableQuery({
38538
- pageSize: PAGE_SIZE,
38539
- prefix: PREFIX
38540
- });
38541
- const { sales_channels, count: count2, isLoading, isError, error } = useSalesChannels(
38542
- {
38543
- ...searchParams
38544
- },
38545
- {
38546
- placeholderData: keepPreviousData
38547
- }
38548
- );
38549
- const filters = useSalesChannelTableFilters();
38550
- const emptyState = useSalesChannelTableEmptyState();
38551
- const columns = useColumns();
38552
- const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
38553
- const handleSubmit = form.handleSubmit(async (data) => {
38554
- const arr = data.sales_channels ?? [];
38555
- const sales_channels2 = arr.map((id) => {
38556
- return {
38557
- id
38558
- };
38559
- });
38560
- await mutateAsync(
38561
- {
38562
- sales_channels: sales_channels2
38563
- },
38564
- {
38565
- onSuccess: () => {
38566
- handleSuccess();
38567
- }
38568
- }
38569
- );
38570
- });
38571
- if (isError) {
38572
- throw error;
38573
- }
38574
- return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
38575
- /* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
38576
- /* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(
38577
- DataTable,
38578
- {
38579
- data: sales_channels,
38580
- columns,
38581
- getRowId: (row) => row.id,
38582
- rowCount: count2,
38583
- isLoading,
38584
- filters,
38585
- rowSelection: {
38586
- state: rowSelection,
38587
- onRowSelectionChange: setRowSelection
38588
- },
38589
- autoFocusSearch: true,
38590
- layout: "fill",
38591
- emptyState,
38592
- prefix: PREFIX
38593
- }
38594
- ) }),
38595
- /* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
38596
- /* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
38597
- /* @__PURE__ */ jsx(Button, { size: "small", isLoading: isMutating, onClick: handleSubmit, children: "Save" })
38598
- ] }) })
38599
- ] }) });
38600
- };
38601
- const columnHelper = createDataTableColumnHelper();
38602
- const useColumns = () => {
38603
- const columns = useSalesChannelTableColumns();
38604
- return useMemo(() => [columnHelper.select(), ...columns], [columns]);
38605
- };
38606
- const ProductSalesChannels = () => {
38607
- const { id } = useParams();
38608
- const { product, isLoading, isError, error } = useProduct(id);
38609
- if (isError) {
38610
- throw error;
38611
- }
38612
- return /* @__PURE__ */ jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsx(EditSalesChannelsForm, { product }) });
38613
- };
38614
38585
  const widgetModule = { widgets: [
38615
38586
  {
38616
38587
  Component: CustomerStoreCreditWidget,
@@ -38655,13 +38626,13 @@ const routeModule = {
38655
38626
  Component: GiftCardDetailsPage,
38656
38627
  path: "/gift-cards/:id",
38657
38628
  children: [
38658
- {
38659
- Component: Note,
38660
- path: "/gift-cards/:id/note"
38661
- },
38662
38629
  {
38663
38630
  Component: GiftCardExpiration,
38664
38631
  path: "/gift-cards/:id/expiration"
38632
+ },
38633
+ {
38634
+ Component: Note,
38635
+ path: "/gift-cards/:id/note"
38665
38636
  }
38666
38637
  ]
38667
38638
  },
@@ -38681,11 +38652,11 @@ const routeModule = {
38681
38652
  children: [
38682
38653
  {
38683
38654
  Component: GiftCardProductEdit$1,
38684
- path: "/gift-cards/gift-card-products/:id/edit"
38655
+ path: "/gift-cards/gift-card-products/:id/denominations"
38685
38656
  },
38686
38657
  {
38687
38658
  Component: GiftCardProductEdit,
38688
- path: "/gift-cards/gift-card-products/:id/denominations"
38659
+ path: "/gift-cards/gift-card-products/:id/edit"
38689
38660
  }
38690
38661
  ]
38691
38662
  },
@@ -38693,13 +38664,13 @@ const routeModule = {
38693
38664
  Component: ProductMedia,
38694
38665
  path: "/gift-cards/gift-card-products/:id/media"
38695
38666
  },
38696
- {
38697
- Component: ProductPrices,
38698
- path: "/gift-cards/gift-card-products/:id/prices"
38699
- },
38700
38667
  {
38701
38668
  Component: ProductSalesChannels,
38702
38669
  path: "/gift-cards/gift-card-products/:id/sales-channels"
38670
+ },
38671
+ {
38672
+ Component: ProductPrices,
38673
+ path: "/gift-cards/gift-card-products/:id/prices"
38703
38674
  }
38704
38675
  ]
38705
38676
  };