@medusajs/loyalty-plugin 2.17.2-snapshot-20260626130753 → 2.17.2

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.
@@ -11,8 +11,8 @@ const icons = require("@medusajs/icons");
11
11
  const reactQuery = require("@tanstack/react-query");
12
12
  const Medusa = require("@medusajs/js-sdk");
13
13
  const components = require("@medusajs/dashboard/components");
14
- const ReactDOM = require("react-dom");
15
14
  const zod = require("@medusajs/framework/zod");
15
+ const ReactDOM = require("react-dom");
16
16
  const _interopDefault = (e2) => e2 && e2.__esModule ? e2 : { default: e2 };
17
17
  function _interopNamespace(e2) {
18
18
  if (e2 && e2.__esModule) return e2;
@@ -442,7 +442,8 @@ const CustomerStoreCreditWidget = () => {
442
442
  ] });
443
443
  };
444
444
  adminSdk.defineWidgetConfig({
445
- zone: "customer.details.side.after"
445
+ zone: "customer.details.side.after",
446
+ id: "medusa:customer-store-credit-widget"
446
447
  });
447
448
  const ORDERS_QUERY_KEY = "orders";
448
449
  const orderQueryKeys = queryKeysFactory(ORDERS_QUERY_KEY);
@@ -511,7 +512,8 @@ const OrderGiftCardsWidget = () => {
511
512
  ] });
512
513
  };
513
514
  adminSdk.defineWidgetConfig({
514
- zone: "order.details.side.after"
515
+ zone: "order.details.side.after",
516
+ id: "medusa:order-gift-cards-widget"
515
517
  });
516
518
  const PRODUCTS_QUERY_KEY = "products";
517
519
  const productsQueryKeys = queryKeysFactory(PRODUCTS_QUERY_KEY);
@@ -5755,9 +5757,10 @@ const SalesChannelGiftCardsWidget = () => {
5755
5757
  return /* @__PURE__ */ jsxRuntime.jsx(SalesChannelGiftCardsSection, { salesChannel });
5756
5758
  };
5757
5759
  adminSdk.defineWidgetConfig({
5758
- zone: "sales_channel.details.after"
5760
+ zone: "sales_channel.details.after",
5761
+ id: "medusa:sales-channel-gift-cards-widget"
5759
5762
  });
5760
- const GiftCardIcon = (props) => {
5763
+ const StoreCreditIcon = (props) => {
5761
5764
  return /* @__PURE__ */ jsxRuntime.jsxs(
5762
5765
  "svg",
5763
5766
  {
@@ -5768,197 +5771,49 @@ const GiftCardIcon = (props) => {
5768
5771
  xmlns: "http://www.w3.org/2000/svg",
5769
5772
  ...props,
5770
5773
  children: [
5771
- /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#F97316" }),
5774
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#8B5CF6" }),
5772
5775
  /* @__PURE__ */ jsxRuntime.jsx(
5773
5776
  "rect",
5774
5777
  {
5775
5778
  width: "15",
5776
5779
  height: "15",
5777
- fill: "url(#paint0_linear_28788_25808)",
5780
+ fill: "url(#paint0_linear_29181_44790)",
5778
5781
  fillOpacity: "0.2"
5779
5782
  }
5780
5783
  ),
5781
- /* @__PURE__ */ jsxRuntime.jsxs("g", { clipPath: "url(#clip0_28788_25808)", children: [
5782
- /* @__PURE__ */ jsxRuntime.jsx(
5783
- "path",
5784
- {
5785
- d: "M7.5 6.375H5.375C4.479 6.375 3.75 5.618 3.75 4.688C3.75 3.757 4.479 3 5.375 3C7.365 3 8.019 5.569 8.047 5.678C8.088 5.846 8.05 6.023 7.943 6.16C7.836 6.296 7.673 6.375 7.5 6.375ZM5.375 4.125C5.099 4.125 4.875 4.377 4.875 4.688C4.875 4.998 5.099 5.25 5.375 5.25H6.688C6.439 4.736 6.011 4.125 5.375 4.125Z",
5786
- fill: "white"
5787
- }
5788
- ),
5789
- /* @__PURE__ */ jsxRuntime.jsx(
5790
- "path",
5791
- {
5792
- d: "M9.625 6.375H7.5C7.328 6.375 7.164 6.296 7.058 6.16C6.95 6.023 6.913 5.846 6.953 5.678C6.98 5.569 7.634 3 9.625 3C10.521 3 11.25 3.757 11.25 4.688C11.25 5.618 10.521 6.375 9.625 6.375ZM8.312 5.25H9.625C9.901 5.25 10.125 4.998 10.125 4.688C10.125 4.377 9.901 4.125 9.625 4.125C8.99 4.125 8.561 4.736 8.312 5.25Z",
5793
- fill: "white"
5794
- }
5795
- ),
5796
- /* @__PURE__ */ jsxRuntime.jsx(
5797
- "path",
5798
- {
5799
- d: "M11.438 6.375H3.562C3.252 6.375 3 6.123 3 5.813C3 5.502 3.252 5.25 3.562 5.25H11.438C11.748 5.25 12 5.502 12 5.813C12 6.123 11.748 6.375 11.438 6.375Z",
5800
- fill: "white"
5801
- }
5802
- ),
5803
- /* @__PURE__ */ jsxRuntime.jsx(
5804
- "path",
5805
- {
5806
- d: "M6.938 7.5H3.75V9.563C3.75 10.7 4.675 11.625 5.813 11.625H6.938V7.5Z",
5807
- fill: "white"
5808
- }
5809
- ),
5810
- /* @__PURE__ */ jsxRuntime.jsx(
5811
- "path",
5812
- {
5813
- d: "M8.063 7.5V11.625H9.188C10.325 11.625 11.25 10.7 11.25 9.563V7.5H8.063Z",
5814
- fill: "white"
5815
- }
5816
- )
5817
- ] }),
5818
- /* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
5819
- /* @__PURE__ */ jsxRuntime.jsxs(
5820
- "linearGradient",
5821
- {
5822
- id: "paint0_linear_28788_25808",
5823
- x1: "7.5",
5824
- y1: "0",
5825
- x2: "7.5",
5826
- y2: "15",
5827
- gradientUnits: "userSpaceOnUse",
5828
- children: [
5829
- /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "white" }),
5830
- /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
5831
- ]
5832
- }
5833
- ),
5834
- /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_28788_25808", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "9", height: "9", fill: "white", transform: "translate(3 3)" }) })
5835
- ] })
5784
+ /* @__PURE__ */ jsxRuntime.jsx(
5785
+ "path",
5786
+ {
5787
+ d: "M12 6V5.813C12 4.675 11.075 3.75 9.938 3.75H5.063C3.925 3.75 3 4.675 3 5.813V6H12Z",
5788
+ fill: "white"
5789
+ }
5790
+ ),
5791
+ /* @__PURE__ */ jsxRuntime.jsx(
5792
+ "path",
5793
+ {
5794
+ d: "M3 7.125V9.188C3 10.325 3.925 11.25 5.063 11.25H9.938C11.075 11.25 12 10.325 12 9.188V7.125H3ZM9.938 9.75H8.438C8.127 9.75 7.875 9.498 7.875 9.188C7.875 8.877 8.127 8.625 8.438 8.625H9.938C10.248 8.625 10.5 8.877 10.5 9.188C10.5 9.498 10.248 9.75 9.938 9.75Z",
5795
+ fill: "white"
5796
+ }
5797
+ ),
5798
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs(
5799
+ "linearGradient",
5800
+ {
5801
+ id: "paint0_linear_29181_44790",
5802
+ x1: "7.5",
5803
+ y1: "0",
5804
+ x2: "7.5",
5805
+ y2: "15",
5806
+ gradientUnits: "userSpaceOnUse",
5807
+ children: [
5808
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "white" }),
5809
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
5810
+ ]
5811
+ }
5812
+ ) })
5836
5813
  ]
5837
5814
  }
5838
5815
  );
5839
5816
  };
5840
- const GiftCardProductsSection = () => {
5841
- const { products: giftCardProducts, count: count2 = 0 } = useProducts({
5842
- is_giftcard: true
5843
- });
5844
- const slicedProducts = (giftCardProducts == null ? void 0 : giftCardProducts.slice(0, 3)) ?? [];
5845
- return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
5846
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
5847
- /* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Gift Card Products" }),
5848
- /* @__PURE__ */ jsxRuntime.jsx(
5849
- reactRouterDom.Link,
5850
- {
5851
- to: `/gift-cards/gift-card-products/create`,
5852
- className: "text-ui-fg-muted text-sm px-6",
5853
- children: "Create"
5854
- }
5855
- )
5856
- ] }),
5857
- (giftCardProducts == null ? void 0 : giftCardProducts.length) === 0 && /* @__PURE__ */ jsxRuntime.jsx(
5858
- NoRecords,
5859
- {
5860
- className: "px-10 py-4 h-[200px]",
5861
- title: "No gift card products",
5862
- message: "There are no gift card products to show. Create one to get started.",
5863
- action: {
5864
- to: "/gift-cards/gift-card-products/create",
5865
- label: "Create gift card product"
5866
- }
5867
- }
5868
- ),
5869
- slicedProducts.map((giftCardProduct) => /* @__PURE__ */ jsxRuntime.jsx(
5870
- SidebarLink,
5871
- {
5872
- to: `/gift-cards/gift-card-products/${giftCardProduct.id}`,
5873
- labelKey: giftCardProduct.title,
5874
- descriptionKey: giftCardProduct.title,
5875
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Tag, {})
5876
- }
5877
- )),
5878
- count2 > 3 && /* @__PURE__ */ jsxRuntime.jsx(
5879
- reactRouterDom.Link,
5880
- {
5881
- to: "/gift-cards/gift-card-products",
5882
- className: "text-ui-fg-muted text-sm px-6 py-4 flex items-center justify-center",
5883
- children: "View more"
5884
- }
5885
- )
5886
- ] });
5887
- };
5888
- const _giftCardQueryKey = queryKeysFactory("gift-card");
5889
- const giftCardQueryKey = {
5890
- ..._giftCardQueryKey,
5891
- orders: (id) => [..._giftCardQueryKey.detail(id), "orders"]
5892
- };
5893
- const useGiftCards = (query, options) => {
5894
- const fetchGiftCards = (query2, headers) => sdk.client.fetch(`/admin/gift-cards`, {
5895
- query: query2,
5896
- headers
5897
- });
5898
- const { data, ...rest } = reactQuery.useQuery({
5899
- ...options,
5900
- queryFn: () => fetchGiftCards(query),
5901
- queryKey: giftCardQueryKey.list(query)
5902
- });
5903
- return { ...data, ...rest };
5904
- };
5905
- const useGiftCard = (id, query, options) => {
5906
- const fetchGiftCard = (id2, query2, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
5907
- query: query2,
5908
- headers
5909
- });
5910
- const { data, ...rest } = reactQuery.useQuery({
5911
- queryFn: () => fetchGiftCard(id, query),
5912
- queryKey: giftCardQueryKey.detail(id, query),
5913
- ...options
5914
- });
5915
- return { ...data, ...rest };
5916
- };
5917
- const useGiftCardOrders = (id, options) => {
5918
- const fetchGiftCardOrders = (id2, query, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}/orders`, {
5919
- query,
5920
- headers
5921
- });
5922
- const { data, ...rest } = reactQuery.useQuery({
5923
- queryFn: () => fetchGiftCardOrders(id),
5924
- queryKey: giftCardQueryKey.orders(id),
5925
- ...options
5926
- });
5927
- return { ...data, ...rest };
5928
- };
5929
- const useUpdateGiftCard = (id, options) => {
5930
- const queryClient = reactQuery.useQueryClient();
5931
- const updateGiftCard = async (id2, body) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
5932
- body,
5933
- method: "POST"
5934
- });
5935
- return reactQuery.useMutation({
5936
- mutationFn: async (payload) => updateGiftCard(id, payload),
5937
- onSuccess: (data, variables, context) => {
5938
- queryClient.invalidateQueries({
5939
- queryKey: giftCardQueryKey.detail(id)
5940
- });
5941
- queryClient.invalidateQueries({
5942
- queryKey: giftCardQueryKey.lists()
5943
- });
5944
- },
5945
- ...options
5946
- });
5947
- };
5948
- const useCreateGiftCard = (options) => {
5949
- const queryClient = reactQuery.useQueryClient();
5950
- const createGiftCard = async (body) => sdk.client.fetch(`/admin/gift-cards`, {
5951
- body,
5952
- method: "POST"
5953
- });
5954
- return reactQuery.useMutation({
5955
- mutationFn: (body) => createGiftCard(body),
5956
- onSuccess: (data, variables, context) => {
5957
- queryClient.invalidateQueries({ queryKey: giftCardQueryKey.lists() });
5958
- },
5959
- ...options
5960
- });
5961
- };
5962
5817
  function getRelativeDate(date2) {
5963
5818
  const now2 = /* @__PURE__ */ new Date();
5964
5819
  return formatDistance(sub(new Date(date2), { minutes: 0 }), now2, {
@@ -5976,31 +5831,52 @@ function formatDate(date2, withTime = true) {
5976
5831
  return format$1(new Date(date2), "dd MMM, yyyy");
5977
5832
  }
5978
5833
  const columnHelper$a = ui.createDataTableColumnHelper();
5979
- const useGiftCardTableColumns = () => {
5834
+ const useStoreCreditAccountTableColumns = () => {
5980
5835
  return React.useMemo(() => {
5981
5836
  return [
5982
- columnHelper$a.accessor("code", {
5983
- header: "Code",
5837
+ columnHelper$a.accessor("currency_code", {
5838
+ header: "Currency",
5984
5839
  cell: ({ row }) => {
5985
- return row.original.code;
5840
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { size: "2xsmall", children: row.original.currency_code.toUpperCase() });
5986
5841
  }
5987
5842
  }),
5988
- columnHelper$a.accessor("line_item.product.title", {
5989
- header: "Product",
5843
+ columnHelper$a.accessor("customer.email", {
5844
+ header: "Customer",
5990
5845
  cell: ({ row }) => {
5991
- var _a2, _b;
5992
- return ((_b = (_a2 = row.original.line_item) == null ? void 0 : _a2.product) == null ? void 0 : _b.title) || "Custom Gift Card";
5846
+ var _a2;
5847
+ return ((_a2 = row.original.customer) == null ? void 0 : _a2.email) ?? "N/A";
5993
5848
  }
5994
5849
  }),
5995
- columnHelper$a.accessor("created_at", {
5996
- header: "Date issued",
5997
- cell: ({ row }) => getRelativeDate(row.original.created_at)
5850
+ columnHelper$a.accessor("balance", {
5851
+ header: "Balance",
5852
+ cell: ({ row }) => {
5853
+ return formatAmount(
5854
+ row.original.balance,
5855
+ row.original.currency_code
5856
+ );
5857
+ }
5998
5858
  }),
5999
- columnHelper$a.accessor("value", {
6000
- header: "Value",
5859
+ columnHelper$a.accessor("credits", {
5860
+ header: "Credits",
6001
5861
  cell: ({ row }) => {
6002
- return formatAmount(row.original.value, row.original.currency_code);
5862
+ return formatAmount(
5863
+ row.original.credits,
5864
+ row.original.currency_code
5865
+ );
5866
+ }
5867
+ }),
5868
+ columnHelper$a.accessor("debits", {
5869
+ header: "Debits",
5870
+ cell: ({ row }) => {
5871
+ return formatAmount(
5872
+ row.original.debits,
5873
+ row.original.currency_code
5874
+ );
6003
5875
  }
5876
+ }),
5877
+ columnHelper$a.accessor("created_at", {
5878
+ header: "Created at",
5879
+ cell: ({ row }) => getRelativeDate(row.original.created_at)
6004
5880
  })
6005
5881
  ];
6006
5882
  }, []);
@@ -6047,75 +5923,83 @@ const useCustomerFilters = () => {
6047
5923
  ];
6048
5924
  }, [customerFilterOptions]);
6049
5925
  };
6050
- const useGiftCardFilters = () => {
5926
+ const useStoreCreditAccountFilters = () => {
6051
5927
  const dateFilterOptions = useDataTableDateFilters$1();
6052
5928
  const customerFilterOptions = useCustomerFilters();
6053
5929
  return React.useMemo(() => {
6054
5930
  return [...dateFilterOptions, ...customerFilterOptions];
6055
5931
  }, [dateFilterOptions, customerFilterOptions]);
6056
5932
  };
6057
- const useGiftCardTableQuery = ({
5933
+ const useStoreCreditAccountsTableQuery = ({
6058
5934
  prefix,
6059
5935
  pageSize = 20
6060
5936
  }) => {
6061
5937
  const queryObject = useQueryParams(
6062
- ["q", "offset", "customer_id", "created_at", "updated_at"],
5938
+ ["offset", "customer_id", "currency_code", "created_at", "updated_at"],
6063
5939
  prefix
6064
5940
  );
6065
- const { offset: offset2, created_at, updated_at, customer_id, ...rest } = queryObject;
5941
+ const {
5942
+ offset: offset2,
5943
+ created_at,
5944
+ updated_at,
5945
+ customer_id,
5946
+ currency_code,
5947
+ ...rest
5948
+ } = queryObject;
6066
5949
  const searchParams = {
6067
5950
  limit: pageSize,
6068
5951
  offset: offset2 ? Number(offset2) : 0,
6069
5952
  created_at: created_at ? JSON.parse(created_at) : void 0,
6070
5953
  updated_at: updated_at ? JSON.parse(updated_at) : void 0,
6071
5954
  customer_id: customer_id ? JSON.parse(customer_id) : void 0,
5955
+ currency_code: currency_code ? JSON.parse(currency_code) : void 0,
6072
5956
  ...rest
6073
5957
  };
6074
5958
  return searchParams;
6075
5959
  };
6076
5960
  const PAGE_SIZE$6 = 10;
6077
- function GiftCardsTable() {
6078
- const queryParams = useGiftCardTableQuery({
5961
+ function StoreCreditAccountsTable() {
5962
+ const queryParams = useStoreCreditAccountsTableQuery({
6079
5963
  pageSize: PAGE_SIZE$6
6080
5964
  });
6081
5965
  const {
6082
- gift_cards: giftCards,
5966
+ store_credit_accounts: storeCreditAccounts,
6083
5967
  isPending,
6084
5968
  count: count2
6085
- } = useGiftCards({
5969
+ } = useStoreCreditAccounts({
6086
5970
  ...queryParams,
6087
- order: queryParams.order ?? "-created_at",
6088
- fields: "+line_item.product.title"
5971
+ order: queryParams.order ?? "-created_at"
6089
5972
  });
6090
- const columns = useGiftCardTableColumns();
6091
- const filters = useGiftCardFilters();
5973
+ const columns = useStoreCreditAccountTableColumns();
5974
+ const filters = useStoreCreditAccountFilters();
6092
5975
  return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
6093
5976
  /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
6094
5977
  DataTable,
6095
5978
  {
6096
- data: giftCards,
5979
+ data: storeCreditAccounts ?? [],
6097
5980
  getRowId: (row) => row.id,
6098
5981
  columns,
6099
5982
  filters,
6100
5983
  isLoading: isPending,
6101
5984
  pageSize: PAGE_SIZE$6,
6102
5985
  rowCount: count2,
6103
- heading: "Gift Cards",
5986
+ enableSearch: false,
5987
+ heading: "Store Credit Accounts",
6104
5988
  rowHref: (row) => `${row.id}`,
6105
5989
  emptyState: {
6106
5990
  empty: {
6107
- heading: "No gift cards found",
6108
- description: "Create a gift card to get started."
5991
+ heading: "No store credit accounts found",
5992
+ description: "Create a new store credit account to get started."
6109
5993
  },
6110
5994
  filtered: {
6111
5995
  heading: "No results found",
6112
- description: "No gift cards match your filter criteria."
5996
+ description: "No store credit accounts match your filter criteria."
6113
5997
  }
6114
5998
  },
6115
5999
  actions: [
6116
6000
  {
6117
6001
  label: "Create",
6118
- to: "create"
6002
+ to: "/store-credit-accounts/create"
6119
6003
  }
6120
6004
  ]
6121
6005
  }
@@ -6123,16 +6007,15 @@ function GiftCardsTable() {
6123
6007
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
6124
6008
  ] });
6125
6009
  }
6126
- const GiftCardsPage = () => {
6010
+ const StoreCreditAccountsPage = () => {
6127
6011
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6128
6012
  /* @__PURE__ */ jsxRuntime.jsx(
6129
6013
  components.LayoutComposer,
6130
6014
  {
6131
- widgetsZonePrefix: "gift_card.list",
6132
- preferredLayoutId: "core:two-column",
6015
+ widgetsZonePrefix: "store_credit_account.list",
6016
+ preferredLayoutId: "core:single-column",
6133
6017
  sections: {
6134
- main: /* @__PURE__ */ jsxRuntime.jsx(GiftCardsTable, {}),
6135
- side: /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductsSection, {})
6018
+ main: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountsTable", children: /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountsTable, {}) })
6136
6019
  }
6137
6020
  }
6138
6021
  ),
@@ -6140,8 +6023,8 @@ const GiftCardsPage = () => {
6140
6023
  ] });
6141
6024
  };
6142
6025
  const config$3 = adminSdk.defineRouteConfig({
6143
- label: "Gift Cards",
6144
- icon: GiftCardIcon
6026
+ label: "Store Credits",
6027
+ icon: StoreCreditIcon
6145
6028
  });
6146
6029
  function setRef$2(ref, value) {
6147
6030
  if (typeof ref === "function") {
@@ -10060,28 +9943,6 @@ const StackedFocusModal = Object.assign(Root, {
10060
9943
  Description,
10061
9944
  Title
10062
9945
  });
10063
- const STORE_QUERY_KEY = "store";
10064
- const storeQueryKeys = queryKeysFactory(STORE_QUERY_KEY);
10065
- async function retrieveActiveStore(query) {
10066
- var _a2;
10067
- const response = await sdk.admin.store.list(query);
10068
- const activeStore = (_a2 = response.stores) == null ? void 0 : _a2[0];
10069
- if (!activeStore) {
10070
- throw new Medusa.FetchError("No active store found", "Not Found", 404);
10071
- }
10072
- return { store: activeStore };
10073
- }
10074
- const useStore$2 = (query, options) => {
10075
- const { data, ...rest } = reactQuery.useQuery({
10076
- queryFn: () => retrieveActiveStore(query),
10077
- queryKey: storeQueryKeys.details(),
10078
- ...options
10079
- });
10080
- return {
10081
- ...data,
10082
- ...rest
10083
- };
10084
- };
10085
9946
  var t$1 = function(t2, n2, e2) {
10086
9947
  if (t2 && "reportValidity" in t2) {
10087
9948
  var i2 = get$3(e2, n2);
@@ -11955,7 +11816,7 @@ function useStoreProps(store, props, key2, setKey) {
11955
11816
  });
11956
11817
  });
11957
11818
  }
11958
- function useStore$1(createStore2, props) {
11819
+ function useStore$2(createStore2, props) {
11959
11820
  const [store, setStore] = React__namespace.useState(() => createStore2(props));
11960
11821
  useSafeLayoutEffect(() => init(store), [store]);
11961
11822
  const useState2 = React__namespace.useCallback(
@@ -12777,7 +12638,7 @@ function useDisclosureStoreProps(store, update, props) {
12777
12638
  return Object.assign(store, { disclosure: props.disclosure });
12778
12639
  }
12779
12640
  function useDisclosureStore(props = {}) {
12780
- const [store, update] = useStore$1(createDisclosureStore, props);
12641
+ const [store, update] = useStore$2(createDisclosureStore, props);
12781
12642
  return useDisclosureStoreProps(store, update, props);
12782
12643
  }
12783
12644
  var ctx$2 = createStoreContext(
@@ -14166,7 +14027,7 @@ function useDialogStoreProps(store, update, props) {
14166
14027
  return useDisclosureStoreProps(store, update, props);
14167
14028
  }
14168
14029
  function useDialogStore(props = {}) {
14169
- const [store, update] = useStore$1(createDialogStore, props);
14030
+ const [store, update] = useStore$2(createDialogStore, props);
14170
14031
  return useDialogStoreProps(store, update, props);
14171
14032
  }
14172
14033
  var TagName$e = "div";
@@ -16212,7 +16073,7 @@ function useComboboxStoreProps(store, update, props) {
16212
16073
  }
16213
16074
  function useComboboxStore(props = {}) {
16214
16075
  props = useComboboxStoreOptions(props);
16215
- const [store, update] = useStore$1(createComboboxStore, props);
16076
+ const [store, update] = useStore$2(createComboboxStore, props);
16216
16077
  return useComboboxStoreProps(store, update, props);
16217
16078
  }
16218
16079
  function ComboboxProvider(props = {}) {
@@ -17318,6 +17179,270 @@ const ComboboxImpl = ({
17318
17179
  );
17319
17180
  };
17320
17181
  const Combobox = genericForwardRef(ComboboxImpl);
17182
+ function isObject$6(value) {
17183
+ var type = typeof value;
17184
+ return value != null && (type == "object" || type == "function");
17185
+ }
17186
+ var isObject_1 = isObject$6;
17187
+ var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
17188
+ var _freeGlobal = freeGlobal$1;
17189
+ var freeGlobal = _freeGlobal;
17190
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
17191
+ var root$4 = freeGlobal || freeSelf || Function("return this")();
17192
+ var _root = root$4;
17193
+ var root$3 = _root;
17194
+ var now$1 = function() {
17195
+ return root$3.Date.now();
17196
+ };
17197
+ var now_1 = now$1;
17198
+ var reWhitespace = /\s/;
17199
+ function trimmedEndIndex$1(string2) {
17200
+ var index = string2.length;
17201
+ while (index-- && reWhitespace.test(string2.charAt(index))) {
17202
+ }
17203
+ return index;
17204
+ }
17205
+ var _trimmedEndIndex = trimmedEndIndex$1;
17206
+ var trimmedEndIndex = _trimmedEndIndex;
17207
+ var reTrimStart = /^\s+/;
17208
+ function baseTrim$1(string2) {
17209
+ return string2 ? string2.slice(0, trimmedEndIndex(string2) + 1).replace(reTrimStart, "") : string2;
17210
+ }
17211
+ var _baseTrim = baseTrim$1;
17212
+ var root$2 = _root;
17213
+ var Symbol$4 = root$2.Symbol;
17214
+ var _Symbol = Symbol$4;
17215
+ var Symbol$3 = _Symbol;
17216
+ var objectProto$5 = Object.prototype;
17217
+ var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
17218
+ var nativeObjectToString$1 = objectProto$5.toString;
17219
+ var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
17220
+ function getRawTag$1(value) {
17221
+ var isOwn = hasOwnProperty$4.call(value, symToStringTag$1), tag = value[symToStringTag$1];
17222
+ try {
17223
+ value[symToStringTag$1] = void 0;
17224
+ var unmasked = true;
17225
+ } catch (e2) {
17226
+ }
17227
+ var result = nativeObjectToString$1.call(value);
17228
+ if (unmasked) {
17229
+ if (isOwn) {
17230
+ value[symToStringTag$1] = tag;
17231
+ } else {
17232
+ delete value[symToStringTag$1];
17233
+ }
17234
+ }
17235
+ return result;
17236
+ }
17237
+ var _getRawTag = getRawTag$1;
17238
+ var objectProto$4 = Object.prototype;
17239
+ var nativeObjectToString = objectProto$4.toString;
17240
+ function objectToString$1(value) {
17241
+ return nativeObjectToString.call(value);
17242
+ }
17243
+ var _objectToString = objectToString$1;
17244
+ var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
17245
+ var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
17246
+ var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
17247
+ function baseGetTag$2(value) {
17248
+ if (value == null) {
17249
+ return value === void 0 ? undefinedTag : nullTag;
17250
+ }
17251
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
17252
+ }
17253
+ var _baseGetTag = baseGetTag$2;
17254
+ function isObjectLike$1(value) {
17255
+ return value != null && typeof value == "object";
17256
+ }
17257
+ var isObjectLike_1 = isObjectLike$1;
17258
+ var baseGetTag$1 = _baseGetTag, isObjectLike = isObjectLike_1;
17259
+ var symbolTag = "[object Symbol]";
17260
+ function isSymbol$4(value) {
17261
+ return typeof value == "symbol" || isObjectLike(value) && baseGetTag$1(value) == symbolTag;
17262
+ }
17263
+ var isSymbol_1 = isSymbol$4;
17264
+ var baseTrim = _baseTrim, isObject$5 = isObject_1, isSymbol$3 = isSymbol_1;
17265
+ var NAN = 0 / 0;
17266
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
17267
+ var reIsBinary = /^0b[01]+$/i;
17268
+ var reIsOctal = /^0o[0-7]+$/i;
17269
+ var freeParseInt = parseInt;
17270
+ function toNumber$1(value) {
17271
+ if (typeof value == "number") {
17272
+ return value;
17273
+ }
17274
+ if (isSymbol$3(value)) {
17275
+ return NAN;
17276
+ }
17277
+ if (isObject$5(value)) {
17278
+ var other = typeof value.valueOf == "function" ? value.valueOf() : value;
17279
+ value = isObject$5(other) ? other + "" : other;
17280
+ }
17281
+ if (typeof value != "string") {
17282
+ return value === 0 ? value : +value;
17283
+ }
17284
+ value = baseTrim(value);
17285
+ var isBinary = reIsBinary.test(value);
17286
+ return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
17287
+ }
17288
+ var toNumber_1 = toNumber$1;
17289
+ var isObject$4 = isObject_1, now = now_1, toNumber = toNumber_1;
17290
+ var FUNC_ERROR_TEXT$1 = "Expected a function";
17291
+ var nativeMax = Math.max, nativeMin = Math.min;
17292
+ function debounce$2(func, wait, options) {
17293
+ var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
17294
+ if (typeof func != "function") {
17295
+ throw new TypeError(FUNC_ERROR_TEXT$1);
17296
+ }
17297
+ wait = toNumber(wait) || 0;
17298
+ if (isObject$4(options)) {
17299
+ leading = !!options.leading;
17300
+ maxing = "maxWait" in options;
17301
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
17302
+ trailing = "trailing" in options ? !!options.trailing : trailing;
17303
+ }
17304
+ function invokeFunc(time2) {
17305
+ var args = lastArgs, thisArg = lastThis;
17306
+ lastArgs = lastThis = void 0;
17307
+ lastInvokeTime = time2;
17308
+ result = func.apply(thisArg, args);
17309
+ return result;
17310
+ }
17311
+ function leadingEdge(time2) {
17312
+ lastInvokeTime = time2;
17313
+ timerId = setTimeout(timerExpired, wait);
17314
+ return leading ? invokeFunc(time2) : result;
17315
+ }
17316
+ function remainingWait(time2) {
17317
+ var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
17318
+ return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
17319
+ }
17320
+ function shouldInvoke(time2) {
17321
+ var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime;
17322
+ return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
17323
+ }
17324
+ function timerExpired() {
17325
+ var time2 = now();
17326
+ if (shouldInvoke(time2)) {
17327
+ return trailingEdge(time2);
17328
+ }
17329
+ timerId = setTimeout(timerExpired, remainingWait(time2));
17330
+ }
17331
+ function trailingEdge(time2) {
17332
+ timerId = void 0;
17333
+ if (trailing && lastArgs) {
17334
+ return invokeFunc(time2);
17335
+ }
17336
+ lastArgs = lastThis = void 0;
17337
+ return result;
17338
+ }
17339
+ function cancel() {
17340
+ if (timerId !== void 0) {
17341
+ clearTimeout(timerId);
17342
+ }
17343
+ lastInvokeTime = 0;
17344
+ lastArgs = lastCallTime = lastThis = timerId = void 0;
17345
+ }
17346
+ function flush() {
17347
+ return timerId === void 0 ? result : trailingEdge(now());
17348
+ }
17349
+ function debounced() {
17350
+ var time2 = now(), isInvoking = shouldInvoke(time2);
17351
+ lastArgs = arguments;
17352
+ lastThis = this;
17353
+ lastCallTime = time2;
17354
+ if (isInvoking) {
17355
+ if (timerId === void 0) {
17356
+ return leadingEdge(lastCallTime);
17357
+ }
17358
+ if (maxing) {
17359
+ clearTimeout(timerId);
17360
+ timerId = setTimeout(timerExpired, wait);
17361
+ return invokeFunc(lastCallTime);
17362
+ }
17363
+ }
17364
+ if (timerId === void 0) {
17365
+ timerId = setTimeout(timerExpired, wait);
17366
+ }
17367
+ return result;
17368
+ }
17369
+ debounced.cancel = cancel;
17370
+ debounced.flush = flush;
17371
+ return debounced;
17372
+ }
17373
+ var debounce_1 = debounce$2;
17374
+ const debounce$1 = /* @__PURE__ */ getDefaultExportFromCjs(debounce_1);
17375
+ const useDebouncedSearch = () => {
17376
+ const [searchValue, onSearchValueChange] = React.useState("");
17377
+ const [debouncedQuery, setDebouncedQuery] = React.useState("");
17378
+ const debouncedUpdate = React.useCallback(
17379
+ debounce$1((query) => setDebouncedQuery(query), 300),
17380
+ []
17381
+ );
17382
+ React.useEffect(() => {
17383
+ debouncedUpdate(searchValue);
17384
+ return () => debouncedUpdate.cancel();
17385
+ }, [searchValue, debouncedUpdate]);
17386
+ return {
17387
+ searchValue,
17388
+ onSearchValueChange,
17389
+ query: debouncedQuery || void 0
17390
+ };
17391
+ };
17392
+ const useComboboxData = ({
17393
+ queryKey,
17394
+ queryFn,
17395
+ getOptions,
17396
+ defaultValue: defaultValue2,
17397
+ defaultValueKey,
17398
+ pageSize = 10
17399
+ }) => {
17400
+ const { searchValue, onSearchValueChange, query } = useDebouncedSearch();
17401
+ const queryInitialDataBy = defaultValueKey || "id";
17402
+ const { data: initialData } = reactQuery.useQuery({
17403
+ queryKey,
17404
+ queryFn: async () => {
17405
+ return queryFn({
17406
+ [queryInitialDataBy]: defaultValue2,
17407
+ limit: Array.isArray(defaultValue2) ? defaultValue2.length : 1
17408
+ });
17409
+ },
17410
+ enabled: !!defaultValue2
17411
+ });
17412
+ const { data, ...rest } = reactQuery.useInfiniteQuery({
17413
+ queryKey: [...queryKey, query],
17414
+ queryFn: async ({ pageParam = 0 }) => {
17415
+ return await queryFn({
17416
+ q: query,
17417
+ limit: pageSize,
17418
+ offset: pageParam
17419
+ });
17420
+ },
17421
+ initialPageParam: 0,
17422
+ getNextPageParam: (lastPage) => {
17423
+ const moreItemsExist = lastPage.count > lastPage.offset + lastPage.limit;
17424
+ return moreItemsExist ? lastPage.offset + lastPage.limit : void 0;
17425
+ },
17426
+ placeholderData: reactQuery.keepPreviousData
17427
+ });
17428
+ const options = (data == null ? void 0 : data.pages.flatMap((page) => getOptions(page))) ?? [];
17429
+ const defaultOptions2 = initialData ? getOptions(initialData) : [];
17430
+ const disabled = !rest.isPending && !options.length && !searchValue;
17431
+ if (defaultValue2 && defaultOptions2.length && !searchValue) {
17432
+ defaultOptions2.forEach((option) => {
17433
+ if (!options.find((o2) => o2.value === option.value)) {
17434
+ options.unshift(option);
17435
+ }
17436
+ });
17437
+ }
17438
+ return {
17439
+ options,
17440
+ searchValue,
17441
+ onSearchValueChange,
17442
+ disabled,
17443
+ ...rest
17444
+ };
17445
+ };
17321
17446
  const currencies = {
17322
17447
  USD: {
17323
17448
  code: "USD",
@@ -18046,6 +18171,504 @@ const currencies = {
18046
18171
  decimal_digits: 0
18047
18172
  }
18048
18173
  };
18174
+ const formSchema = zod.z.object({
18175
+ currency_code: zod.z.string().min(1, "Please select a currency"),
18176
+ customer_id: zod.z.string().optional()
18177
+ });
18178
+ const StoreCreditAccountCreateForm = () => {
18179
+ const { handleSuccess } = useRouteModal();
18180
+ const form = useForm({
18181
+ defaultValues: {
18182
+ currency_code: "",
18183
+ customer_id: ""
18184
+ },
18185
+ resolver: t(formSchema)
18186
+ });
18187
+ const { mutateAsync: createStoreCreditAccount, isPending } = useCreateStoreCreditAccount();
18188
+ const handleSubmit = form.handleSubmit(async (data) => {
18189
+ if (!data.customer_id) {
18190
+ delete data.customer_id;
18191
+ }
18192
+ await createStoreCreditAccount(data, {
18193
+ onSuccess: (data2) => {
18194
+ ui.toast.success(`Store credit account was successfully created.`);
18195
+ handleSuccess(`../${data2.store_credit_account.id}`);
18196
+ },
18197
+ onError: (error) => {
18198
+ ui.toast.error(error.message);
18199
+ }
18200
+ });
18201
+ });
18202
+ const [currencySearchValue, setCurrencySearchValue] = React.useState("");
18203
+ const currencyOptions = React.useMemo(() => {
18204
+ const options = Object.values(currencies).map((currency) => ({
18205
+ label: `${currency.code} - ${currency.name} (${currency.symbol_native})`,
18206
+ value: currency.code.toLowerCase()
18207
+ }));
18208
+ if (!currencySearchValue) {
18209
+ return options;
18210
+ }
18211
+ return options.filter(
18212
+ (option) => option.label.toLowerCase().includes(currencySearchValue.toLowerCase())
18213
+ );
18214
+ }, [currencySearchValue]);
18215
+ const {
18216
+ options: customerOptions,
18217
+ fetchNextPage,
18218
+ isFetchingNextPage,
18219
+ searchValue,
18220
+ onSearchValueChange,
18221
+ isLoading
18222
+ } = useComboboxData({
18223
+ queryKey: customersQueryKeys.list(),
18224
+ queryFn: async (params) => {
18225
+ return sdk.admin.customer.list(params);
18226
+ },
18227
+ getOptions: (data) => {
18228
+ var _a2;
18229
+ return ((_a2 = data.customers) == null ? void 0 : _a2.map((customer) => {
18230
+ const fullName = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
18231
+ const label = fullName ? `${customer.email} (${fullName})` : customer.email;
18232
+ return {
18233
+ label,
18234
+ value: customer.id
18235
+ };
18236
+ })) || [];
18237
+ }
18238
+ });
18239
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Form, { form, children: [
18240
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "-my-2 w-full border-l" }) }),
18241
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "size-full overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col items-center p-16", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children: [
18242
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
18243
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Create Store Credit Account" }),
18244
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", size: "small", children: "Create a new store credit account for a customer" })
18245
+ ] }),
18246
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-x-4", children: [
18247
+ /* @__PURE__ */ jsxRuntime.jsx(
18248
+ Form$2.Field,
18249
+ {
18250
+ control: form.control,
18251
+ name: "currency_code",
18252
+ render: ({ field }) => {
18253
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
18254
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Currency" }),
18255
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
18256
+ Combobox,
18257
+ {
18258
+ value: field.value,
18259
+ onChange: field.onChange,
18260
+ searchValue: currencySearchValue,
18261
+ onSearchValueChange: setCurrencySearchValue,
18262
+ options: currencyOptions,
18263
+ placeholder: "Search for a currency..."
18264
+ }
18265
+ ) }),
18266
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
18267
+ ] });
18268
+ }
18269
+ }
18270
+ ),
18271
+ /* @__PURE__ */ jsxRuntime.jsx(
18272
+ Form$2.Field,
18273
+ {
18274
+ control: form.control,
18275
+ name: "customer_id",
18276
+ render: ({ field }) => {
18277
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
18278
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Customer" }),
18279
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
18280
+ Combobox,
18281
+ {
18282
+ value: field.value,
18283
+ onChange: field.onChange,
18284
+ searchValue,
18285
+ onSearchValueChange,
18286
+ options: customerOptions,
18287
+ placeholder: "Search for a customer...",
18288
+ fetchNextPage,
18289
+ isFetchingNextPage,
18290
+ noResultsPlaceholder: isLoading ? "Loading customers..." : "No customers found"
18291
+ }
18292
+ ) }),
18293
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
18294
+ ] });
18295
+ }
18296
+ }
18297
+ )
18298
+ ] })
18299
+ ] }) }) }),
18300
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Footer, { children: [
18301
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, disabled: isPending, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", disabled: isPending, children: "Cancel" }) }),
18302
+ /* @__PURE__ */ jsxRuntime.jsx(
18303
+ ui.Button,
18304
+ {
18305
+ variant: "primary",
18306
+ size: "small",
18307
+ onClick: handleSubmit,
18308
+ disabled: isPending,
18309
+ children: "Create"
18310
+ }
18311
+ )
18312
+ ] })
18313
+ ] });
18314
+ };
18315
+ const StoreCreditAccountCreate = () => {
18316
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal, { children: [
18317
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create Store Credit Account" }) }),
18318
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create a new store credit account" }) }),
18319
+ /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCreateForm, {})
18320
+ ] });
18321
+ };
18322
+ const GiftCardIcon = (props) => {
18323
+ return /* @__PURE__ */ jsxRuntime.jsxs(
18324
+ "svg",
18325
+ {
18326
+ width: "15",
18327
+ height: "15",
18328
+ viewBox: "0 0 15 15",
18329
+ fill: "none",
18330
+ xmlns: "http://www.w3.org/2000/svg",
18331
+ ...props,
18332
+ children: [
18333
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#F97316" }),
18334
+ /* @__PURE__ */ jsxRuntime.jsx(
18335
+ "rect",
18336
+ {
18337
+ width: "15",
18338
+ height: "15",
18339
+ fill: "url(#paint0_linear_28788_25808)",
18340
+ fillOpacity: "0.2"
18341
+ }
18342
+ ),
18343
+ /* @__PURE__ */ jsxRuntime.jsxs("g", { clipPath: "url(#clip0_28788_25808)", children: [
18344
+ /* @__PURE__ */ jsxRuntime.jsx(
18345
+ "path",
18346
+ {
18347
+ d: "M7.5 6.375H5.375C4.479 6.375 3.75 5.618 3.75 4.688C3.75 3.757 4.479 3 5.375 3C7.365 3 8.019 5.569 8.047 5.678C8.088 5.846 8.05 6.023 7.943 6.16C7.836 6.296 7.673 6.375 7.5 6.375ZM5.375 4.125C5.099 4.125 4.875 4.377 4.875 4.688C4.875 4.998 5.099 5.25 5.375 5.25H6.688C6.439 4.736 6.011 4.125 5.375 4.125Z",
18348
+ fill: "white"
18349
+ }
18350
+ ),
18351
+ /* @__PURE__ */ jsxRuntime.jsx(
18352
+ "path",
18353
+ {
18354
+ d: "M9.625 6.375H7.5C7.328 6.375 7.164 6.296 7.058 6.16C6.95 6.023 6.913 5.846 6.953 5.678C6.98 5.569 7.634 3 9.625 3C10.521 3 11.25 3.757 11.25 4.688C11.25 5.618 10.521 6.375 9.625 6.375ZM8.312 5.25H9.625C9.901 5.25 10.125 4.998 10.125 4.688C10.125 4.377 9.901 4.125 9.625 4.125C8.99 4.125 8.561 4.736 8.312 5.25Z",
18355
+ fill: "white"
18356
+ }
18357
+ ),
18358
+ /* @__PURE__ */ jsxRuntime.jsx(
18359
+ "path",
18360
+ {
18361
+ d: "M11.438 6.375H3.562C3.252 6.375 3 6.123 3 5.813C3 5.502 3.252 5.25 3.562 5.25H11.438C11.748 5.25 12 5.502 12 5.813C12 6.123 11.748 6.375 11.438 6.375Z",
18362
+ fill: "white"
18363
+ }
18364
+ ),
18365
+ /* @__PURE__ */ jsxRuntime.jsx(
18366
+ "path",
18367
+ {
18368
+ d: "M6.938 7.5H3.75V9.563C3.75 10.7 4.675 11.625 5.813 11.625H6.938V7.5Z",
18369
+ fill: "white"
18370
+ }
18371
+ ),
18372
+ /* @__PURE__ */ jsxRuntime.jsx(
18373
+ "path",
18374
+ {
18375
+ d: "M8.063 7.5V11.625H9.188C10.325 11.625 11.25 10.7 11.25 9.563V7.5H8.063Z",
18376
+ fill: "white"
18377
+ }
18378
+ )
18379
+ ] }),
18380
+ /* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
18381
+ /* @__PURE__ */ jsxRuntime.jsxs(
18382
+ "linearGradient",
18383
+ {
18384
+ id: "paint0_linear_28788_25808",
18385
+ x1: "7.5",
18386
+ y1: "0",
18387
+ x2: "7.5",
18388
+ y2: "15",
18389
+ gradientUnits: "userSpaceOnUse",
18390
+ children: [
18391
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "white" }),
18392
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
18393
+ ]
18394
+ }
18395
+ ),
18396
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_28788_25808", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "9", height: "9", fill: "white", transform: "translate(3 3)" }) })
18397
+ ] })
18398
+ ]
18399
+ }
18400
+ );
18401
+ };
18402
+ const GiftCardProductsSection = () => {
18403
+ const { products: giftCardProducts, count: count2 = 0 } = useProducts({
18404
+ is_giftcard: true
18405
+ });
18406
+ const slicedProducts = (giftCardProducts == null ? void 0 : giftCardProducts.slice(0, 3)) ?? [];
18407
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
18408
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
18409
+ /* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Gift Card Products" }),
18410
+ /* @__PURE__ */ jsxRuntime.jsx(
18411
+ reactRouterDom.Link,
18412
+ {
18413
+ to: `/gift-cards/gift-card-products/create`,
18414
+ className: "text-ui-fg-muted text-sm px-6",
18415
+ children: "Create"
18416
+ }
18417
+ )
18418
+ ] }),
18419
+ (giftCardProducts == null ? void 0 : giftCardProducts.length) === 0 && /* @__PURE__ */ jsxRuntime.jsx(
18420
+ NoRecords,
18421
+ {
18422
+ className: "px-10 py-4 h-[200px]",
18423
+ title: "No gift card products",
18424
+ message: "There are no gift card products to show. Create one to get started.",
18425
+ action: {
18426
+ to: "/gift-cards/gift-card-products/create",
18427
+ label: "Create gift card product"
18428
+ }
18429
+ }
18430
+ ),
18431
+ slicedProducts.map((giftCardProduct) => /* @__PURE__ */ jsxRuntime.jsx(
18432
+ SidebarLink,
18433
+ {
18434
+ to: `/gift-cards/gift-card-products/${giftCardProduct.id}`,
18435
+ labelKey: giftCardProduct.title,
18436
+ descriptionKey: giftCardProduct.title,
18437
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Tag, {})
18438
+ }
18439
+ )),
18440
+ count2 > 3 && /* @__PURE__ */ jsxRuntime.jsx(
18441
+ reactRouterDom.Link,
18442
+ {
18443
+ to: "/gift-cards/gift-card-products",
18444
+ className: "text-ui-fg-muted text-sm px-6 py-4 flex items-center justify-center",
18445
+ children: "View more"
18446
+ }
18447
+ )
18448
+ ] });
18449
+ };
18450
+ const _giftCardQueryKey = queryKeysFactory("gift-card");
18451
+ const giftCardQueryKey = {
18452
+ ..._giftCardQueryKey,
18453
+ orders: (id) => [..._giftCardQueryKey.detail(id), "orders"]
18454
+ };
18455
+ const useGiftCards = (query, options) => {
18456
+ const fetchGiftCards = (query2, headers) => sdk.client.fetch(`/admin/gift-cards`, {
18457
+ query: query2,
18458
+ headers
18459
+ });
18460
+ const { data, ...rest } = reactQuery.useQuery({
18461
+ ...options,
18462
+ queryFn: () => fetchGiftCards(query),
18463
+ queryKey: giftCardQueryKey.list(query)
18464
+ });
18465
+ return { ...data, ...rest };
18466
+ };
18467
+ const useGiftCard = (id, query, options) => {
18468
+ const fetchGiftCard = (id2, query2, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
18469
+ query: query2,
18470
+ headers
18471
+ });
18472
+ const { data, ...rest } = reactQuery.useQuery({
18473
+ queryFn: () => fetchGiftCard(id, query),
18474
+ queryKey: giftCardQueryKey.detail(id, query),
18475
+ ...options
18476
+ });
18477
+ return { ...data, ...rest };
18478
+ };
18479
+ const useGiftCardOrders = (id, options) => {
18480
+ const fetchGiftCardOrders = (id2, query, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}/orders`, {
18481
+ query,
18482
+ headers
18483
+ });
18484
+ const { data, ...rest } = reactQuery.useQuery({
18485
+ queryFn: () => fetchGiftCardOrders(id),
18486
+ queryKey: giftCardQueryKey.orders(id),
18487
+ ...options
18488
+ });
18489
+ return { ...data, ...rest };
18490
+ };
18491
+ const useUpdateGiftCard = (id, options) => {
18492
+ const queryClient = reactQuery.useQueryClient();
18493
+ const updateGiftCard = async (id2, body) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
18494
+ body,
18495
+ method: "POST"
18496
+ });
18497
+ return reactQuery.useMutation({
18498
+ mutationFn: async (payload) => updateGiftCard(id, payload),
18499
+ onSuccess: (data, variables, context) => {
18500
+ queryClient.invalidateQueries({
18501
+ queryKey: giftCardQueryKey.detail(id)
18502
+ });
18503
+ queryClient.invalidateQueries({
18504
+ queryKey: giftCardQueryKey.lists()
18505
+ });
18506
+ },
18507
+ ...options
18508
+ });
18509
+ };
18510
+ const useCreateGiftCard = (options) => {
18511
+ const queryClient = reactQuery.useQueryClient();
18512
+ const createGiftCard = async (body) => sdk.client.fetch(`/admin/gift-cards`, {
18513
+ body,
18514
+ method: "POST"
18515
+ });
18516
+ return reactQuery.useMutation({
18517
+ mutationFn: (body) => createGiftCard(body),
18518
+ onSuccess: (data, variables, context) => {
18519
+ queryClient.invalidateQueries({ queryKey: giftCardQueryKey.lists() });
18520
+ },
18521
+ ...options
18522
+ });
18523
+ };
18524
+ const columnHelper$9 = ui.createDataTableColumnHelper();
18525
+ const useGiftCardTableColumns = () => {
18526
+ return React.useMemo(() => {
18527
+ return [
18528
+ columnHelper$9.accessor("code", {
18529
+ header: "Code",
18530
+ cell: ({ row }) => {
18531
+ return row.original.code;
18532
+ }
18533
+ }),
18534
+ columnHelper$9.accessor("line_item.product.title", {
18535
+ header: "Product",
18536
+ cell: ({ row }) => {
18537
+ var _a2, _b;
18538
+ return ((_b = (_a2 = row.original.line_item) == null ? void 0 : _a2.product) == null ? void 0 : _b.title) || "Custom Gift Card";
18539
+ }
18540
+ }),
18541
+ columnHelper$9.accessor("created_at", {
18542
+ header: "Date issued",
18543
+ cell: ({ row }) => getRelativeDate(row.original.created_at)
18544
+ }),
18545
+ columnHelper$9.accessor("value", {
18546
+ header: "Value",
18547
+ cell: ({ row }) => {
18548
+ return formatAmount(row.original.value, row.original.currency_code);
18549
+ }
18550
+ })
18551
+ ];
18552
+ }, []);
18553
+ };
18554
+ const useGiftCardFilters = () => {
18555
+ const dateFilterOptions = useDataTableDateFilters$1();
18556
+ const customerFilterOptions = useCustomerFilters();
18557
+ return React.useMemo(() => {
18558
+ return [...dateFilterOptions, ...customerFilterOptions];
18559
+ }, [dateFilterOptions, customerFilterOptions]);
18560
+ };
18561
+ const useGiftCardTableQuery = ({
18562
+ prefix,
18563
+ pageSize = 20
18564
+ }) => {
18565
+ const queryObject = useQueryParams(
18566
+ ["q", "offset", "customer_id", "created_at", "updated_at"],
18567
+ prefix
18568
+ );
18569
+ const { offset: offset2, created_at, updated_at, customer_id, ...rest } = queryObject;
18570
+ const searchParams = {
18571
+ limit: pageSize,
18572
+ offset: offset2 ? Number(offset2) : 0,
18573
+ created_at: created_at ? JSON.parse(created_at) : void 0,
18574
+ updated_at: updated_at ? JSON.parse(updated_at) : void 0,
18575
+ customer_id: customer_id ? JSON.parse(customer_id) : void 0,
18576
+ ...rest
18577
+ };
18578
+ return searchParams;
18579
+ };
18580
+ const PAGE_SIZE$5 = 10;
18581
+ function GiftCardsTable() {
18582
+ const queryParams = useGiftCardTableQuery({
18583
+ pageSize: PAGE_SIZE$5
18584
+ });
18585
+ const {
18586
+ gift_cards: giftCards,
18587
+ isPending,
18588
+ count: count2
18589
+ } = useGiftCards({
18590
+ ...queryParams,
18591
+ order: queryParams.order ?? "-created_at",
18592
+ fields: "+line_item.product.title"
18593
+ });
18594
+ const columns = useGiftCardTableColumns();
18595
+ const filters = useGiftCardFilters();
18596
+ return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
18597
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
18598
+ DataTable,
18599
+ {
18600
+ data: giftCards,
18601
+ getRowId: (row) => row.id,
18602
+ columns,
18603
+ filters,
18604
+ isLoading: isPending,
18605
+ pageSize: PAGE_SIZE$5,
18606
+ rowCount: count2,
18607
+ heading: "Gift Cards",
18608
+ rowHref: (row) => `${row.id}`,
18609
+ emptyState: {
18610
+ empty: {
18611
+ heading: "No gift cards found",
18612
+ description: "Create a gift card to get started."
18613
+ },
18614
+ filtered: {
18615
+ heading: "No results found",
18616
+ description: "No gift cards match your filter criteria."
18617
+ }
18618
+ },
18619
+ actions: [
18620
+ {
18621
+ label: "Create",
18622
+ to: "create"
18623
+ }
18624
+ ]
18625
+ }
18626
+ ) }),
18627
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
18628
+ ] });
18629
+ }
18630
+ const GiftCardsPage = () => {
18631
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
18632
+ /* @__PURE__ */ jsxRuntime.jsx(
18633
+ components.LayoutComposer,
18634
+ {
18635
+ widgetsZonePrefix: "gift_card.list",
18636
+ preferredLayoutId: "core:two-column",
18637
+ sections: {
18638
+ main: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardsTable", children: /* @__PURE__ */ jsxRuntime.jsx(GiftCardsTable, {}) }),
18639
+ side: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardProductsSection", children: /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductsSection, {}) })
18640
+ }
18641
+ }
18642
+ ),
18643
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Toaster, {})
18644
+ ] });
18645
+ };
18646
+ const config$2 = adminSdk.defineRouteConfig({
18647
+ label: "Gift Cards",
18648
+ icon: GiftCardIcon
18649
+ });
18650
+ const STORE_QUERY_KEY = "store";
18651
+ const storeQueryKeys = queryKeysFactory(STORE_QUERY_KEY);
18652
+ async function retrieveActiveStore(query) {
18653
+ var _a2;
18654
+ const response = await sdk.admin.store.list(query);
18655
+ const activeStore = (_a2 = response.stores) == null ? void 0 : _a2[0];
18656
+ if (!activeStore) {
18657
+ throw new Medusa.FetchError("No active store found", "Not Found", 404);
18658
+ }
18659
+ return { store: activeStore };
18660
+ }
18661
+ const useStore$1 = (query, options) => {
18662
+ const { data, ...rest } = reactQuery.useQuery({
18663
+ queryFn: () => retrieveActiveStore(query),
18664
+ queryKey: storeQueryKeys.details(),
18665
+ ...options
18666
+ });
18667
+ return {
18668
+ ...data,
18669
+ ...rest
18670
+ };
18671
+ };
18049
18672
  function $constructor(name, initializer2, params) {
18050
18673
  function init2(inst, def) {
18051
18674
  if (!inst._zod) {
@@ -18110,7 +18733,7 @@ class $ZodEncodeError extends Error {
18110
18733
  }
18111
18734
  }
18112
18735
  const globalConfig = {};
18113
- function config$2(newConfig) {
18736
+ function config$1(newConfig) {
18114
18737
  return globalConfig;
18115
18738
  }
18116
18739
  function getEnumValues(entries) {
@@ -18204,7 +18827,7 @@ function slugify(input) {
18204
18827
  }
18205
18828
  const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
18206
18829
  };
18207
- function isObject$6(data) {
18830
+ function isObject$3(data) {
18208
18831
  return typeof data === "object" && data !== null && !Array.isArray(data);
18209
18832
  }
18210
18833
  const allowsEval = cached(() => {
@@ -18221,7 +18844,7 @@ const allowsEval = cached(() => {
18221
18844
  }
18222
18845
  });
18223
18846
  function isPlainObject(o2) {
18224
- if (isObject$6(o2) === false)
18847
+ if (isObject$3(o2) === false)
18225
18848
  return false;
18226
18849
  const ctor = o2.constructor;
18227
18850
  if (ctor === void 0)
@@ -18229,7 +18852,7 @@ function isPlainObject(o2) {
18229
18852
  if (typeof ctor !== "function")
18230
18853
  return true;
18231
18854
  const prot = ctor.prototype;
18232
- if (isObject$6(prot) === false)
18855
+ if (isObject$3(prot) === false)
18233
18856
  return false;
18234
18857
  if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
18235
18858
  return false;
@@ -18560,7 +19183,7 @@ const _parse = (_Err) => (schema2, value, _ctx, _params) => {
18560
19183
  throw new $ZodAsyncError();
18561
19184
  }
18562
19185
  if (result.issues.length) {
18563
- const e2 = new ((_params == null ? void 0 : _params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())));
19186
+ const e2 = new ((_params == null ? void 0 : _params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())));
18564
19187
  captureStackTrace(e2, _params == null ? void 0 : _params.callee);
18565
19188
  throw e2;
18566
19189
  }
@@ -18572,7 +19195,7 @@ const _parseAsync = (_Err) => async (schema2, value, _ctx, params) => {
18572
19195
  if (result instanceof Promise)
18573
19196
  result = await result;
18574
19197
  if (result.issues.length) {
18575
- const e2 = new ((params == null ? void 0 : params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())));
19198
+ const e2 = new ((params == null ? void 0 : params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())));
18576
19199
  captureStackTrace(e2, params == null ? void 0 : params.callee);
18577
19200
  throw e2;
18578
19201
  }
@@ -18586,7 +19209,7 @@ const _safeParse = (_Err) => (schema2, value, _ctx) => {
18586
19209
  }
18587
19210
  return result.issues.length ? {
18588
19211
  success: false,
18589
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())))
19212
+ error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())))
18590
19213
  } : { success: true, data: result.value };
18591
19214
  };
18592
19215
  const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
@@ -18597,7 +19220,7 @@ const _safeParseAsync = (_Err) => async (schema2, value, _ctx) => {
18597
19220
  result = await result;
18598
19221
  return result.issues.length ? {
18599
19222
  success: false,
18600
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())))
19223
+ error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())))
18601
19224
  } : { success: true, data: result.value };
18602
19225
  };
18603
19226
  const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
@@ -19736,7 +20359,7 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
19736
20359
  }
19737
20360
  return propValues;
19738
20361
  });
19739
- const isObject2 = isObject$6;
20362
+ const isObject2 = isObject$3;
19740
20363
  const catchall = def.catchall;
19741
20364
  let value;
19742
20365
  inst._zod.parse = (payload, ctx2) => {
@@ -19816,7 +20439,7 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
19816
20439
  return (payload, ctx2) => fn(shape, payload, ctx2);
19817
20440
  };
19818
20441
  let fastpass;
19819
- const isObject2 = isObject$6;
20442
+ const isObject2 = isObject$3;
19820
20443
  const jit = !globalConfig.jitless;
19821
20444
  const allowsEval$1 = allowsEval;
19822
20445
  const fastEnabled = jit && allowsEval$1.value;
@@ -19861,7 +20484,7 @@ function handleUnionResults(results, final, inst, ctx2) {
19861
20484
  code: "invalid_union",
19862
20485
  input: final.value,
19863
20486
  inst,
19864
- errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())))
20487
+ errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())))
19865
20488
  });
19866
20489
  return final;
19867
20490
  }
@@ -20054,7 +20677,7 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
20054
20677
  payload.issues.push({
20055
20678
  code: "invalid_key",
20056
20679
  origin: "record",
20057
- issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())),
20680
+ issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())),
20058
20681
  input: key2,
20059
20682
  path: [key2],
20060
20683
  inst
@@ -20253,7 +20876,7 @@ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
20253
20876
  payload.value = def.catchValue({
20254
20877
  ...payload,
20255
20878
  error: {
20256
- issues: result2.issues.map((iss) => finalizeIssue(iss, ctx2, config$2()))
20879
+ issues: result2.issues.map((iss) => finalizeIssue(iss, ctx2, config$1()))
20257
20880
  },
20258
20881
  input: payload.value
20259
20882
  });
@@ -20267,7 +20890,7 @@ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
20267
20890
  payload.value = def.catchValue({
20268
20891
  ...payload,
20269
20892
  error: {
20270
- issues: result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2()))
20893
+ issues: result.issues.map((iss) => finalizeIssue(iss, ctx2, config$1()))
20271
20894
  },
20272
20895
  input: payload.value
20273
20896
  });
@@ -22327,633 +22950,546 @@ const GiftCardCreateForm = ({
22327
22950
  ] });
22328
22951
  };
22329
22952
  const GiftCardCreate = () => {
22330
- const { store, isLoading } = useStore$2({});
22953
+ const { store, isLoading } = useStore$1({});
22331
22954
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal, { children: [
22332
22955
  /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create Gift Card" }) }),
22333
22956
  /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create a new gift card" }) }),
22334
22957
  !isLoading && /* @__PURE__ */ jsxRuntime.jsx(GiftCardCreateForm, { store })
22335
22958
  ] });
22336
22959
  };
22337
- const StoreCreditIcon = (props) => {
22338
- return /* @__PURE__ */ jsxRuntime.jsxs(
22339
- "svg",
22340
- {
22341
- width: "15",
22342
- height: "15",
22343
- viewBox: "0 0 15 15",
22344
- fill: "none",
22345
- xmlns: "http://www.w3.org/2000/svg",
22346
- ...props,
22347
- children: [
22348
- /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#8B5CF6" }),
22349
- /* @__PURE__ */ jsxRuntime.jsx(
22350
- "rect",
22351
- {
22352
- width: "15",
22353
- height: "15",
22354
- fill: "url(#paint0_linear_29181_44790)",
22355
- fillOpacity: "0.2"
22356
- }
22357
- ),
22358
- /* @__PURE__ */ jsxRuntime.jsx(
22359
- "path",
22360
- {
22361
- d: "M12 6V5.813C12 4.675 11.075 3.75 9.938 3.75H5.063C3.925 3.75 3 4.675 3 5.813V6H12Z",
22362
- fill: "white"
22363
- }
22364
- ),
22365
- /* @__PURE__ */ jsxRuntime.jsx(
22366
- "path",
22367
- {
22368
- d: "M3 7.125V9.188C3 10.325 3.925 11.25 5.063 11.25H9.938C11.075 11.25 12 10.325 12 9.188V7.125H3ZM9.938 9.75H8.438C8.127 9.75 7.875 9.498 7.875 9.188C7.875 8.877 8.127 8.625 8.438 8.625H9.938C10.248 8.625 10.5 8.877 10.5 9.188C10.5 9.498 10.248 9.75 9.938 9.75Z",
22369
- fill: "white"
22370
- }
22371
- ),
22372
- /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs(
22373
- "linearGradient",
22960
+ const StoreCreditAccountBalanceSection = ({
22961
+ storeCreditAccount
22962
+ }) => {
22963
+ if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
22964
+ return;
22965
+ }
22966
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "grid grid-cols-2 gap-x-2 px-6 py-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-x-3", children: [
22967
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-ui-tag-green-icon h-8 w-1 rounded-full" }),
22968
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
22969
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", size: "small", className: "text-ui-fg-subtle", children: "Current Balance" }),
22970
+ /* @__PURE__ */ jsxRuntime.jsx(
22971
+ ui.Text,
22972
+ {
22973
+ weight: "plus",
22974
+ size: "xlarge",
22975
+ className: "tabular-nums text-ui-fg-base",
22976
+ children: formatAmount(
22977
+ storeCreditAccount.balance,
22978
+ storeCreditAccount.currency_code
22979
+ )
22980
+ }
22981
+ )
22982
+ ] })
22983
+ ] }) });
22984
+ };
22985
+ var toggleSelection = function() {
22986
+ var selection = document.getSelection();
22987
+ if (!selection.rangeCount) {
22988
+ return function() {
22989
+ };
22990
+ }
22991
+ var active = document.activeElement;
22992
+ var ranges = [];
22993
+ for (var i2 = 0; i2 < selection.rangeCount; i2++) {
22994
+ ranges.push(selection.getRangeAt(i2));
22995
+ }
22996
+ switch (active.tagName.toUpperCase()) {
22997
+ // .toUpperCase handles XHTML
22998
+ case "INPUT":
22999
+ case "TEXTAREA":
23000
+ active.blur();
23001
+ break;
23002
+ default:
23003
+ active = null;
23004
+ break;
23005
+ }
23006
+ selection.removeAllRanges();
23007
+ return function() {
23008
+ selection.type === "Caret" && selection.removeAllRanges();
23009
+ if (!selection.rangeCount) {
23010
+ ranges.forEach(function(range) {
23011
+ selection.addRange(range);
23012
+ });
23013
+ }
23014
+ active && active.focus();
23015
+ };
23016
+ };
23017
+ var deselectCurrent = toggleSelection;
23018
+ var clipboardToIE11Formatting = {
23019
+ "text/plain": "Text",
23020
+ "text/html": "Url",
23021
+ "default": "Text"
23022
+ };
23023
+ var defaultMessage = "Copy to clipboard: #{key}, Enter";
23024
+ function format(message2) {
23025
+ var copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C";
23026
+ return message2.replace(/#{\s*key\s*}/g, copyKey);
23027
+ }
23028
+ function copy$2(text2, options) {
23029
+ var debug2, message2, reselectPrevious, range, selection, mark, success = false;
23030
+ if (!options) {
23031
+ options = {};
23032
+ }
23033
+ debug2 = options.debug || false;
23034
+ try {
23035
+ reselectPrevious = deselectCurrent();
23036
+ range = document.createRange();
23037
+ selection = document.getSelection();
23038
+ mark = document.createElement("span");
23039
+ mark.textContent = text2;
23040
+ mark.ariaHidden = "true";
23041
+ mark.style.all = "unset";
23042
+ mark.style.position = "fixed";
23043
+ mark.style.top = 0;
23044
+ mark.style.clip = "rect(0, 0, 0, 0)";
23045
+ mark.style.whiteSpace = "pre";
23046
+ mark.style.webkitUserSelect = "text";
23047
+ mark.style.MozUserSelect = "text";
23048
+ mark.style.msUserSelect = "text";
23049
+ mark.style.userSelect = "text";
23050
+ mark.addEventListener("copy", function(e2) {
23051
+ e2.stopPropagation();
23052
+ if (options.format) {
23053
+ e2.preventDefault();
23054
+ if (typeof e2.clipboardData === "undefined") {
23055
+ debug2 && console.warn("unable to use e.clipboardData");
23056
+ debug2 && console.warn("trying IE specific stuff");
23057
+ window.clipboardData.clearData();
23058
+ var format2 = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting["default"];
23059
+ window.clipboardData.setData(format2, text2);
23060
+ } else {
23061
+ e2.clipboardData.clearData();
23062
+ e2.clipboardData.setData(options.format, text2);
23063
+ }
23064
+ }
23065
+ if (options.onCopy) {
23066
+ e2.preventDefault();
23067
+ options.onCopy(e2.clipboardData);
23068
+ }
23069
+ });
23070
+ document.body.appendChild(mark);
23071
+ range.selectNodeContents(mark);
23072
+ selection.addRange(range);
23073
+ var successful = document.execCommand("copy");
23074
+ if (!successful) {
23075
+ throw new Error("copy command was unsuccessful");
23076
+ }
23077
+ success = true;
23078
+ } catch (err) {
23079
+ debug2 && console.error("unable to copy using execCommand: ", err);
23080
+ debug2 && console.warn("trying IE specific stuff");
23081
+ try {
23082
+ window.clipboardData.setData(options.format || "text", text2);
23083
+ options.onCopy && options.onCopy(window.clipboardData);
23084
+ success = true;
23085
+ } catch (err2) {
23086
+ debug2 && console.error("unable to copy using clipboardData: ", err2);
23087
+ debug2 && console.error("falling back to prompt");
23088
+ message2 = format("message" in options ? options.message : defaultMessage);
23089
+ window.prompt(message2, text2);
23090
+ }
23091
+ } finally {
23092
+ if (selection) {
23093
+ if (typeof selection.removeRange == "function") {
23094
+ selection.removeRange(range);
23095
+ } else {
23096
+ selection.removeAllRanges();
23097
+ }
23098
+ }
23099
+ if (mark) {
23100
+ document.body.removeChild(mark);
23101
+ }
23102
+ reselectPrevious();
23103
+ }
23104
+ return success;
23105
+ }
23106
+ var copyToClipboard = copy$2;
23107
+ const copy$1 = /* @__PURE__ */ getDefaultExportFromCjs(copyToClipboard);
23108
+ function DisplayId({ id, className }) {
23109
+ const [open, setOpen] = React.useState(false);
23110
+ const onClick = () => {
23111
+ copy$1(id);
23112
+ ui.toast.success("Copied to clipboard");
23113
+ };
23114
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { maxWidth: 260, content: id, open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { onClick, className: ui.clx("cursor-pointer", className), children: [
23115
+ "#",
23116
+ id.slice(-7)
23117
+ ] }) });
23118
+ }
23119
+ const StoreCreditAccountDetailsSection = ({
23120
+ storeCreditAccount
23121
+ }) => {
23122
+ if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
23123
+ return;
23124
+ }
23125
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "flex justify-between gap-x-2 px-6 py-6", children: [
23126
+ /* @__PURE__ */ jsxRuntime.jsxs(
23127
+ ui.Text,
23128
+ {
23129
+ weight: "plus",
23130
+ size: "xlarge",
23131
+ className: "text-ui-fg-base flex gap-x-4",
23132
+ children: [
23133
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2", children: [
23134
+ /* @__PURE__ */ jsxRuntime.jsx(CreditCardIcon, { className: "inline" }),
23135
+ " "
23136
+ ] }),
23137
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
23138
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle", children: [
23139
+ storeCreditAccount.currency_code.toUpperCase(),
23140
+ " Account"
23141
+ ] }),
23142
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx(
23143
+ ui.Text,
23144
+ {
23145
+ weight: "regular",
23146
+ size: "small",
23147
+ className: "text-ui-fg-base flex gap-x-4",
23148
+ children: /* @__PURE__ */ jsxRuntime.jsx(DisplayId, { id: storeCreditAccount.id })
23149
+ }
23150
+ ) })
23151
+ ] })
23152
+ ]
23153
+ }
23154
+ ),
23155
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-x-4", children: /* @__PURE__ */ jsxRuntime.jsx(
23156
+ ActionMenu,
23157
+ {
23158
+ groups: [
22374
23159
  {
22375
- id: "paint0_linear_29181_44790",
22376
- x1: "7.5",
22377
- y1: "0",
22378
- x2: "7.5",
22379
- y2: "15",
22380
- gradientUnits: "userSpaceOnUse",
22381
- children: [
22382
- /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "white" }),
22383
- /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
23160
+ actions: [
23161
+ {
23162
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CreditCard, {}),
23163
+ label: "Credit the account",
23164
+ to: "credit"
23165
+ }
22384
23166
  ]
22385
23167
  }
22386
- ) })
22387
- ]
22388
- }
22389
- );
23168
+ ]
23169
+ }
23170
+ ) })
23171
+ ] });
22390
23172
  };
22391
- const columnHelper$9 = ui.createDataTableColumnHelper();
22392
- const useStoreCreditAccountTableColumns = () => {
23173
+ function StoreCreditAccountCustomerSection({
23174
+ customerId
23175
+ }) {
23176
+ const { customer, isPending } = useCustomer(customerId, void 0, {
23177
+ enabled: !!customerId
23178
+ });
23179
+ if (isPending || !customer) {
23180
+ return null;
23181
+ }
23182
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
23183
+ /* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Customer" }),
23184
+ /* @__PURE__ */ jsxRuntime.jsx(
23185
+ SidebarLink,
23186
+ {
23187
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {}),
23188
+ labelKey: customer.email || "N/A",
23189
+ descriptionKey: !customer.first_name && !customer.last_name ? "N/A" : `${customer.first_name} ${customer.last_name}`,
23190
+ to: `/customers/${customer.id}`
23191
+ },
23192
+ customer.id
23193
+ )
23194
+ ] });
23195
+ }
23196
+ const columnHelper$8 = ui.createDataTableColumnHelper();
23197
+ const useTransactionsTableColumns = () => {
22393
23198
  return React.useMemo(() => {
22394
23199
  return [
22395
- columnHelper$9.accessor("currency_code", {
22396
- header: "Currency",
23200
+ columnHelper$8.accessor("id", {
23201
+ header: "ID",
22397
23202
  cell: ({ row }) => {
22398
- return /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { size: "2xsmall", children: row.original.currency_code.toUpperCase() });
23203
+ return /* @__PURE__ */ jsxRuntime.jsx(DisplayId, { id: row.original.id });
22399
23204
  }
22400
23205
  }),
22401
- columnHelper$9.accessor("customer.email", {
22402
- header: "Customer",
22403
- cell: ({ row }) => {
22404
- var _a2;
22405
- return ((_a2 = row.original.customer) == null ? void 0 : _a2.email) ?? "N/A";
22406
- }
23206
+ columnHelper$8.accessor("created_at", {
23207
+ header: "Created At",
23208
+ cell: ({ row }) => formatDate(row.original.created_at, false)
22407
23209
  }),
22408
- columnHelper$9.accessor("balance", {
22409
- header: "Balance",
22410
- cell: ({ row }) => {
22411
- return formatAmount(
22412
- row.original.balance,
22413
- row.original.currency_code
22414
- );
22415
- }
23210
+ columnHelper$8.accessor("note", {
23211
+ header: "Description",
23212
+ cell: ({ row }) => row.original.note
22416
23213
  }),
22417
- columnHelper$9.accessor("credits", {
22418
- header: "Credits",
23214
+ columnHelper$8.accessor("note", {
23215
+ header: "Note",
22419
23216
  cell: ({ row }) => {
22420
- return formatAmount(
22421
- row.original.credits,
22422
- row.original.currency_code
22423
- );
23217
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { title: row.original.note, className: "max-w-[300px] truncate", children: row.original.note || "-" });
22424
23218
  }
22425
23219
  }),
22426
- columnHelper$9.accessor("debits", {
22427
- header: "Debits",
23220
+ columnHelper$8.accessor("amount", {
23221
+ header: "Amount",
22428
23222
  cell: ({ row }) => {
22429
- return formatAmount(
22430
- row.original.debits,
22431
- row.original.currency_code
23223
+ const isDebit = row.original.type === "debit";
23224
+ return row.original.account.currency_code && formatAmount(
23225
+ row.original.amount * (isDebit ? -1 : 1),
23226
+ row.original.account.currency_code
22432
23227
  );
22433
23228
  }
22434
- }),
22435
- columnHelper$9.accessor("created_at", {
22436
- header: "Created at",
22437
- cell: ({ row }) => getRelativeDate(row.original.created_at)
22438
23229
  })
22439
23230
  ];
22440
23231
  }, []);
22441
23232
  };
22442
- const useStoreCreditAccountFilters = () => {
23233
+ const useTransactionsTableFilters = ({}) => {
22443
23234
  const dateFilterOptions = useDataTableDateFilters$1();
22444
- const customerFilterOptions = useCustomerFilters();
22445
23235
  return React.useMemo(() => {
22446
- return [...dateFilterOptions, ...customerFilterOptions];
22447
- }, [dateFilterOptions, customerFilterOptions]);
23236
+ return [...dateFilterOptions];
23237
+ }, [dateFilterOptions]);
22448
23238
  };
22449
- const useStoreCreditAccountsTableQuery = ({
23239
+ const useTransactionsTableQuery = ({
22450
23240
  prefix,
22451
23241
  pageSize = 20
22452
23242
  }) => {
22453
23243
  const queryObject = useQueryParams(
22454
- ["offset", "customer_id", "currency_code", "created_at", "updated_at"],
23244
+ ["offset", "limit", "currency_code", "created_at", "updated_at"],
22455
23245
  prefix
22456
23246
  );
22457
- const {
22458
- offset: offset2,
22459
- created_at,
22460
- updated_at,
22461
- customer_id,
22462
- currency_code,
22463
- ...rest
22464
- } = queryObject;
23247
+ const { offset: offset2, limit, created_at, updated_at, ...rest } = queryObject;
22465
23248
  const searchParams = {
22466
- limit: pageSize,
23249
+ limit: limit ? Number(limit) : pageSize,
22467
23250
  offset: offset2 ? Number(offset2) : 0,
22468
23251
  created_at: created_at ? JSON.parse(created_at) : void 0,
22469
23252
  updated_at: updated_at ? JSON.parse(updated_at) : void 0,
22470
- customer_id: customer_id ? JSON.parse(customer_id) : void 0,
22471
- currency_code: currency_code ? JSON.parse(currency_code) : void 0,
22472
23253
  ...rest
22473
23254
  };
22474
23255
  return searchParams;
22475
23256
  };
22476
- const PAGE_SIZE$5 = 10;
22477
- function StoreCreditAccountsTable() {
22478
- const queryParams = useStoreCreditAccountsTableQuery({
22479
- pageSize: PAGE_SIZE$5
22480
- });
22481
- const {
22482
- store_credit_accounts: storeCreditAccounts,
22483
- isPending,
22484
- count: count2
22485
- } = useStoreCreditAccounts({
22486
- ...queryParams,
22487
- order: queryParams.order ?? "-created_at"
23257
+ const PAGE_SIZE$4 = 10;
23258
+ function TransactionsTable({ id }) {
23259
+ const queryParams = useTransactionsTableQuery({
23260
+ pageSize: PAGE_SIZE$4
22488
23261
  });
22489
- const columns = useStoreCreditAccountTableColumns();
22490
- const filters = useStoreCreditAccountFilters();
23262
+ const { transactions, isLoading, count: count2 } = useStoreCreditAccountTransactions(
23263
+ id,
23264
+ {
23265
+ ...queryParams,
23266
+ order: queryParams.order ?? "-created_at",
23267
+ fields: "*account"
23268
+ }
23269
+ );
23270
+ const columns = useTransactionsTableColumns();
23271
+ const filters = useTransactionsTableFilters({});
22491
23272
  return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
22492
23273
  /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
22493
23274
  DataTable,
22494
23275
  {
22495
- data: storeCreditAccounts ?? [],
23276
+ data: transactions ?? [],
22496
23277
  getRowId: (row) => row.id,
22497
23278
  columns,
22498
23279
  filters,
22499
- isLoading: isPending,
22500
- pageSize: PAGE_SIZE$5,
23280
+ isLoading,
23281
+ pageSize: PAGE_SIZE$4,
22501
23282
  rowCount: count2,
22502
23283
  enableSearch: false,
22503
- heading: "Store Credit Accounts",
22504
- rowHref: (row) => `${row.id}`,
23284
+ heading: "Transactions",
22505
23285
  emptyState: {
22506
23286
  empty: {
22507
- heading: "No store credit accounts found",
22508
- description: "Create a new store credit account to get started."
23287
+ heading: "No transactions found"
22509
23288
  },
22510
23289
  filtered: {
22511
23290
  heading: "No results found",
22512
- description: "No store credit accounts match your filter criteria."
22513
- }
22514
- },
22515
- actions: [
22516
- {
22517
- label: "Create",
22518
- to: "/store-credit-accounts/create"
23291
+ description: "No transactions match your filter criteria."
22519
23292
  }
22520
- ]
23293
+ }
22521
23294
  }
22522
23295
  ) }),
22523
23296
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
22524
23297
  ] });
22525
23298
  }
22526
- const StoreCreditAccountsPage = () => {
22527
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
22528
- /* @__PURE__ */ jsxRuntime.jsx(
22529
- components.LayoutComposer,
22530
- {
22531
- widgetsZonePrefix: "store_credit_account.list",
22532
- preferredLayoutId: "core:single-column",
22533
- sections: {
22534
- main: /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountsTable, {})
22535
- }
22536
- }
22537
- ),
22538
- /* @__PURE__ */ jsxRuntime.jsx(ui.Toaster, {})
22539
- ] });
22540
- };
22541
- const config$1 = adminSdk.defineRouteConfig({
22542
- label: "Store Credits",
22543
- icon: StoreCreditIcon
22544
- });
22545
- function isObject$5(value) {
22546
- var type = typeof value;
22547
- return value != null && (type == "object" || type == "function");
22548
- }
22549
- var isObject_1 = isObject$5;
22550
- var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
22551
- var _freeGlobal = freeGlobal$1;
22552
- var freeGlobal = _freeGlobal;
22553
- var freeSelf = typeof self == "object" && self && self.Object === Object && self;
22554
- var root$4 = freeGlobal || freeSelf || Function("return this")();
22555
- var _root = root$4;
22556
- var root$3 = _root;
22557
- var now$1 = function() {
22558
- return root$3.Date.now();
22559
- };
22560
- var now_1 = now$1;
22561
- var reWhitespace = /\s/;
22562
- function trimmedEndIndex$1(string2) {
22563
- var index = string2.length;
22564
- while (index-- && reWhitespace.test(string2.charAt(index))) {
22565
- }
22566
- return index;
22567
- }
22568
- var _trimmedEndIndex = trimmedEndIndex$1;
22569
- var trimmedEndIndex = _trimmedEndIndex;
22570
- var reTrimStart = /^\s+/;
22571
- function baseTrim$1(string2) {
22572
- return string2 ? string2.slice(0, trimmedEndIndex(string2) + 1).replace(reTrimStart, "") : string2;
22573
- }
22574
- var _baseTrim = baseTrim$1;
22575
- var root$2 = _root;
22576
- var Symbol$4 = root$2.Symbol;
22577
- var _Symbol = Symbol$4;
22578
- var Symbol$3 = _Symbol;
22579
- var objectProto$5 = Object.prototype;
22580
- var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
22581
- var nativeObjectToString$1 = objectProto$5.toString;
22582
- var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
22583
- function getRawTag$1(value) {
22584
- var isOwn = hasOwnProperty$4.call(value, symToStringTag$1), tag = value[symToStringTag$1];
22585
- try {
22586
- value[symToStringTag$1] = void 0;
22587
- var unmasked = true;
22588
- } catch (e2) {
22589
- }
22590
- var result = nativeObjectToString$1.call(value);
22591
- if (unmasked) {
22592
- if (isOwn) {
22593
- value[symToStringTag$1] = tag;
22594
- } else {
22595
- delete value[symToStringTag$1];
22596
- }
22597
- }
22598
- return result;
22599
- }
22600
- var _getRawTag = getRawTag$1;
22601
- var objectProto$4 = Object.prototype;
22602
- var nativeObjectToString = objectProto$4.toString;
22603
- function objectToString$1(value) {
22604
- return nativeObjectToString.call(value);
22605
- }
22606
- var _objectToString = objectToString$1;
22607
- var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
22608
- var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
22609
- var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
22610
- function baseGetTag$2(value) {
22611
- if (value == null) {
22612
- return value === void 0 ? undefinedTag : nullTag;
22613
- }
22614
- return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
22615
- }
22616
- var _baseGetTag = baseGetTag$2;
22617
- function isObjectLike$1(value) {
22618
- return value != null && typeof value == "object";
22619
- }
22620
- var isObjectLike_1 = isObjectLike$1;
22621
- var baseGetTag$1 = _baseGetTag, isObjectLike = isObjectLike_1;
22622
- var symbolTag = "[object Symbol]";
22623
- function isSymbol$4(value) {
22624
- return typeof value == "symbol" || isObjectLike(value) && baseGetTag$1(value) == symbolTag;
22625
- }
22626
- var isSymbol_1 = isSymbol$4;
22627
- var baseTrim = _baseTrim, isObject$4 = isObject_1, isSymbol$3 = isSymbol_1;
22628
- var NAN = 0 / 0;
22629
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
22630
- var reIsBinary = /^0b[01]+$/i;
22631
- var reIsOctal = /^0o[0-7]+$/i;
22632
- var freeParseInt = parseInt;
22633
- function toNumber$1(value) {
22634
- if (typeof value == "number") {
22635
- return value;
22636
- }
22637
- if (isSymbol$3(value)) {
22638
- return NAN;
22639
- }
22640
- if (isObject$4(value)) {
22641
- var other = typeof value.valueOf == "function" ? value.valueOf() : value;
22642
- value = isObject$4(other) ? other + "" : other;
22643
- }
22644
- if (typeof value != "string") {
22645
- return value === 0 ? value : +value;
23299
+ function StoreCreditAccountCodeSection({ code }) {
23300
+ if (!code) {
23301
+ return null;
22646
23302
  }
22647
- value = baseTrim(value);
22648
- var isBinary = reIsBinary.test(value);
22649
- return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
23303
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
23304
+ /* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Account Code" }),
23305
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-4 px-6 mb-2", children: [
23306
+ /* @__PURE__ */ jsxRuntime.jsx(icons.Share, { className: "inline" }),
23307
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle text-sm", children: code })
23308
+ ] })
23309
+ ] });
22650
23310
  }
22651
- var toNumber_1 = toNumber$1;
22652
- var isObject$3 = isObject_1, now = now_1, toNumber = toNumber_1;
22653
- var FUNC_ERROR_TEXT$1 = "Expected a function";
22654
- var nativeMax = Math.max, nativeMin = Math.min;
22655
- function debounce$2(func, wait, options) {
22656
- var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
22657
- if (typeof func != "function") {
22658
- throw new TypeError(FUNC_ERROR_TEXT$1);
22659
- }
22660
- wait = toNumber(wait) || 0;
22661
- if (isObject$3(options)) {
22662
- leading = !!options.leading;
22663
- maxing = "maxWait" in options;
22664
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
22665
- trailing = "trailing" in options ? !!options.trailing : trailing;
22666
- }
22667
- function invokeFunc(time2) {
22668
- var args = lastArgs, thisArg = lastThis;
22669
- lastArgs = lastThis = void 0;
22670
- lastInvokeTime = time2;
22671
- result = func.apply(thisArg, args);
22672
- return result;
22673
- }
22674
- function leadingEdge(time2) {
22675
- lastInvokeTime = time2;
22676
- timerId = setTimeout(timerExpired, wait);
22677
- return leading ? invokeFunc(time2) : result;
22678
- }
22679
- function remainingWait(time2) {
22680
- var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
22681
- return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
22682
- }
22683
- function shouldInvoke(time2) {
22684
- var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime;
22685
- return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
22686
- }
22687
- function timerExpired() {
22688
- var time2 = now();
22689
- if (shouldInvoke(time2)) {
22690
- return trailingEdge(time2);
22691
- }
22692
- timerId = setTimeout(timerExpired, remainingWait(time2));
22693
- }
22694
- function trailingEdge(time2) {
22695
- timerId = void 0;
22696
- if (trailing && lastArgs) {
22697
- return invokeFunc(time2);
22698
- }
22699
- lastArgs = lastThis = void 0;
22700
- return result;
23311
+ const StoreCreditAccountPage = () => {
23312
+ const { id } = reactRouterDom.useParams();
23313
+ const { store_credit_account: storeCreditAccount } = useStoreCreditAccount(
23314
+ id
23315
+ );
23316
+ if (!storeCreditAccount) {
23317
+ return;
22701
23318
  }
22702
- function cancel() {
22703
- if (timerId !== void 0) {
22704
- clearTimeout(timerId);
23319
+ return /* @__PURE__ */ jsxRuntime.jsx(
23320
+ components.LayoutComposer,
23321
+ {
23322
+ widgetsZonePrefix: "store_credit_account.details",
23323
+ preferredLayoutId: "core:two-column",
23324
+ data: storeCreditAccount,
23325
+ sections: {
23326
+ main: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
23327
+ /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountDetailsSection", children: /* @__PURE__ */ jsxRuntime.jsx(
23328
+ StoreCreditAccountDetailsSection,
23329
+ {
23330
+ storeCreditAccount
23331
+ }
23332
+ ) }),
23333
+ /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "TransactionsTable", children: /* @__PURE__ */ jsxRuntime.jsx(TransactionsTable, { id: storeCreditAccount.id }) })
23334
+ ] }),
23335
+ side: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
23336
+ /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountBalanceSection", children: /* @__PURE__ */ jsxRuntime.jsx(
23337
+ StoreCreditAccountBalanceSection,
23338
+ {
23339
+ storeCreditAccount
23340
+ }
23341
+ ) }),
23342
+ /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountCodeSection", children: /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCodeSection, { code: storeCreditAccount.code }) }),
23343
+ /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountCustomerSection", children: /* @__PURE__ */ jsxRuntime.jsx(
23344
+ StoreCreditAccountCustomerSection,
23345
+ {
23346
+ customerId: storeCreditAccount.customer_id
23347
+ }
23348
+ ) })
23349
+ ] })
23350
+ }
22705
23351
  }
22706
- lastInvokeTime = 0;
22707
- lastArgs = lastCallTime = lastThis = timerId = void 0;
22708
- }
22709
- function flush() {
22710
- return timerId === void 0 ? result : trailingEdge(now());
22711
- }
22712
- function debounced() {
22713
- var time2 = now(), isInvoking = shouldInvoke(time2);
22714
- lastArgs = arguments;
22715
- lastThis = this;
22716
- lastCallTime = time2;
22717
- if (isInvoking) {
22718
- if (timerId === void 0) {
22719
- return leadingEdge(lastCallTime);
23352
+ );
23353
+ };
23354
+ const KeyboundForm = React__namespace.default.forwardRef(({ onSubmit, onKeyDown, ...rest }, ref) => {
23355
+ const handleSubmit = (event) => {
23356
+ event.preventDefault();
23357
+ onSubmit == null ? void 0 : onSubmit(event);
23358
+ };
23359
+ const handleKeyDown = (event) => {
23360
+ if (event.key === "Enter") {
23361
+ if (event.target instanceof HTMLTextAreaElement && !(event.metaKey || event.ctrlKey)) {
23362
+ return;
22720
23363
  }
22721
- if (maxing) {
22722
- clearTimeout(timerId);
22723
- timerId = setTimeout(timerExpired, wait);
22724
- return invokeFunc(lastCallTime);
23364
+ event.preventDefault();
23365
+ if (event.metaKey || event.ctrlKey) {
23366
+ handleSubmit(event);
22725
23367
  }
22726
23368
  }
22727
- if (timerId === void 0) {
22728
- timerId = setTimeout(timerExpired, wait);
23369
+ };
23370
+ return /* @__PURE__ */ jsxRuntime.jsx(
23371
+ "form",
23372
+ {
23373
+ ...rest,
23374
+ onSubmit: handleSubmit,
23375
+ onKeyDown: onKeyDown ?? handleKeyDown,
23376
+ ref
22729
23377
  }
22730
- return result;
22731
- }
22732
- debounced.cancel = cancel;
22733
- debounced.flush = flush;
22734
- return debounced;
22735
- }
22736
- var debounce_1 = debounce$2;
22737
- const debounce$1 = /* @__PURE__ */ getDefaultExportFromCjs(debounce_1);
22738
- const useDebouncedSearch = () => {
22739
- const [searchValue, onSearchValueChange] = React.useState("");
22740
- const [debouncedQuery, setDebouncedQuery] = React.useState("");
22741
- const debouncedUpdate = React.useCallback(
22742
- debounce$1((query) => setDebouncedQuery(query), 300),
22743
- []
22744
23378
  );
22745
- React.useEffect(() => {
22746
- debouncedUpdate(searchValue);
22747
- return () => debouncedUpdate.cancel();
22748
- }, [searchValue, debouncedUpdate]);
22749
- return {
22750
- searchValue,
22751
- onSearchValueChange,
22752
- query: debouncedQuery || void 0
22753
- };
22754
- };
22755
- const useComboboxData = ({
22756
- queryKey,
22757
- queryFn,
22758
- getOptions,
22759
- defaultValue: defaultValue2,
22760
- defaultValueKey,
22761
- pageSize = 10
22762
- }) => {
22763
- const { searchValue, onSearchValueChange, query } = useDebouncedSearch();
22764
- const queryInitialDataBy = defaultValueKey || "id";
22765
- const { data: initialData } = reactQuery.useQuery({
22766
- queryKey,
22767
- queryFn: async () => {
22768
- return queryFn({
22769
- [queryInitialDataBy]: defaultValue2,
22770
- limit: Array.isArray(defaultValue2) ? defaultValue2.length : 1
22771
- });
22772
- },
22773
- enabled: !!defaultValue2
22774
- });
22775
- const { data, ...rest } = reactQuery.useInfiniteQuery({
22776
- queryKey: [...queryKey, query],
22777
- queryFn: async ({ pageParam = 0 }) => {
22778
- return await queryFn({
22779
- q: query,
22780
- limit: pageSize,
22781
- offset: pageParam
22782
- });
22783
- },
22784
- initialPageParam: 0,
22785
- getNextPageParam: (lastPage) => {
22786
- const moreItemsExist = lastPage.count > lastPage.offset + lastPage.limit;
22787
- return moreItemsExist ? lastPage.offset + lastPage.limit : void 0;
22788
- },
22789
- placeholderData: reactQuery.keepPreviousData
22790
- });
22791
- const options = (data == null ? void 0 : data.pages.flatMap((page) => getOptions(page))) ?? [];
22792
- const defaultOptions2 = initialData ? getOptions(initialData) : [];
22793
- const disabled = !rest.isPending && !options.length && !searchValue;
22794
- if (defaultValue2 && defaultOptions2.length && !searchValue) {
22795
- defaultOptions2.forEach((option) => {
22796
- if (!options.find((o2) => o2.value === option.value)) {
22797
- options.unshift(option);
22798
- }
22799
- });
23379
+ });
23380
+ KeyboundForm.displayName = "KeyboundForm";
23381
+ const Note$1 = () => {
23382
+ const { id } = reactRouterDom.useParams();
23383
+ const {
23384
+ store_credit_account: storeCreditAccount,
23385
+ isPending,
23386
+ isError,
23387
+ error
23388
+ } = useStoreCreditAccount(id, {});
23389
+ if (isError) {
23390
+ throw error;
22800
23391
  }
22801
- return {
22802
- options,
22803
- searchValue,
22804
- onSearchValueChange,
22805
- disabled,
22806
- ...rest
22807
- };
23392
+ const isReady = !isPending && !!storeCreditAccount;
23393
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
23394
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
23395
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Credit store credit account" }) }),
23396
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Credit the store credit account" }) })
23397
+ ] }),
23398
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCreditForm, { storeCreditAccount })
23399
+ ] });
22808
23400
  };
22809
- const formSchema = zod.z.object({
22810
- currency_code: zod.z.string().min(1, "Please select a currency"),
22811
- customer_id: zod.z.string().optional()
22812
- });
22813
- const StoreCreditAccountCreateForm = () => {
22814
- const { handleSuccess } = useRouteModal();
23401
+ const StoreCreditAccountCreditForm = ({
23402
+ storeCreditAccount
23403
+ }) => {
22815
23404
  const form = useForm({
22816
23405
  defaultValues: {
22817
- currency_code: "",
22818
- customer_id: ""
23406
+ amount: {
23407
+ float: 0,
23408
+ value: ""
23409
+ },
23410
+ note: ""
22819
23411
  },
22820
- resolver: t(formSchema)
23412
+ resolver: t(schema$2)
22821
23413
  });
22822
- const { mutateAsync: createStoreCreditAccount, isPending } = useCreateStoreCreditAccount();
22823
- const handleSubmit = form.handleSubmit(async (data) => {
22824
- if (!data.customer_id) {
22825
- delete data.customer_id;
23414
+ const { mutateAsync, isPending } = useCreditStoreCreditAccount(
23415
+ storeCreditAccount.id
23416
+ );
23417
+ const { handleSuccess } = useRouteModal();
23418
+ const onSubmit = form.handleSubmit(async (data) => {
23419
+ if (data.amount.float <= 0) {
23420
+ form.setError("amount", { message: "Amount must be greater than 0" });
23421
+ return;
22826
23422
  }
22827
- await createStoreCreditAccount(data, {
22828
- onSuccess: (data2) => {
22829
- ui.toast.success(`Store credit account was successfully created.`);
22830
- handleSuccess(`../${data2.store_credit_account.id}`);
22831
- },
22832
- onError: (error) => {
22833
- ui.toast.error(error.message);
23423
+ await mutateAsync(
23424
+ { amount: data.amount.float, note: data.note },
23425
+ {
23426
+ onSuccess: () => handleSuccess(),
23427
+ onError: (error) => ui.toast.error(error.message)
22834
23428
  }
22835
- });
22836
- });
22837
- const [currencySearchValue, setCurrencySearchValue] = React.useState("");
22838
- const currencyOptions = React.useMemo(() => {
22839
- const options = Object.values(currencies).map((currency) => ({
22840
- label: `${currency.code} - ${currency.name} (${currency.symbol_native})`,
22841
- value: currency.code.toLowerCase()
22842
- }));
22843
- if (!currencySearchValue) {
22844
- return options;
22845
- }
22846
- return options.filter(
22847
- (option) => option.label.toLowerCase().includes(currencySearchValue.toLowerCase())
22848
23429
  );
22849
- }, [currencySearchValue]);
22850
- const {
22851
- options: customerOptions,
22852
- fetchNextPage,
22853
- isFetchingNextPage,
22854
- searchValue,
22855
- onSearchValueChange,
22856
- isLoading
22857
- } = useComboboxData({
22858
- queryKey: customersQueryKeys.list(),
22859
- queryFn: async (params) => {
22860
- return sdk.admin.customer.list(params);
22861
- },
22862
- getOptions: (data) => {
22863
- var _a2;
22864
- return ((_a2 = data.customers) == null ? void 0 : _a2.map((customer) => {
22865
- const fullName = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
22866
- const label = fullName ? `${customer.email} (${fullName})` : customer.email;
22867
- return {
22868
- label,
22869
- value: customer.id
22870
- };
22871
- })) || [];
22872
- }
22873
23430
  });
22874
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Form, { form, children: [
22875
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "-my-2 w-full border-l" }) }),
22876
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "size-full overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col items-center p-16", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children: [
22877
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
22878
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Create Store Credit Account" }),
22879
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", size: "small", children: "Create a new store credit account for a customer" })
22880
- ] }),
22881
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-x-4", children: [
22882
- /* @__PURE__ */ jsxRuntime.jsx(
22883
- Form$2.Field,
22884
- {
22885
- control: form.control,
22886
- name: "currency_code",
22887
- render: ({ field }) => {
22888
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
22889
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Currency" }),
23431
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
23432
+ KeyboundForm,
23433
+ {
23434
+ className: "flex flex-1 flex-col overflow-hidden",
23435
+ onSubmit,
23436
+ children: [
23437
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
23438
+ /* @__PURE__ */ jsxRuntime.jsx(
23439
+ Form$2.Field,
23440
+ {
23441
+ control: form.control,
23442
+ name: "amount",
23443
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
23444
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Amount" }),
22890
23445
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
22891
- Combobox,
23446
+ ui.CurrencyInput,
22892
23447
  {
22893
- value: field.value,
22894
- onChange: field.onChange,
22895
- searchValue: currencySearchValue,
22896
- onSearchValueChange: setCurrencySearchValue,
22897
- options: currencyOptions,
22898
- placeholder: "Search for a currency..."
23448
+ min: 0,
23449
+ placeholder: "0",
23450
+ value: field.value.value,
23451
+ onValueChange: (_value, _name, values) => {
23452
+ field.onChange({
23453
+ value: values == null ? void 0 : values.value,
23454
+ float: (values == null ? void 0 : values.float) || null
23455
+ });
23456
+ },
23457
+ symbol: currencies[storeCreditAccount.currency_code.toUpperCase()].symbol_native,
23458
+ code: storeCreditAccount.currency_code.toUpperCase()
22899
23459
  }
22900
23460
  ) }),
22901
23461
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
22902
- ] });
23462
+ ] })
22903
23463
  }
22904
- }
22905
- ),
22906
- /* @__PURE__ */ jsxRuntime.jsx(
22907
- Form$2.Field,
22908
- {
22909
- control: form.control,
22910
- name: "customer_id",
22911
- render: ({ field }) => {
22912
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
22913
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Customer" }),
22914
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
22915
- Combobox,
22916
- {
22917
- value: field.value,
22918
- onChange: field.onChange,
22919
- searchValue,
22920
- onSearchValueChange,
22921
- options: customerOptions,
22922
- placeholder: "Search for a customer...",
22923
- fetchNextPage,
22924
- isFetchingNextPage,
22925
- noResultsPlaceholder: isLoading ? "Loading customers..." : "No customers found"
22926
- }
22927
- ) }),
23464
+ ),
23465
+ /* @__PURE__ */ jsxRuntime.jsx(
23466
+ Form$2.Field,
23467
+ {
23468
+ control: form.control,
23469
+ name: "note",
23470
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
23471
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
23472
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
22928
23473
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
22929
- ] });
23474
+ ] })
22930
23475
  }
22931
- }
22932
- )
22933
- ] })
22934
- ] }) }) }),
22935
- /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Footer, { children: [
22936
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, disabled: isPending, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", disabled: isPending, children: "Cancel" }) }),
22937
- /* @__PURE__ */ jsxRuntime.jsx(
22938
- ui.Button,
22939
- {
22940
- variant: "primary",
22941
- size: "small",
22942
- onClick: handleSubmit,
22943
- disabled: isPending,
22944
- children: "Create"
22945
- }
22946
- )
22947
- ] })
22948
- ] });
22949
- };
22950
- const StoreCreditAccountCreate = () => {
22951
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal, { children: [
22952
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create Store Credit Account" }) }),
22953
- /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create a new store credit account" }) }),
22954
- /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCreateForm, {})
22955
- ] });
23476
+ )
23477
+ ] }),
23478
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
23479
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
23480
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
23481
+ ] }) })
23482
+ ]
23483
+ }
23484
+ ) });
22956
23485
  };
23486
+ const schema$2 = zod.z.object({
23487
+ note: zod.z.string(),
23488
+ amount: zod.z.object({
23489
+ float: zod.z.number(),
23490
+ value: zod.z.string()
23491
+ })
23492
+ });
22957
23493
  function _extends() {
22958
23494
  return _extends = Object.assign ? Object.assign.bind() : function(n2) {
22959
23495
  for (var e2 = 1; e2 < arguments.length; e2++) {
@@ -25634,243 +26170,6 @@ const GiftCardOrderSection = ({ giftCard }) => {
25634
26170
  ))
25635
26171
  ] });
25636
26172
  };
25637
- var toggleSelection = function() {
25638
- var selection = document.getSelection();
25639
- if (!selection.rangeCount) {
25640
- return function() {
25641
- };
25642
- }
25643
- var active = document.activeElement;
25644
- var ranges = [];
25645
- for (var i2 = 0; i2 < selection.rangeCount; i2++) {
25646
- ranges.push(selection.getRangeAt(i2));
25647
- }
25648
- switch (active.tagName.toUpperCase()) {
25649
- // .toUpperCase handles XHTML
25650
- case "INPUT":
25651
- case "TEXTAREA":
25652
- active.blur();
25653
- break;
25654
- default:
25655
- active = null;
25656
- break;
25657
- }
25658
- selection.removeAllRanges();
25659
- return function() {
25660
- selection.type === "Caret" && selection.removeAllRanges();
25661
- if (!selection.rangeCount) {
25662
- ranges.forEach(function(range) {
25663
- selection.addRange(range);
25664
- });
25665
- }
25666
- active && active.focus();
25667
- };
25668
- };
25669
- var deselectCurrent = toggleSelection;
25670
- var clipboardToIE11Formatting = {
25671
- "text/plain": "Text",
25672
- "text/html": "Url",
25673
- "default": "Text"
25674
- };
25675
- var defaultMessage = "Copy to clipboard: #{key}, Enter";
25676
- function format(message2) {
25677
- var copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C";
25678
- return message2.replace(/#{\s*key\s*}/g, copyKey);
25679
- }
25680
- function copy$2(text2, options) {
25681
- var debug2, message2, reselectPrevious, range, selection, mark, success = false;
25682
- if (!options) {
25683
- options = {};
25684
- }
25685
- debug2 = options.debug || false;
25686
- try {
25687
- reselectPrevious = deselectCurrent();
25688
- range = document.createRange();
25689
- selection = document.getSelection();
25690
- mark = document.createElement("span");
25691
- mark.textContent = text2;
25692
- mark.ariaHidden = "true";
25693
- mark.style.all = "unset";
25694
- mark.style.position = "fixed";
25695
- mark.style.top = 0;
25696
- mark.style.clip = "rect(0, 0, 0, 0)";
25697
- mark.style.whiteSpace = "pre";
25698
- mark.style.webkitUserSelect = "text";
25699
- mark.style.MozUserSelect = "text";
25700
- mark.style.msUserSelect = "text";
25701
- mark.style.userSelect = "text";
25702
- mark.addEventListener("copy", function(e2) {
25703
- e2.stopPropagation();
25704
- if (options.format) {
25705
- e2.preventDefault();
25706
- if (typeof e2.clipboardData === "undefined") {
25707
- debug2 && console.warn("unable to use e.clipboardData");
25708
- debug2 && console.warn("trying IE specific stuff");
25709
- window.clipboardData.clearData();
25710
- var format2 = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting["default"];
25711
- window.clipboardData.setData(format2, text2);
25712
- } else {
25713
- e2.clipboardData.clearData();
25714
- e2.clipboardData.setData(options.format, text2);
25715
- }
25716
- }
25717
- if (options.onCopy) {
25718
- e2.preventDefault();
25719
- options.onCopy(e2.clipboardData);
25720
- }
25721
- });
25722
- document.body.appendChild(mark);
25723
- range.selectNodeContents(mark);
25724
- selection.addRange(range);
25725
- var successful = document.execCommand("copy");
25726
- if (!successful) {
25727
- throw new Error("copy command was unsuccessful");
25728
- }
25729
- success = true;
25730
- } catch (err) {
25731
- debug2 && console.error("unable to copy using execCommand: ", err);
25732
- debug2 && console.warn("trying IE specific stuff");
25733
- try {
25734
- window.clipboardData.setData(options.format || "text", text2);
25735
- options.onCopy && options.onCopy(window.clipboardData);
25736
- success = true;
25737
- } catch (err2) {
25738
- debug2 && console.error("unable to copy using clipboardData: ", err2);
25739
- debug2 && console.error("falling back to prompt");
25740
- message2 = format("message" in options ? options.message : defaultMessage);
25741
- window.prompt(message2, text2);
25742
- }
25743
- } finally {
25744
- if (selection) {
25745
- if (typeof selection.removeRange == "function") {
25746
- selection.removeRange(range);
25747
- } else {
25748
- selection.removeAllRanges();
25749
- }
25750
- }
25751
- if (mark) {
25752
- document.body.removeChild(mark);
25753
- }
25754
- reselectPrevious();
25755
- }
25756
- return success;
25757
- }
25758
- var copyToClipboard = copy$2;
25759
- const copy$1 = /* @__PURE__ */ getDefaultExportFromCjs(copyToClipboard);
25760
- function DisplayId({ id, className }) {
25761
- const [open, setOpen] = React.useState(false);
25762
- const onClick = () => {
25763
- copy$1(id);
25764
- ui.toast.success("Copied to clipboard");
25765
- };
25766
- return /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { maxWidth: 260, content: id, open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { onClick, className: ui.clx("cursor-pointer", className), children: [
25767
- "#",
25768
- id.slice(-7)
25769
- ] }) });
25770
- }
25771
- const columnHelper$8 = ui.createDataTableColumnHelper();
25772
- const useTransactionsTableColumns = () => {
25773
- return React.useMemo(() => {
25774
- return [
25775
- columnHelper$8.accessor("id", {
25776
- header: "ID",
25777
- cell: ({ row }) => {
25778
- return /* @__PURE__ */ jsxRuntime.jsx(DisplayId, { id: row.original.id });
25779
- }
25780
- }),
25781
- columnHelper$8.accessor("created_at", {
25782
- header: "Created At",
25783
- cell: ({ row }) => formatDate(row.original.created_at, false)
25784
- }),
25785
- columnHelper$8.accessor("note", {
25786
- header: "Description",
25787
- cell: ({ row }) => row.original.note
25788
- }),
25789
- columnHelper$8.accessor("note", {
25790
- header: "Note",
25791
- cell: ({ row }) => {
25792
- return /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { title: row.original.note, className: "max-w-[300px] truncate", children: row.original.note || "-" });
25793
- }
25794
- }),
25795
- columnHelper$8.accessor("amount", {
25796
- header: "Amount",
25797
- cell: ({ row }) => {
25798
- const isDebit = row.original.type === "debit";
25799
- return row.original.account.currency_code && formatAmount(
25800
- row.original.amount * (isDebit ? -1 : 1),
25801
- row.original.account.currency_code
25802
- );
25803
- }
25804
- })
25805
- ];
25806
- }, []);
25807
- };
25808
- const useTransactionsTableFilters = ({}) => {
25809
- const dateFilterOptions = useDataTableDateFilters$1();
25810
- return React.useMemo(() => {
25811
- return [...dateFilterOptions];
25812
- }, [dateFilterOptions]);
25813
- };
25814
- const useTransactionsTableQuery = ({
25815
- prefix,
25816
- pageSize = 20
25817
- }) => {
25818
- const queryObject = useQueryParams(
25819
- ["offset", "limit", "currency_code", "created_at", "updated_at"],
25820
- prefix
25821
- );
25822
- const { offset: offset2, limit, created_at, updated_at, ...rest } = queryObject;
25823
- const searchParams = {
25824
- limit: limit ? Number(limit) : pageSize,
25825
- offset: offset2 ? Number(offset2) : 0,
25826
- created_at: created_at ? JSON.parse(created_at) : void 0,
25827
- updated_at: updated_at ? JSON.parse(updated_at) : void 0,
25828
- ...rest
25829
- };
25830
- return searchParams;
25831
- };
25832
- const PAGE_SIZE$4 = 10;
25833
- function TransactionsTable({ id }) {
25834
- const queryParams = useTransactionsTableQuery({
25835
- pageSize: PAGE_SIZE$4
25836
- });
25837
- const { transactions, isLoading, count: count2 } = useStoreCreditAccountTransactions(
25838
- id,
25839
- {
25840
- ...queryParams,
25841
- order: queryParams.order ?? "-created_at",
25842
- fields: "*account"
25843
- }
25844
- );
25845
- const columns = useTransactionsTableColumns();
25846
- const filters = useTransactionsTableFilters({});
25847
- return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
25848
- /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
25849
- DataTable,
25850
- {
25851
- data: transactions ?? [],
25852
- getRowId: (row) => row.id,
25853
- columns,
25854
- filters,
25855
- isLoading,
25856
- pageSize: PAGE_SIZE$4,
25857
- rowCount: count2,
25858
- enableSearch: false,
25859
- heading: "Transactions",
25860
- emptyState: {
25861
- empty: {
25862
- heading: "No transactions found"
25863
- },
25864
- filtered: {
25865
- heading: "No results found",
25866
- description: "No transactions match your filter criteria."
25867
- }
25868
- }
25869
- }
25870
- ) }),
25871
- /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
25872
- ] });
25873
- }
25874
26173
  const GiftCardTransactionsSection = ({
25875
26174
  storeCreditAccount
25876
26175
  }) => {
@@ -25896,57 +26195,30 @@ const GiftCardDetailsPage = () => {
25896
26195
  data: giftCard,
25897
26196
  sections: {
25898
26197
  main: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
25899
- /* @__PURE__ */ jsxRuntime.jsx(GiftCardGeneralSection, { giftCard }),
25900
- storeCreditAccount && /* @__PURE__ */ jsxRuntime.jsx(
26198
+ /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardGeneralSection", children: /* @__PURE__ */ jsxRuntime.jsx(GiftCardGeneralSection, { giftCard }) }),
26199
+ storeCreditAccount && /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardTransactionsSection", children: /* @__PURE__ */ jsxRuntime.jsx(
25901
26200
  GiftCardTransactionsSection,
25902
26201
  {
25903
26202
  storeCreditAccount
25904
26203
  }
25905
- ),
25906
- /* @__PURE__ */ jsxRuntime.jsx(JsonViewSection, { data: giftCard })
26204
+ ) }),
26205
+ /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "JsonViewSection", children: /* @__PURE__ */ jsxRuntime.jsx(JsonViewSection, { data: giftCard }) })
25907
26206
  ] }),
25908
26207
  side: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
25909
- storeCreditAccount && /* @__PURE__ */ jsxRuntime.jsx(
26208
+ storeCreditAccount && /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardBalanceSection", children: /* @__PURE__ */ jsxRuntime.jsx(
25910
26209
  GiftCardBalanceSection,
25911
26210
  {
25912
26211
  storeCreditAccount,
25913
26212
  giftCard
25914
26213
  }
25915
- ),
25916
- /* @__PURE__ */ jsxRuntime.jsx(GiftCardNoteSection, { giftCard }),
25917
- /* @__PURE__ */ jsxRuntime.jsx(GiftCardOrderSection, { giftCard })
26214
+ ) }),
26215
+ /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardNoteSection", children: /* @__PURE__ */ jsxRuntime.jsx(GiftCardNoteSection, { giftCard }) }),
26216
+ /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardOrderSection", children: /* @__PURE__ */ jsxRuntime.jsx(GiftCardOrderSection, { giftCard }) })
25918
26217
  ] })
25919
26218
  }
25920
26219
  }
25921
26220
  );
25922
26221
  };
25923
- const KeyboundForm = React__namespace.default.forwardRef(({ onSubmit, onKeyDown, ...rest }, ref) => {
25924
- const handleSubmit = (event) => {
25925
- event.preventDefault();
25926
- onSubmit == null ? void 0 : onSubmit(event);
25927
- };
25928
- const handleKeyDown = (event) => {
25929
- if (event.key === "Enter") {
25930
- if (event.target instanceof HTMLTextAreaElement && !(event.metaKey || event.ctrlKey)) {
25931
- return;
25932
- }
25933
- event.preventDefault();
25934
- if (event.metaKey || event.ctrlKey) {
25935
- handleSubmit(event);
25936
- }
25937
- }
25938
- };
25939
- return /* @__PURE__ */ jsxRuntime.jsx(
25940
- "form",
25941
- {
25942
- ...rest,
25943
- onSubmit: handleSubmit,
25944
- onKeyDown: onKeyDown ?? handleKeyDown,
25945
- ref
25946
- }
25947
- );
25948
- });
25949
- KeyboundForm.displayName = "KeyboundForm";
25950
26222
  const GiftCardExpiration = () => {
25951
26223
  const { id } = reactRouterDom.useParams();
25952
26224
  const { gift_card: giftCard, isPending, isError, error } = useGiftCard(id);
@@ -25967,7 +26239,7 @@ const GiftCardExpirationForm = ({ giftCard }) => {
25967
26239
  defaultValues: {
25968
26240
  expires_at: giftCard.expires_at ? new Date(giftCard.expires_at) : null
25969
26241
  },
25970
- resolver: t(schema$2)
26242
+ resolver: t(schema$1)
25971
26243
  });
25972
26244
  const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
25973
26245
  const { handleSuccess } = useRouteModal();
@@ -26062,10 +26334,10 @@ const GiftCardExpirationForm = ({ giftCard }) => {
26062
26334
  }
26063
26335
  ) });
26064
26336
  };
26065
- const schema$2 = zod.z.object({
26337
+ const schema$1 = zod.z.object({
26066
26338
  expires_at: zod.z.date().nullish()
26067
26339
  });
26068
- const Note$1 = () => {
26340
+ const Note = () => {
26069
26341
  const { id } = reactRouterDom.useParams();
26070
26342
  const {
26071
26343
  gift_card: giftCard,
@@ -26090,7 +26362,7 @@ const GiftCardNoteForm = ({ giftCard }) => {
26090
26362
  defaultValues: {
26091
26363
  note: giftCard.note ?? ""
26092
26364
  },
26093
- resolver: t(schema$1)
26365
+ resolver: t(schema)
26094
26366
  });
26095
26367
  const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
26096
26368
  const { handleSuccess } = useRouteModal();
@@ -26129,7 +26401,7 @@ const GiftCardNoteForm = ({ giftCard }) => {
26129
26401
  }
26130
26402
  ) });
26131
26403
  };
26132
- const schema$1 = zod.z.object({
26404
+ const schema = zod.z.object({
26133
26405
  note: zod.z.string().optional()
26134
26406
  });
26135
26407
  const columnHelper$7 = createColumnHelper();
@@ -26241,7 +26513,7 @@ const GiftCardProductsPage = () => {
26241
26513
  widgetsZonePrefix: "gift_card_product.list",
26242
26514
  preferredLayoutId: "core:single-column",
26243
26515
  sections: {
26244
- main: /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductsTable, {})
26516
+ main: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardProductsTable", children: /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductsTable, {}) })
26245
26517
  }
26246
26518
  }
26247
26519
  ),
@@ -39470,7 +39742,7 @@ const GiftCardProductCreate = () => {
39470
39742
  isPending: isStorePending,
39471
39743
  isError: isStoreError,
39472
39744
  error: storeError
39473
- } = useStore$2({
39745
+ } = useStore$1({
39474
39746
  fields: "+default_sales_channel"
39475
39747
  });
39476
39748
  const {
@@ -39522,275 +39794,6 @@ const GiftCardProductCreate = () => {
39522
39794
  )
39523
39795
  ] });
39524
39796
  };
39525
- const StoreCreditAccountBalanceSection = ({
39526
- storeCreditAccount
39527
- }) => {
39528
- if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
39529
- return;
39530
- }
39531
- return /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "grid grid-cols-2 gap-x-2 px-6 py-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-x-3", children: [
39532
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-ui-tag-green-icon h-8 w-1 rounded-full" }),
39533
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
39534
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", size: "small", className: "text-ui-fg-subtle", children: "Current Balance" }),
39535
- /* @__PURE__ */ jsxRuntime.jsx(
39536
- ui.Text,
39537
- {
39538
- weight: "plus",
39539
- size: "xlarge",
39540
- className: "tabular-nums text-ui-fg-base",
39541
- children: formatAmount(
39542
- storeCreditAccount.balance,
39543
- storeCreditAccount.currency_code
39544
- )
39545
- }
39546
- )
39547
- ] })
39548
- ] }) });
39549
- };
39550
- const StoreCreditAccountDetailsSection = ({
39551
- storeCreditAccount
39552
- }) => {
39553
- if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
39554
- return;
39555
- }
39556
- return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "flex justify-between gap-x-2 px-6 py-6", children: [
39557
- /* @__PURE__ */ jsxRuntime.jsxs(
39558
- ui.Text,
39559
- {
39560
- weight: "plus",
39561
- size: "xlarge",
39562
- className: "text-ui-fg-base flex gap-x-4",
39563
- children: [
39564
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2", children: [
39565
- /* @__PURE__ */ jsxRuntime.jsx(CreditCardIcon, { className: "inline" }),
39566
- " "
39567
- ] }),
39568
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
39569
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle", children: [
39570
- storeCreditAccount.currency_code.toUpperCase(),
39571
- " Account"
39572
- ] }),
39573
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx(
39574
- ui.Text,
39575
- {
39576
- weight: "regular",
39577
- size: "small",
39578
- className: "text-ui-fg-base flex gap-x-4",
39579
- children: /* @__PURE__ */ jsxRuntime.jsx(DisplayId, { id: storeCreditAccount.id })
39580
- }
39581
- ) })
39582
- ] })
39583
- ]
39584
- }
39585
- ),
39586
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-x-4", children: /* @__PURE__ */ jsxRuntime.jsx(
39587
- ActionMenu,
39588
- {
39589
- groups: [
39590
- {
39591
- actions: [
39592
- {
39593
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CreditCard, {}),
39594
- label: "Credit the account",
39595
- to: "credit"
39596
- }
39597
- ]
39598
- }
39599
- ]
39600
- }
39601
- ) })
39602
- ] });
39603
- };
39604
- function StoreCreditAccountCustomerSection({
39605
- customerId
39606
- }) {
39607
- const { customer, isPending } = useCustomer(customerId, void 0, {
39608
- enabled: !!customerId
39609
- });
39610
- if (isPending || !customer) {
39611
- return null;
39612
- }
39613
- return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
39614
- /* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Customer" }),
39615
- /* @__PURE__ */ jsxRuntime.jsx(
39616
- SidebarLink,
39617
- {
39618
- icon: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {}),
39619
- labelKey: customer.email || "N/A",
39620
- descriptionKey: !customer.first_name && !customer.last_name ? "N/A" : `${customer.first_name} ${customer.last_name}`,
39621
- to: `/customers/${customer.id}`
39622
- },
39623
- customer.id
39624
- )
39625
- ] });
39626
- }
39627
- function StoreCreditAccountCodeSection({ code }) {
39628
- if (!code) {
39629
- return null;
39630
- }
39631
- return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
39632
- /* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Account Code" }),
39633
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-4 px-6 mb-2", children: [
39634
- /* @__PURE__ */ jsxRuntime.jsx(icons.Share, { className: "inline" }),
39635
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle text-sm", children: code })
39636
- ] })
39637
- ] });
39638
- }
39639
- const StoreCreditAccountPage = () => {
39640
- const { id } = reactRouterDom.useParams();
39641
- const { store_credit_account: storeCreditAccount } = useStoreCreditAccount(
39642
- id
39643
- );
39644
- if (!storeCreditAccount) {
39645
- return;
39646
- }
39647
- return /* @__PURE__ */ jsxRuntime.jsx(
39648
- components.LayoutComposer,
39649
- {
39650
- widgetsZonePrefix: "store_credit_account.details",
39651
- preferredLayoutId: "core:two-column",
39652
- data: storeCreditAccount,
39653
- sections: {
39654
- main: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
39655
- /* @__PURE__ */ jsxRuntime.jsx(
39656
- StoreCreditAccountDetailsSection,
39657
- {
39658
- storeCreditAccount
39659
- }
39660
- ),
39661
- /* @__PURE__ */ jsxRuntime.jsx(TransactionsTable, { id: storeCreditAccount.id })
39662
- ] }),
39663
- side: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
39664
- /* @__PURE__ */ jsxRuntime.jsx(
39665
- StoreCreditAccountBalanceSection,
39666
- {
39667
- storeCreditAccount
39668
- }
39669
- ),
39670
- /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCodeSection, { code: storeCreditAccount.code }),
39671
- /* @__PURE__ */ jsxRuntime.jsx(
39672
- StoreCreditAccountCustomerSection,
39673
- {
39674
- customerId: storeCreditAccount.customer_id
39675
- }
39676
- )
39677
- ] })
39678
- }
39679
- }
39680
- );
39681
- };
39682
- const Note = () => {
39683
- const { id } = reactRouterDom.useParams();
39684
- const {
39685
- store_credit_account: storeCreditAccount,
39686
- isPending,
39687
- isError,
39688
- error
39689
- } = useStoreCreditAccount(id, {});
39690
- if (isError) {
39691
- throw error;
39692
- }
39693
- const isReady = !isPending && !!storeCreditAccount;
39694
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
39695
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
39696
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Credit store credit account" }) }),
39697
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Credit the store credit account" }) })
39698
- ] }),
39699
- isReady && /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCreditForm, { storeCreditAccount })
39700
- ] });
39701
- };
39702
- const StoreCreditAccountCreditForm = ({
39703
- storeCreditAccount
39704
- }) => {
39705
- const form = useForm({
39706
- defaultValues: {
39707
- amount: {
39708
- float: 0,
39709
- value: ""
39710
- },
39711
- note: ""
39712
- },
39713
- resolver: t(schema)
39714
- });
39715
- const { mutateAsync, isPending } = useCreditStoreCreditAccount(
39716
- storeCreditAccount.id
39717
- );
39718
- const { handleSuccess } = useRouteModal();
39719
- const onSubmit = form.handleSubmit(async (data) => {
39720
- if (data.amount.float <= 0) {
39721
- form.setError("amount", { message: "Amount must be greater than 0" });
39722
- return;
39723
- }
39724
- await mutateAsync(
39725
- { amount: data.amount.float, note: data.note },
39726
- {
39727
- onSuccess: () => handleSuccess(),
39728
- onError: (error) => ui.toast.error(error.message)
39729
- }
39730
- );
39731
- });
39732
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
39733
- KeyboundForm,
39734
- {
39735
- className: "flex flex-1 flex-col overflow-hidden",
39736
- onSubmit,
39737
- children: [
39738
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
39739
- /* @__PURE__ */ jsxRuntime.jsx(
39740
- Form$2.Field,
39741
- {
39742
- control: form.control,
39743
- name: "amount",
39744
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
39745
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Amount" }),
39746
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
39747
- ui.CurrencyInput,
39748
- {
39749
- min: 0,
39750
- placeholder: "0",
39751
- value: field.value.value,
39752
- onValueChange: (_value, _name, values) => {
39753
- field.onChange({
39754
- value: values == null ? void 0 : values.value,
39755
- float: (values == null ? void 0 : values.float) || null
39756
- });
39757
- },
39758
- symbol: currencies[storeCreditAccount.currency_code.toUpperCase()].symbol_native,
39759
- code: storeCreditAccount.currency_code.toUpperCase()
39760
- }
39761
- ) }),
39762
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
39763
- ] })
39764
- }
39765
- ),
39766
- /* @__PURE__ */ jsxRuntime.jsx(
39767
- Form$2.Field,
39768
- {
39769
- control: form.control,
39770
- name: "note",
39771
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
39772
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
39773
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
39774
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
39775
- ] })
39776
- }
39777
- )
39778
- ] }),
39779
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
39780
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
39781
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
39782
- ] }) })
39783
- ]
39784
- }
39785
- ) });
39786
- };
39787
- const schema = zod.z.object({
39788
- note: zod.z.string(),
39789
- amount: zod.z.object({
39790
- float: zod.z.number(),
39791
- value: zod.z.string()
39792
- })
39793
- });
39794
39797
  const productStatusColor = (status) => {
39795
39798
  switch (status) {
39796
39799
  case "draft":
@@ -40255,19 +40258,166 @@ const ProductDetail = () => {
40255
40258
  data: product,
40256
40259
  sections: {
40257
40260
  main: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
40258
- /* @__PURE__ */ jsxRuntime.jsx(ProductGeneralSection, { product }),
40259
- /* @__PURE__ */ jsxRuntime.jsx(ProductVariantSection, { product }),
40260
- /* @__PURE__ */ jsxRuntime.jsx(JsonViewSection, { data: product })
40261
+ /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "ProductGeneralSection", children: /* @__PURE__ */ jsxRuntime.jsx(ProductGeneralSection, { product }) }),
40262
+ /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "ProductVariantSection", children: /* @__PURE__ */ jsxRuntime.jsx(ProductVariantSection, { product }) }),
40263
+ /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "JsonViewSection", children: /* @__PURE__ */ jsxRuntime.jsx(JsonViewSection, { data: product }) })
40261
40264
  ] }),
40262
40265
  side: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
40263
- /* @__PURE__ */ jsxRuntime.jsx(ProductSalesChannelSection, { product }),
40264
- /* @__PURE__ */ jsxRuntime.jsx(ProductMediaSection, { product })
40266
+ /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "ProductSalesChannelSection", children: /* @__PURE__ */ jsxRuntime.jsx(ProductSalesChannelSection, { product }) }),
40267
+ /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "ProductMediaSection", children: /* @__PURE__ */ jsxRuntime.jsx(ProductMediaSection, { product }) })
40265
40268
  ] })
40266
40269
  }
40267
40270
  }
40268
40271
  );
40269
40272
  };
40270
40273
  const EditProductSchema$1 = zod.z.object({
40274
+ denominations: zod.z.array(
40275
+ zod.z.object({
40276
+ id: zod.z.string().optional(),
40277
+ value: zod.z.string().min(1),
40278
+ prices: zod.z.record(zod.z.string(), optionalFloat).optional()
40279
+ })
40280
+ ).min(1)
40281
+ });
40282
+ const GiftCardProductEditDenominationsForm = ({
40283
+ product
40284
+ }) => {
40285
+ var _a2;
40286
+ const { handleSuccess } = useRouteModal();
40287
+ const form = useForm({
40288
+ defaultValues: {
40289
+ denominations: (_a2 = product.variants) == null ? void 0 : _a2.map((variant) => ({
40290
+ id: variant.id,
40291
+ value: variant.title
40292
+ }))
40293
+ },
40294
+ resolver: t(EditProductSchema$1)
40295
+ });
40296
+ const { mutateAsync, isPending } = useUpdateProduct(product.id);
40297
+ const handleSubmit = form.handleSubmit(async (data) => {
40298
+ const optionValues = data.denominations.map(
40299
+ (denomination) => denomination.value
40300
+ );
40301
+ const options = [
40302
+ {
40303
+ title: "denomination",
40304
+ values: optionValues
40305
+ }
40306
+ ];
40307
+ await mutateAsync(
40308
+ {
40309
+ options,
40310
+ variants: data.denominations.map((denomination) => ({
40311
+ id: denomination.id,
40312
+ title: denomination.value,
40313
+ manage_inventory: false,
40314
+ options: {
40315
+ denomination: denomination.value
40316
+ }
40317
+ }))
40318
+ },
40319
+ {
40320
+ onSuccess: () => {
40321
+ ui.toast.success(`Denominations updated successfully`);
40322
+ handleSuccess();
40323
+ },
40324
+ onError: (e2) => {
40325
+ ui.toast.error(e2.message);
40326
+ }
40327
+ }
40328
+ );
40329
+ });
40330
+ const {
40331
+ fields: denominationsFields,
40332
+ append: addDenomination,
40333
+ remove: removeDenomination
40334
+ } = useFieldArray({
40335
+ name: "denominations",
40336
+ control: form.control
40337
+ });
40338
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
40339
+ KeyboundForm,
40340
+ {
40341
+ onSubmit: handleSubmit,
40342
+ className: "flex flex-1 flex-col overflow-hidden",
40343
+ children: [
40344
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-2", children: [
40345
+ denominationsFields.map((denominationField, index) => {
40346
+ return /* @__PURE__ */ jsxRuntime.jsxs(
40347
+ "div",
40348
+ {
40349
+ className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg flex items-center justify-between rounded-md px-4 py-2",
40350
+ children: [
40351
+ /* @__PURE__ */ jsxRuntime.jsx(
40352
+ Form$2.Field,
40353
+ {
40354
+ control: form.control,
40355
+ name: `denominations.${index}.value`,
40356
+ render: ({ field }) => {
40357
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
40358
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field, placeholder: "100" }) }),
40359
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
40360
+ ] });
40361
+ }
40362
+ },
40363
+ denominationField.id
40364
+ ),
40365
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsxRuntime.jsx(
40366
+ ui.Button,
40367
+ {
40368
+ size: "small",
40369
+ variant: "secondary",
40370
+ type: "button",
40371
+ className: "ml-4 rounded-full p-0",
40372
+ onClick: () => {
40373
+ removeDenomination(index);
40374
+ },
40375
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.XCircleSolid, { className: "rounded-full" })
40376
+ }
40377
+ ) })
40378
+ ]
40379
+ },
40380
+ denominationField.id
40381
+ );
40382
+ }),
40383
+ /* @__PURE__ */ jsxRuntime.jsx(
40384
+ ui.Button,
40385
+ {
40386
+ size: "small",
40387
+ variant: "secondary",
40388
+ type: "button",
40389
+ className: "w-full",
40390
+ onClick: () => {
40391
+ addDenomination({ value: "", prices: {} });
40392
+ },
40393
+ children: "Add denomination"
40394
+ }
40395
+ ),
40396
+ form.formState.errors.denominations && /* @__PURE__ */ jsxRuntime.jsx(ui.Alert, { variant: "error", children: "Please add at least one denomination." })
40397
+ ] }) }) }) }),
40398
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
40399
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
40400
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
40401
+ ] }) })
40402
+ ]
40403
+ }
40404
+ ) });
40405
+ };
40406
+ const GiftCardProductEdit$1 = () => {
40407
+ const { id } = reactRouterDom.useParams();
40408
+ const { product, isLoading, isError, error } = useProduct(id, {});
40409
+ if (isError) {
40410
+ throw error;
40411
+ }
40412
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
40413
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
40414
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift cards denominations" }) }),
40415
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
40416
+ ] }),
40417
+ !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditDenominationsForm, { product })
40418
+ ] });
40419
+ };
40420
+ const EditProductSchema = zod.z.object({
40271
40421
  status: zod.z.enum(["draft", "published", "proposed", "rejected"]),
40272
40422
  title: zod.z.string().min(1),
40273
40423
  subtitle: zod.z.string().optional(),
@@ -40286,7 +40436,7 @@ const GiftCardProductEditForm = ({
40286
40436
  handle: product.handle || "",
40287
40437
  description: product.description || ""
40288
40438
  },
40289
- resolver: t(EditProductSchema$1)
40439
+ resolver: t(EditProductSchema)
40290
40440
  });
40291
40441
  const { mutateAsync, isPending } = useUpdateProduct(product.id);
40292
40442
  const handleSubmit = form.handleSubmit(async (data) => {
@@ -40427,7 +40577,7 @@ const GiftCardProductEditForm = ({
40427
40577
  }
40428
40578
  ) });
40429
40579
  };
40430
- const GiftCardProductEdit$1 = () => {
40580
+ const GiftCardProductEdit = () => {
40431
40581
  const { id } = reactRouterDom.useParams();
40432
40582
  const { product, isLoading, isError, error } = useProduct(id, {});
40433
40583
  if (isError) {
@@ -40441,153 +40591,6 @@ const GiftCardProductEdit$1 = () => {
40441
40591
  !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditForm, { product })
40442
40592
  ] });
40443
40593
  };
40444
- const EditProductSchema = zod.z.object({
40445
- denominations: zod.z.array(
40446
- zod.z.object({
40447
- id: zod.z.string().optional(),
40448
- value: zod.z.string().min(1),
40449
- prices: zod.z.record(zod.z.string(), optionalFloat).optional()
40450
- })
40451
- ).min(1)
40452
- });
40453
- const GiftCardProductEditDenominationsForm = ({
40454
- product
40455
- }) => {
40456
- var _a2;
40457
- const { handleSuccess } = useRouteModal();
40458
- const form = useForm({
40459
- defaultValues: {
40460
- denominations: (_a2 = product.variants) == null ? void 0 : _a2.map((variant) => ({
40461
- id: variant.id,
40462
- value: variant.title
40463
- }))
40464
- },
40465
- resolver: t(EditProductSchema)
40466
- });
40467
- const { mutateAsync, isPending } = useUpdateProduct(product.id);
40468
- const handleSubmit = form.handleSubmit(async (data) => {
40469
- const optionValues = data.denominations.map(
40470
- (denomination) => denomination.value
40471
- );
40472
- const options = [
40473
- {
40474
- title: "denomination",
40475
- values: optionValues
40476
- }
40477
- ];
40478
- await mutateAsync(
40479
- {
40480
- options,
40481
- variants: data.denominations.map((denomination) => ({
40482
- id: denomination.id,
40483
- title: denomination.value,
40484
- manage_inventory: false,
40485
- options: {
40486
- denomination: denomination.value
40487
- }
40488
- }))
40489
- },
40490
- {
40491
- onSuccess: () => {
40492
- ui.toast.success(`Denominations updated successfully`);
40493
- handleSuccess();
40494
- },
40495
- onError: (e2) => {
40496
- ui.toast.error(e2.message);
40497
- }
40498
- }
40499
- );
40500
- });
40501
- const {
40502
- fields: denominationsFields,
40503
- append: addDenomination,
40504
- remove: removeDenomination
40505
- } = useFieldArray({
40506
- name: "denominations",
40507
- control: form.control
40508
- });
40509
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
40510
- KeyboundForm,
40511
- {
40512
- onSubmit: handleSubmit,
40513
- className: "flex flex-1 flex-col overflow-hidden",
40514
- children: [
40515
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-2", children: [
40516
- denominationsFields.map((denominationField, index) => {
40517
- return /* @__PURE__ */ jsxRuntime.jsxs(
40518
- "div",
40519
- {
40520
- className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg flex items-center justify-between rounded-md px-4 py-2",
40521
- children: [
40522
- /* @__PURE__ */ jsxRuntime.jsx(
40523
- Form$2.Field,
40524
- {
40525
- control: form.control,
40526
- name: `denominations.${index}.value`,
40527
- render: ({ field }) => {
40528
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
40529
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field, placeholder: "100" }) }),
40530
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
40531
- ] });
40532
- }
40533
- },
40534
- denominationField.id
40535
- ),
40536
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsxRuntime.jsx(
40537
- ui.Button,
40538
- {
40539
- size: "small",
40540
- variant: "secondary",
40541
- type: "button",
40542
- className: "ml-4 rounded-full p-0",
40543
- onClick: () => {
40544
- removeDenomination(index);
40545
- },
40546
- children: /* @__PURE__ */ jsxRuntime.jsx(icons.XCircleSolid, { className: "rounded-full" })
40547
- }
40548
- ) })
40549
- ]
40550
- },
40551
- denominationField.id
40552
- );
40553
- }),
40554
- /* @__PURE__ */ jsxRuntime.jsx(
40555
- ui.Button,
40556
- {
40557
- size: "small",
40558
- variant: "secondary",
40559
- type: "button",
40560
- className: "w-full",
40561
- onClick: () => {
40562
- addDenomination({ value: "", prices: {} });
40563
- },
40564
- children: "Add denomination"
40565
- }
40566
- ),
40567
- form.formState.errors.denominations && /* @__PURE__ */ jsxRuntime.jsx(ui.Alert, { variant: "error", children: "Please add at least one denomination." })
40568
- ] }) }) }) }),
40569
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
40570
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
40571
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
40572
- ] }) })
40573
- ]
40574
- }
40575
- ) });
40576
- };
40577
- const GiftCardProductEdit = () => {
40578
- const { id } = reactRouterDom.useParams();
40579
- const { product, isLoading, isError, error } = useProduct(id, {});
40580
- if (isError) {
40581
- throw error;
40582
- }
40583
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
40584
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
40585
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift cards denominations" }) }),
40586
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
40587
- ] }),
40588
- !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditDenominationsForm, { product })
40589
- ] });
40590
- };
40591
40594
  const EditProductMediaForm = ({ product }) => {
40592
40595
  const [selection, setSelection] = React.useState({});
40593
40596
  const { handleSuccess } = useRouteModal();
@@ -41202,7 +41205,7 @@ const ProductMedia = () => {
41202
41205
  ] });
41203
41206
  };
41204
41207
  const VariantPricingForm = ({ form }) => {
41205
- const { store } = useStore$2();
41208
+ const { store } = useStore$1();
41206
41209
  const { regions } = useRegions({ limit: 9999 });
41207
41210
  const { price_preferences: pricePreferences } = usePricePreferences({});
41208
41211
  const { setCloseOnEscape } = useRouteModal();
@@ -41468,19 +41471,32 @@ const ProductSalesChannels = () => {
41468
41471
  const widgetModule = { widgets: [
41469
41472
  {
41470
41473
  Component: CustomerStoreCreditWidget,
41471
- zone: ["customer.details.side.after"]
41474
+ zone: ["customer.details.side.after"],
41475
+ widgetId: "medusa:customer-store-credit-widget"
41472
41476
  },
41473
41477
  {
41474
41478
  Component: OrderGiftCardsWidget,
41475
- zone: ["order.details.side.after"]
41479
+ zone: ["order.details.side.after"],
41480
+ widgetId: "medusa:order-gift-cards-widget"
41476
41481
  },
41477
41482
  {
41478
41483
  Component: SalesChannelGiftCardsWidget,
41479
- zone: ["sales_channel.details.after"]
41484
+ zone: ["sales_channel.details.after"],
41485
+ widgetId: "medusa:sales-channel-gift-cards-widget"
41480
41486
  }
41481
41487
  ] };
41482
41488
  const routeModule = {
41483
41489
  routes: [
41490
+ {
41491
+ Component: StoreCreditAccountsPage,
41492
+ path: "/store-credit-accounts",
41493
+ children: [
41494
+ {
41495
+ Component: StoreCreditAccountCreate,
41496
+ path: "/store-credit-accounts/create"
41497
+ }
41498
+ ]
41499
+ },
41484
41500
  {
41485
41501
  Component: GiftCardsPage,
41486
41502
  path: "/gift-cards",
@@ -41492,12 +41508,12 @@ const routeModule = {
41492
41508
  ]
41493
41509
  },
41494
41510
  {
41495
- Component: StoreCreditAccountsPage,
41496
- path: "/store-credit-accounts",
41511
+ Component: StoreCreditAccountPage,
41512
+ path: "/store-credit-accounts/:id",
41497
41513
  children: [
41498
41514
  {
41499
- Component: StoreCreditAccountCreate,
41500
- path: "/store-credit-accounts/create"
41515
+ Component: Note$1,
41516
+ path: "/store-credit-accounts/:id/credit"
41501
41517
  }
41502
41518
  ]
41503
41519
  },
@@ -41510,7 +41526,7 @@ const routeModule = {
41510
41526
  path: "/gift-cards/:id/expiration"
41511
41527
  },
41512
41528
  {
41513
- Component: Note$1,
41529
+ Component: Note,
41514
41530
  path: "/gift-cards/:id/note"
41515
41531
  }
41516
41532
  ]
@@ -41525,27 +41541,17 @@ const routeModule = {
41525
41541
  }
41526
41542
  ]
41527
41543
  },
41528
- {
41529
- Component: StoreCreditAccountPage,
41530
- path: "/store-credit-accounts/:id",
41531
- children: [
41532
- {
41533
- Component: Note,
41534
- path: "/store-credit-accounts/:id/credit"
41535
- }
41536
- ]
41537
- },
41538
41544
  {
41539
41545
  Component: ProductDetail,
41540
41546
  path: "/gift-cards/gift-card-products/:id",
41541
41547
  children: [
41542
41548
  {
41543
41549
  Component: GiftCardProductEdit$1,
41544
- path: "/gift-cards/gift-card-products/:id/edit"
41550
+ path: "/gift-cards/gift-card-products/:id/denominations"
41545
41551
  },
41546
41552
  {
41547
41553
  Component: GiftCardProductEdit,
41548
- path: "/gift-cards/gift-card-products/:id/denominations"
41554
+ path: "/gift-cards/gift-card-products/:id/edit"
41549
41555
  }
41550
41556
  ]
41551
41557
  },
@@ -41566,16 +41572,16 @@ const routeModule = {
41566
41572
  const menuItemModule = {
41567
41573
  menuItems: [
41568
41574
  {
41569
- label: config$3.label,
41570
- icon: config$3.icon,
41575
+ label: config$2.label,
41576
+ icon: config$2.icon,
41571
41577
  path: "/gift-cards",
41572
41578
  nested: void 0,
41573
41579
  rank: void 0,
41574
41580
  translationNs: void 0
41575
41581
  },
41576
41582
  {
41577
- label: config$1.label,
41578
- icon: config$1.icon,
41583
+ label: config$3.label,
41584
+ icon: config$3.icon,
41579
41585
  path: "/store-credit-accounts",
41580
41586
  nested: void 0,
41581
41587
  rank: void 0,
@@ -41596,12 +41602,14 @@ const displayModule = {
41596
41602
  displays: {}
41597
41603
  };
41598
41604
  const i18nModule = { resources: {} };
41605
+ const layoutModule = { layouts: [] };
41599
41606
  const plugin = {
41600
41607
  widgetModule,
41601
41608
  routeModule,
41602
41609
  menuItemModule,
41603
41610
  formModule,
41604
41611
  displayModule,
41605
- i18nModule
41612
+ i18nModule,
41613
+ layoutModule
41606
41614
  };
41607
41615
  module.exports = plugin;