@medusajs/loyalty-plugin 2.16.0 → 2.16.1-preview-20260618184311

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;
@@ -5757,7 +5757,7 @@ const SalesChannelGiftCardsWidget = () => {
5757
5757
  adminSdk.defineWidgetConfig({
5758
5758
  zone: "sales_channel.details.after"
5759
5759
  });
5760
- const GiftCardIcon = (props) => {
5760
+ const StoreCreditIcon = (props) => {
5761
5761
  return /* @__PURE__ */ jsxRuntime.jsxs(
5762
5762
  "svg",
5763
5763
  {
@@ -5768,197 +5768,49 @@ const GiftCardIcon = (props) => {
5768
5768
  xmlns: "http://www.w3.org/2000/svg",
5769
5769
  ...props,
5770
5770
  children: [
5771
- /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#F97316" }),
5771
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#8B5CF6" }),
5772
5772
  /* @__PURE__ */ jsxRuntime.jsx(
5773
5773
  "rect",
5774
5774
  {
5775
5775
  width: "15",
5776
5776
  height: "15",
5777
- fill: "url(#paint0_linear_28788_25808)",
5777
+ fill: "url(#paint0_linear_29181_44790)",
5778
5778
  fillOpacity: "0.2"
5779
5779
  }
5780
5780
  ),
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
- ] })
5781
+ /* @__PURE__ */ jsxRuntime.jsx(
5782
+ "path",
5783
+ {
5784
+ d: "M12 6V5.813C12 4.675 11.075 3.75 9.938 3.75H5.063C3.925 3.75 3 4.675 3 5.813V6H12Z",
5785
+ fill: "white"
5786
+ }
5787
+ ),
5788
+ /* @__PURE__ */ jsxRuntime.jsx(
5789
+ "path",
5790
+ {
5791
+ 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",
5792
+ fill: "white"
5793
+ }
5794
+ ),
5795
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs(
5796
+ "linearGradient",
5797
+ {
5798
+ id: "paint0_linear_29181_44790",
5799
+ x1: "7.5",
5800
+ y1: "0",
5801
+ x2: "7.5",
5802
+ y2: "15",
5803
+ gradientUnits: "userSpaceOnUse",
5804
+ children: [
5805
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "white" }),
5806
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
5807
+ ]
5808
+ }
5809
+ ) })
5836
5810
  ]
5837
5811
  }
5838
5812
  );
5839
5813
  };
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
5814
  function getRelativeDate(date2) {
5963
5815
  const now2 = /* @__PURE__ */ new Date();
5964
5816
  return formatDistance(sub(new Date(date2), { minutes: 0 }), now2, {
@@ -5976,31 +5828,52 @@ function formatDate(date2, withTime = true) {
5976
5828
  return format$1(new Date(date2), "dd MMM, yyyy");
5977
5829
  }
5978
5830
  const columnHelper$a = ui.createDataTableColumnHelper();
5979
- const useGiftCardTableColumns = () => {
5831
+ const useStoreCreditAccountTableColumns = () => {
5980
5832
  return React.useMemo(() => {
5981
5833
  return [
5982
- columnHelper$a.accessor("code", {
5983
- header: "Code",
5834
+ columnHelper$a.accessor("currency_code", {
5835
+ header: "Currency",
5984
5836
  cell: ({ row }) => {
5985
- return row.original.code;
5837
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { size: "2xsmall", children: row.original.currency_code.toUpperCase() });
5986
5838
  }
5987
5839
  }),
5988
- columnHelper$a.accessor("line_item.product.title", {
5989
- header: "Product",
5840
+ columnHelper$a.accessor("customer.email", {
5841
+ header: "Customer",
5990
5842
  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";
5843
+ var _a2;
5844
+ return ((_a2 = row.original.customer) == null ? void 0 : _a2.email) ?? "N/A";
5993
5845
  }
5994
5846
  }),
5995
- columnHelper$a.accessor("created_at", {
5996
- header: "Date issued",
5997
- cell: ({ row }) => getRelativeDate(row.original.created_at)
5847
+ columnHelper$a.accessor("balance", {
5848
+ header: "Balance",
5849
+ cell: ({ row }) => {
5850
+ return formatAmount(
5851
+ row.original.balance,
5852
+ row.original.currency_code
5853
+ );
5854
+ }
5998
5855
  }),
5999
- columnHelper$a.accessor("value", {
6000
- header: "Value",
5856
+ columnHelper$a.accessor("credits", {
5857
+ header: "Credits",
6001
5858
  cell: ({ row }) => {
6002
- return formatAmount(row.original.value, row.original.currency_code);
5859
+ return formatAmount(
5860
+ row.original.credits,
5861
+ row.original.currency_code
5862
+ );
5863
+ }
5864
+ }),
5865
+ columnHelper$a.accessor("debits", {
5866
+ header: "Debits",
5867
+ cell: ({ row }) => {
5868
+ return formatAmount(
5869
+ row.original.debits,
5870
+ row.original.currency_code
5871
+ );
6003
5872
  }
5873
+ }),
5874
+ columnHelper$a.accessor("created_at", {
5875
+ header: "Created at",
5876
+ cell: ({ row }) => getRelativeDate(row.original.created_at)
6004
5877
  })
6005
5878
  ];
6006
5879
  }, []);
@@ -6047,75 +5920,83 @@ const useCustomerFilters = () => {
6047
5920
  ];
6048
5921
  }, [customerFilterOptions]);
6049
5922
  };
6050
- const useGiftCardFilters = () => {
5923
+ const useStoreCreditAccountFilters = () => {
6051
5924
  const dateFilterOptions = useDataTableDateFilters$1();
6052
5925
  const customerFilterOptions = useCustomerFilters();
6053
5926
  return React.useMemo(() => {
6054
5927
  return [...dateFilterOptions, ...customerFilterOptions];
6055
5928
  }, [dateFilterOptions, customerFilterOptions]);
6056
5929
  };
6057
- const useGiftCardTableQuery = ({
5930
+ const useStoreCreditAccountsTableQuery = ({
6058
5931
  prefix,
6059
5932
  pageSize = 20
6060
5933
  }) => {
6061
5934
  const queryObject = useQueryParams(
6062
- ["q", "offset", "customer_id", "created_at", "updated_at"],
5935
+ ["offset", "customer_id", "currency_code", "created_at", "updated_at"],
6063
5936
  prefix
6064
5937
  );
6065
- const { offset: offset2, created_at, updated_at, customer_id, ...rest } = queryObject;
5938
+ const {
5939
+ offset: offset2,
5940
+ created_at,
5941
+ updated_at,
5942
+ customer_id,
5943
+ currency_code,
5944
+ ...rest
5945
+ } = queryObject;
6066
5946
  const searchParams = {
6067
5947
  limit: pageSize,
6068
5948
  offset: offset2 ? Number(offset2) : 0,
6069
5949
  created_at: created_at ? JSON.parse(created_at) : void 0,
6070
5950
  updated_at: updated_at ? JSON.parse(updated_at) : void 0,
6071
5951
  customer_id: customer_id ? JSON.parse(customer_id) : void 0,
5952
+ currency_code: currency_code ? JSON.parse(currency_code) : void 0,
6072
5953
  ...rest
6073
5954
  };
6074
5955
  return searchParams;
6075
5956
  };
6076
5957
  const PAGE_SIZE$6 = 10;
6077
- function GiftCardsTable() {
6078
- const queryParams = useGiftCardTableQuery({
5958
+ function StoreCreditAccountsTable() {
5959
+ const queryParams = useStoreCreditAccountsTableQuery({
6079
5960
  pageSize: PAGE_SIZE$6
6080
5961
  });
6081
5962
  const {
6082
- gift_cards: giftCards,
5963
+ store_credit_accounts: storeCreditAccounts,
6083
5964
  isPending,
6084
5965
  count: count2
6085
- } = useGiftCards({
5966
+ } = useStoreCreditAccounts({
6086
5967
  ...queryParams,
6087
- order: queryParams.order ?? "-created_at",
6088
- fields: "+line_item.product.title"
5968
+ order: queryParams.order ?? "-created_at"
6089
5969
  });
6090
- const columns = useGiftCardTableColumns();
6091
- const filters = useGiftCardFilters();
5970
+ const columns = useStoreCreditAccountTableColumns();
5971
+ const filters = useStoreCreditAccountFilters();
6092
5972
  return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
6093
5973
  /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
6094
5974
  DataTable,
6095
5975
  {
6096
- data: giftCards,
5976
+ data: storeCreditAccounts ?? [],
6097
5977
  getRowId: (row) => row.id,
6098
5978
  columns,
6099
5979
  filters,
6100
5980
  isLoading: isPending,
6101
5981
  pageSize: PAGE_SIZE$6,
6102
5982
  rowCount: count2,
6103
- heading: "Gift Cards",
5983
+ enableSearch: false,
5984
+ heading: "Store Credit Accounts",
6104
5985
  rowHref: (row) => `${row.id}`,
6105
5986
  emptyState: {
6106
5987
  empty: {
6107
- heading: "No gift cards found",
6108
- description: "Create a gift card to get started."
5988
+ heading: "No store credit accounts found",
5989
+ description: "Create a new store credit account to get started."
6109
5990
  },
6110
5991
  filtered: {
6111
5992
  heading: "No results found",
6112
- description: "No gift cards match your filter criteria."
5993
+ description: "No store credit accounts match your filter criteria."
6113
5994
  }
6114
5995
  },
6115
5996
  actions: [
6116
5997
  {
6117
5998
  label: "Create",
6118
- to: "create"
5999
+ to: "/store-credit-accounts/create"
6119
6000
  }
6120
6001
  ]
6121
6002
  }
@@ -6123,16 +6004,15 @@ function GiftCardsTable() {
6123
6004
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
6124
6005
  ] });
6125
6006
  }
6126
- const GiftCardsPage = () => {
6007
+ const StoreCreditAccountsPage = () => {
6127
6008
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6128
6009
  /* @__PURE__ */ jsxRuntime.jsx(
6129
6010
  components.LayoutComposer,
6130
6011
  {
6131
- widgetsZonePrefix: "gift_card.list",
6132
- preferredLayoutId: "core:two-column",
6012
+ widgetsZonePrefix: "store_credit_account.list",
6013
+ preferredLayoutId: "core:single-column",
6133
6014
  sections: {
6134
- main: /* @__PURE__ */ jsxRuntime.jsx(GiftCardsTable, {}),
6135
- side: /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductsSection, {})
6015
+ main: /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountsTable, {})
6136
6016
  }
6137
6017
  }
6138
6018
  ),
@@ -6140,8 +6020,8 @@ const GiftCardsPage = () => {
6140
6020
  ] });
6141
6021
  };
6142
6022
  const config$3 = adminSdk.defineRouteConfig({
6143
- label: "Gift Cards",
6144
- icon: GiftCardIcon
6023
+ label: "Store Credits",
6024
+ icon: StoreCreditIcon
6145
6025
  });
6146
6026
  function setRef$2(ref, value) {
6147
6027
  if (typeof ref === "function") {
@@ -10060,28 +9940,6 @@ const StackedFocusModal = Object.assign(Root, {
10060
9940
  Description,
10061
9941
  Title
10062
9942
  });
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
9943
  var t$1 = function(t2, n2, e2) {
10086
9944
  if (t2 && "reportValidity" in t2) {
10087
9945
  var i2 = get$3(e2, n2);
@@ -11955,7 +11813,7 @@ function useStoreProps(store, props, key2, setKey) {
11955
11813
  });
11956
11814
  });
11957
11815
  }
11958
- function useStore$1(createStore2, props) {
11816
+ function useStore$2(createStore2, props) {
11959
11817
  const [store, setStore] = React__namespace.useState(() => createStore2(props));
11960
11818
  useSafeLayoutEffect(() => init(store), [store]);
11961
11819
  const useState2 = React__namespace.useCallback(
@@ -12777,7 +12635,7 @@ function useDisclosureStoreProps(store, update, props) {
12777
12635
  return Object.assign(store, { disclosure: props.disclosure });
12778
12636
  }
12779
12637
  function useDisclosureStore(props = {}) {
12780
- const [store, update] = useStore$1(createDisclosureStore, props);
12638
+ const [store, update] = useStore$2(createDisclosureStore, props);
12781
12639
  return useDisclosureStoreProps(store, update, props);
12782
12640
  }
12783
12641
  var ctx$2 = createStoreContext(
@@ -14166,7 +14024,7 @@ function useDialogStoreProps(store, update, props) {
14166
14024
  return useDisclosureStoreProps(store, update, props);
14167
14025
  }
14168
14026
  function useDialogStore(props = {}) {
14169
- const [store, update] = useStore$1(createDialogStore, props);
14027
+ const [store, update] = useStore$2(createDialogStore, props);
14170
14028
  return useDialogStoreProps(store, update, props);
14171
14029
  }
14172
14030
  var TagName$e = "div";
@@ -16212,7 +16070,7 @@ function useComboboxStoreProps(store, update, props) {
16212
16070
  }
16213
16071
  function useComboboxStore(props = {}) {
16214
16072
  props = useComboboxStoreOptions(props);
16215
- const [store, update] = useStore$1(createComboboxStore, props);
16073
+ const [store, update] = useStore$2(createComboboxStore, props);
16216
16074
  return useComboboxStoreProps(store, update, props);
16217
16075
  }
16218
16076
  function ComboboxProvider(props = {}) {
@@ -17318,6 +17176,270 @@ const ComboboxImpl = ({
17318
17176
  );
17319
17177
  };
17320
17178
  const Combobox = genericForwardRef(ComboboxImpl);
17179
+ function isObject$6(value) {
17180
+ var type = typeof value;
17181
+ return value != null && (type == "object" || type == "function");
17182
+ }
17183
+ var isObject_1 = isObject$6;
17184
+ var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
17185
+ var _freeGlobal = freeGlobal$1;
17186
+ var freeGlobal = _freeGlobal;
17187
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
17188
+ var root$4 = freeGlobal || freeSelf || Function("return this")();
17189
+ var _root = root$4;
17190
+ var root$3 = _root;
17191
+ var now$1 = function() {
17192
+ return root$3.Date.now();
17193
+ };
17194
+ var now_1 = now$1;
17195
+ var reWhitespace = /\s/;
17196
+ function trimmedEndIndex$1(string2) {
17197
+ var index = string2.length;
17198
+ while (index-- && reWhitespace.test(string2.charAt(index))) {
17199
+ }
17200
+ return index;
17201
+ }
17202
+ var _trimmedEndIndex = trimmedEndIndex$1;
17203
+ var trimmedEndIndex = _trimmedEndIndex;
17204
+ var reTrimStart = /^\s+/;
17205
+ function baseTrim$1(string2) {
17206
+ return string2 ? string2.slice(0, trimmedEndIndex(string2) + 1).replace(reTrimStart, "") : string2;
17207
+ }
17208
+ var _baseTrim = baseTrim$1;
17209
+ var root$2 = _root;
17210
+ var Symbol$4 = root$2.Symbol;
17211
+ var _Symbol = Symbol$4;
17212
+ var Symbol$3 = _Symbol;
17213
+ var objectProto$5 = Object.prototype;
17214
+ var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
17215
+ var nativeObjectToString$1 = objectProto$5.toString;
17216
+ var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
17217
+ function getRawTag$1(value) {
17218
+ var isOwn = hasOwnProperty$4.call(value, symToStringTag$1), tag = value[symToStringTag$1];
17219
+ try {
17220
+ value[symToStringTag$1] = void 0;
17221
+ var unmasked = true;
17222
+ } catch (e2) {
17223
+ }
17224
+ var result = nativeObjectToString$1.call(value);
17225
+ if (unmasked) {
17226
+ if (isOwn) {
17227
+ value[symToStringTag$1] = tag;
17228
+ } else {
17229
+ delete value[symToStringTag$1];
17230
+ }
17231
+ }
17232
+ return result;
17233
+ }
17234
+ var _getRawTag = getRawTag$1;
17235
+ var objectProto$4 = Object.prototype;
17236
+ var nativeObjectToString = objectProto$4.toString;
17237
+ function objectToString$1(value) {
17238
+ return nativeObjectToString.call(value);
17239
+ }
17240
+ var _objectToString = objectToString$1;
17241
+ var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
17242
+ var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
17243
+ var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
17244
+ function baseGetTag$2(value) {
17245
+ if (value == null) {
17246
+ return value === void 0 ? undefinedTag : nullTag;
17247
+ }
17248
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
17249
+ }
17250
+ var _baseGetTag = baseGetTag$2;
17251
+ function isObjectLike$1(value) {
17252
+ return value != null && typeof value == "object";
17253
+ }
17254
+ var isObjectLike_1 = isObjectLike$1;
17255
+ var baseGetTag$1 = _baseGetTag, isObjectLike = isObjectLike_1;
17256
+ var symbolTag = "[object Symbol]";
17257
+ function isSymbol$4(value) {
17258
+ return typeof value == "symbol" || isObjectLike(value) && baseGetTag$1(value) == symbolTag;
17259
+ }
17260
+ var isSymbol_1 = isSymbol$4;
17261
+ var baseTrim = _baseTrim, isObject$5 = isObject_1, isSymbol$3 = isSymbol_1;
17262
+ var NAN = 0 / 0;
17263
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
17264
+ var reIsBinary = /^0b[01]+$/i;
17265
+ var reIsOctal = /^0o[0-7]+$/i;
17266
+ var freeParseInt = parseInt;
17267
+ function toNumber$1(value) {
17268
+ if (typeof value == "number") {
17269
+ return value;
17270
+ }
17271
+ if (isSymbol$3(value)) {
17272
+ return NAN;
17273
+ }
17274
+ if (isObject$5(value)) {
17275
+ var other = typeof value.valueOf == "function" ? value.valueOf() : value;
17276
+ value = isObject$5(other) ? other + "" : other;
17277
+ }
17278
+ if (typeof value != "string") {
17279
+ return value === 0 ? value : +value;
17280
+ }
17281
+ value = baseTrim(value);
17282
+ var isBinary = reIsBinary.test(value);
17283
+ return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
17284
+ }
17285
+ var toNumber_1 = toNumber$1;
17286
+ var isObject$4 = isObject_1, now = now_1, toNumber = toNumber_1;
17287
+ var FUNC_ERROR_TEXT$1 = "Expected a function";
17288
+ var nativeMax = Math.max, nativeMin = Math.min;
17289
+ function debounce$2(func, wait, options) {
17290
+ var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
17291
+ if (typeof func != "function") {
17292
+ throw new TypeError(FUNC_ERROR_TEXT$1);
17293
+ }
17294
+ wait = toNumber(wait) || 0;
17295
+ if (isObject$4(options)) {
17296
+ leading = !!options.leading;
17297
+ maxing = "maxWait" in options;
17298
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
17299
+ trailing = "trailing" in options ? !!options.trailing : trailing;
17300
+ }
17301
+ function invokeFunc(time2) {
17302
+ var args = lastArgs, thisArg = lastThis;
17303
+ lastArgs = lastThis = void 0;
17304
+ lastInvokeTime = time2;
17305
+ result = func.apply(thisArg, args);
17306
+ return result;
17307
+ }
17308
+ function leadingEdge(time2) {
17309
+ lastInvokeTime = time2;
17310
+ timerId = setTimeout(timerExpired, wait);
17311
+ return leading ? invokeFunc(time2) : result;
17312
+ }
17313
+ function remainingWait(time2) {
17314
+ var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
17315
+ return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
17316
+ }
17317
+ function shouldInvoke(time2) {
17318
+ var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime;
17319
+ return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
17320
+ }
17321
+ function timerExpired() {
17322
+ var time2 = now();
17323
+ if (shouldInvoke(time2)) {
17324
+ return trailingEdge(time2);
17325
+ }
17326
+ timerId = setTimeout(timerExpired, remainingWait(time2));
17327
+ }
17328
+ function trailingEdge(time2) {
17329
+ timerId = void 0;
17330
+ if (trailing && lastArgs) {
17331
+ return invokeFunc(time2);
17332
+ }
17333
+ lastArgs = lastThis = void 0;
17334
+ return result;
17335
+ }
17336
+ function cancel() {
17337
+ if (timerId !== void 0) {
17338
+ clearTimeout(timerId);
17339
+ }
17340
+ lastInvokeTime = 0;
17341
+ lastArgs = lastCallTime = lastThis = timerId = void 0;
17342
+ }
17343
+ function flush() {
17344
+ return timerId === void 0 ? result : trailingEdge(now());
17345
+ }
17346
+ function debounced() {
17347
+ var time2 = now(), isInvoking = shouldInvoke(time2);
17348
+ lastArgs = arguments;
17349
+ lastThis = this;
17350
+ lastCallTime = time2;
17351
+ if (isInvoking) {
17352
+ if (timerId === void 0) {
17353
+ return leadingEdge(lastCallTime);
17354
+ }
17355
+ if (maxing) {
17356
+ clearTimeout(timerId);
17357
+ timerId = setTimeout(timerExpired, wait);
17358
+ return invokeFunc(lastCallTime);
17359
+ }
17360
+ }
17361
+ if (timerId === void 0) {
17362
+ timerId = setTimeout(timerExpired, wait);
17363
+ }
17364
+ return result;
17365
+ }
17366
+ debounced.cancel = cancel;
17367
+ debounced.flush = flush;
17368
+ return debounced;
17369
+ }
17370
+ var debounce_1 = debounce$2;
17371
+ const debounce$1 = /* @__PURE__ */ getDefaultExportFromCjs(debounce_1);
17372
+ const useDebouncedSearch = () => {
17373
+ const [searchValue, onSearchValueChange] = React.useState("");
17374
+ const [debouncedQuery, setDebouncedQuery] = React.useState("");
17375
+ const debouncedUpdate = React.useCallback(
17376
+ debounce$1((query) => setDebouncedQuery(query), 300),
17377
+ []
17378
+ );
17379
+ React.useEffect(() => {
17380
+ debouncedUpdate(searchValue);
17381
+ return () => debouncedUpdate.cancel();
17382
+ }, [searchValue, debouncedUpdate]);
17383
+ return {
17384
+ searchValue,
17385
+ onSearchValueChange,
17386
+ query: debouncedQuery || void 0
17387
+ };
17388
+ };
17389
+ const useComboboxData = ({
17390
+ queryKey,
17391
+ queryFn,
17392
+ getOptions,
17393
+ defaultValue: defaultValue2,
17394
+ defaultValueKey,
17395
+ pageSize = 10
17396
+ }) => {
17397
+ const { searchValue, onSearchValueChange, query } = useDebouncedSearch();
17398
+ const queryInitialDataBy = defaultValueKey || "id";
17399
+ const { data: initialData } = reactQuery.useQuery({
17400
+ queryKey,
17401
+ queryFn: async () => {
17402
+ return queryFn({
17403
+ [queryInitialDataBy]: defaultValue2,
17404
+ limit: Array.isArray(defaultValue2) ? defaultValue2.length : 1
17405
+ });
17406
+ },
17407
+ enabled: !!defaultValue2
17408
+ });
17409
+ const { data, ...rest } = reactQuery.useInfiniteQuery({
17410
+ queryKey: [...queryKey, query],
17411
+ queryFn: async ({ pageParam = 0 }) => {
17412
+ return await queryFn({
17413
+ q: query,
17414
+ limit: pageSize,
17415
+ offset: pageParam
17416
+ });
17417
+ },
17418
+ initialPageParam: 0,
17419
+ getNextPageParam: (lastPage) => {
17420
+ const moreItemsExist = lastPage.count > lastPage.offset + lastPage.limit;
17421
+ return moreItemsExist ? lastPage.offset + lastPage.limit : void 0;
17422
+ },
17423
+ placeholderData: reactQuery.keepPreviousData
17424
+ });
17425
+ const options = (data == null ? void 0 : data.pages.flatMap((page) => getOptions(page))) ?? [];
17426
+ const defaultOptions2 = initialData ? getOptions(initialData) : [];
17427
+ const disabled = !rest.isPending && !options.length && !searchValue;
17428
+ if (defaultValue2 && defaultOptions2.length && !searchValue) {
17429
+ defaultOptions2.forEach((option) => {
17430
+ if (!options.find((o2) => o2.value === option.value)) {
17431
+ options.unshift(option);
17432
+ }
17433
+ });
17434
+ }
17435
+ return {
17436
+ options,
17437
+ searchValue,
17438
+ onSearchValueChange,
17439
+ disabled,
17440
+ ...rest
17441
+ };
17442
+ };
17321
17443
  const currencies = {
17322
17444
  USD: {
17323
17445
  code: "USD",
@@ -18046,6 +18168,504 @@ const currencies = {
18046
18168
  decimal_digits: 0
18047
18169
  }
18048
18170
  };
18171
+ const formSchema = zod.z.object({
18172
+ currency_code: zod.z.string().min(1, "Please select a currency"),
18173
+ customer_id: zod.z.string().optional()
18174
+ });
18175
+ const StoreCreditAccountCreateForm = () => {
18176
+ const { handleSuccess } = useRouteModal();
18177
+ const form = useForm({
18178
+ defaultValues: {
18179
+ currency_code: "",
18180
+ customer_id: ""
18181
+ },
18182
+ resolver: t(formSchema)
18183
+ });
18184
+ const { mutateAsync: createStoreCreditAccount, isPending } = useCreateStoreCreditAccount();
18185
+ const handleSubmit = form.handleSubmit(async (data) => {
18186
+ if (!data.customer_id) {
18187
+ delete data.customer_id;
18188
+ }
18189
+ await createStoreCreditAccount(data, {
18190
+ onSuccess: (data2) => {
18191
+ ui.toast.success(`Store credit account was successfully created.`);
18192
+ handleSuccess(`../${data2.store_credit_account.id}`);
18193
+ },
18194
+ onError: (error) => {
18195
+ ui.toast.error(error.message);
18196
+ }
18197
+ });
18198
+ });
18199
+ const [currencySearchValue, setCurrencySearchValue] = React.useState("");
18200
+ const currencyOptions = React.useMemo(() => {
18201
+ const options = Object.values(currencies).map((currency) => ({
18202
+ label: `${currency.code} - ${currency.name} (${currency.symbol_native})`,
18203
+ value: currency.code.toLowerCase()
18204
+ }));
18205
+ if (!currencySearchValue) {
18206
+ return options;
18207
+ }
18208
+ return options.filter(
18209
+ (option) => option.label.toLowerCase().includes(currencySearchValue.toLowerCase())
18210
+ );
18211
+ }, [currencySearchValue]);
18212
+ const {
18213
+ options: customerOptions,
18214
+ fetchNextPage,
18215
+ isFetchingNextPage,
18216
+ searchValue,
18217
+ onSearchValueChange,
18218
+ isLoading
18219
+ } = useComboboxData({
18220
+ queryKey: customersQueryKeys.list(),
18221
+ queryFn: async (params) => {
18222
+ return sdk.admin.customer.list(params);
18223
+ },
18224
+ getOptions: (data) => {
18225
+ var _a2;
18226
+ return ((_a2 = data.customers) == null ? void 0 : _a2.map((customer) => {
18227
+ const fullName = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
18228
+ const label = fullName ? `${customer.email} (${fullName})` : customer.email;
18229
+ return {
18230
+ label,
18231
+ value: customer.id
18232
+ };
18233
+ })) || [];
18234
+ }
18235
+ });
18236
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Form, { form, children: [
18237
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "-my-2 w-full border-l" }) }),
18238
+ /* @__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: [
18239
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
18240
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Create Store Credit Account" }),
18241
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", size: "small", children: "Create a new store credit account for a customer" })
18242
+ ] }),
18243
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-x-4", children: [
18244
+ /* @__PURE__ */ jsxRuntime.jsx(
18245
+ Form$2.Field,
18246
+ {
18247
+ control: form.control,
18248
+ name: "currency_code",
18249
+ render: ({ field }) => {
18250
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
18251
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Currency" }),
18252
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
18253
+ Combobox,
18254
+ {
18255
+ value: field.value,
18256
+ onChange: field.onChange,
18257
+ searchValue: currencySearchValue,
18258
+ onSearchValueChange: setCurrencySearchValue,
18259
+ options: currencyOptions,
18260
+ placeholder: "Search for a currency..."
18261
+ }
18262
+ ) }),
18263
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
18264
+ ] });
18265
+ }
18266
+ }
18267
+ ),
18268
+ /* @__PURE__ */ jsxRuntime.jsx(
18269
+ Form$2.Field,
18270
+ {
18271
+ control: form.control,
18272
+ name: "customer_id",
18273
+ render: ({ field }) => {
18274
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
18275
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Customer" }),
18276
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
18277
+ Combobox,
18278
+ {
18279
+ value: field.value,
18280
+ onChange: field.onChange,
18281
+ searchValue,
18282
+ onSearchValueChange,
18283
+ options: customerOptions,
18284
+ placeholder: "Search for a customer...",
18285
+ fetchNextPage,
18286
+ isFetchingNextPage,
18287
+ noResultsPlaceholder: isLoading ? "Loading customers..." : "No customers found"
18288
+ }
18289
+ ) }),
18290
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
18291
+ ] });
18292
+ }
18293
+ }
18294
+ )
18295
+ ] })
18296
+ ] }) }) }),
18297
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Footer, { children: [
18298
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, disabled: isPending, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", disabled: isPending, children: "Cancel" }) }),
18299
+ /* @__PURE__ */ jsxRuntime.jsx(
18300
+ ui.Button,
18301
+ {
18302
+ variant: "primary",
18303
+ size: "small",
18304
+ onClick: handleSubmit,
18305
+ disabled: isPending,
18306
+ children: "Create"
18307
+ }
18308
+ )
18309
+ ] })
18310
+ ] });
18311
+ };
18312
+ const StoreCreditAccountCreate = () => {
18313
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal, { children: [
18314
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create Store Credit Account" }) }),
18315
+ /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create a new store credit account" }) }),
18316
+ /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCreateForm, {})
18317
+ ] });
18318
+ };
18319
+ const GiftCardIcon = (props) => {
18320
+ return /* @__PURE__ */ jsxRuntime.jsxs(
18321
+ "svg",
18322
+ {
18323
+ width: "15",
18324
+ height: "15",
18325
+ viewBox: "0 0 15 15",
18326
+ fill: "none",
18327
+ xmlns: "http://www.w3.org/2000/svg",
18328
+ ...props,
18329
+ children: [
18330
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#F97316" }),
18331
+ /* @__PURE__ */ jsxRuntime.jsx(
18332
+ "rect",
18333
+ {
18334
+ width: "15",
18335
+ height: "15",
18336
+ fill: "url(#paint0_linear_28788_25808)",
18337
+ fillOpacity: "0.2"
18338
+ }
18339
+ ),
18340
+ /* @__PURE__ */ jsxRuntime.jsxs("g", { clipPath: "url(#clip0_28788_25808)", children: [
18341
+ /* @__PURE__ */ jsxRuntime.jsx(
18342
+ "path",
18343
+ {
18344
+ 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",
18345
+ fill: "white"
18346
+ }
18347
+ ),
18348
+ /* @__PURE__ */ jsxRuntime.jsx(
18349
+ "path",
18350
+ {
18351
+ 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",
18352
+ fill: "white"
18353
+ }
18354
+ ),
18355
+ /* @__PURE__ */ jsxRuntime.jsx(
18356
+ "path",
18357
+ {
18358
+ 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",
18359
+ fill: "white"
18360
+ }
18361
+ ),
18362
+ /* @__PURE__ */ jsxRuntime.jsx(
18363
+ "path",
18364
+ {
18365
+ d: "M6.938 7.5H3.75V9.563C3.75 10.7 4.675 11.625 5.813 11.625H6.938V7.5Z",
18366
+ fill: "white"
18367
+ }
18368
+ ),
18369
+ /* @__PURE__ */ jsxRuntime.jsx(
18370
+ "path",
18371
+ {
18372
+ d: "M8.063 7.5V11.625H9.188C10.325 11.625 11.25 10.7 11.25 9.563V7.5H8.063Z",
18373
+ fill: "white"
18374
+ }
18375
+ )
18376
+ ] }),
18377
+ /* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
18378
+ /* @__PURE__ */ jsxRuntime.jsxs(
18379
+ "linearGradient",
18380
+ {
18381
+ id: "paint0_linear_28788_25808",
18382
+ x1: "7.5",
18383
+ y1: "0",
18384
+ x2: "7.5",
18385
+ y2: "15",
18386
+ gradientUnits: "userSpaceOnUse",
18387
+ children: [
18388
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "white" }),
18389
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
18390
+ ]
18391
+ }
18392
+ ),
18393
+ /* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_28788_25808", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "9", height: "9", fill: "white", transform: "translate(3 3)" }) })
18394
+ ] })
18395
+ ]
18396
+ }
18397
+ );
18398
+ };
18399
+ const GiftCardProductsSection = () => {
18400
+ const { products: giftCardProducts, count: count2 = 0 } = useProducts({
18401
+ is_giftcard: true
18402
+ });
18403
+ const slicedProducts = (giftCardProducts == null ? void 0 : giftCardProducts.slice(0, 3)) ?? [];
18404
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
18405
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
18406
+ /* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Gift Card Products" }),
18407
+ /* @__PURE__ */ jsxRuntime.jsx(
18408
+ reactRouterDom.Link,
18409
+ {
18410
+ to: `/gift-cards/gift-card-products/create`,
18411
+ className: "text-ui-fg-muted text-sm px-6",
18412
+ children: "Create"
18413
+ }
18414
+ )
18415
+ ] }),
18416
+ (giftCardProducts == null ? void 0 : giftCardProducts.length) === 0 && /* @__PURE__ */ jsxRuntime.jsx(
18417
+ NoRecords,
18418
+ {
18419
+ className: "px-10 py-4 h-[200px]",
18420
+ title: "No gift card products",
18421
+ message: "There are no gift card products to show. Create one to get started.",
18422
+ action: {
18423
+ to: "/gift-cards/gift-card-products/create",
18424
+ label: "Create gift card product"
18425
+ }
18426
+ }
18427
+ ),
18428
+ slicedProducts.map((giftCardProduct) => /* @__PURE__ */ jsxRuntime.jsx(
18429
+ SidebarLink,
18430
+ {
18431
+ to: `/gift-cards/gift-card-products/${giftCardProduct.id}`,
18432
+ labelKey: giftCardProduct.title,
18433
+ descriptionKey: giftCardProduct.title,
18434
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Tag, {})
18435
+ }
18436
+ )),
18437
+ count2 > 3 && /* @__PURE__ */ jsxRuntime.jsx(
18438
+ reactRouterDom.Link,
18439
+ {
18440
+ to: "/gift-cards/gift-card-products",
18441
+ className: "text-ui-fg-muted text-sm px-6 py-4 flex items-center justify-center",
18442
+ children: "View more"
18443
+ }
18444
+ )
18445
+ ] });
18446
+ };
18447
+ const _giftCardQueryKey = queryKeysFactory("gift-card");
18448
+ const giftCardQueryKey = {
18449
+ ..._giftCardQueryKey,
18450
+ orders: (id) => [..._giftCardQueryKey.detail(id), "orders"]
18451
+ };
18452
+ const useGiftCards = (query, options) => {
18453
+ const fetchGiftCards = (query2, headers) => sdk.client.fetch(`/admin/gift-cards`, {
18454
+ query: query2,
18455
+ headers
18456
+ });
18457
+ const { data, ...rest } = reactQuery.useQuery({
18458
+ ...options,
18459
+ queryFn: () => fetchGiftCards(query),
18460
+ queryKey: giftCardQueryKey.list(query)
18461
+ });
18462
+ return { ...data, ...rest };
18463
+ };
18464
+ const useGiftCard = (id, query, options) => {
18465
+ const fetchGiftCard = (id2, query2, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
18466
+ query: query2,
18467
+ headers
18468
+ });
18469
+ const { data, ...rest } = reactQuery.useQuery({
18470
+ queryFn: () => fetchGiftCard(id, query),
18471
+ queryKey: giftCardQueryKey.detail(id, query),
18472
+ ...options
18473
+ });
18474
+ return { ...data, ...rest };
18475
+ };
18476
+ const useGiftCardOrders = (id, options) => {
18477
+ const fetchGiftCardOrders = (id2, query, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}/orders`, {
18478
+ query,
18479
+ headers
18480
+ });
18481
+ const { data, ...rest } = reactQuery.useQuery({
18482
+ queryFn: () => fetchGiftCardOrders(id),
18483
+ queryKey: giftCardQueryKey.orders(id),
18484
+ ...options
18485
+ });
18486
+ return { ...data, ...rest };
18487
+ };
18488
+ const useUpdateGiftCard = (id, options) => {
18489
+ const queryClient = reactQuery.useQueryClient();
18490
+ const updateGiftCard = async (id2, body) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
18491
+ body,
18492
+ method: "POST"
18493
+ });
18494
+ return reactQuery.useMutation({
18495
+ mutationFn: async (payload) => updateGiftCard(id, payload),
18496
+ onSuccess: (data, variables, context) => {
18497
+ queryClient.invalidateQueries({
18498
+ queryKey: giftCardQueryKey.detail(id)
18499
+ });
18500
+ queryClient.invalidateQueries({
18501
+ queryKey: giftCardQueryKey.lists()
18502
+ });
18503
+ },
18504
+ ...options
18505
+ });
18506
+ };
18507
+ const useCreateGiftCard = (options) => {
18508
+ const queryClient = reactQuery.useQueryClient();
18509
+ const createGiftCard = async (body) => sdk.client.fetch(`/admin/gift-cards`, {
18510
+ body,
18511
+ method: "POST"
18512
+ });
18513
+ return reactQuery.useMutation({
18514
+ mutationFn: (body) => createGiftCard(body),
18515
+ onSuccess: (data, variables, context) => {
18516
+ queryClient.invalidateQueries({ queryKey: giftCardQueryKey.lists() });
18517
+ },
18518
+ ...options
18519
+ });
18520
+ };
18521
+ const columnHelper$9 = ui.createDataTableColumnHelper();
18522
+ const useGiftCardTableColumns = () => {
18523
+ return React.useMemo(() => {
18524
+ return [
18525
+ columnHelper$9.accessor("code", {
18526
+ header: "Code",
18527
+ cell: ({ row }) => {
18528
+ return row.original.code;
18529
+ }
18530
+ }),
18531
+ columnHelper$9.accessor("line_item.product.title", {
18532
+ header: "Product",
18533
+ cell: ({ row }) => {
18534
+ var _a2, _b;
18535
+ return ((_b = (_a2 = row.original.line_item) == null ? void 0 : _a2.product) == null ? void 0 : _b.title) || "Custom Gift Card";
18536
+ }
18537
+ }),
18538
+ columnHelper$9.accessor("created_at", {
18539
+ header: "Date issued",
18540
+ cell: ({ row }) => getRelativeDate(row.original.created_at)
18541
+ }),
18542
+ columnHelper$9.accessor("value", {
18543
+ header: "Value",
18544
+ cell: ({ row }) => {
18545
+ return formatAmount(row.original.value, row.original.currency_code);
18546
+ }
18547
+ })
18548
+ ];
18549
+ }, []);
18550
+ };
18551
+ const useGiftCardFilters = () => {
18552
+ const dateFilterOptions = useDataTableDateFilters$1();
18553
+ const customerFilterOptions = useCustomerFilters();
18554
+ return React.useMemo(() => {
18555
+ return [...dateFilterOptions, ...customerFilterOptions];
18556
+ }, [dateFilterOptions, customerFilterOptions]);
18557
+ };
18558
+ const useGiftCardTableQuery = ({
18559
+ prefix,
18560
+ pageSize = 20
18561
+ }) => {
18562
+ const queryObject = useQueryParams(
18563
+ ["q", "offset", "customer_id", "created_at", "updated_at"],
18564
+ prefix
18565
+ );
18566
+ const { offset: offset2, created_at, updated_at, customer_id, ...rest } = queryObject;
18567
+ const searchParams = {
18568
+ limit: pageSize,
18569
+ offset: offset2 ? Number(offset2) : 0,
18570
+ created_at: created_at ? JSON.parse(created_at) : void 0,
18571
+ updated_at: updated_at ? JSON.parse(updated_at) : void 0,
18572
+ customer_id: customer_id ? JSON.parse(customer_id) : void 0,
18573
+ ...rest
18574
+ };
18575
+ return searchParams;
18576
+ };
18577
+ const PAGE_SIZE$5 = 10;
18578
+ function GiftCardsTable() {
18579
+ const queryParams = useGiftCardTableQuery({
18580
+ pageSize: PAGE_SIZE$5
18581
+ });
18582
+ const {
18583
+ gift_cards: giftCards,
18584
+ isPending,
18585
+ count: count2
18586
+ } = useGiftCards({
18587
+ ...queryParams,
18588
+ order: queryParams.order ?? "-created_at",
18589
+ fields: "+line_item.product.title"
18590
+ });
18591
+ const columns = useGiftCardTableColumns();
18592
+ const filters = useGiftCardFilters();
18593
+ return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
18594
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
18595
+ DataTable,
18596
+ {
18597
+ data: giftCards,
18598
+ getRowId: (row) => row.id,
18599
+ columns,
18600
+ filters,
18601
+ isLoading: isPending,
18602
+ pageSize: PAGE_SIZE$5,
18603
+ rowCount: count2,
18604
+ heading: "Gift Cards",
18605
+ rowHref: (row) => `${row.id}`,
18606
+ emptyState: {
18607
+ empty: {
18608
+ heading: "No gift cards found",
18609
+ description: "Create a gift card to get started."
18610
+ },
18611
+ filtered: {
18612
+ heading: "No results found",
18613
+ description: "No gift cards match your filter criteria."
18614
+ }
18615
+ },
18616
+ actions: [
18617
+ {
18618
+ label: "Create",
18619
+ to: "create"
18620
+ }
18621
+ ]
18622
+ }
18623
+ ) }),
18624
+ /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
18625
+ ] });
18626
+ }
18627
+ const GiftCardsPage = () => {
18628
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
18629
+ /* @__PURE__ */ jsxRuntime.jsx(
18630
+ components.LayoutComposer,
18631
+ {
18632
+ widgetsZonePrefix: "gift_card.list",
18633
+ preferredLayoutId: "core:two-column",
18634
+ sections: {
18635
+ main: /* @__PURE__ */ jsxRuntime.jsx(GiftCardsTable, {}),
18636
+ side: /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductsSection, {})
18637
+ }
18638
+ }
18639
+ ),
18640
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Toaster, {})
18641
+ ] });
18642
+ };
18643
+ const config$2 = adminSdk.defineRouteConfig({
18644
+ label: "Gift Cards",
18645
+ icon: GiftCardIcon
18646
+ });
18647
+ const STORE_QUERY_KEY = "store";
18648
+ const storeQueryKeys = queryKeysFactory(STORE_QUERY_KEY);
18649
+ async function retrieveActiveStore(query) {
18650
+ var _a2;
18651
+ const response = await sdk.admin.store.list(query);
18652
+ const activeStore = (_a2 = response.stores) == null ? void 0 : _a2[0];
18653
+ if (!activeStore) {
18654
+ throw new Medusa.FetchError("No active store found", "Not Found", 404);
18655
+ }
18656
+ return { store: activeStore };
18657
+ }
18658
+ const useStore$1 = (query, options) => {
18659
+ const { data, ...rest } = reactQuery.useQuery({
18660
+ queryFn: () => retrieveActiveStore(query),
18661
+ queryKey: storeQueryKeys.details(),
18662
+ ...options
18663
+ });
18664
+ return {
18665
+ ...data,
18666
+ ...rest
18667
+ };
18668
+ };
18049
18669
  function $constructor(name, initializer2, params) {
18050
18670
  function init2(inst, def) {
18051
18671
  if (!inst._zod) {
@@ -18110,7 +18730,7 @@ class $ZodEncodeError extends Error {
18110
18730
  }
18111
18731
  }
18112
18732
  const globalConfig = {};
18113
- function config$2(newConfig) {
18733
+ function config$1(newConfig) {
18114
18734
  return globalConfig;
18115
18735
  }
18116
18736
  function getEnumValues(entries) {
@@ -18204,7 +18824,7 @@ function slugify(input) {
18204
18824
  }
18205
18825
  const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
18206
18826
  };
18207
- function isObject$6(data) {
18827
+ function isObject$3(data) {
18208
18828
  return typeof data === "object" && data !== null && !Array.isArray(data);
18209
18829
  }
18210
18830
  const allowsEval = cached(() => {
@@ -18221,7 +18841,7 @@ const allowsEval = cached(() => {
18221
18841
  }
18222
18842
  });
18223
18843
  function isPlainObject(o2) {
18224
- if (isObject$6(o2) === false)
18844
+ if (isObject$3(o2) === false)
18225
18845
  return false;
18226
18846
  const ctor = o2.constructor;
18227
18847
  if (ctor === void 0)
@@ -18229,7 +18849,7 @@ function isPlainObject(o2) {
18229
18849
  if (typeof ctor !== "function")
18230
18850
  return true;
18231
18851
  const prot = ctor.prototype;
18232
- if (isObject$6(prot) === false)
18852
+ if (isObject$3(prot) === false)
18233
18853
  return false;
18234
18854
  if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
18235
18855
  return false;
@@ -18560,7 +19180,7 @@ const _parse = (_Err) => (schema2, value, _ctx, _params) => {
18560
19180
  throw new $ZodAsyncError();
18561
19181
  }
18562
19182
  if (result.issues.length) {
18563
- const e2 = new ((_params == null ? void 0 : _params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())));
19183
+ const e2 = new ((_params == null ? void 0 : _params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())));
18564
19184
  captureStackTrace(e2, _params == null ? void 0 : _params.callee);
18565
19185
  throw e2;
18566
19186
  }
@@ -18572,7 +19192,7 @@ const _parseAsync = (_Err) => async (schema2, value, _ctx, params) => {
18572
19192
  if (result instanceof Promise)
18573
19193
  result = await result;
18574
19194
  if (result.issues.length) {
18575
- const e2 = new ((params == null ? void 0 : params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())));
19195
+ const e2 = new ((params == null ? void 0 : params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())));
18576
19196
  captureStackTrace(e2, params == null ? void 0 : params.callee);
18577
19197
  throw e2;
18578
19198
  }
@@ -18586,7 +19206,7 @@ const _safeParse = (_Err) => (schema2, value, _ctx) => {
18586
19206
  }
18587
19207
  return result.issues.length ? {
18588
19208
  success: false,
18589
- error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())))
19209
+ error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())))
18590
19210
  } : { success: true, data: result.value };
18591
19211
  };
18592
19212
  const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
@@ -18597,7 +19217,7 @@ const _safeParseAsync = (_Err) => async (schema2, value, _ctx) => {
18597
19217
  result = await result;
18598
19218
  return result.issues.length ? {
18599
19219
  success: false,
18600
- error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())))
19220
+ error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())))
18601
19221
  } : { success: true, data: result.value };
18602
19222
  };
18603
19223
  const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
@@ -19736,7 +20356,7 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
19736
20356
  }
19737
20357
  return propValues;
19738
20358
  });
19739
- const isObject2 = isObject$6;
20359
+ const isObject2 = isObject$3;
19740
20360
  const catchall = def.catchall;
19741
20361
  let value;
19742
20362
  inst._zod.parse = (payload, ctx2) => {
@@ -19816,7 +20436,7 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
19816
20436
  return (payload, ctx2) => fn(shape, payload, ctx2);
19817
20437
  };
19818
20438
  let fastpass;
19819
- const isObject2 = isObject$6;
20439
+ const isObject2 = isObject$3;
19820
20440
  const jit = !globalConfig.jitless;
19821
20441
  const allowsEval$1 = allowsEval;
19822
20442
  const fastEnabled = jit && allowsEval$1.value;
@@ -19861,7 +20481,7 @@ function handleUnionResults(results, final, inst, ctx2) {
19861
20481
  code: "invalid_union",
19862
20482
  input: final.value,
19863
20483
  inst,
19864
- errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())))
20484
+ errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())))
19865
20485
  });
19866
20486
  return final;
19867
20487
  }
@@ -20054,7 +20674,7 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
20054
20674
  payload.issues.push({
20055
20675
  code: "invalid_key",
20056
20676
  origin: "record",
20057
- issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())),
20677
+ issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())),
20058
20678
  input: key2,
20059
20679
  path: [key2],
20060
20680
  inst
@@ -20253,7 +20873,7 @@ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
20253
20873
  payload.value = def.catchValue({
20254
20874
  ...payload,
20255
20875
  error: {
20256
- issues: result2.issues.map((iss) => finalizeIssue(iss, ctx2, config$2()))
20876
+ issues: result2.issues.map((iss) => finalizeIssue(iss, ctx2, config$1()))
20257
20877
  },
20258
20878
  input: payload.value
20259
20879
  });
@@ -20267,7 +20887,7 @@ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
20267
20887
  payload.value = def.catchValue({
20268
20888
  ...payload,
20269
20889
  error: {
20270
- issues: result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2()))
20890
+ issues: result.issues.map((iss) => finalizeIssue(iss, ctx2, config$1()))
20271
20891
  },
20272
20892
  input: payload.value
20273
20893
  });
@@ -22327,633 +22947,546 @@ const GiftCardCreateForm = ({
22327
22947
  ] });
22328
22948
  };
22329
22949
  const GiftCardCreate = () => {
22330
- const { store, isLoading } = useStore$2({});
22950
+ const { store, isLoading } = useStore$1({});
22331
22951
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal, { children: [
22332
22952
  /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create Gift Card" }) }),
22333
22953
  /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create a new gift card" }) }),
22334
22954
  !isLoading && /* @__PURE__ */ jsxRuntime.jsx(GiftCardCreateForm, { store })
22335
22955
  ] });
22336
22956
  };
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",
22957
+ const StoreCreditAccountBalanceSection = ({
22958
+ storeCreditAccount
22959
+ }) => {
22960
+ if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
22961
+ return;
22962
+ }
22963
+ 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: [
22964
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-ui-tag-green-icon h-8 w-1 rounded-full" }),
22965
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
22966
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", size: "small", className: "text-ui-fg-subtle", children: "Current Balance" }),
22967
+ /* @__PURE__ */ jsxRuntime.jsx(
22968
+ ui.Text,
22969
+ {
22970
+ weight: "plus",
22971
+ size: "xlarge",
22972
+ className: "tabular-nums text-ui-fg-base",
22973
+ children: formatAmount(
22974
+ storeCreditAccount.balance,
22975
+ storeCreditAccount.currency_code
22976
+ )
22977
+ }
22978
+ )
22979
+ ] })
22980
+ ] }) });
22981
+ };
22982
+ var toggleSelection = function() {
22983
+ var selection = document.getSelection();
22984
+ if (!selection.rangeCount) {
22985
+ return function() {
22986
+ };
22987
+ }
22988
+ var active = document.activeElement;
22989
+ var ranges = [];
22990
+ for (var i2 = 0; i2 < selection.rangeCount; i2++) {
22991
+ ranges.push(selection.getRangeAt(i2));
22992
+ }
22993
+ switch (active.tagName.toUpperCase()) {
22994
+ // .toUpperCase handles XHTML
22995
+ case "INPUT":
22996
+ case "TEXTAREA":
22997
+ active.blur();
22998
+ break;
22999
+ default:
23000
+ active = null;
23001
+ break;
23002
+ }
23003
+ selection.removeAllRanges();
23004
+ return function() {
23005
+ selection.type === "Caret" && selection.removeAllRanges();
23006
+ if (!selection.rangeCount) {
23007
+ ranges.forEach(function(range) {
23008
+ selection.addRange(range);
23009
+ });
23010
+ }
23011
+ active && active.focus();
23012
+ };
23013
+ };
23014
+ var deselectCurrent = toggleSelection;
23015
+ var clipboardToIE11Formatting = {
23016
+ "text/plain": "Text",
23017
+ "text/html": "Url",
23018
+ "default": "Text"
23019
+ };
23020
+ var defaultMessage = "Copy to clipboard: #{key}, Enter";
23021
+ function format(message2) {
23022
+ var copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C";
23023
+ return message2.replace(/#{\s*key\s*}/g, copyKey);
23024
+ }
23025
+ function copy$2(text2, options) {
23026
+ var debug2, message2, reselectPrevious, range, selection, mark, success = false;
23027
+ if (!options) {
23028
+ options = {};
23029
+ }
23030
+ debug2 = options.debug || false;
23031
+ try {
23032
+ reselectPrevious = deselectCurrent();
23033
+ range = document.createRange();
23034
+ selection = document.getSelection();
23035
+ mark = document.createElement("span");
23036
+ mark.textContent = text2;
23037
+ mark.ariaHidden = "true";
23038
+ mark.style.all = "unset";
23039
+ mark.style.position = "fixed";
23040
+ mark.style.top = 0;
23041
+ mark.style.clip = "rect(0, 0, 0, 0)";
23042
+ mark.style.whiteSpace = "pre";
23043
+ mark.style.webkitUserSelect = "text";
23044
+ mark.style.MozUserSelect = "text";
23045
+ mark.style.msUserSelect = "text";
23046
+ mark.style.userSelect = "text";
23047
+ mark.addEventListener("copy", function(e2) {
23048
+ e2.stopPropagation();
23049
+ if (options.format) {
23050
+ e2.preventDefault();
23051
+ if (typeof e2.clipboardData === "undefined") {
23052
+ debug2 && console.warn("unable to use e.clipboardData");
23053
+ debug2 && console.warn("trying IE specific stuff");
23054
+ window.clipboardData.clearData();
23055
+ var format2 = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting["default"];
23056
+ window.clipboardData.setData(format2, text2);
23057
+ } else {
23058
+ e2.clipboardData.clearData();
23059
+ e2.clipboardData.setData(options.format, text2);
23060
+ }
23061
+ }
23062
+ if (options.onCopy) {
23063
+ e2.preventDefault();
23064
+ options.onCopy(e2.clipboardData);
23065
+ }
23066
+ });
23067
+ document.body.appendChild(mark);
23068
+ range.selectNodeContents(mark);
23069
+ selection.addRange(range);
23070
+ var successful = document.execCommand("copy");
23071
+ if (!successful) {
23072
+ throw new Error("copy command was unsuccessful");
23073
+ }
23074
+ success = true;
23075
+ } catch (err) {
23076
+ debug2 && console.error("unable to copy using execCommand: ", err);
23077
+ debug2 && console.warn("trying IE specific stuff");
23078
+ try {
23079
+ window.clipboardData.setData(options.format || "text", text2);
23080
+ options.onCopy && options.onCopy(window.clipboardData);
23081
+ success = true;
23082
+ } catch (err2) {
23083
+ debug2 && console.error("unable to copy using clipboardData: ", err2);
23084
+ debug2 && console.error("falling back to prompt");
23085
+ message2 = format("message" in options ? options.message : defaultMessage);
23086
+ window.prompt(message2, text2);
23087
+ }
23088
+ } finally {
23089
+ if (selection) {
23090
+ if (typeof selection.removeRange == "function") {
23091
+ selection.removeRange(range);
23092
+ } else {
23093
+ selection.removeAllRanges();
23094
+ }
23095
+ }
23096
+ if (mark) {
23097
+ document.body.removeChild(mark);
23098
+ }
23099
+ reselectPrevious();
23100
+ }
23101
+ return success;
23102
+ }
23103
+ var copyToClipboard = copy$2;
23104
+ const copy$1 = /* @__PURE__ */ getDefaultExportFromCjs(copyToClipboard);
23105
+ function DisplayId({ id, className }) {
23106
+ const [open, setOpen] = React.useState(false);
23107
+ const onClick = () => {
23108
+ copy$1(id);
23109
+ ui.toast.success("Copied to clipboard");
23110
+ };
23111
+ 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: [
23112
+ "#",
23113
+ id.slice(-7)
23114
+ ] }) });
23115
+ }
23116
+ const StoreCreditAccountDetailsSection = ({
23117
+ storeCreditAccount
23118
+ }) => {
23119
+ if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
23120
+ return;
23121
+ }
23122
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "flex justify-between gap-x-2 px-6 py-6", children: [
23123
+ /* @__PURE__ */ jsxRuntime.jsxs(
23124
+ ui.Text,
23125
+ {
23126
+ weight: "plus",
23127
+ size: "xlarge",
23128
+ className: "text-ui-fg-base flex gap-x-4",
23129
+ children: [
23130
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2", children: [
23131
+ /* @__PURE__ */ jsxRuntime.jsx(CreditCardIcon, { className: "inline" }),
23132
+ " "
23133
+ ] }),
23134
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
23135
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle", children: [
23136
+ storeCreditAccount.currency_code.toUpperCase(),
23137
+ " Account"
23138
+ ] }),
23139
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx(
23140
+ ui.Text,
23141
+ {
23142
+ weight: "regular",
23143
+ size: "small",
23144
+ className: "text-ui-fg-base flex gap-x-4",
23145
+ children: /* @__PURE__ */ jsxRuntime.jsx(DisplayId, { id: storeCreditAccount.id })
23146
+ }
23147
+ ) })
23148
+ ] })
23149
+ ]
23150
+ }
23151
+ ),
23152
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-x-4", children: /* @__PURE__ */ jsxRuntime.jsx(
23153
+ ActionMenu,
23154
+ {
23155
+ groups: [
22374
23156
  {
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" })
23157
+ actions: [
23158
+ {
23159
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CreditCard, {}),
23160
+ label: "Credit the account",
23161
+ to: "credit"
23162
+ }
22384
23163
  ]
22385
23164
  }
22386
- ) })
22387
- ]
22388
- }
22389
- );
23165
+ ]
23166
+ }
23167
+ ) })
23168
+ ] });
22390
23169
  };
22391
- const columnHelper$9 = ui.createDataTableColumnHelper();
22392
- const useStoreCreditAccountTableColumns = () => {
23170
+ function StoreCreditAccountCustomerSection({
23171
+ customerId
23172
+ }) {
23173
+ const { customer, isPending } = useCustomer(customerId, void 0, {
23174
+ enabled: !!customerId
23175
+ });
23176
+ if (isPending || !customer) {
23177
+ return null;
23178
+ }
23179
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
23180
+ /* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Customer" }),
23181
+ /* @__PURE__ */ jsxRuntime.jsx(
23182
+ SidebarLink,
23183
+ {
23184
+ icon: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {}),
23185
+ labelKey: customer.email || "N/A",
23186
+ descriptionKey: !customer.first_name && !customer.last_name ? "N/A" : `${customer.first_name} ${customer.last_name}`,
23187
+ to: `/customers/${customer.id}`
23188
+ },
23189
+ customer.id
23190
+ )
23191
+ ] });
23192
+ }
23193
+ const columnHelper$8 = ui.createDataTableColumnHelper();
23194
+ const useTransactionsTableColumns = () => {
22393
23195
  return React.useMemo(() => {
22394
23196
  return [
22395
- columnHelper$9.accessor("currency_code", {
22396
- header: "Currency",
23197
+ columnHelper$8.accessor("id", {
23198
+ header: "ID",
22397
23199
  cell: ({ row }) => {
22398
- return /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { size: "2xsmall", children: row.original.currency_code.toUpperCase() });
23200
+ return /* @__PURE__ */ jsxRuntime.jsx(DisplayId, { id: row.original.id });
22399
23201
  }
22400
23202
  }),
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
- }
23203
+ columnHelper$8.accessor("created_at", {
23204
+ header: "Created At",
23205
+ cell: ({ row }) => formatDate(row.original.created_at, false)
22407
23206
  }),
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
- }
23207
+ columnHelper$8.accessor("note", {
23208
+ header: "Description",
23209
+ cell: ({ row }) => row.original.note
22416
23210
  }),
22417
- columnHelper$9.accessor("credits", {
22418
- header: "Credits",
23211
+ columnHelper$8.accessor("note", {
23212
+ header: "Note",
22419
23213
  cell: ({ row }) => {
22420
- return formatAmount(
22421
- row.original.credits,
22422
- row.original.currency_code
22423
- );
23214
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { title: row.original.note, className: "max-w-[300px] truncate", children: row.original.note || "-" });
22424
23215
  }
22425
23216
  }),
22426
- columnHelper$9.accessor("debits", {
22427
- header: "Debits",
23217
+ columnHelper$8.accessor("amount", {
23218
+ header: "Amount",
22428
23219
  cell: ({ row }) => {
22429
- return formatAmount(
22430
- row.original.debits,
22431
- row.original.currency_code
23220
+ const isDebit = row.original.type === "debit";
23221
+ return row.original.account.currency_code && formatAmount(
23222
+ row.original.amount * (isDebit ? -1 : 1),
23223
+ row.original.account.currency_code
22432
23224
  );
22433
23225
  }
22434
- }),
22435
- columnHelper$9.accessor("created_at", {
22436
- header: "Created at",
22437
- cell: ({ row }) => getRelativeDate(row.original.created_at)
22438
23226
  })
22439
23227
  ];
22440
23228
  }, []);
22441
23229
  };
22442
- const useStoreCreditAccountFilters = () => {
23230
+ const useTransactionsTableFilters = ({}) => {
22443
23231
  const dateFilterOptions = useDataTableDateFilters$1();
22444
- const customerFilterOptions = useCustomerFilters();
22445
23232
  return React.useMemo(() => {
22446
- return [...dateFilterOptions, ...customerFilterOptions];
22447
- }, [dateFilterOptions, customerFilterOptions]);
23233
+ return [...dateFilterOptions];
23234
+ }, [dateFilterOptions]);
22448
23235
  };
22449
- const useStoreCreditAccountsTableQuery = ({
23236
+ const useTransactionsTableQuery = ({
22450
23237
  prefix,
22451
23238
  pageSize = 20
22452
23239
  }) => {
22453
23240
  const queryObject = useQueryParams(
22454
- ["offset", "customer_id", "currency_code", "created_at", "updated_at"],
23241
+ ["offset", "limit", "currency_code", "created_at", "updated_at"],
22455
23242
  prefix
22456
23243
  );
22457
- const {
22458
- offset: offset2,
22459
- created_at,
22460
- updated_at,
22461
- customer_id,
22462
- currency_code,
22463
- ...rest
22464
- } = queryObject;
23244
+ const { offset: offset2, limit, created_at, updated_at, ...rest } = queryObject;
22465
23245
  const searchParams = {
22466
- limit: pageSize,
23246
+ limit: limit ? Number(limit) : pageSize,
22467
23247
  offset: offset2 ? Number(offset2) : 0,
22468
23248
  created_at: created_at ? JSON.parse(created_at) : void 0,
22469
23249
  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
23250
  ...rest
22473
23251
  };
22474
23252
  return searchParams;
22475
23253
  };
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"
23254
+ const PAGE_SIZE$4 = 10;
23255
+ function TransactionsTable({ id }) {
23256
+ const queryParams = useTransactionsTableQuery({
23257
+ pageSize: PAGE_SIZE$4
22488
23258
  });
22489
- const columns = useStoreCreditAccountTableColumns();
22490
- const filters = useStoreCreditAccountFilters();
23259
+ const { transactions, isLoading, count: count2 } = useStoreCreditAccountTransactions(
23260
+ id,
23261
+ {
23262
+ ...queryParams,
23263
+ order: queryParams.order ?? "-created_at",
23264
+ fields: "*account"
23265
+ }
23266
+ );
23267
+ const columns = useTransactionsTableColumns();
23268
+ const filters = useTransactionsTableFilters({});
22491
23269
  return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
22492
23270
  /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
22493
23271
  DataTable,
22494
23272
  {
22495
- data: storeCreditAccounts ?? [],
23273
+ data: transactions ?? [],
22496
23274
  getRowId: (row) => row.id,
22497
23275
  columns,
22498
23276
  filters,
22499
- isLoading: isPending,
22500
- pageSize: PAGE_SIZE$5,
23277
+ isLoading,
23278
+ pageSize: PAGE_SIZE$4,
22501
23279
  rowCount: count2,
22502
23280
  enableSearch: false,
22503
- heading: "Store Credit Accounts",
22504
- rowHref: (row) => `${row.id}`,
23281
+ heading: "Transactions",
22505
23282
  emptyState: {
22506
23283
  empty: {
22507
- heading: "No store credit accounts found",
22508
- description: "Create a new store credit account to get started."
23284
+ heading: "No transactions found"
22509
23285
  },
22510
23286
  filtered: {
22511
23287
  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"
23288
+ description: "No transactions match your filter criteria."
22519
23289
  }
22520
- ]
23290
+ }
22521
23291
  }
22522
23292
  ) }),
22523
23293
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
22524
23294
  ] });
22525
23295
  }
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;
23296
+ function StoreCreditAccountCodeSection({ code }) {
23297
+ if (!code) {
23298
+ return null;
22646
23299
  }
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;
23300
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
23301
+ /* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Account Code" }),
23302
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-4 px-6 mb-2", children: [
23303
+ /* @__PURE__ */ jsxRuntime.jsx(icons.Share, { className: "inline" }),
23304
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle text-sm", children: code })
23305
+ ] })
23306
+ ] });
22650
23307
  }
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;
23308
+ const StoreCreditAccountPage = () => {
23309
+ const { id } = reactRouterDom.useParams();
23310
+ const { store_credit_account: storeCreditAccount } = useStoreCreditAccount(
23311
+ id
23312
+ );
23313
+ if (!storeCreditAccount) {
23314
+ return;
22701
23315
  }
22702
- function cancel() {
22703
- if (timerId !== void 0) {
22704
- clearTimeout(timerId);
23316
+ return /* @__PURE__ */ jsxRuntime.jsx(
23317
+ components.LayoutComposer,
23318
+ {
23319
+ widgetsZonePrefix: "store_credit_account.details",
23320
+ preferredLayoutId: "core:two-column",
23321
+ data: storeCreditAccount,
23322
+ sections: {
23323
+ main: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
23324
+ /* @__PURE__ */ jsxRuntime.jsx(
23325
+ StoreCreditAccountDetailsSection,
23326
+ {
23327
+ storeCreditAccount
23328
+ }
23329
+ ),
23330
+ /* @__PURE__ */ jsxRuntime.jsx(TransactionsTable, { id: storeCreditAccount.id })
23331
+ ] }),
23332
+ side: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
23333
+ /* @__PURE__ */ jsxRuntime.jsx(
23334
+ StoreCreditAccountBalanceSection,
23335
+ {
23336
+ storeCreditAccount
23337
+ }
23338
+ ),
23339
+ /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCodeSection, { code: storeCreditAccount.code }),
23340
+ /* @__PURE__ */ jsxRuntime.jsx(
23341
+ StoreCreditAccountCustomerSection,
23342
+ {
23343
+ customerId: storeCreditAccount.customer_id
23344
+ }
23345
+ )
23346
+ ] })
23347
+ }
22705
23348
  }
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);
23349
+ );
23350
+ };
23351
+ const KeyboundForm = React__namespace.default.forwardRef(({ onSubmit, onKeyDown, ...rest }, ref) => {
23352
+ const handleSubmit = (event) => {
23353
+ event.preventDefault();
23354
+ onSubmit == null ? void 0 : onSubmit(event);
23355
+ };
23356
+ const handleKeyDown = (event) => {
23357
+ if (event.key === "Enter") {
23358
+ if (event.target instanceof HTMLTextAreaElement && !(event.metaKey || event.ctrlKey)) {
23359
+ return;
22720
23360
  }
22721
- if (maxing) {
22722
- clearTimeout(timerId);
22723
- timerId = setTimeout(timerExpired, wait);
22724
- return invokeFunc(lastCallTime);
23361
+ event.preventDefault();
23362
+ if (event.metaKey || event.ctrlKey) {
23363
+ handleSubmit(event);
22725
23364
  }
22726
23365
  }
22727
- if (timerId === void 0) {
22728
- timerId = setTimeout(timerExpired, wait);
23366
+ };
23367
+ return /* @__PURE__ */ jsxRuntime.jsx(
23368
+ "form",
23369
+ {
23370
+ ...rest,
23371
+ onSubmit: handleSubmit,
23372
+ onKeyDown: onKeyDown ?? handleKeyDown,
23373
+ ref
22729
23374
  }
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
23375
  );
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
- });
23376
+ });
23377
+ KeyboundForm.displayName = "KeyboundForm";
23378
+ const Note$1 = () => {
23379
+ const { id } = reactRouterDom.useParams();
23380
+ const {
23381
+ store_credit_account: storeCreditAccount,
23382
+ isPending,
23383
+ isError,
23384
+ error
23385
+ } = useStoreCreditAccount(id, {});
23386
+ if (isError) {
23387
+ throw error;
22800
23388
  }
22801
- return {
22802
- options,
22803
- searchValue,
22804
- onSearchValueChange,
22805
- disabled,
22806
- ...rest
22807
- };
23389
+ const isReady = !isPending && !!storeCreditAccount;
23390
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
23391
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
23392
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Credit store credit account" }) }),
23393
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Credit the store credit account" }) })
23394
+ ] }),
23395
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCreditForm, { storeCreditAccount })
23396
+ ] });
22808
23397
  };
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();
23398
+ const StoreCreditAccountCreditForm = ({
23399
+ storeCreditAccount
23400
+ }) => {
22815
23401
  const form = useForm({
22816
23402
  defaultValues: {
22817
- currency_code: "",
22818
- customer_id: ""
23403
+ amount: {
23404
+ float: 0,
23405
+ value: ""
23406
+ },
23407
+ note: ""
22819
23408
  },
22820
- resolver: t(formSchema)
23409
+ resolver: t(schema$2)
22821
23410
  });
22822
- const { mutateAsync: createStoreCreditAccount, isPending } = useCreateStoreCreditAccount();
22823
- const handleSubmit = form.handleSubmit(async (data) => {
22824
- if (!data.customer_id) {
22825
- delete data.customer_id;
23411
+ const { mutateAsync, isPending } = useCreditStoreCreditAccount(
23412
+ storeCreditAccount.id
23413
+ );
23414
+ const { handleSuccess } = useRouteModal();
23415
+ const onSubmit = form.handleSubmit(async (data) => {
23416
+ if (data.amount.float <= 0) {
23417
+ form.setError("amount", { message: "Amount must be greater than 0" });
23418
+ return;
22826
23419
  }
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);
23420
+ await mutateAsync(
23421
+ { amount: data.amount.float, note: data.note },
23422
+ {
23423
+ onSuccess: () => handleSuccess(),
23424
+ onError: (error) => ui.toast.error(error.message)
22834
23425
  }
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
23426
  );
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
23427
  });
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" }),
23428
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
23429
+ KeyboundForm,
23430
+ {
23431
+ className: "flex flex-1 flex-col overflow-hidden",
23432
+ onSubmit,
23433
+ children: [
23434
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
23435
+ /* @__PURE__ */ jsxRuntime.jsx(
23436
+ Form$2.Field,
23437
+ {
23438
+ control: form.control,
23439
+ name: "amount",
23440
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
23441
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Amount" }),
22890
23442
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
22891
- Combobox,
23443
+ ui.CurrencyInput,
22892
23444
  {
22893
- value: field.value,
22894
- onChange: field.onChange,
22895
- searchValue: currencySearchValue,
22896
- onSearchValueChange: setCurrencySearchValue,
22897
- options: currencyOptions,
22898
- placeholder: "Search for a currency..."
23445
+ min: 0,
23446
+ placeholder: "0",
23447
+ value: field.value.value,
23448
+ onValueChange: (_value, _name, values) => {
23449
+ field.onChange({
23450
+ value: values == null ? void 0 : values.value,
23451
+ float: (values == null ? void 0 : values.float) || null
23452
+ });
23453
+ },
23454
+ symbol: currencies[storeCreditAccount.currency_code.toUpperCase()].symbol_native,
23455
+ code: storeCreditAccount.currency_code.toUpperCase()
22899
23456
  }
22900
23457
  ) }),
22901
23458
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
22902
- ] });
23459
+ ] })
22903
23460
  }
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
- ) }),
23461
+ ),
23462
+ /* @__PURE__ */ jsxRuntime.jsx(
23463
+ Form$2.Field,
23464
+ {
23465
+ control: form.control,
23466
+ name: "note",
23467
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
23468
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
23469
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
22928
23470
  /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
22929
- ] });
23471
+ ] })
22930
23472
  }
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
- ] });
23473
+ )
23474
+ ] }),
23475
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
23476
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
23477
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
23478
+ ] }) })
23479
+ ]
23480
+ }
23481
+ ) });
22956
23482
  };
23483
+ const schema$2 = zod.z.object({
23484
+ note: zod.z.string(),
23485
+ amount: zod.z.object({
23486
+ float: zod.z.number(),
23487
+ value: zod.z.string()
23488
+ })
23489
+ });
22957
23490
  function _extends() {
22958
23491
  return _extends = Object.assign ? Object.assign.bind() : function(n2) {
22959
23492
  for (var e2 = 1; e2 < arguments.length; e2++) {
@@ -25634,243 +26167,6 @@ const GiftCardOrderSection = ({ giftCard }) => {
25634
26167
  ))
25635
26168
  ] });
25636
26169
  };
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
26170
  const GiftCardTransactionsSection = ({
25875
26171
  storeCreditAccount
25876
26172
  }) => {
@@ -25920,33 +26216,6 @@ const GiftCardDetailsPage = () => {
25920
26216
  }
25921
26217
  );
25922
26218
  };
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
26219
  const GiftCardExpiration = () => {
25951
26220
  const { id } = reactRouterDom.useParams();
25952
26221
  const { gift_card: giftCard, isPending, isError, error } = useGiftCard(id);
@@ -25967,7 +26236,7 @@ const GiftCardExpirationForm = ({ giftCard }) => {
25967
26236
  defaultValues: {
25968
26237
  expires_at: giftCard.expires_at ? new Date(giftCard.expires_at) : null
25969
26238
  },
25970
- resolver: t(schema$2)
26239
+ resolver: t(schema$1)
25971
26240
  });
25972
26241
  const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
25973
26242
  const { handleSuccess } = useRouteModal();
@@ -26062,10 +26331,10 @@ const GiftCardExpirationForm = ({ giftCard }) => {
26062
26331
  }
26063
26332
  ) });
26064
26333
  };
26065
- const schema$2 = zod.z.object({
26334
+ const schema$1 = zod.z.object({
26066
26335
  expires_at: zod.z.date().nullish()
26067
26336
  });
26068
- const Note$1 = () => {
26337
+ const Note = () => {
26069
26338
  const { id } = reactRouterDom.useParams();
26070
26339
  const {
26071
26340
  gift_card: giftCard,
@@ -26090,7 +26359,7 @@ const GiftCardNoteForm = ({ giftCard }) => {
26090
26359
  defaultValues: {
26091
26360
  note: giftCard.note ?? ""
26092
26361
  },
26093
- resolver: t(schema$1)
26362
+ resolver: t(schema)
26094
26363
  });
26095
26364
  const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
26096
26365
  const { handleSuccess } = useRouteModal();
@@ -26129,7 +26398,7 @@ const GiftCardNoteForm = ({ giftCard }) => {
26129
26398
  }
26130
26399
  ) });
26131
26400
  };
26132
- const schema$1 = zod.z.object({
26401
+ const schema = zod.z.object({
26133
26402
  note: zod.z.string().optional()
26134
26403
  });
26135
26404
  const columnHelper$7 = createColumnHelper();
@@ -39470,7 +39739,7 @@ const GiftCardProductCreate = () => {
39470
39739
  isPending: isStorePending,
39471
39740
  isError: isStoreError,
39472
39741
  error: storeError
39473
- } = useStore$2({
39742
+ } = useStore$1({
39474
39743
  fields: "+default_sales_channel"
39475
39744
  });
39476
39745
  const {
@@ -39522,275 +39791,6 @@ const GiftCardProductCreate = () => {
39522
39791
  )
39523
39792
  ] });
39524
39793
  };
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
39794
  const productStatusColor = (status) => {
39795
39795
  switch (status) {
39796
39796
  case "draft":
@@ -41202,7 +41202,7 @@ const ProductMedia = () => {
41202
41202
  ] });
41203
41203
  };
41204
41204
  const VariantPricingForm = ({ form }) => {
41205
- const { store } = useStore$2();
41205
+ const { store } = useStore$1();
41206
41206
  const { regions } = useRegions({ limit: 9999 });
41207
41207
  const { price_preferences: pricePreferences } = usePricePreferences({});
41208
41208
  const { setCloseOnEscape } = useRouteModal();
@@ -41481,6 +41481,16 @@ const widgetModule = { widgets: [
41481
41481
  ] };
41482
41482
  const routeModule = {
41483
41483
  routes: [
41484
+ {
41485
+ Component: StoreCreditAccountsPage,
41486
+ path: "/store-credit-accounts",
41487
+ children: [
41488
+ {
41489
+ Component: StoreCreditAccountCreate,
41490
+ path: "/store-credit-accounts/create"
41491
+ }
41492
+ ]
41493
+ },
41484
41494
  {
41485
41495
  Component: GiftCardsPage,
41486
41496
  path: "/gift-cards",
@@ -41492,12 +41502,12 @@ const routeModule = {
41492
41502
  ]
41493
41503
  },
41494
41504
  {
41495
- Component: StoreCreditAccountsPage,
41496
- path: "/store-credit-accounts",
41505
+ Component: StoreCreditAccountPage,
41506
+ path: "/store-credit-accounts/:id",
41497
41507
  children: [
41498
41508
  {
41499
- Component: StoreCreditAccountCreate,
41500
- path: "/store-credit-accounts/create"
41509
+ Component: Note$1,
41510
+ path: "/store-credit-accounts/:id/credit"
41501
41511
  }
41502
41512
  ]
41503
41513
  },
@@ -41510,7 +41520,7 @@ const routeModule = {
41510
41520
  path: "/gift-cards/:id/expiration"
41511
41521
  },
41512
41522
  {
41513
- Component: Note$1,
41523
+ Component: Note,
41514
41524
  path: "/gift-cards/:id/note"
41515
41525
  }
41516
41526
  ]
@@ -41525,16 +41535,6 @@ const routeModule = {
41525
41535
  }
41526
41536
  ]
41527
41537
  },
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
41538
  {
41539
41539
  Component: ProductDetail,
41540
41540
  path: "/gift-cards/gift-card-products/:id",
@@ -41568,15 +41568,15 @@ const menuItemModule = {
41568
41568
  {
41569
41569
  label: config$3.label,
41570
41570
  icon: config$3.icon,
41571
- path: "/gift-cards",
41571
+ path: "/store-credit-accounts",
41572
41572
  nested: void 0,
41573
41573
  rank: void 0,
41574
41574
  translationNs: void 0
41575
41575
  },
41576
41576
  {
41577
- label: config$1.label,
41578
- icon: config$1.icon,
41579
- path: "/store-credit-accounts",
41577
+ label: config$2.label,
41578
+ icon: config$2.icon,
41579
+ path: "/gift-cards",
41580
41580
  nested: void 0,
41581
41581
  rank: void 0,
41582
41582
  translationNs: void 0