@medusajs/loyalty-plugin 2.22.4-preview-20261106081111 → 2.22.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/index.js +1671 -1671
- package/.medusa/server/src/admin/index.mjs +1673 -1673
- package/package.json +19 -19
|
@@ -9,8 +9,8 @@ const icons = require("@medusajs/icons");
|
|
|
9
9
|
const reactQuery = require("@tanstack/react-query");
|
|
10
10
|
const Medusa = require("@medusajs/js-sdk");
|
|
11
11
|
const components = require("@medusajs/dashboard/components");
|
|
12
|
-
const ReactDOM = require("react-dom");
|
|
13
12
|
const zod = require("@medusajs/framework/zod");
|
|
13
|
+
const ReactDOM = require("react-dom");
|
|
14
14
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
15
15
|
function _interopNamespace(e) {
|
|
16
16
|
if (e && e.__esModule) return e;
|
|
@@ -5794,7 +5794,7 @@ adminSdk.defineWidgetConfig({
|
|
|
5794
5794
|
zone: "sales_channel.details.after",
|
|
5795
5795
|
id: "medusa:sales-channel-gift-cards-widget"
|
|
5796
5796
|
});
|
|
5797
|
-
const
|
|
5797
|
+
const StoreCreditIcon = (props) => {
|
|
5798
5798
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5799
5799
|
"svg",
|
|
5800
5800
|
{
|
|
@@ -5805,199 +5805,49 @@ const GiftCardIcon = (props) => {
|
|
|
5805
5805
|
xmlns: "http://www.w3.org/2000/svg",
|
|
5806
5806
|
...props,
|
|
5807
5807
|
children: [
|
|
5808
|
-
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#
|
|
5808
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#8B5CF6" }),
|
|
5809
5809
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5810
5810
|
"rect",
|
|
5811
5811
|
{
|
|
5812
5812
|
width: "15",
|
|
5813
5813
|
height: "15",
|
|
5814
|
-
fill: "url(#
|
|
5814
|
+
fill: "url(#paint0_linear_29181_44790)",
|
|
5815
5815
|
fillOpacity: "0.2"
|
|
5816
5816
|
}
|
|
5817
5817
|
),
|
|
5818
|
-
/* @__PURE__ */ jsxRuntime.
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5848
|
-
"path",
|
|
5849
|
-
{
|
|
5850
|
-
d: "M8.063 7.5V11.625H9.188C10.325 11.625 11.25 10.7 11.25 9.563V7.5H8.063Z",
|
|
5851
|
-
fill: "white"
|
|
5852
|
-
}
|
|
5853
|
-
)
|
|
5854
|
-
] }),
|
|
5855
|
-
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
5856
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5857
|
-
"linearGradient",
|
|
5858
|
-
{
|
|
5859
|
-
id: "paint0_linear_28788_25808",
|
|
5860
|
-
x1: "7.5",
|
|
5861
|
-
y1: "0",
|
|
5862
|
-
x2: "7.5",
|
|
5863
|
-
y2: "15",
|
|
5864
|
-
gradientUnits: "userSpaceOnUse",
|
|
5865
|
-
children: [
|
|
5866
|
-
/* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "white" }),
|
|
5867
|
-
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
|
|
5868
|
-
]
|
|
5869
|
-
}
|
|
5870
|
-
),
|
|
5871
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_28788_25808", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "9", height: "9", fill: "white", transform: "translate(3 3)" }) })
|
|
5872
|
-
] })
|
|
5818
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5819
|
+
"path",
|
|
5820
|
+
{
|
|
5821
|
+
d: "M12 6V5.813C12 4.675 11.075 3.75 9.938 3.75H5.063C3.925 3.75 3 4.675 3 5.813V6H12Z",
|
|
5822
|
+
fill: "white"
|
|
5823
|
+
}
|
|
5824
|
+
),
|
|
5825
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5826
|
+
"path",
|
|
5827
|
+
{
|
|
5828
|
+
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",
|
|
5829
|
+
fill: "white"
|
|
5830
|
+
}
|
|
5831
|
+
),
|
|
5832
|
+
/* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5833
|
+
"linearGradient",
|
|
5834
|
+
{
|
|
5835
|
+
id: "paint0_linear_29181_44790",
|
|
5836
|
+
x1: "7.5",
|
|
5837
|
+
y1: "0",
|
|
5838
|
+
x2: "7.5",
|
|
5839
|
+
y2: "15",
|
|
5840
|
+
gradientUnits: "userSpaceOnUse",
|
|
5841
|
+
children: [
|
|
5842
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "white" }),
|
|
5843
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
|
|
5844
|
+
]
|
|
5845
|
+
}
|
|
5846
|
+
) })
|
|
5873
5847
|
]
|
|
5874
5848
|
}
|
|
5875
5849
|
);
|
|
5876
5850
|
};
|
|
5877
|
-
const GiftCardProductsSection = () => {
|
|
5878
|
-
const { hasPermission } = hooks.usePermissions();
|
|
5879
|
-
const canCreateProduct = hasPermission("product:create");
|
|
5880
|
-
const { products: giftCardProducts, count: count2 = 0 } = useProducts({
|
|
5881
|
-
is_giftcard: true
|
|
5882
|
-
});
|
|
5883
|
-
const slicedProducts = giftCardProducts?.slice(0, 3) ?? [];
|
|
5884
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
5885
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
5886
|
-
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Gift Card Products" }),
|
|
5887
|
-
canCreateProduct && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5888
|
-
reactRouterDom.Link,
|
|
5889
|
-
{
|
|
5890
|
-
to: `/gift-cards/gift-card-products/create`,
|
|
5891
|
-
className: "text-ui-fg-muted text-sm px-6",
|
|
5892
|
-
children: "Create"
|
|
5893
|
-
}
|
|
5894
|
-
)
|
|
5895
|
-
] }),
|
|
5896
|
-
giftCardProducts?.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5897
|
-
NoRecords,
|
|
5898
|
-
{
|
|
5899
|
-
className: "px-10 py-4 h-[200px]",
|
|
5900
|
-
title: "No gift card products",
|
|
5901
|
-
message: "There are no gift card products to show. Create one to get started.",
|
|
5902
|
-
action: canCreateProduct ? {
|
|
5903
|
-
to: "/gift-cards/gift-card-products/create",
|
|
5904
|
-
label: "Create gift card product"
|
|
5905
|
-
} : void 0
|
|
5906
|
-
}
|
|
5907
|
-
),
|
|
5908
|
-
slicedProducts.map((giftCardProduct) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5909
|
-
SidebarLink,
|
|
5910
|
-
{
|
|
5911
|
-
to: `/gift-cards/gift-card-products/${giftCardProduct.id}`,
|
|
5912
|
-
labelKey: giftCardProduct.title,
|
|
5913
|
-
descriptionKey: giftCardProduct.title,
|
|
5914
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Tag, {})
|
|
5915
|
-
}
|
|
5916
|
-
)),
|
|
5917
|
-
count2 > 3 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5918
|
-
reactRouterDom.Link,
|
|
5919
|
-
{
|
|
5920
|
-
to: "/gift-cards/gift-card-products",
|
|
5921
|
-
className: "text-ui-fg-muted text-sm px-6 py-4 flex items-center justify-center",
|
|
5922
|
-
children: "View more"
|
|
5923
|
-
}
|
|
5924
|
-
)
|
|
5925
|
-
] });
|
|
5926
|
-
};
|
|
5927
|
-
const _giftCardQueryKey = queryKeysFactory("gift-card");
|
|
5928
|
-
const giftCardQueryKey = {
|
|
5929
|
-
..._giftCardQueryKey,
|
|
5930
|
-
orders: (id) => [..._giftCardQueryKey.detail(id), "orders"]
|
|
5931
|
-
};
|
|
5932
|
-
const useGiftCards = (query, options) => {
|
|
5933
|
-
const fetchGiftCards = (query2, headers) => sdk.client.fetch(`/admin/gift-cards`, {
|
|
5934
|
-
query: query2,
|
|
5935
|
-
headers
|
|
5936
|
-
});
|
|
5937
|
-
const { data, ...rest } = reactQuery.useQuery({
|
|
5938
|
-
...options,
|
|
5939
|
-
queryFn: () => fetchGiftCards(query),
|
|
5940
|
-
queryKey: giftCardQueryKey.list(query)
|
|
5941
|
-
});
|
|
5942
|
-
return { ...data, ...rest };
|
|
5943
|
-
};
|
|
5944
|
-
const useGiftCard = (id, query, options) => {
|
|
5945
|
-
const fetchGiftCard = (id2, query2, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
|
|
5946
|
-
query: query2,
|
|
5947
|
-
headers
|
|
5948
|
-
});
|
|
5949
|
-
const { data, ...rest } = reactQuery.useQuery({
|
|
5950
|
-
queryFn: () => fetchGiftCard(id, query),
|
|
5951
|
-
queryKey: giftCardQueryKey.detail(id, query),
|
|
5952
|
-
...options
|
|
5953
|
-
});
|
|
5954
|
-
return { ...data, ...rest };
|
|
5955
|
-
};
|
|
5956
|
-
const useGiftCardOrders = (id, options) => {
|
|
5957
|
-
const fetchGiftCardOrders = (id2, query, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}/orders`, {
|
|
5958
|
-
query,
|
|
5959
|
-
headers
|
|
5960
|
-
});
|
|
5961
|
-
const { data, ...rest } = reactQuery.useQuery({
|
|
5962
|
-
queryFn: () => fetchGiftCardOrders(id),
|
|
5963
|
-
queryKey: giftCardQueryKey.orders(id),
|
|
5964
|
-
...options
|
|
5965
|
-
});
|
|
5966
|
-
return { ...data, ...rest };
|
|
5967
|
-
};
|
|
5968
|
-
const useUpdateGiftCard = (id, options) => {
|
|
5969
|
-
const queryClient = reactQuery.useQueryClient();
|
|
5970
|
-
const updateGiftCard = async (id2, body) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
|
|
5971
|
-
body,
|
|
5972
|
-
method: "POST"
|
|
5973
|
-
});
|
|
5974
|
-
return reactQuery.useMutation({
|
|
5975
|
-
mutationFn: async (payload) => updateGiftCard(id, payload),
|
|
5976
|
-
onSuccess: (data, variables, context) => {
|
|
5977
|
-
queryClient.invalidateQueries({
|
|
5978
|
-
queryKey: giftCardQueryKey.detail(id)
|
|
5979
|
-
});
|
|
5980
|
-
queryClient.invalidateQueries({
|
|
5981
|
-
queryKey: giftCardQueryKey.lists()
|
|
5982
|
-
});
|
|
5983
|
-
},
|
|
5984
|
-
...options
|
|
5985
|
-
});
|
|
5986
|
-
};
|
|
5987
|
-
const useCreateGiftCard = (options) => {
|
|
5988
|
-
const queryClient = reactQuery.useQueryClient();
|
|
5989
|
-
const createGiftCard = async (body) => sdk.client.fetch(`/admin/gift-cards`, {
|
|
5990
|
-
body,
|
|
5991
|
-
method: "POST"
|
|
5992
|
-
});
|
|
5993
|
-
return reactQuery.useMutation({
|
|
5994
|
-
mutationFn: (body) => createGiftCard(body),
|
|
5995
|
-
onSuccess: (data, variables, context) => {
|
|
5996
|
-
queryClient.invalidateQueries({ queryKey: giftCardQueryKey.lists() });
|
|
5997
|
-
},
|
|
5998
|
-
...options
|
|
5999
|
-
});
|
|
6000
|
-
};
|
|
6001
5851
|
function getRelativeDate(date2) {
|
|
6002
5852
|
const now = /* @__PURE__ */ new Date();
|
|
6003
5853
|
return formatDistance(sub(new Date(date2), { minutes: 0 }), now, {
|
|
@@ -6015,30 +5865,51 @@ function formatDate(date2, withTime = true) {
|
|
|
6015
5865
|
return format(new Date(date2), "dd MMM, yyyy");
|
|
6016
5866
|
}
|
|
6017
5867
|
const columnHelper$a = ui.createDataTableColumnHelper();
|
|
6018
|
-
const
|
|
5868
|
+
const useStoreCreditAccountTableColumns = () => {
|
|
6019
5869
|
return React.useMemo(() => {
|
|
6020
5870
|
return [
|
|
6021
|
-
columnHelper$a.accessor("
|
|
6022
|
-
header: "
|
|
5871
|
+
columnHelper$a.accessor("currency_code", {
|
|
5872
|
+
header: "Currency",
|
|
6023
5873
|
cell: ({ row }) => {
|
|
6024
|
-
return row.original.
|
|
5874
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { size: "2xsmall", children: row.original.currency_code.toUpperCase() });
|
|
6025
5875
|
}
|
|
6026
5876
|
}),
|
|
6027
|
-
columnHelper$a.accessor("
|
|
6028
|
-
header: "
|
|
5877
|
+
columnHelper$a.accessor("customer.email", {
|
|
5878
|
+
header: "Customer",
|
|
6029
5879
|
cell: ({ row }) => {
|
|
6030
|
-
return row.original.
|
|
5880
|
+
return row.original.customer?.email ?? "N/A";
|
|
6031
5881
|
}
|
|
6032
5882
|
}),
|
|
6033
|
-
columnHelper$a.accessor("
|
|
6034
|
-
header: "
|
|
6035
|
-
cell: ({ row }) =>
|
|
5883
|
+
columnHelper$a.accessor("balance", {
|
|
5884
|
+
header: "Balance",
|
|
5885
|
+
cell: ({ row }) => {
|
|
5886
|
+
return formatAmount(
|
|
5887
|
+
row.original.balance,
|
|
5888
|
+
row.original.currency_code
|
|
5889
|
+
);
|
|
5890
|
+
}
|
|
6036
5891
|
}),
|
|
6037
|
-
columnHelper$a.accessor("
|
|
6038
|
-
header: "
|
|
5892
|
+
columnHelper$a.accessor("credits", {
|
|
5893
|
+
header: "Credits",
|
|
6039
5894
|
cell: ({ row }) => {
|
|
6040
|
-
return formatAmount(
|
|
5895
|
+
return formatAmount(
|
|
5896
|
+
row.original.credits,
|
|
5897
|
+
row.original.currency_code
|
|
5898
|
+
);
|
|
5899
|
+
}
|
|
5900
|
+
}),
|
|
5901
|
+
columnHelper$a.accessor("debits", {
|
|
5902
|
+
header: "Debits",
|
|
5903
|
+
cell: ({ row }) => {
|
|
5904
|
+
return formatAmount(
|
|
5905
|
+
row.original.debits,
|
|
5906
|
+
row.original.currency_code
|
|
5907
|
+
);
|
|
6041
5908
|
}
|
|
5909
|
+
}),
|
|
5910
|
+
columnHelper$a.accessor("created_at", {
|
|
5911
|
+
header: "Created at",
|
|
5912
|
+
cell: ({ row }) => getRelativeDate(row.original.created_at)
|
|
6042
5913
|
})
|
|
6043
5914
|
];
|
|
6044
5915
|
}, []);
|
|
@@ -6090,77 +5961,85 @@ const useCustomerFilters = () => {
|
|
|
6090
5961
|
];
|
|
6091
5962
|
}, [canReadCustomers, customerFilterOptions]);
|
|
6092
5963
|
};
|
|
6093
|
-
const
|
|
5964
|
+
const useStoreCreditAccountFilters = () => {
|
|
6094
5965
|
const dateFilterOptions = useDataTableDateFilters$1();
|
|
6095
5966
|
const customerFilterOptions = useCustomerFilters();
|
|
6096
5967
|
return React.useMemo(() => {
|
|
6097
5968
|
return [...dateFilterOptions, ...customerFilterOptions];
|
|
6098
5969
|
}, [dateFilterOptions, customerFilterOptions]);
|
|
6099
5970
|
};
|
|
6100
|
-
const
|
|
5971
|
+
const useStoreCreditAccountsTableQuery = ({
|
|
6101
5972
|
prefix,
|
|
6102
5973
|
pageSize = 20
|
|
6103
5974
|
}) => {
|
|
6104
5975
|
const queryObject = useQueryParams(
|
|
6105
|
-
["
|
|
5976
|
+
["offset", "customer_id", "currency_code", "created_at", "updated_at"],
|
|
6106
5977
|
prefix
|
|
6107
5978
|
);
|
|
6108
|
-
const {
|
|
5979
|
+
const {
|
|
5980
|
+
offset: offset2,
|
|
5981
|
+
created_at,
|
|
5982
|
+
updated_at,
|
|
5983
|
+
customer_id,
|
|
5984
|
+
currency_code,
|
|
5985
|
+
...rest
|
|
5986
|
+
} = queryObject;
|
|
6109
5987
|
const searchParams = {
|
|
6110
5988
|
limit: pageSize,
|
|
6111
5989
|
offset: offset2 ? Number(offset2) : 0,
|
|
6112
5990
|
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
6113
5991
|
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
6114
5992
|
customer_id: customer_id ? JSON.parse(customer_id) : void 0,
|
|
5993
|
+
currency_code: currency_code ? JSON.parse(currency_code) : void 0,
|
|
6115
5994
|
...rest
|
|
6116
5995
|
};
|
|
6117
5996
|
return searchParams;
|
|
6118
5997
|
};
|
|
6119
5998
|
const PAGE_SIZE$6 = 10;
|
|
6120
|
-
function
|
|
6121
|
-
const queryParams =
|
|
5999
|
+
function StoreCreditAccountsTable() {
|
|
6000
|
+
const queryParams = useStoreCreditAccountsTableQuery({
|
|
6122
6001
|
pageSize: PAGE_SIZE$6
|
|
6123
6002
|
});
|
|
6124
6003
|
const {
|
|
6125
|
-
|
|
6004
|
+
store_credit_accounts: storeCreditAccounts,
|
|
6126
6005
|
isPending,
|
|
6127
6006
|
count: count2
|
|
6128
|
-
} =
|
|
6007
|
+
} = useStoreCreditAccounts({
|
|
6129
6008
|
...queryParams,
|
|
6130
|
-
order: queryParams.order ?? "-created_at"
|
|
6131
|
-
fields: "+line_item.product.title"
|
|
6009
|
+
order: queryParams.order ?? "-created_at"
|
|
6132
6010
|
});
|
|
6133
|
-
const columns =
|
|
6134
|
-
const filters =
|
|
6011
|
+
const columns = useStoreCreditAccountTableColumns();
|
|
6012
|
+
const filters = useStoreCreditAccountFilters();
|
|
6135
6013
|
const { hasPermission } = hooks.usePermissions();
|
|
6136
|
-
const canCreate = hasPermission("
|
|
6014
|
+
const canCreate = hasPermission("store_credit_account:create");
|
|
6137
6015
|
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
6138
6016
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6139
6017
|
DataTable,
|
|
6140
6018
|
{
|
|
6141
|
-
data:
|
|
6019
|
+
data: storeCreditAccounts ?? [],
|
|
6142
6020
|
getRowId: (row) => row.id,
|
|
6143
6021
|
columns,
|
|
6144
6022
|
filters,
|
|
6145
6023
|
isLoading: isPending,
|
|
6146
6024
|
pageSize: PAGE_SIZE$6,
|
|
6147
6025
|
rowCount: count2,
|
|
6148
|
-
|
|
6026
|
+
enableSearch: false,
|
|
6027
|
+
heading: "Store Credit Accounts",
|
|
6149
6028
|
rowHref: (row) => `${row.id}`,
|
|
6150
6029
|
emptyState: {
|
|
6151
6030
|
empty: {
|
|
6152
|
-
heading: "No
|
|
6153
|
-
description: "Create a
|
|
6031
|
+
heading: "No store credit accounts found",
|
|
6032
|
+
description: "Create a new store credit account to get started."
|
|
6154
6033
|
},
|
|
6155
6034
|
filtered: {
|
|
6156
6035
|
heading: "No results found",
|
|
6157
|
-
description: "No
|
|
6036
|
+
description: "No store credit accounts match your filter criteria."
|
|
6158
6037
|
}
|
|
6159
6038
|
},
|
|
6160
6039
|
actions: canCreate ? [
|
|
6161
6040
|
{
|
|
6162
6041
|
label: "Create",
|
|
6163
|
-
to: "create"
|
|
6042
|
+
to: "/store-credit-accounts/create"
|
|
6164
6043
|
}
|
|
6165
6044
|
] : []
|
|
6166
6045
|
}
|
|
@@ -6168,16 +6047,15 @@ function GiftCardsTable() {
|
|
|
6168
6047
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
6169
6048
|
] });
|
|
6170
6049
|
}
|
|
6171
|
-
const
|
|
6050
|
+
const StoreCreditAccountsPage = () => {
|
|
6172
6051
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6173
6052
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6174
6053
|
components.LayoutComposer,
|
|
6175
6054
|
{
|
|
6176
|
-
widgetsZonePrefix: "
|
|
6177
|
-
preferredLayoutId: "core:
|
|
6055
|
+
widgetsZonePrefix: "store_credit_account.list",
|
|
6056
|
+
preferredLayoutId: "core:single-column",
|
|
6178
6057
|
sections: {
|
|
6179
|
-
main: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "
|
|
6180
|
-
side: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardProductsSection", children: /* @__PURE__ */ jsxRuntime.jsx(hooks.PermissionGuard, { permission: "product:read", children: /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductsSection, {}) }) })
|
|
6058
|
+
main: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountsTable", children: /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountsTable, {}) })
|
|
6181
6059
|
}
|
|
6182
6060
|
}
|
|
6183
6061
|
),
|
|
@@ -6185,9 +6063,9 @@ const GiftCardsPage = () => {
|
|
|
6185
6063
|
] });
|
|
6186
6064
|
};
|
|
6187
6065
|
const config$3 = adminSdk.defineRouteConfig({
|
|
6188
|
-
label: "
|
|
6189
|
-
icon:
|
|
6190
|
-
permissions: ["
|
|
6066
|
+
label: "Store Credits",
|
|
6067
|
+
icon: StoreCreditIcon,
|
|
6068
|
+
permissions: ["store_credit_account:read"]
|
|
6191
6069
|
});
|
|
6192
6070
|
function setRef$2(ref, value) {
|
|
6193
6071
|
if (typeof ref === "function") {
|
|
@@ -10882,27 +10760,6 @@ const StackedFocusModal = Object.assign(Root, {
|
|
|
10882
10760
|
Description,
|
|
10883
10761
|
Title
|
|
10884
10762
|
});
|
|
10885
|
-
const STORE_QUERY_KEY = "store";
|
|
10886
|
-
const storeQueryKeys = queryKeysFactory(STORE_QUERY_KEY);
|
|
10887
|
-
async function retrieveActiveStore(query) {
|
|
10888
|
-
const response = await sdk.admin.store.list(query);
|
|
10889
|
-
const activeStore = response.stores?.[0];
|
|
10890
|
-
if (!activeStore) {
|
|
10891
|
-
throw new Medusa.FetchError("No active store found", "Not Found", 404);
|
|
10892
|
-
}
|
|
10893
|
-
return { store: activeStore };
|
|
10894
|
-
}
|
|
10895
|
-
const useStore$2 = (query, options) => {
|
|
10896
|
-
const { data, ...rest } = reactQuery.useQuery({
|
|
10897
|
-
queryFn: () => retrieveActiveStore(query),
|
|
10898
|
-
queryKey: storeQueryKeys.details(),
|
|
10899
|
-
...options
|
|
10900
|
-
});
|
|
10901
|
-
return {
|
|
10902
|
-
...data,
|
|
10903
|
-
...rest
|
|
10904
|
-
};
|
|
10905
|
-
};
|
|
10906
10763
|
const t$1 = (r, t2, s2) => {
|
|
10907
10764
|
if (r && "reportValidity" in r) {
|
|
10908
10765
|
const o2 = get$2(s2, t2);
|
|
@@ -13948,7 +13805,7 @@ function useStoreProps(store, props, key2, setKey) {
|
|
|
13948
13805
|
});
|
|
13949
13806
|
});
|
|
13950
13807
|
}
|
|
13951
|
-
function useStore$
|
|
13808
|
+
function useStore$2(createStore2, props) {
|
|
13952
13809
|
const [store, setStore] = React__namespace.useState(() => createStore2(props));
|
|
13953
13810
|
useSafeLayoutEffect(() => init(store), [store]);
|
|
13954
13811
|
const useState = React__namespace.useCallback((keyOrSelector) => useStoreState(store, keyOrSelector), [store]);
|
|
@@ -14905,7 +14762,7 @@ function useDisclosureStoreProps(store, update, props) {
|
|
|
14905
14762
|
return Object.assign(store, { disclosure: props.disclosure });
|
|
14906
14763
|
}
|
|
14907
14764
|
function useDisclosureStore(props = {}) {
|
|
14908
|
-
const [store, update] = useStore$
|
|
14765
|
+
const [store, update] = useStore$2(createDisclosureStore, props);
|
|
14909
14766
|
return useDisclosureStoreProps(store, update, props);
|
|
14910
14767
|
}
|
|
14911
14768
|
const ctx$2 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]);
|
|
@@ -15714,7 +15571,7 @@ function useDialogStoreProps(store, update, props) {
|
|
|
15714
15571
|
return useDisclosureStoreProps(store, update, props);
|
|
15715
15572
|
}
|
|
15716
15573
|
function useDialogStore(props = {}) {
|
|
15717
|
-
const [store, update] = useStore$
|
|
15574
|
+
const [store, update] = useStore$2(createDialogStore, props);
|
|
15718
15575
|
return useDialogStoreProps(store, update, props);
|
|
15719
15576
|
}
|
|
15720
15577
|
function isHiddenDismiss(element, ...ids2) {
|
|
@@ -19030,7 +18887,7 @@ function useComboboxStoreProps(store, update, props) {
|
|
|
19030
18887
|
}
|
|
19031
18888
|
function useComboboxStore(props = {}) {
|
|
19032
18889
|
props = useComboboxStoreOptions(props);
|
|
19033
|
-
const [store, update] = useStore$
|
|
18890
|
+
const [store, update] = useStore$2(createComboboxStore, props);
|
|
19034
18891
|
return useComboboxStoreProps(store, update, props);
|
|
19035
18892
|
}
|
|
19036
18893
|
function ComboboxProvider(props = {}) {
|
|
@@ -20149,6 +20006,371 @@ const ComboboxImpl = ({
|
|
|
20149
20006
|
);
|
|
20150
20007
|
};
|
|
20151
20008
|
const Combobox2 = genericForwardRef(ComboboxImpl);
|
|
20009
|
+
var isObject_1;
|
|
20010
|
+
var hasRequiredIsObject;
|
|
20011
|
+
function requireIsObject() {
|
|
20012
|
+
if (hasRequiredIsObject) return isObject_1;
|
|
20013
|
+
hasRequiredIsObject = 1;
|
|
20014
|
+
function isObject2(value) {
|
|
20015
|
+
var type = typeof value;
|
|
20016
|
+
return value != null && (type == "object" || type == "function");
|
|
20017
|
+
}
|
|
20018
|
+
isObject_1 = isObject2;
|
|
20019
|
+
return isObject_1;
|
|
20020
|
+
}
|
|
20021
|
+
var _freeGlobal;
|
|
20022
|
+
var hasRequired_freeGlobal;
|
|
20023
|
+
function require_freeGlobal() {
|
|
20024
|
+
if (hasRequired_freeGlobal) return _freeGlobal;
|
|
20025
|
+
hasRequired_freeGlobal = 1;
|
|
20026
|
+
var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
20027
|
+
_freeGlobal = freeGlobal;
|
|
20028
|
+
return _freeGlobal;
|
|
20029
|
+
}
|
|
20030
|
+
var _root;
|
|
20031
|
+
var hasRequired_root;
|
|
20032
|
+
function require_root() {
|
|
20033
|
+
if (hasRequired_root) return _root;
|
|
20034
|
+
hasRequired_root = 1;
|
|
20035
|
+
var freeGlobal = require_freeGlobal();
|
|
20036
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
20037
|
+
var root = freeGlobal || freeSelf || Function("return this")();
|
|
20038
|
+
_root = root;
|
|
20039
|
+
return _root;
|
|
20040
|
+
}
|
|
20041
|
+
var now_1;
|
|
20042
|
+
var hasRequiredNow;
|
|
20043
|
+
function requireNow() {
|
|
20044
|
+
if (hasRequiredNow) return now_1;
|
|
20045
|
+
hasRequiredNow = 1;
|
|
20046
|
+
var root = require_root();
|
|
20047
|
+
var now = function() {
|
|
20048
|
+
return root.Date.now();
|
|
20049
|
+
};
|
|
20050
|
+
now_1 = now;
|
|
20051
|
+
return now_1;
|
|
20052
|
+
}
|
|
20053
|
+
var _trimmedEndIndex;
|
|
20054
|
+
var hasRequired_trimmedEndIndex;
|
|
20055
|
+
function require_trimmedEndIndex() {
|
|
20056
|
+
if (hasRequired_trimmedEndIndex) return _trimmedEndIndex;
|
|
20057
|
+
hasRequired_trimmedEndIndex = 1;
|
|
20058
|
+
var reWhitespace = /\s/;
|
|
20059
|
+
function trimmedEndIndex(string2) {
|
|
20060
|
+
var index = string2.length;
|
|
20061
|
+
while (index-- && reWhitespace.test(string2.charAt(index))) {
|
|
20062
|
+
}
|
|
20063
|
+
return index;
|
|
20064
|
+
}
|
|
20065
|
+
_trimmedEndIndex = trimmedEndIndex;
|
|
20066
|
+
return _trimmedEndIndex;
|
|
20067
|
+
}
|
|
20068
|
+
var _baseTrim;
|
|
20069
|
+
var hasRequired_baseTrim;
|
|
20070
|
+
function require_baseTrim() {
|
|
20071
|
+
if (hasRequired_baseTrim) return _baseTrim;
|
|
20072
|
+
hasRequired_baseTrim = 1;
|
|
20073
|
+
var trimmedEndIndex = require_trimmedEndIndex();
|
|
20074
|
+
var reTrimStart = /^\s+/;
|
|
20075
|
+
function baseTrim(string2) {
|
|
20076
|
+
return string2 ? string2.slice(0, trimmedEndIndex(string2) + 1).replace(reTrimStart, "") : string2;
|
|
20077
|
+
}
|
|
20078
|
+
_baseTrim = baseTrim;
|
|
20079
|
+
return _baseTrim;
|
|
20080
|
+
}
|
|
20081
|
+
var _Symbol;
|
|
20082
|
+
var hasRequired_Symbol;
|
|
20083
|
+
function require_Symbol() {
|
|
20084
|
+
if (hasRequired_Symbol) return _Symbol;
|
|
20085
|
+
hasRequired_Symbol = 1;
|
|
20086
|
+
var root = require_root();
|
|
20087
|
+
var Symbol2 = root.Symbol;
|
|
20088
|
+
_Symbol = Symbol2;
|
|
20089
|
+
return _Symbol;
|
|
20090
|
+
}
|
|
20091
|
+
var _getRawTag;
|
|
20092
|
+
var hasRequired_getRawTag;
|
|
20093
|
+
function require_getRawTag() {
|
|
20094
|
+
if (hasRequired_getRawTag) return _getRawTag;
|
|
20095
|
+
hasRequired_getRawTag = 1;
|
|
20096
|
+
var Symbol2 = require_Symbol();
|
|
20097
|
+
var objectProto = Object.prototype;
|
|
20098
|
+
var hasOwnProperty2 = objectProto.hasOwnProperty;
|
|
20099
|
+
var nativeObjectToString = objectProto.toString;
|
|
20100
|
+
var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
|
|
20101
|
+
function getRawTag(value) {
|
|
20102
|
+
var isOwn = hasOwnProperty2.call(value, symToStringTag), tag = value[symToStringTag];
|
|
20103
|
+
try {
|
|
20104
|
+
value[symToStringTag] = void 0;
|
|
20105
|
+
var unmasked = true;
|
|
20106
|
+
} catch (e) {
|
|
20107
|
+
}
|
|
20108
|
+
var result = nativeObjectToString.call(value);
|
|
20109
|
+
if (unmasked) {
|
|
20110
|
+
if (isOwn) {
|
|
20111
|
+
value[symToStringTag] = tag;
|
|
20112
|
+
} else {
|
|
20113
|
+
delete value[symToStringTag];
|
|
20114
|
+
}
|
|
20115
|
+
}
|
|
20116
|
+
return result;
|
|
20117
|
+
}
|
|
20118
|
+
_getRawTag = getRawTag;
|
|
20119
|
+
return _getRawTag;
|
|
20120
|
+
}
|
|
20121
|
+
var _objectToString;
|
|
20122
|
+
var hasRequired_objectToString;
|
|
20123
|
+
function require_objectToString() {
|
|
20124
|
+
if (hasRequired_objectToString) return _objectToString;
|
|
20125
|
+
hasRequired_objectToString = 1;
|
|
20126
|
+
var objectProto = Object.prototype;
|
|
20127
|
+
var nativeObjectToString = objectProto.toString;
|
|
20128
|
+
function objectToString(value) {
|
|
20129
|
+
return nativeObjectToString.call(value);
|
|
20130
|
+
}
|
|
20131
|
+
_objectToString = objectToString;
|
|
20132
|
+
return _objectToString;
|
|
20133
|
+
}
|
|
20134
|
+
var _baseGetTag;
|
|
20135
|
+
var hasRequired_baseGetTag;
|
|
20136
|
+
function require_baseGetTag() {
|
|
20137
|
+
if (hasRequired_baseGetTag) return _baseGetTag;
|
|
20138
|
+
hasRequired_baseGetTag = 1;
|
|
20139
|
+
var Symbol2 = require_Symbol(), getRawTag = require_getRawTag(), objectToString = require_objectToString();
|
|
20140
|
+
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
|
|
20141
|
+
var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
|
|
20142
|
+
function baseGetTag(value) {
|
|
20143
|
+
if (value == null) {
|
|
20144
|
+
return value === void 0 ? undefinedTag : nullTag;
|
|
20145
|
+
}
|
|
20146
|
+
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
20147
|
+
}
|
|
20148
|
+
_baseGetTag = baseGetTag;
|
|
20149
|
+
return _baseGetTag;
|
|
20150
|
+
}
|
|
20151
|
+
var isObjectLike_1;
|
|
20152
|
+
var hasRequiredIsObjectLike;
|
|
20153
|
+
function requireIsObjectLike() {
|
|
20154
|
+
if (hasRequiredIsObjectLike) return isObjectLike_1;
|
|
20155
|
+
hasRequiredIsObjectLike = 1;
|
|
20156
|
+
function isObjectLike(value) {
|
|
20157
|
+
return value != null && typeof value == "object";
|
|
20158
|
+
}
|
|
20159
|
+
isObjectLike_1 = isObjectLike;
|
|
20160
|
+
return isObjectLike_1;
|
|
20161
|
+
}
|
|
20162
|
+
var isSymbol_1;
|
|
20163
|
+
var hasRequiredIsSymbol;
|
|
20164
|
+
function requireIsSymbol() {
|
|
20165
|
+
if (hasRequiredIsSymbol) return isSymbol_1;
|
|
20166
|
+
hasRequiredIsSymbol = 1;
|
|
20167
|
+
var baseGetTag = require_baseGetTag(), isObjectLike = requireIsObjectLike();
|
|
20168
|
+
var symbolTag = "[object Symbol]";
|
|
20169
|
+
function isSymbol(value) {
|
|
20170
|
+
return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
|
|
20171
|
+
}
|
|
20172
|
+
isSymbol_1 = isSymbol;
|
|
20173
|
+
return isSymbol_1;
|
|
20174
|
+
}
|
|
20175
|
+
var toNumber_1;
|
|
20176
|
+
var hasRequiredToNumber;
|
|
20177
|
+
function requireToNumber() {
|
|
20178
|
+
if (hasRequiredToNumber) return toNumber_1;
|
|
20179
|
+
hasRequiredToNumber = 1;
|
|
20180
|
+
var baseTrim = require_baseTrim(), isObject2 = requireIsObject(), isSymbol = requireIsSymbol();
|
|
20181
|
+
var NAN = 0 / 0;
|
|
20182
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
20183
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
20184
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
20185
|
+
var freeParseInt = parseInt;
|
|
20186
|
+
function toNumber(value) {
|
|
20187
|
+
if (typeof value == "number") {
|
|
20188
|
+
return value;
|
|
20189
|
+
}
|
|
20190
|
+
if (isSymbol(value)) {
|
|
20191
|
+
return NAN;
|
|
20192
|
+
}
|
|
20193
|
+
if (isObject2(value)) {
|
|
20194
|
+
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
20195
|
+
value = isObject2(other) ? other + "" : other;
|
|
20196
|
+
}
|
|
20197
|
+
if (typeof value != "string") {
|
|
20198
|
+
return value === 0 ? value : +value;
|
|
20199
|
+
}
|
|
20200
|
+
value = baseTrim(value);
|
|
20201
|
+
var isBinary = reIsBinary.test(value);
|
|
20202
|
+
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
|
20203
|
+
}
|
|
20204
|
+
toNumber_1 = toNumber;
|
|
20205
|
+
return toNumber_1;
|
|
20206
|
+
}
|
|
20207
|
+
var debounce_1;
|
|
20208
|
+
var hasRequiredDebounce;
|
|
20209
|
+
function requireDebounce() {
|
|
20210
|
+
if (hasRequiredDebounce) return debounce_1;
|
|
20211
|
+
hasRequiredDebounce = 1;
|
|
20212
|
+
var isObject2 = requireIsObject(), now = requireNow(), toNumber = requireToNumber();
|
|
20213
|
+
var FUNC_ERROR_TEXT = "Expected a function";
|
|
20214
|
+
var nativeMax = Math.max, nativeMin = Math.min;
|
|
20215
|
+
function debounce2(func, wait, options) {
|
|
20216
|
+
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
20217
|
+
if (typeof func != "function") {
|
|
20218
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
20219
|
+
}
|
|
20220
|
+
wait = toNumber(wait) || 0;
|
|
20221
|
+
if (isObject2(options)) {
|
|
20222
|
+
leading = !!options.leading;
|
|
20223
|
+
maxing = "maxWait" in options;
|
|
20224
|
+
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
20225
|
+
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
20226
|
+
}
|
|
20227
|
+
function invokeFunc(time2) {
|
|
20228
|
+
var args = lastArgs, thisArg = lastThis;
|
|
20229
|
+
lastArgs = lastThis = void 0;
|
|
20230
|
+
lastInvokeTime = time2;
|
|
20231
|
+
result = func.apply(thisArg, args);
|
|
20232
|
+
return result;
|
|
20233
|
+
}
|
|
20234
|
+
function leadingEdge(time2) {
|
|
20235
|
+
lastInvokeTime = time2;
|
|
20236
|
+
timerId = setTimeout(timerExpired, wait);
|
|
20237
|
+
return leading ? invokeFunc(time2) : result;
|
|
20238
|
+
}
|
|
20239
|
+
function remainingWait(time2) {
|
|
20240
|
+
var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
|
|
20241
|
+
return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
|
|
20242
|
+
}
|
|
20243
|
+
function shouldInvoke(time2) {
|
|
20244
|
+
var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime;
|
|
20245
|
+
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
|
20246
|
+
}
|
|
20247
|
+
function timerExpired() {
|
|
20248
|
+
var time2 = now();
|
|
20249
|
+
if (shouldInvoke(time2)) {
|
|
20250
|
+
return trailingEdge(time2);
|
|
20251
|
+
}
|
|
20252
|
+
timerId = setTimeout(timerExpired, remainingWait(time2));
|
|
20253
|
+
}
|
|
20254
|
+
function trailingEdge(time2) {
|
|
20255
|
+
timerId = void 0;
|
|
20256
|
+
if (trailing && lastArgs) {
|
|
20257
|
+
return invokeFunc(time2);
|
|
20258
|
+
}
|
|
20259
|
+
lastArgs = lastThis = void 0;
|
|
20260
|
+
return result;
|
|
20261
|
+
}
|
|
20262
|
+
function cancel() {
|
|
20263
|
+
if (timerId !== void 0) {
|
|
20264
|
+
clearTimeout(timerId);
|
|
20265
|
+
}
|
|
20266
|
+
lastInvokeTime = 0;
|
|
20267
|
+
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
|
20268
|
+
}
|
|
20269
|
+
function flush() {
|
|
20270
|
+
return timerId === void 0 ? result : trailingEdge(now());
|
|
20271
|
+
}
|
|
20272
|
+
function debounced() {
|
|
20273
|
+
var time2 = now(), isInvoking = shouldInvoke(time2);
|
|
20274
|
+
lastArgs = arguments;
|
|
20275
|
+
lastThis = this;
|
|
20276
|
+
lastCallTime = time2;
|
|
20277
|
+
if (isInvoking) {
|
|
20278
|
+
if (timerId === void 0) {
|
|
20279
|
+
return leadingEdge(lastCallTime);
|
|
20280
|
+
}
|
|
20281
|
+
if (maxing) {
|
|
20282
|
+
clearTimeout(timerId);
|
|
20283
|
+
timerId = setTimeout(timerExpired, wait);
|
|
20284
|
+
return invokeFunc(lastCallTime);
|
|
20285
|
+
}
|
|
20286
|
+
}
|
|
20287
|
+
if (timerId === void 0) {
|
|
20288
|
+
timerId = setTimeout(timerExpired, wait);
|
|
20289
|
+
}
|
|
20290
|
+
return result;
|
|
20291
|
+
}
|
|
20292
|
+
debounced.cancel = cancel;
|
|
20293
|
+
debounced.flush = flush;
|
|
20294
|
+
return debounced;
|
|
20295
|
+
}
|
|
20296
|
+
debounce_1 = debounce2;
|
|
20297
|
+
return debounce_1;
|
|
20298
|
+
}
|
|
20299
|
+
var debounceExports = requireDebounce();
|
|
20300
|
+
const debounce$1 = /* @__PURE__ */ getDefaultExportFromCjs(debounceExports);
|
|
20301
|
+
const useDebouncedSearch = () => {
|
|
20302
|
+
const [searchValue, onSearchValueChange] = React.useState("");
|
|
20303
|
+
const [debouncedQuery, setDebouncedQuery] = React.useState("");
|
|
20304
|
+
const debouncedUpdate = React.useCallback(
|
|
20305
|
+
debounce$1((query) => setDebouncedQuery(query), 300),
|
|
20306
|
+
[]
|
|
20307
|
+
);
|
|
20308
|
+
React.useEffect(() => {
|
|
20309
|
+
debouncedUpdate(searchValue);
|
|
20310
|
+
return () => debouncedUpdate.cancel();
|
|
20311
|
+
}, [searchValue, debouncedUpdate]);
|
|
20312
|
+
return {
|
|
20313
|
+
searchValue,
|
|
20314
|
+
onSearchValueChange,
|
|
20315
|
+
query: debouncedQuery || void 0
|
|
20316
|
+
};
|
|
20317
|
+
};
|
|
20318
|
+
const useComboboxData = ({
|
|
20319
|
+
queryKey,
|
|
20320
|
+
queryFn,
|
|
20321
|
+
getOptions,
|
|
20322
|
+
defaultValue: defaultValue2,
|
|
20323
|
+
defaultValueKey,
|
|
20324
|
+
pageSize = 10,
|
|
20325
|
+
enabled = true
|
|
20326
|
+
}) => {
|
|
20327
|
+
const { searchValue, onSearchValueChange, query } = useDebouncedSearch();
|
|
20328
|
+
const queryInitialDataBy = defaultValueKey || "id";
|
|
20329
|
+
const { data: initialData } = reactQuery.useQuery({
|
|
20330
|
+
queryKey,
|
|
20331
|
+
queryFn: async () => {
|
|
20332
|
+
return queryFn({
|
|
20333
|
+
[queryInitialDataBy]: defaultValue2,
|
|
20334
|
+
limit: Array.isArray(defaultValue2) ? defaultValue2.length : 1
|
|
20335
|
+
});
|
|
20336
|
+
},
|
|
20337
|
+
enabled: enabled && !!defaultValue2
|
|
20338
|
+
});
|
|
20339
|
+
const { data, ...rest } = reactQuery.useInfiniteQuery({
|
|
20340
|
+
queryKey: [...queryKey, query],
|
|
20341
|
+
queryFn: async ({ pageParam = 0 }) => {
|
|
20342
|
+
return await queryFn({
|
|
20343
|
+
q: query,
|
|
20344
|
+
limit: pageSize,
|
|
20345
|
+
offset: pageParam
|
|
20346
|
+
});
|
|
20347
|
+
},
|
|
20348
|
+
initialPageParam: 0,
|
|
20349
|
+
getNextPageParam: (lastPage) => {
|
|
20350
|
+
const moreItemsExist = lastPage.count > lastPage.offset + lastPage.limit;
|
|
20351
|
+
return moreItemsExist ? lastPage.offset + lastPage.limit : void 0;
|
|
20352
|
+
},
|
|
20353
|
+
placeholderData: reactQuery.keepPreviousData,
|
|
20354
|
+
enabled
|
|
20355
|
+
});
|
|
20356
|
+
const options = data?.pages.flatMap((page) => getOptions(page)) ?? [];
|
|
20357
|
+
const defaultOptions2 = initialData ? getOptions(initialData) : [];
|
|
20358
|
+
const disabled = !rest.isPending && !options.length && !searchValue;
|
|
20359
|
+
if (defaultValue2 && defaultOptions2.length && !searchValue) {
|
|
20360
|
+
defaultOptions2.forEach((option) => {
|
|
20361
|
+
if (!options.find((o2) => o2.value === option.value)) {
|
|
20362
|
+
options.unshift(option);
|
|
20363
|
+
}
|
|
20364
|
+
});
|
|
20365
|
+
}
|
|
20366
|
+
return {
|
|
20367
|
+
options,
|
|
20368
|
+
searchValue,
|
|
20369
|
+
onSearchValueChange,
|
|
20370
|
+
disabled,
|
|
20371
|
+
...rest
|
|
20372
|
+
};
|
|
20373
|
+
};
|
|
20152
20374
|
const currencies = {
|
|
20153
20375
|
USD: {
|
|
20154
20376
|
code: "USD",
|
|
@@ -20901,6 +21123,515 @@ const currencies = {
|
|
|
20901
21123
|
decimal_digits: 0
|
|
20902
21124
|
}
|
|
20903
21125
|
};
|
|
21126
|
+
const formSchema = zod.z.object({
|
|
21127
|
+
currency_code: zod.z.string().min(1, "Please select a currency"),
|
|
21128
|
+
customer_id: zod.z.string().optional()
|
|
21129
|
+
});
|
|
21130
|
+
const StoreCreditAccountCreateForm = () => {
|
|
21131
|
+
const { handleSuccess } = useRouteModal();
|
|
21132
|
+
const [searchParams] = reactRouterDom.useSearchParams();
|
|
21133
|
+
const prefilledCustomerId = searchParams.get("prefill_customer_id") ?? "";
|
|
21134
|
+
const { hasPermission } = hooks.usePermissions();
|
|
21135
|
+
const canReadCustomers = hasPermission("customer:read");
|
|
21136
|
+
const form = useForm({
|
|
21137
|
+
defaultValues: {
|
|
21138
|
+
currency_code: "",
|
|
21139
|
+
customer_id: prefilledCustomerId
|
|
21140
|
+
},
|
|
21141
|
+
resolver: u(formSchema)
|
|
21142
|
+
});
|
|
21143
|
+
const { mutateAsync: createStoreCreditAccount, isPending } = useCreateStoreCreditAccount();
|
|
21144
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
21145
|
+
if (!data.customer_id) {
|
|
21146
|
+
delete data.customer_id;
|
|
21147
|
+
}
|
|
21148
|
+
await createStoreCreditAccount(data, {
|
|
21149
|
+
onSuccess: (data2) => {
|
|
21150
|
+
ui.toast.success(`Store credit account was successfully created.`);
|
|
21151
|
+
handleSuccess(`../${data2.store_credit_account.id}`);
|
|
21152
|
+
},
|
|
21153
|
+
onError: (error2) => {
|
|
21154
|
+
ui.toast.error(error2.message);
|
|
21155
|
+
}
|
|
21156
|
+
});
|
|
21157
|
+
});
|
|
21158
|
+
const [currencySearchValue, setCurrencySearchValue] = React.useState("");
|
|
21159
|
+
const currencyOptions = React.useMemo(() => {
|
|
21160
|
+
const options = Object.values(currencies).map((currency) => ({
|
|
21161
|
+
label: `${currency.code} - ${currency.name} (${currency.symbol_native})`,
|
|
21162
|
+
value: currency.code.toLowerCase()
|
|
21163
|
+
}));
|
|
21164
|
+
if (!currencySearchValue) {
|
|
21165
|
+
return options;
|
|
21166
|
+
}
|
|
21167
|
+
return options.filter(
|
|
21168
|
+
(option) => option.label.toLowerCase().includes(currencySearchValue.toLowerCase())
|
|
21169
|
+
);
|
|
21170
|
+
}, [currencySearchValue]);
|
|
21171
|
+
const {
|
|
21172
|
+
options: customerOptions,
|
|
21173
|
+
fetchNextPage,
|
|
21174
|
+
isFetchingNextPage,
|
|
21175
|
+
searchValue,
|
|
21176
|
+
onSearchValueChange,
|
|
21177
|
+
isLoading
|
|
21178
|
+
} = useComboboxData({
|
|
21179
|
+
queryKey: customersQueryKeys.list(),
|
|
21180
|
+
defaultValue: prefilledCustomerId || void 0,
|
|
21181
|
+
enabled: canReadCustomers,
|
|
21182
|
+
queryFn: async (params) => {
|
|
21183
|
+
return sdk.admin.customer.list(params);
|
|
21184
|
+
},
|
|
21185
|
+
getOptions: (data) => {
|
|
21186
|
+
return data.customers?.map((customer) => {
|
|
21187
|
+
const fullName = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
21188
|
+
const label = fullName ? `${customer.email} (${fullName})` : customer.email;
|
|
21189
|
+
return {
|
|
21190
|
+
label,
|
|
21191
|
+
value: customer.id
|
|
21192
|
+
};
|
|
21193
|
+
}) || [];
|
|
21194
|
+
}
|
|
21195
|
+
});
|
|
21196
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Form, { form, children: [
|
|
21197
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "-my-2 w-full border-l" }) }),
|
|
21198
|
+
/* @__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: [
|
|
21199
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
21200
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Create Store Credit Account" }),
|
|
21201
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", size: "small", children: "Create a new store credit account for a customer" })
|
|
21202
|
+
] }),
|
|
21203
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-x-4", children: [
|
|
21204
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21205
|
+
Form$2.Field,
|
|
21206
|
+
{
|
|
21207
|
+
control: form.control,
|
|
21208
|
+
name: "currency_code",
|
|
21209
|
+
render: ({ field }) => {
|
|
21210
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
21211
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Currency" }),
|
|
21212
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
21213
|
+
Combobox2,
|
|
21214
|
+
{
|
|
21215
|
+
value: field.value,
|
|
21216
|
+
onChange: field.onChange,
|
|
21217
|
+
searchValue: currencySearchValue,
|
|
21218
|
+
onSearchValueChange: setCurrencySearchValue,
|
|
21219
|
+
options: currencyOptions,
|
|
21220
|
+
placeholder: "Search for a currency..."
|
|
21221
|
+
}
|
|
21222
|
+
) }),
|
|
21223
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
21224
|
+
] });
|
|
21225
|
+
}
|
|
21226
|
+
}
|
|
21227
|
+
),
|
|
21228
|
+
canReadCustomers && /* @__PURE__ */ jsxRuntime.jsx(
|
|
21229
|
+
Form$2.Field,
|
|
21230
|
+
{
|
|
21231
|
+
control: form.control,
|
|
21232
|
+
name: "customer_id",
|
|
21233
|
+
render: ({ field }) => {
|
|
21234
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
21235
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Customer" }),
|
|
21236
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
21237
|
+
Combobox2,
|
|
21238
|
+
{
|
|
21239
|
+
value: field.value,
|
|
21240
|
+
onChange: field.onChange,
|
|
21241
|
+
searchValue,
|
|
21242
|
+
onSearchValueChange,
|
|
21243
|
+
options: customerOptions,
|
|
21244
|
+
placeholder: "Search for a customer...",
|
|
21245
|
+
fetchNextPage,
|
|
21246
|
+
isFetchingNextPage,
|
|
21247
|
+
noResultsPlaceholder: isLoading ? "Loading customers..." : "No customers found"
|
|
21248
|
+
}
|
|
21249
|
+
) }),
|
|
21250
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
21251
|
+
] });
|
|
21252
|
+
}
|
|
21253
|
+
}
|
|
21254
|
+
)
|
|
21255
|
+
] })
|
|
21256
|
+
] }) }) }),
|
|
21257
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Footer, { children: [
|
|
21258
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, disabled: isPending, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", disabled: isPending, children: "Cancel" }) }),
|
|
21259
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21260
|
+
ui.Button,
|
|
21261
|
+
{
|
|
21262
|
+
variant: "primary",
|
|
21263
|
+
size: "small",
|
|
21264
|
+
onClick: handleSubmit,
|
|
21265
|
+
disabled: isPending,
|
|
21266
|
+
children: "Create"
|
|
21267
|
+
}
|
|
21268
|
+
)
|
|
21269
|
+
] })
|
|
21270
|
+
] });
|
|
21271
|
+
};
|
|
21272
|
+
const StoreCreditAccountCreate = () => {
|
|
21273
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal, { children: [
|
|
21274
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create Store Credit Account" }) }),
|
|
21275
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create a new store credit account" }) }),
|
|
21276
|
+
/* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCreateForm, {})
|
|
21277
|
+
] });
|
|
21278
|
+
};
|
|
21279
|
+
const handle$e = {
|
|
21280
|
+
permissions: ["store_credit_account:create"]
|
|
21281
|
+
};
|
|
21282
|
+
const GiftCardIcon = (props) => {
|
|
21283
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
21284
|
+
"svg",
|
|
21285
|
+
{
|
|
21286
|
+
width: "15",
|
|
21287
|
+
height: "15",
|
|
21288
|
+
viewBox: "0 0 15 15",
|
|
21289
|
+
fill: "none",
|
|
21290
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
21291
|
+
...props,
|
|
21292
|
+
children: [
|
|
21293
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#F97316" }),
|
|
21294
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21295
|
+
"rect",
|
|
21296
|
+
{
|
|
21297
|
+
width: "15",
|
|
21298
|
+
height: "15",
|
|
21299
|
+
fill: "url(#paint0_linear_28788_25808)",
|
|
21300
|
+
fillOpacity: "0.2"
|
|
21301
|
+
}
|
|
21302
|
+
),
|
|
21303
|
+
/* @__PURE__ */ jsxRuntime.jsxs("g", { clipPath: "url(#clip0_28788_25808)", children: [
|
|
21304
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21305
|
+
"path",
|
|
21306
|
+
{
|
|
21307
|
+
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",
|
|
21308
|
+
fill: "white"
|
|
21309
|
+
}
|
|
21310
|
+
),
|
|
21311
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21312
|
+
"path",
|
|
21313
|
+
{
|
|
21314
|
+
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",
|
|
21315
|
+
fill: "white"
|
|
21316
|
+
}
|
|
21317
|
+
),
|
|
21318
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21319
|
+
"path",
|
|
21320
|
+
{
|
|
21321
|
+
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",
|
|
21322
|
+
fill: "white"
|
|
21323
|
+
}
|
|
21324
|
+
),
|
|
21325
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21326
|
+
"path",
|
|
21327
|
+
{
|
|
21328
|
+
d: "M6.938 7.5H3.75V9.563C3.75 10.7 4.675 11.625 5.813 11.625H6.938V7.5Z",
|
|
21329
|
+
fill: "white"
|
|
21330
|
+
}
|
|
21331
|
+
),
|
|
21332
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21333
|
+
"path",
|
|
21334
|
+
{
|
|
21335
|
+
d: "M8.063 7.5V11.625H9.188C10.325 11.625 11.25 10.7 11.25 9.563V7.5H8.063Z",
|
|
21336
|
+
fill: "white"
|
|
21337
|
+
}
|
|
21338
|
+
)
|
|
21339
|
+
] }),
|
|
21340
|
+
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
21341
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
21342
|
+
"linearGradient",
|
|
21343
|
+
{
|
|
21344
|
+
id: "paint0_linear_28788_25808",
|
|
21345
|
+
x1: "7.5",
|
|
21346
|
+
y1: "0",
|
|
21347
|
+
x2: "7.5",
|
|
21348
|
+
y2: "15",
|
|
21349
|
+
gradientUnits: "userSpaceOnUse",
|
|
21350
|
+
children: [
|
|
21351
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "white" }),
|
|
21352
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
|
|
21353
|
+
]
|
|
21354
|
+
}
|
|
21355
|
+
),
|
|
21356
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_28788_25808", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "9", height: "9", fill: "white", transform: "translate(3 3)" }) })
|
|
21357
|
+
] })
|
|
21358
|
+
]
|
|
21359
|
+
}
|
|
21360
|
+
);
|
|
21361
|
+
};
|
|
21362
|
+
const GiftCardProductsSection = () => {
|
|
21363
|
+
const { hasPermission } = hooks.usePermissions();
|
|
21364
|
+
const canCreateProduct = hasPermission("product:create");
|
|
21365
|
+
const { products: giftCardProducts, count: count2 = 0 } = useProducts({
|
|
21366
|
+
is_giftcard: true
|
|
21367
|
+
});
|
|
21368
|
+
const slicedProducts = giftCardProducts?.slice(0, 3) ?? [];
|
|
21369
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
21370
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
21371
|
+
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Gift Card Products" }),
|
|
21372
|
+
canCreateProduct && /* @__PURE__ */ jsxRuntime.jsx(
|
|
21373
|
+
reactRouterDom.Link,
|
|
21374
|
+
{
|
|
21375
|
+
to: `/gift-cards/gift-card-products/create`,
|
|
21376
|
+
className: "text-ui-fg-muted text-sm px-6",
|
|
21377
|
+
children: "Create"
|
|
21378
|
+
}
|
|
21379
|
+
)
|
|
21380
|
+
] }),
|
|
21381
|
+
giftCardProducts?.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
21382
|
+
NoRecords,
|
|
21383
|
+
{
|
|
21384
|
+
className: "px-10 py-4 h-[200px]",
|
|
21385
|
+
title: "No gift card products",
|
|
21386
|
+
message: "There are no gift card products to show. Create one to get started.",
|
|
21387
|
+
action: canCreateProduct ? {
|
|
21388
|
+
to: "/gift-cards/gift-card-products/create",
|
|
21389
|
+
label: "Create gift card product"
|
|
21390
|
+
} : void 0
|
|
21391
|
+
}
|
|
21392
|
+
),
|
|
21393
|
+
slicedProducts.map((giftCardProduct) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
21394
|
+
SidebarLink,
|
|
21395
|
+
{
|
|
21396
|
+
to: `/gift-cards/gift-card-products/${giftCardProduct.id}`,
|
|
21397
|
+
labelKey: giftCardProduct.title,
|
|
21398
|
+
descriptionKey: giftCardProduct.title,
|
|
21399
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Tag, {})
|
|
21400
|
+
}
|
|
21401
|
+
)),
|
|
21402
|
+
count2 > 3 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
21403
|
+
reactRouterDom.Link,
|
|
21404
|
+
{
|
|
21405
|
+
to: "/gift-cards/gift-card-products",
|
|
21406
|
+
className: "text-ui-fg-muted text-sm px-6 py-4 flex items-center justify-center",
|
|
21407
|
+
children: "View more"
|
|
21408
|
+
}
|
|
21409
|
+
)
|
|
21410
|
+
] });
|
|
21411
|
+
};
|
|
21412
|
+
const _giftCardQueryKey = queryKeysFactory("gift-card");
|
|
21413
|
+
const giftCardQueryKey = {
|
|
21414
|
+
..._giftCardQueryKey,
|
|
21415
|
+
orders: (id) => [..._giftCardQueryKey.detail(id), "orders"]
|
|
21416
|
+
};
|
|
21417
|
+
const useGiftCards = (query, options) => {
|
|
21418
|
+
const fetchGiftCards = (query2, headers) => sdk.client.fetch(`/admin/gift-cards`, {
|
|
21419
|
+
query: query2,
|
|
21420
|
+
headers
|
|
21421
|
+
});
|
|
21422
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
21423
|
+
...options,
|
|
21424
|
+
queryFn: () => fetchGiftCards(query),
|
|
21425
|
+
queryKey: giftCardQueryKey.list(query)
|
|
21426
|
+
});
|
|
21427
|
+
return { ...data, ...rest };
|
|
21428
|
+
};
|
|
21429
|
+
const useGiftCard = (id, query, options) => {
|
|
21430
|
+
const fetchGiftCard = (id2, query2, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
|
|
21431
|
+
query: query2,
|
|
21432
|
+
headers
|
|
21433
|
+
});
|
|
21434
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
21435
|
+
queryFn: () => fetchGiftCard(id, query),
|
|
21436
|
+
queryKey: giftCardQueryKey.detail(id, query),
|
|
21437
|
+
...options
|
|
21438
|
+
});
|
|
21439
|
+
return { ...data, ...rest };
|
|
21440
|
+
};
|
|
21441
|
+
const useGiftCardOrders = (id, options) => {
|
|
21442
|
+
const fetchGiftCardOrders = (id2, query, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}/orders`, {
|
|
21443
|
+
query,
|
|
21444
|
+
headers
|
|
21445
|
+
});
|
|
21446
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
21447
|
+
queryFn: () => fetchGiftCardOrders(id),
|
|
21448
|
+
queryKey: giftCardQueryKey.orders(id),
|
|
21449
|
+
...options
|
|
21450
|
+
});
|
|
21451
|
+
return { ...data, ...rest };
|
|
21452
|
+
};
|
|
21453
|
+
const useUpdateGiftCard = (id, options) => {
|
|
21454
|
+
const queryClient = reactQuery.useQueryClient();
|
|
21455
|
+
const updateGiftCard = async (id2, body) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
|
|
21456
|
+
body,
|
|
21457
|
+
method: "POST"
|
|
21458
|
+
});
|
|
21459
|
+
return reactQuery.useMutation({
|
|
21460
|
+
mutationFn: async (payload) => updateGiftCard(id, payload),
|
|
21461
|
+
onSuccess: (data, variables, context) => {
|
|
21462
|
+
queryClient.invalidateQueries({
|
|
21463
|
+
queryKey: giftCardQueryKey.detail(id)
|
|
21464
|
+
});
|
|
21465
|
+
queryClient.invalidateQueries({
|
|
21466
|
+
queryKey: giftCardQueryKey.lists()
|
|
21467
|
+
});
|
|
21468
|
+
},
|
|
21469
|
+
...options
|
|
21470
|
+
});
|
|
21471
|
+
};
|
|
21472
|
+
const useCreateGiftCard = (options) => {
|
|
21473
|
+
const queryClient = reactQuery.useQueryClient();
|
|
21474
|
+
const createGiftCard = async (body) => sdk.client.fetch(`/admin/gift-cards`, {
|
|
21475
|
+
body,
|
|
21476
|
+
method: "POST"
|
|
21477
|
+
});
|
|
21478
|
+
return reactQuery.useMutation({
|
|
21479
|
+
mutationFn: (body) => createGiftCard(body),
|
|
21480
|
+
onSuccess: (data, variables, context) => {
|
|
21481
|
+
queryClient.invalidateQueries({ queryKey: giftCardQueryKey.lists() });
|
|
21482
|
+
},
|
|
21483
|
+
...options
|
|
21484
|
+
});
|
|
21485
|
+
};
|
|
21486
|
+
const columnHelper$9 = ui.createDataTableColumnHelper();
|
|
21487
|
+
const useGiftCardTableColumns = () => {
|
|
21488
|
+
return React.useMemo(() => {
|
|
21489
|
+
return [
|
|
21490
|
+
columnHelper$9.accessor("code", {
|
|
21491
|
+
header: "Code",
|
|
21492
|
+
cell: ({ row }) => {
|
|
21493
|
+
return row.original.code;
|
|
21494
|
+
}
|
|
21495
|
+
}),
|
|
21496
|
+
columnHelper$9.accessor("line_item.product.title", {
|
|
21497
|
+
header: "Product",
|
|
21498
|
+
cell: ({ row }) => {
|
|
21499
|
+
return row.original.line_item?.product?.title || "Custom Gift Card";
|
|
21500
|
+
}
|
|
21501
|
+
}),
|
|
21502
|
+
columnHelper$9.accessor("created_at", {
|
|
21503
|
+
header: "Date issued",
|
|
21504
|
+
cell: ({ row }) => getRelativeDate(row.original.created_at)
|
|
21505
|
+
}),
|
|
21506
|
+
columnHelper$9.accessor("value", {
|
|
21507
|
+
header: "Value",
|
|
21508
|
+
cell: ({ row }) => {
|
|
21509
|
+
return formatAmount(row.original.value, row.original.currency_code);
|
|
21510
|
+
}
|
|
21511
|
+
})
|
|
21512
|
+
];
|
|
21513
|
+
}, []);
|
|
21514
|
+
};
|
|
21515
|
+
const useGiftCardFilters = () => {
|
|
21516
|
+
const dateFilterOptions = useDataTableDateFilters$1();
|
|
21517
|
+
const customerFilterOptions = useCustomerFilters();
|
|
21518
|
+
return React.useMemo(() => {
|
|
21519
|
+
return [...dateFilterOptions, ...customerFilterOptions];
|
|
21520
|
+
}, [dateFilterOptions, customerFilterOptions]);
|
|
21521
|
+
};
|
|
21522
|
+
const useGiftCardTableQuery = ({
|
|
21523
|
+
prefix,
|
|
21524
|
+
pageSize = 20
|
|
21525
|
+
}) => {
|
|
21526
|
+
const queryObject = useQueryParams(
|
|
21527
|
+
["q", "offset", "customer_id", "created_at", "updated_at"],
|
|
21528
|
+
prefix
|
|
21529
|
+
);
|
|
21530
|
+
const { offset: offset2, created_at, updated_at, customer_id, ...rest } = queryObject;
|
|
21531
|
+
const searchParams = {
|
|
21532
|
+
limit: pageSize,
|
|
21533
|
+
offset: offset2 ? Number(offset2) : 0,
|
|
21534
|
+
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
21535
|
+
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
21536
|
+
customer_id: customer_id ? JSON.parse(customer_id) : void 0,
|
|
21537
|
+
...rest
|
|
21538
|
+
};
|
|
21539
|
+
return searchParams;
|
|
21540
|
+
};
|
|
21541
|
+
const PAGE_SIZE$5 = 10;
|
|
21542
|
+
function GiftCardsTable() {
|
|
21543
|
+
const queryParams = useGiftCardTableQuery({
|
|
21544
|
+
pageSize: PAGE_SIZE$5
|
|
21545
|
+
});
|
|
21546
|
+
const {
|
|
21547
|
+
gift_cards: giftCards,
|
|
21548
|
+
isPending,
|
|
21549
|
+
count: count2
|
|
21550
|
+
} = useGiftCards({
|
|
21551
|
+
...queryParams,
|
|
21552
|
+
order: queryParams.order ?? "-created_at",
|
|
21553
|
+
fields: "+line_item.product.title"
|
|
21554
|
+
});
|
|
21555
|
+
const columns = useGiftCardTableColumns();
|
|
21556
|
+
const filters = useGiftCardFilters();
|
|
21557
|
+
const { hasPermission } = hooks.usePermissions();
|
|
21558
|
+
const canCreate = hasPermission("gift_card:create");
|
|
21559
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
21560
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
21561
|
+
DataTable,
|
|
21562
|
+
{
|
|
21563
|
+
data: giftCards,
|
|
21564
|
+
getRowId: (row) => row.id,
|
|
21565
|
+
columns,
|
|
21566
|
+
filters,
|
|
21567
|
+
isLoading: isPending,
|
|
21568
|
+
pageSize: PAGE_SIZE$5,
|
|
21569
|
+
rowCount: count2,
|
|
21570
|
+
heading: "Gift Cards",
|
|
21571
|
+
rowHref: (row) => `${row.id}`,
|
|
21572
|
+
emptyState: {
|
|
21573
|
+
empty: {
|
|
21574
|
+
heading: "No gift cards found",
|
|
21575
|
+
description: "Create a gift card to get started."
|
|
21576
|
+
},
|
|
21577
|
+
filtered: {
|
|
21578
|
+
heading: "No results found",
|
|
21579
|
+
description: "No gift cards match your filter criteria."
|
|
21580
|
+
}
|
|
21581
|
+
},
|
|
21582
|
+
actions: canCreate ? [
|
|
21583
|
+
{
|
|
21584
|
+
label: "Create",
|
|
21585
|
+
to: "create"
|
|
21586
|
+
}
|
|
21587
|
+
] : []
|
|
21588
|
+
}
|
|
21589
|
+
) }),
|
|
21590
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
21591
|
+
] });
|
|
21592
|
+
}
|
|
21593
|
+
const GiftCardsPage = () => {
|
|
21594
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
21595
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21596
|
+
components.LayoutComposer,
|
|
21597
|
+
{
|
|
21598
|
+
widgetsZonePrefix: "gift_card.list",
|
|
21599
|
+
preferredLayoutId: "core:two-column",
|
|
21600
|
+
sections: {
|
|
21601
|
+
main: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardsTable", children: /* @__PURE__ */ jsxRuntime.jsx(GiftCardsTable, {}) }),
|
|
21602
|
+
side: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardProductsSection", children: /* @__PURE__ */ jsxRuntime.jsx(hooks.PermissionGuard, { permission: "product:read", children: /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductsSection, {}) }) })
|
|
21603
|
+
}
|
|
21604
|
+
}
|
|
21605
|
+
),
|
|
21606
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Toaster, {})
|
|
21607
|
+
] });
|
|
21608
|
+
};
|
|
21609
|
+
const config$2 = adminSdk.defineRouteConfig({
|
|
21610
|
+
label: "Gift Cards",
|
|
21611
|
+
icon: GiftCardIcon,
|
|
21612
|
+
permissions: ["gift_card:read"]
|
|
21613
|
+
});
|
|
21614
|
+
const STORE_QUERY_KEY = "store";
|
|
21615
|
+
const storeQueryKeys = queryKeysFactory(STORE_QUERY_KEY);
|
|
21616
|
+
async function retrieveActiveStore(query) {
|
|
21617
|
+
const response = await sdk.admin.store.list(query);
|
|
21618
|
+
const activeStore = response.stores?.[0];
|
|
21619
|
+
if (!activeStore) {
|
|
21620
|
+
throw new Medusa.FetchError("No active store found", "Not Found", 404);
|
|
21621
|
+
}
|
|
21622
|
+
return { store: activeStore };
|
|
21623
|
+
}
|
|
21624
|
+
const useStore$1 = (query, options) => {
|
|
21625
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
21626
|
+
queryFn: () => retrieveActiveStore(query),
|
|
21627
|
+
queryKey: storeQueryKeys.details(),
|
|
21628
|
+
...options
|
|
21629
|
+
});
|
|
21630
|
+
return {
|
|
21631
|
+
...data,
|
|
21632
|
+
...rest
|
|
21633
|
+
};
|
|
21634
|
+
};
|
|
20904
21635
|
function getEnumValues(entries) {
|
|
20905
21636
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
20906
21637
|
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
@@ -21567,7 +22298,7 @@ class $ZodEncodeError extends Error {
|
|
|
21567
22298
|
}
|
|
21568
22299
|
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
|
|
21569
22300
|
const globalConfig = globalThis.__zod_globalConfig;
|
|
21570
|
-
function config$
|
|
22301
|
+
function config$1(newConfig) {
|
|
21571
22302
|
if (newConfig)
|
|
21572
22303
|
Object.assign(globalConfig, newConfig);
|
|
21573
22304
|
return globalConfig;
|
|
@@ -21693,7 +22424,7 @@ const _parse = (_Err) => {
|
|
|
21693
22424
|
throw new $ZodAsyncError();
|
|
21694
22425
|
}
|
|
21695
22426
|
if (result.issues.length) {
|
|
21696
|
-
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
22427
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())));
|
|
21697
22428
|
captureStackTrace(e, _params?.callee ?? fn);
|
|
21698
22429
|
throw e;
|
|
21699
22430
|
}
|
|
@@ -21708,7 +22439,7 @@ const _parseAsync = (_Err) => {
|
|
|
21708
22439
|
if (result instanceof Promise)
|
|
21709
22440
|
result = await result;
|
|
21710
22441
|
if (result.issues.length) {
|
|
21711
|
-
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
22442
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())));
|
|
21712
22443
|
captureStackTrace(e, params?.callee ?? fn);
|
|
21713
22444
|
throw e;
|
|
21714
22445
|
}
|
|
@@ -21730,7 +22461,7 @@ function failure(Err, issues, ctx2) {
|
|
|
21730
22461
|
success: false,
|
|
21731
22462
|
get error() {
|
|
21732
22463
|
if (!error2) {
|
|
21733
|
-
error2 = new Err(issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
22464
|
+
error2 = new Err(issues.map((iss) => finalizeIssue(iss, ctx2, config$1())));
|
|
21734
22465
|
issues = void 0;
|
|
21735
22466
|
ctx2 = void 0;
|
|
21736
22467
|
}
|
|
@@ -22355,7 +23086,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
22355
23086
|
own(this, "~standard", value);
|
|
22356
23087
|
}
|
|
22357
23088
|
});
|
|
22358
|
-
const toStandardResult = (r, ctx2) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
23089
|
+
const toStandardResult = (r, ctx2) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())) } : { value: r.value };
|
|
22359
23090
|
async function validateAsync(inst, value) {
|
|
22360
23091
|
const ctx2 = { async: true };
|
|
22361
23092
|
return toStandardResult(await inst._zod.run({ value, issues: [] }, ctx2), ctx2);
|
|
@@ -23217,7 +23948,7 @@ function handleUnionResults(results, final, inst, ctx2) {
|
|
|
23217
23948
|
code: "invalid_union",
|
|
23218
23949
|
input: final.value,
|
|
23219
23950
|
inst,
|
|
23220
|
-
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
23951
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())))
|
|
23221
23952
|
});
|
|
23222
23953
|
return final;
|
|
23223
23954
|
}
|
|
@@ -23413,7 +24144,7 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
23413
24144
|
payload.issues.push({
|
|
23414
24145
|
code: "invalid_key",
|
|
23415
24146
|
origin: "record",
|
|
23416
|
-
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
24147
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())),
|
|
23417
24148
|
input: key2,
|
|
23418
24149
|
path: [key2],
|
|
23419
24150
|
inst
|
|
@@ -23493,7 +24224,7 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
23493
24224
|
payload.issues.push({
|
|
23494
24225
|
code: "invalid_key",
|
|
23495
24226
|
origin: "record",
|
|
23496
|
-
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
24227
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config$1())),
|
|
23497
24228
|
input: key2,
|
|
23498
24229
|
path: [key2],
|
|
23499
24230
|
inst
|
|
@@ -23709,7 +24440,7 @@ function handleCatchResult(payload, result, def, ctx2) {
|
|
|
23709
24440
|
...result,
|
|
23710
24441
|
value: payload.value,
|
|
23711
24442
|
error: {
|
|
23712
|
-
issues: result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
24443
|
+
issues: result.issues.map((iss) => finalizeIssue(iss, ctx2, config$1()))
|
|
23713
24444
|
},
|
|
23714
24445
|
input: payload.value
|
|
23715
24446
|
});
|
|
@@ -25853,11 +26584,11 @@ const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
|
25853
26584
|
const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
25854
26585
|
function _ensureDefaultLocale() {
|
|
25855
26586
|
if (!globalConfig.localeError)
|
|
25856
|
-
config$
|
|
26587
|
+
config$1(en());
|
|
25857
26588
|
}
|
|
25858
26589
|
function _ensureDefaultMemoizer() {
|
|
25859
26590
|
if (!globalConfig.memoizer)
|
|
25860
|
-
config$
|
|
26591
|
+
config$1({ memoizer: memoizer() });
|
|
25861
26592
|
}
|
|
25862
26593
|
const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
25863
26594
|
_ensureDefaultLocale();
|
|
@@ -26961,746 +27692,742 @@ const GiftCardCreateForm = ({
|
|
|
26961
27692
|
] });
|
|
26962
27693
|
};
|
|
26963
27694
|
const GiftCardCreate = () => {
|
|
26964
|
-
const { store, isLoading } = useStore$
|
|
27695
|
+
const { store, isLoading } = useStore$1({});
|
|
26965
27696
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal, { children: [
|
|
26966
27697
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create Gift Card" }) }),
|
|
26967
27698
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create a new gift card" }) }),
|
|
26968
27699
|
!isLoading && /* @__PURE__ */ jsxRuntime.jsx(GiftCardCreateForm, { store })
|
|
26969
27700
|
] });
|
|
26970
27701
|
};
|
|
26971
|
-
const handle$
|
|
27702
|
+
const handle$d = {
|
|
26972
27703
|
permissions: ["gift_card:create", "store:read"]
|
|
26973
27704
|
};
|
|
26974
|
-
const
|
|
26975
|
-
|
|
26976
|
-
|
|
26977
|
-
|
|
26978
|
-
|
|
26979
|
-
|
|
26980
|
-
|
|
26981
|
-
|
|
26982
|
-
|
|
26983
|
-
|
|
26984
|
-
|
|
26985
|
-
|
|
26986
|
-
|
|
26987
|
-
"
|
|
26988
|
-
|
|
26989
|
-
|
|
26990
|
-
|
|
26991
|
-
|
|
26992
|
-
|
|
26993
|
-
|
|
26994
|
-
|
|
26995
|
-
|
|
26996
|
-
|
|
26997
|
-
|
|
26998
|
-
|
|
26999
|
-
|
|
27000
|
-
|
|
27001
|
-
|
|
27002
|
-
|
|
27003
|
-
|
|
27004
|
-
|
|
27005
|
-
|
|
27006
|
-
|
|
27007
|
-
|
|
27008
|
-
|
|
27009
|
-
|
|
27010
|
-
|
|
27705
|
+
const StoreCreditAccountBalanceSection = ({
|
|
27706
|
+
storeCreditAccount
|
|
27707
|
+
}) => {
|
|
27708
|
+
if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
|
|
27709
|
+
return;
|
|
27710
|
+
}
|
|
27711
|
+
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: [
|
|
27712
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-ui-tag-green-icon h-8 w-1 rounded-full" }),
|
|
27713
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
27714
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", size: "small", className: "text-ui-fg-subtle", children: "Current Balance" }),
|
|
27715
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
27716
|
+
ui.Text,
|
|
27717
|
+
{
|
|
27718
|
+
weight: "plus",
|
|
27719
|
+
size: "xlarge",
|
|
27720
|
+
className: "tabular-nums text-ui-fg-base",
|
|
27721
|
+
children: formatAmount(
|
|
27722
|
+
storeCreditAccount.balance,
|
|
27723
|
+
storeCreditAccount.currency_code
|
|
27724
|
+
)
|
|
27725
|
+
}
|
|
27726
|
+
)
|
|
27727
|
+
] })
|
|
27728
|
+
] }) });
|
|
27729
|
+
};
|
|
27730
|
+
var __create = Object.create;
|
|
27731
|
+
var __defProp = Object.defineProperty;
|
|
27732
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
27733
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
27734
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
27735
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
27736
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
27737
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
27738
|
+
};
|
|
27739
|
+
var __copyProps = (to, from, except, desc) => {
|
|
27740
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
27741
|
+
for (let key2 of __getOwnPropNames(from))
|
|
27742
|
+
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
|
27743
|
+
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
|
|
27744
|
+
}
|
|
27745
|
+
return to;
|
|
27746
|
+
};
|
|
27747
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27748
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27749
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27750
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27751
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27752
|
+
__defProp(target, "default", { value: mod, enumerable: true }),
|
|
27753
|
+
mod
|
|
27754
|
+
));
|
|
27755
|
+
var require_toggle_selection = __commonJS({
|
|
27756
|
+
"node_modules/toggle-selection/index.js"(exports2, module2) {
|
|
27757
|
+
module2.exports = function() {
|
|
27758
|
+
var selection = document.getSelection();
|
|
27759
|
+
if (!selection.rangeCount) {
|
|
27760
|
+
return function() {
|
|
27761
|
+
};
|
|
27762
|
+
}
|
|
27763
|
+
var active = document.activeElement;
|
|
27764
|
+
var ranges = [];
|
|
27765
|
+
for (var i2 = 0; i2 < selection.rangeCount; i2++) {
|
|
27766
|
+
ranges.push(selection.getRangeAt(i2));
|
|
27767
|
+
}
|
|
27768
|
+
switch (active.tagName.toUpperCase()) {
|
|
27769
|
+
// .toUpperCase handles XHTML
|
|
27770
|
+
case "INPUT":
|
|
27771
|
+
case "TEXTAREA":
|
|
27772
|
+
active.blur();
|
|
27773
|
+
break;
|
|
27774
|
+
default:
|
|
27775
|
+
active = null;
|
|
27776
|
+
break;
|
|
27777
|
+
}
|
|
27778
|
+
selection.removeAllRanges();
|
|
27779
|
+
return function() {
|
|
27780
|
+
selection.type === "Caret" && selection.removeAllRanges();
|
|
27781
|
+
if (!selection.rangeCount) {
|
|
27782
|
+
ranges.forEach(function(range) {
|
|
27783
|
+
selection.addRange(range);
|
|
27784
|
+
});
|
|
27785
|
+
}
|
|
27786
|
+
active && active.focus();
|
|
27787
|
+
};
|
|
27788
|
+
};
|
|
27789
|
+
}
|
|
27790
|
+
});
|
|
27791
|
+
var import_index = __toESM(require_toggle_selection());
|
|
27792
|
+
var toggle_selection_default = import_index.default;
|
|
27793
|
+
var defaultMessage = "Copy to clipboard: #{key}, Enter";
|
|
27794
|
+
function formatPromptMessage(message2) {
|
|
27795
|
+
var isMac2 = navigator.userAgentData ? /mac/i.test(navigator.userAgentData.platform) : /mac os x/i.test(navigator.userAgent);
|
|
27796
|
+
var copyKey = (isMac2 ? "⌘" : "Ctrl") + "+C";
|
|
27797
|
+
return message2.replace(/#{\s*key\s*}/g, copyKey);
|
|
27798
|
+
}
|
|
27799
|
+
function buildClipboardItem(text2, format2) {
|
|
27800
|
+
var items = {};
|
|
27801
|
+
items["text/plain"] = new Blob([text2], { type: "text/plain" });
|
|
27802
|
+
if (format2 && format2 !== "text/plain") {
|
|
27803
|
+
items[format2] = new Blob([text2], { type: format2 });
|
|
27804
|
+
}
|
|
27805
|
+
return new ClipboardItem(items);
|
|
27806
|
+
}
|
|
27807
|
+
async function copyViaClipboardAPI(text2, options) {
|
|
27808
|
+
if (!options.format && !options.onCopy) {
|
|
27809
|
+
await navigator.clipboard.writeText(text2);
|
|
27810
|
+
return true;
|
|
27811
|
+
}
|
|
27812
|
+
var item = buildClipboardItem(text2, options.format);
|
|
27813
|
+
if (options.onCopy) {
|
|
27814
|
+
item = options.onCopy(item) || item;
|
|
27815
|
+
}
|
|
27816
|
+
await navigator.clipboard.write([item]);
|
|
27817
|
+
return true;
|
|
27818
|
+
}
|
|
27819
|
+
function createHiddenSpan(text2, options) {
|
|
27820
|
+
var mark = document.createElement("span");
|
|
27821
|
+
mark.textContent = text2;
|
|
27822
|
+
mark.ariaHidden = "true";
|
|
27823
|
+
mark.style.all = "unset";
|
|
27824
|
+
mark.style.position = "fixed";
|
|
27825
|
+
mark.style.top = "0";
|
|
27826
|
+
mark.style.clip = "rect(0, 0, 0, 0)";
|
|
27827
|
+
mark.style.whiteSpace = "pre";
|
|
27828
|
+
mark.style.webkitUserSelect = "text";
|
|
27829
|
+
mark.style.MozUserSelect = "text";
|
|
27830
|
+
mark.style.msUserSelect = "text";
|
|
27831
|
+
mark.style.userSelect = "text";
|
|
27832
|
+
mark.addEventListener("copy", function(e) {
|
|
27833
|
+
e.stopPropagation();
|
|
27834
|
+
if (options.format) {
|
|
27835
|
+
e.preventDefault();
|
|
27836
|
+
if (e.clipboardData) {
|
|
27837
|
+
e.clipboardData.setData(options.format, text2);
|
|
27838
|
+
}
|
|
27839
|
+
}
|
|
27840
|
+
if (options.onCopy && e.clipboardData) {
|
|
27841
|
+
options.onCopy(e.clipboardData);
|
|
27842
|
+
}
|
|
27843
|
+
});
|
|
27844
|
+
return mark;
|
|
27845
|
+
}
|
|
27846
|
+
function findOpenedModalDialog() {
|
|
27847
|
+
let element = document.activeElement;
|
|
27848
|
+
while (element) {
|
|
27849
|
+
if (element.tagName === "DIALOG" && element.open) {
|
|
27850
|
+
return element;
|
|
27851
|
+
}
|
|
27852
|
+
element = element.parentElement;
|
|
27853
|
+
}
|
|
27854
|
+
return null;
|
|
27855
|
+
}
|
|
27856
|
+
function copyViaExecCommand(text2, options) {
|
|
27857
|
+
var reselectPrevious = toggle_selection_default();
|
|
27858
|
+
var range = document.createRange();
|
|
27859
|
+
var selection = document.getSelection();
|
|
27860
|
+
var mark = createHiddenSpan(text2, options);
|
|
27861
|
+
var root = findOpenedModalDialog() || document.fullscreenElement || document.body;
|
|
27862
|
+
var success = false;
|
|
27863
|
+
try {
|
|
27864
|
+
root.appendChild(mark);
|
|
27865
|
+
range.selectNodeContents(mark);
|
|
27866
|
+
selection.removeAllRanges();
|
|
27867
|
+
selection.addRange(range);
|
|
27868
|
+
var successful = document.execCommand("copy");
|
|
27869
|
+
if (!successful) {
|
|
27870
|
+
throw new Error("copy command was unsuccessful");
|
|
27871
|
+
}
|
|
27872
|
+
success = true;
|
|
27873
|
+
} finally {
|
|
27874
|
+
if (typeof selection.removeRange == "function") {
|
|
27875
|
+
selection.removeRange(range);
|
|
27876
|
+
} else {
|
|
27877
|
+
selection.removeAllRanges();
|
|
27878
|
+
}
|
|
27879
|
+
root.removeChild(mark);
|
|
27880
|
+
reselectPrevious();
|
|
27881
|
+
}
|
|
27882
|
+
return success;
|
|
27883
|
+
}
|
|
27884
|
+
async function copy$1(text2, options = {}) {
|
|
27885
|
+
var debug2 = options.debug || false;
|
|
27886
|
+
if (window.isSecureContext && navigator.clipboard) {
|
|
27887
|
+
try {
|
|
27888
|
+
return await copyViaClipboardAPI(text2, options);
|
|
27889
|
+
} catch (err) {
|
|
27890
|
+
debug2 && console.error("unable to copy using navigator.clipboard: ", err);
|
|
27891
|
+
debug2 && console.warn("falling back to execCommand");
|
|
27892
|
+
}
|
|
27893
|
+
} else {
|
|
27894
|
+
debug2 && !window.isSecureContext && console.warn("copy-to-clipboard: navigator.clipboard requires a secure context (HTTPS/localhost). Falling back to execCommand.");
|
|
27895
|
+
}
|
|
27896
|
+
try {
|
|
27897
|
+
return copyViaExecCommand(text2, options);
|
|
27898
|
+
} catch (err) {
|
|
27899
|
+
debug2 && console.error("unable to copy using execCommand: ", err);
|
|
27900
|
+
debug2 && console.error("falling back to prompt");
|
|
27901
|
+
if (options.fallbackToPrompt) {
|
|
27902
|
+
var message2 = formatPromptMessage("message" in options ? options.message : defaultMessage);
|
|
27903
|
+
window.prompt(message2, text2);
|
|
27904
|
+
}
|
|
27905
|
+
}
|
|
27906
|
+
return false;
|
|
27907
|
+
}
|
|
27908
|
+
var index_default = copy$1;
|
|
27909
|
+
function DisplayId({ id, className }) {
|
|
27910
|
+
const [open2, setOpen] = React.useState(false);
|
|
27911
|
+
const onClick = () => {
|
|
27912
|
+
index_default(id);
|
|
27913
|
+
ui.toast.success("Copied to clipboard");
|
|
27914
|
+
};
|
|
27915
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { maxWidth: 260, content: id, open: open2, onOpenChange: setOpen, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { onClick, className: ui.clx("cursor-pointer", className), children: [
|
|
27916
|
+
"#",
|
|
27917
|
+
id.slice(-7)
|
|
27918
|
+
] }) });
|
|
27919
|
+
}
|
|
27920
|
+
const StoreCreditAccountDetailsSection = ({
|
|
27921
|
+
storeCreditAccount
|
|
27922
|
+
}) => {
|
|
27923
|
+
const { hasPermission } = hooks.usePermissions();
|
|
27924
|
+
const canUpdate = hasPermission("store_credit_account:update");
|
|
27925
|
+
if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
|
|
27926
|
+
return;
|
|
27927
|
+
}
|
|
27928
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "flex justify-between gap-x-2 px-6 py-6", children: [
|
|
27929
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
27930
|
+
ui.Text,
|
|
27931
|
+
{
|
|
27932
|
+
weight: "plus",
|
|
27933
|
+
size: "xlarge",
|
|
27934
|
+
className: "text-ui-fg-base flex gap-x-4",
|
|
27935
|
+
children: [
|
|
27936
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
27937
|
+
/* @__PURE__ */ jsxRuntime.jsx(CreditCardIcon, { className: "inline" }),
|
|
27938
|
+
" "
|
|
27939
|
+
] }),
|
|
27940
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
27941
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle", children: [
|
|
27942
|
+
storeCreditAccount.currency_code.toUpperCase(),
|
|
27943
|
+
" Account"
|
|
27944
|
+
] }),
|
|
27945
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
27946
|
+
ui.Text,
|
|
27947
|
+
{
|
|
27948
|
+
weight: "regular",
|
|
27949
|
+
size: "small",
|
|
27950
|
+
className: "text-ui-fg-base flex gap-x-4",
|
|
27951
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(DisplayId, { id: storeCreditAccount.id })
|
|
27952
|
+
}
|
|
27953
|
+
) })
|
|
27954
|
+
] })
|
|
27955
|
+
]
|
|
27956
|
+
}
|
|
27957
|
+
),
|
|
27958
|
+
canUpdate && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-x-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
27959
|
+
ActionMenu,
|
|
27960
|
+
{
|
|
27961
|
+
groups: [
|
|
27011
27962
|
{
|
|
27012
|
-
|
|
27013
|
-
|
|
27014
|
-
|
|
27015
|
-
|
|
27016
|
-
|
|
27017
|
-
|
|
27018
|
-
|
|
27019
|
-
|
|
27020
|
-
|
|
27963
|
+
actions: [
|
|
27964
|
+
{
|
|
27965
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CreditCard, {}),
|
|
27966
|
+
label: "Credit the account",
|
|
27967
|
+
to: "credit"
|
|
27968
|
+
},
|
|
27969
|
+
{
|
|
27970
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.MinusMini, {}),
|
|
27971
|
+
label: "Debit the account",
|
|
27972
|
+
to: "debit",
|
|
27973
|
+
disabled: !Number(storeCreditAccount.balance)
|
|
27974
|
+
}
|
|
27021
27975
|
]
|
|
27022
27976
|
}
|
|
27023
|
-
|
|
27024
|
-
|
|
27025
|
-
}
|
|
27026
|
-
);
|
|
27977
|
+
]
|
|
27978
|
+
}
|
|
27979
|
+
) })
|
|
27980
|
+
] });
|
|
27027
27981
|
};
|
|
27028
|
-
|
|
27029
|
-
|
|
27982
|
+
function StoreCreditAccountCustomerSection({
|
|
27983
|
+
customerId
|
|
27984
|
+
}) {
|
|
27985
|
+
const { hasPermission } = hooks.usePermissions();
|
|
27986
|
+
const canReadCustomer = hasPermission("customer:read");
|
|
27987
|
+
const { customer, isPending } = useCustomer(customerId, void 0, {
|
|
27988
|
+
enabled: !!customerId && canReadCustomer
|
|
27989
|
+
});
|
|
27990
|
+
if (!canReadCustomer || isPending || !customer) {
|
|
27991
|
+
return null;
|
|
27992
|
+
}
|
|
27993
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
27994
|
+
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Customer" }),
|
|
27995
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
27996
|
+
SidebarLink,
|
|
27997
|
+
{
|
|
27998
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {}),
|
|
27999
|
+
labelKey: customer.email || "N/A",
|
|
28000
|
+
descriptionKey: !customer.first_name && !customer.last_name ? "N/A" : `${customer.first_name} ${customer.last_name}`,
|
|
28001
|
+
to: `/customers/${customer.id}`
|
|
28002
|
+
},
|
|
28003
|
+
customer.id
|
|
28004
|
+
)
|
|
28005
|
+
] });
|
|
28006
|
+
}
|
|
28007
|
+
const columnHelper$8 = ui.createDataTableColumnHelper();
|
|
28008
|
+
const useTransactionsTableColumns = () => {
|
|
27030
28009
|
return React.useMemo(() => {
|
|
27031
28010
|
return [
|
|
27032
|
-
columnHelper$
|
|
27033
|
-
header: "
|
|
28011
|
+
columnHelper$8.accessor("id", {
|
|
28012
|
+
header: "ID",
|
|
27034
28013
|
cell: ({ row }) => {
|
|
27035
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
28014
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DisplayId, { id: row.original.id });
|
|
27036
28015
|
}
|
|
27037
28016
|
}),
|
|
27038
|
-
columnHelper$
|
|
27039
|
-
header: "
|
|
27040
|
-
cell: ({ row }) =>
|
|
27041
|
-
return row.original.customer?.email ?? "N/A";
|
|
27042
|
-
}
|
|
28017
|
+
columnHelper$8.accessor("created_at", {
|
|
28018
|
+
header: "Created At",
|
|
28019
|
+
cell: ({ row }) => formatDate(row.original.created_at, false)
|
|
27043
28020
|
}),
|
|
27044
|
-
columnHelper$
|
|
27045
|
-
header: "
|
|
27046
|
-
cell: ({ row }) =>
|
|
27047
|
-
return formatAmount(
|
|
27048
|
-
row.original.balance,
|
|
27049
|
-
row.original.currency_code
|
|
27050
|
-
);
|
|
27051
|
-
}
|
|
28021
|
+
columnHelper$8.accessor("note", {
|
|
28022
|
+
header: "Description",
|
|
28023
|
+
cell: ({ row }) => row.original.note
|
|
27052
28024
|
}),
|
|
27053
|
-
columnHelper$
|
|
27054
|
-
header: "
|
|
28025
|
+
columnHelper$8.accessor("note", {
|
|
28026
|
+
header: "Note",
|
|
27055
28027
|
cell: ({ row }) => {
|
|
27056
|
-
return
|
|
27057
|
-
row.original.credits,
|
|
27058
|
-
row.original.currency_code
|
|
27059
|
-
);
|
|
28028
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { title: row.original.note, className: "max-w-[300px] truncate", children: row.original.note || "-" });
|
|
27060
28029
|
}
|
|
27061
28030
|
}),
|
|
27062
|
-
columnHelper$
|
|
27063
|
-
header: "
|
|
28031
|
+
columnHelper$8.accessor("amount", {
|
|
28032
|
+
header: "Amount",
|
|
27064
28033
|
cell: ({ row }) => {
|
|
27065
|
-
|
|
27066
|
-
|
|
27067
|
-
row.original.
|
|
28034
|
+
const isDebit = row.original.type === "debit";
|
|
28035
|
+
return row.original.account.currency_code && formatAmount(
|
|
28036
|
+
row.original.amount * (isDebit ? -1 : 1),
|
|
28037
|
+
row.original.account.currency_code
|
|
27068
28038
|
);
|
|
27069
28039
|
}
|
|
27070
|
-
}),
|
|
27071
|
-
columnHelper$9.accessor("created_at", {
|
|
27072
|
-
header: "Created at",
|
|
27073
|
-
cell: ({ row }) => getRelativeDate(row.original.created_at)
|
|
27074
28040
|
})
|
|
27075
28041
|
];
|
|
27076
28042
|
}, []);
|
|
27077
28043
|
};
|
|
27078
|
-
const
|
|
28044
|
+
const useTransactionsTableFilters = ({}) => {
|
|
27079
28045
|
const dateFilterOptions = useDataTableDateFilters$1();
|
|
27080
|
-
const customerFilterOptions = useCustomerFilters();
|
|
27081
28046
|
return React.useMemo(() => {
|
|
27082
|
-
return [...dateFilterOptions
|
|
27083
|
-
}, [dateFilterOptions
|
|
28047
|
+
return [...dateFilterOptions];
|
|
28048
|
+
}, [dateFilterOptions]);
|
|
27084
28049
|
};
|
|
27085
|
-
const
|
|
28050
|
+
const useTransactionsTableQuery = ({
|
|
27086
28051
|
prefix,
|
|
27087
28052
|
pageSize = 20
|
|
27088
28053
|
}) => {
|
|
27089
28054
|
const queryObject = useQueryParams(
|
|
27090
|
-
["offset", "
|
|
28055
|
+
["offset", "limit", "currency_code", "created_at", "updated_at"],
|
|
27091
28056
|
prefix
|
|
27092
28057
|
);
|
|
27093
|
-
const {
|
|
27094
|
-
offset: offset2,
|
|
27095
|
-
created_at,
|
|
27096
|
-
updated_at,
|
|
27097
|
-
customer_id,
|
|
27098
|
-
currency_code,
|
|
27099
|
-
...rest
|
|
27100
|
-
} = queryObject;
|
|
28058
|
+
const { offset: offset2, limit, created_at, updated_at, ...rest } = queryObject;
|
|
27101
28059
|
const searchParams = {
|
|
27102
|
-
limit: pageSize,
|
|
28060
|
+
limit: limit ? Number(limit) : pageSize,
|
|
27103
28061
|
offset: offset2 ? Number(offset2) : 0,
|
|
27104
28062
|
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
27105
28063
|
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
27106
|
-
customer_id: customer_id ? JSON.parse(customer_id) : void 0,
|
|
27107
|
-
currency_code: currency_code ? JSON.parse(currency_code) : void 0,
|
|
27108
28064
|
...rest
|
|
27109
28065
|
};
|
|
27110
28066
|
return searchParams;
|
|
27111
28067
|
};
|
|
27112
|
-
const PAGE_SIZE$
|
|
27113
|
-
function
|
|
27114
|
-
const queryParams =
|
|
27115
|
-
pageSize: PAGE_SIZE$
|
|
27116
|
-
});
|
|
27117
|
-
const {
|
|
27118
|
-
store_credit_accounts: storeCreditAccounts,
|
|
27119
|
-
isPending,
|
|
27120
|
-
count: count2
|
|
27121
|
-
} = useStoreCreditAccounts({
|
|
27122
|
-
...queryParams,
|
|
27123
|
-
order: queryParams.order ?? "-created_at"
|
|
28068
|
+
const PAGE_SIZE$4 = 10;
|
|
28069
|
+
function TransactionsTable({ id }) {
|
|
28070
|
+
const queryParams = useTransactionsTableQuery({
|
|
28071
|
+
pageSize: PAGE_SIZE$4
|
|
27124
28072
|
});
|
|
27125
|
-
const
|
|
27126
|
-
|
|
27127
|
-
|
|
27128
|
-
|
|
28073
|
+
const { transactions, isLoading, count: count2 } = useStoreCreditAccountTransactions(
|
|
28074
|
+
id,
|
|
28075
|
+
{
|
|
28076
|
+
...queryParams,
|
|
28077
|
+
order: queryParams.order ?? "-created_at",
|
|
28078
|
+
fields: "*account"
|
|
28079
|
+
}
|
|
28080
|
+
);
|
|
28081
|
+
const columns = useTransactionsTableColumns();
|
|
28082
|
+
const filters = useTransactionsTableFilters({});
|
|
27129
28083
|
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
27130
28084
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
27131
28085
|
DataTable,
|
|
27132
28086
|
{
|
|
27133
|
-
data:
|
|
28087
|
+
data: transactions ?? [],
|
|
27134
28088
|
getRowId: (row) => row.id,
|
|
27135
28089
|
columns,
|
|
27136
28090
|
filters,
|
|
27137
|
-
isLoading
|
|
27138
|
-
pageSize: PAGE_SIZE$
|
|
28091
|
+
isLoading,
|
|
28092
|
+
pageSize: PAGE_SIZE$4,
|
|
27139
28093
|
rowCount: count2,
|
|
27140
28094
|
enableSearch: false,
|
|
27141
|
-
heading: "
|
|
27142
|
-
rowHref: (row) => `${row.id}`,
|
|
28095
|
+
heading: "Transactions",
|
|
27143
28096
|
emptyState: {
|
|
27144
28097
|
empty: {
|
|
27145
|
-
heading: "No
|
|
27146
|
-
description: "Create a new store credit account to get started."
|
|
28098
|
+
heading: "No transactions found"
|
|
27147
28099
|
},
|
|
27148
28100
|
filtered: {
|
|
27149
28101
|
heading: "No results found",
|
|
27150
|
-
description: "No
|
|
27151
|
-
}
|
|
27152
|
-
},
|
|
27153
|
-
actions: canCreate ? [
|
|
27154
|
-
{
|
|
27155
|
-
label: "Create",
|
|
27156
|
-
to: "/store-credit-accounts/create"
|
|
28102
|
+
description: "No transactions match your filter criteria."
|
|
27157
28103
|
}
|
|
27158
|
-
|
|
28104
|
+
}
|
|
27159
28105
|
}
|
|
27160
28106
|
) }),
|
|
27161
28107
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
27162
28108
|
] });
|
|
27163
28109
|
}
|
|
27164
|
-
|
|
27165
|
-
|
|
27166
|
-
|
|
27167
|
-
components.LayoutComposer,
|
|
27168
|
-
{
|
|
27169
|
-
widgetsZonePrefix: "store_credit_account.list",
|
|
27170
|
-
preferredLayoutId: "core:single-column",
|
|
27171
|
-
sections: {
|
|
27172
|
-
main: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountsTable", children: /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountsTable, {}) })
|
|
27173
|
-
}
|
|
27174
|
-
}
|
|
27175
|
-
),
|
|
27176
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Toaster, {})
|
|
27177
|
-
] });
|
|
27178
|
-
};
|
|
27179
|
-
const config$1 = adminSdk.defineRouteConfig({
|
|
27180
|
-
label: "Store Credits",
|
|
27181
|
-
icon: StoreCreditIcon,
|
|
27182
|
-
permissions: ["store_credit_account:read"]
|
|
27183
|
-
});
|
|
27184
|
-
var isObject_1;
|
|
27185
|
-
var hasRequiredIsObject;
|
|
27186
|
-
function requireIsObject() {
|
|
27187
|
-
if (hasRequiredIsObject) return isObject_1;
|
|
27188
|
-
hasRequiredIsObject = 1;
|
|
27189
|
-
function isObject2(value) {
|
|
27190
|
-
var type = typeof value;
|
|
27191
|
-
return value != null && (type == "object" || type == "function");
|
|
28110
|
+
function StoreCreditAccountCodeSection({ code }) {
|
|
28111
|
+
if (!code) {
|
|
28112
|
+
return null;
|
|
27192
28113
|
}
|
|
27193
|
-
|
|
27194
|
-
|
|
27195
|
-
|
|
27196
|
-
|
|
27197
|
-
|
|
27198
|
-
|
|
27199
|
-
|
|
27200
|
-
hasRequired_freeGlobal = 1;
|
|
27201
|
-
var freeGlobal = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
27202
|
-
_freeGlobal = freeGlobal;
|
|
27203
|
-
return _freeGlobal;
|
|
27204
|
-
}
|
|
27205
|
-
var _root;
|
|
27206
|
-
var hasRequired_root;
|
|
27207
|
-
function require_root() {
|
|
27208
|
-
if (hasRequired_root) return _root;
|
|
27209
|
-
hasRequired_root = 1;
|
|
27210
|
-
var freeGlobal = require_freeGlobal();
|
|
27211
|
-
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
27212
|
-
var root = freeGlobal || freeSelf || Function("return this")();
|
|
27213
|
-
_root = root;
|
|
27214
|
-
return _root;
|
|
27215
|
-
}
|
|
27216
|
-
var now_1;
|
|
27217
|
-
var hasRequiredNow;
|
|
27218
|
-
function requireNow() {
|
|
27219
|
-
if (hasRequiredNow) return now_1;
|
|
27220
|
-
hasRequiredNow = 1;
|
|
27221
|
-
var root = require_root();
|
|
27222
|
-
var now = function() {
|
|
27223
|
-
return root.Date.now();
|
|
27224
|
-
};
|
|
27225
|
-
now_1 = now;
|
|
27226
|
-
return now_1;
|
|
27227
|
-
}
|
|
27228
|
-
var _trimmedEndIndex;
|
|
27229
|
-
var hasRequired_trimmedEndIndex;
|
|
27230
|
-
function require_trimmedEndIndex() {
|
|
27231
|
-
if (hasRequired_trimmedEndIndex) return _trimmedEndIndex;
|
|
27232
|
-
hasRequired_trimmedEndIndex = 1;
|
|
27233
|
-
var reWhitespace = /\s/;
|
|
27234
|
-
function trimmedEndIndex(string2) {
|
|
27235
|
-
var index = string2.length;
|
|
27236
|
-
while (index-- && reWhitespace.test(string2.charAt(index))) {
|
|
27237
|
-
}
|
|
27238
|
-
return index;
|
|
27239
|
-
}
|
|
27240
|
-
_trimmedEndIndex = trimmedEndIndex;
|
|
27241
|
-
return _trimmedEndIndex;
|
|
27242
|
-
}
|
|
27243
|
-
var _baseTrim;
|
|
27244
|
-
var hasRequired_baseTrim;
|
|
27245
|
-
function require_baseTrim() {
|
|
27246
|
-
if (hasRequired_baseTrim) return _baseTrim;
|
|
27247
|
-
hasRequired_baseTrim = 1;
|
|
27248
|
-
var trimmedEndIndex = require_trimmedEndIndex();
|
|
27249
|
-
var reTrimStart = /^\s+/;
|
|
27250
|
-
function baseTrim(string2) {
|
|
27251
|
-
return string2 ? string2.slice(0, trimmedEndIndex(string2) + 1).replace(reTrimStart, "") : string2;
|
|
27252
|
-
}
|
|
27253
|
-
_baseTrim = baseTrim;
|
|
27254
|
-
return _baseTrim;
|
|
27255
|
-
}
|
|
27256
|
-
var _Symbol;
|
|
27257
|
-
var hasRequired_Symbol;
|
|
27258
|
-
function require_Symbol() {
|
|
27259
|
-
if (hasRequired_Symbol) return _Symbol;
|
|
27260
|
-
hasRequired_Symbol = 1;
|
|
27261
|
-
var root = require_root();
|
|
27262
|
-
var Symbol2 = root.Symbol;
|
|
27263
|
-
_Symbol = Symbol2;
|
|
27264
|
-
return _Symbol;
|
|
27265
|
-
}
|
|
27266
|
-
var _getRawTag;
|
|
27267
|
-
var hasRequired_getRawTag;
|
|
27268
|
-
function require_getRawTag() {
|
|
27269
|
-
if (hasRequired_getRawTag) return _getRawTag;
|
|
27270
|
-
hasRequired_getRawTag = 1;
|
|
27271
|
-
var Symbol2 = require_Symbol();
|
|
27272
|
-
var objectProto = Object.prototype;
|
|
27273
|
-
var hasOwnProperty2 = objectProto.hasOwnProperty;
|
|
27274
|
-
var nativeObjectToString = objectProto.toString;
|
|
27275
|
-
var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
|
|
27276
|
-
function getRawTag(value) {
|
|
27277
|
-
var isOwn = hasOwnProperty2.call(value, symToStringTag), tag = value[symToStringTag];
|
|
27278
|
-
try {
|
|
27279
|
-
value[symToStringTag] = void 0;
|
|
27280
|
-
var unmasked = true;
|
|
27281
|
-
} catch (e) {
|
|
27282
|
-
}
|
|
27283
|
-
var result = nativeObjectToString.call(value);
|
|
27284
|
-
if (unmasked) {
|
|
27285
|
-
if (isOwn) {
|
|
27286
|
-
value[symToStringTag] = tag;
|
|
27287
|
-
} else {
|
|
27288
|
-
delete value[symToStringTag];
|
|
27289
|
-
}
|
|
27290
|
-
}
|
|
27291
|
-
return result;
|
|
27292
|
-
}
|
|
27293
|
-
_getRawTag = getRawTag;
|
|
27294
|
-
return _getRawTag;
|
|
27295
|
-
}
|
|
27296
|
-
var _objectToString;
|
|
27297
|
-
var hasRequired_objectToString;
|
|
27298
|
-
function require_objectToString() {
|
|
27299
|
-
if (hasRequired_objectToString) return _objectToString;
|
|
27300
|
-
hasRequired_objectToString = 1;
|
|
27301
|
-
var objectProto = Object.prototype;
|
|
27302
|
-
var nativeObjectToString = objectProto.toString;
|
|
27303
|
-
function objectToString(value) {
|
|
27304
|
-
return nativeObjectToString.call(value);
|
|
27305
|
-
}
|
|
27306
|
-
_objectToString = objectToString;
|
|
27307
|
-
return _objectToString;
|
|
27308
|
-
}
|
|
27309
|
-
var _baseGetTag;
|
|
27310
|
-
var hasRequired_baseGetTag;
|
|
27311
|
-
function require_baseGetTag() {
|
|
27312
|
-
if (hasRequired_baseGetTag) return _baseGetTag;
|
|
27313
|
-
hasRequired_baseGetTag = 1;
|
|
27314
|
-
var Symbol2 = require_Symbol(), getRawTag = require_getRawTag(), objectToString = require_objectToString();
|
|
27315
|
-
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
|
|
27316
|
-
var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
|
|
27317
|
-
function baseGetTag(value) {
|
|
27318
|
-
if (value == null) {
|
|
27319
|
-
return value === void 0 ? undefinedTag : nullTag;
|
|
27320
|
-
}
|
|
27321
|
-
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
27322
|
-
}
|
|
27323
|
-
_baseGetTag = baseGetTag;
|
|
27324
|
-
return _baseGetTag;
|
|
27325
|
-
}
|
|
27326
|
-
var isObjectLike_1;
|
|
27327
|
-
var hasRequiredIsObjectLike;
|
|
27328
|
-
function requireIsObjectLike() {
|
|
27329
|
-
if (hasRequiredIsObjectLike) return isObjectLike_1;
|
|
27330
|
-
hasRequiredIsObjectLike = 1;
|
|
27331
|
-
function isObjectLike(value) {
|
|
27332
|
-
return value != null && typeof value == "object";
|
|
27333
|
-
}
|
|
27334
|
-
isObjectLike_1 = isObjectLike;
|
|
27335
|
-
return isObjectLike_1;
|
|
27336
|
-
}
|
|
27337
|
-
var isSymbol_1;
|
|
27338
|
-
var hasRequiredIsSymbol;
|
|
27339
|
-
function requireIsSymbol() {
|
|
27340
|
-
if (hasRequiredIsSymbol) return isSymbol_1;
|
|
27341
|
-
hasRequiredIsSymbol = 1;
|
|
27342
|
-
var baseGetTag = require_baseGetTag(), isObjectLike = requireIsObjectLike();
|
|
27343
|
-
var symbolTag = "[object Symbol]";
|
|
27344
|
-
function isSymbol(value) {
|
|
27345
|
-
return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
|
|
27346
|
-
}
|
|
27347
|
-
isSymbol_1 = isSymbol;
|
|
27348
|
-
return isSymbol_1;
|
|
28114
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
28115
|
+
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Account Code" }),
|
|
28116
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-4 px-6 mb-2", children: [
|
|
28117
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Share, { className: "inline" }),
|
|
28118
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle text-sm", children: code })
|
|
28119
|
+
] })
|
|
28120
|
+
] });
|
|
27349
28121
|
}
|
|
27350
|
-
|
|
27351
|
-
|
|
27352
|
-
|
|
27353
|
-
|
|
27354
|
-
|
|
27355
|
-
|
|
27356
|
-
|
|
27357
|
-
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
27358
|
-
var reIsBinary = /^0b[01]+$/i;
|
|
27359
|
-
var reIsOctal = /^0o[0-7]+$/i;
|
|
27360
|
-
var freeParseInt = parseInt;
|
|
27361
|
-
function toNumber(value) {
|
|
27362
|
-
if (typeof value == "number") {
|
|
27363
|
-
return value;
|
|
27364
|
-
}
|
|
27365
|
-
if (isSymbol(value)) {
|
|
27366
|
-
return NAN;
|
|
27367
|
-
}
|
|
27368
|
-
if (isObject2(value)) {
|
|
27369
|
-
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
27370
|
-
value = isObject2(other) ? other + "" : other;
|
|
27371
|
-
}
|
|
27372
|
-
if (typeof value != "string") {
|
|
27373
|
-
return value === 0 ? value : +value;
|
|
27374
|
-
}
|
|
27375
|
-
value = baseTrim(value);
|
|
27376
|
-
var isBinary = reIsBinary.test(value);
|
|
27377
|
-
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
|
28122
|
+
const StoreCreditAccountPage = () => {
|
|
28123
|
+
const { id } = reactRouterDom.useParams();
|
|
28124
|
+
const { store_credit_account: storeCreditAccount } = useStoreCreditAccount(
|
|
28125
|
+
id
|
|
28126
|
+
);
|
|
28127
|
+
if (!storeCreditAccount) {
|
|
28128
|
+
return;
|
|
27378
28129
|
}
|
|
27379
|
-
|
|
27380
|
-
|
|
27381
|
-
|
|
27382
|
-
|
|
27383
|
-
|
|
27384
|
-
|
|
27385
|
-
|
|
27386
|
-
|
|
27387
|
-
|
|
27388
|
-
|
|
27389
|
-
|
|
27390
|
-
|
|
27391
|
-
|
|
27392
|
-
|
|
27393
|
-
|
|
27394
|
-
|
|
27395
|
-
|
|
27396
|
-
|
|
27397
|
-
|
|
27398
|
-
|
|
27399
|
-
|
|
27400
|
-
|
|
27401
|
-
|
|
27402
|
-
|
|
27403
|
-
|
|
27404
|
-
|
|
27405
|
-
|
|
27406
|
-
|
|
27407
|
-
|
|
27408
|
-
|
|
27409
|
-
|
|
27410
|
-
lastInvokeTime = time2;
|
|
27411
|
-
timerId = setTimeout(timerExpired, wait);
|
|
27412
|
-
return leading ? invokeFunc(time2) : result;
|
|
27413
|
-
}
|
|
27414
|
-
function remainingWait(time2) {
|
|
27415
|
-
var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
|
|
27416
|
-
return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
|
|
27417
|
-
}
|
|
27418
|
-
function shouldInvoke(time2) {
|
|
27419
|
-
var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime;
|
|
27420
|
-
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
|
27421
|
-
}
|
|
27422
|
-
function timerExpired() {
|
|
27423
|
-
var time2 = now();
|
|
27424
|
-
if (shouldInvoke(time2)) {
|
|
27425
|
-
return trailingEdge(time2);
|
|
28130
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
28131
|
+
components.LayoutComposer,
|
|
28132
|
+
{
|
|
28133
|
+
widgetsZonePrefix: "store_credit_account.details",
|
|
28134
|
+
preferredLayoutId: "core:two-column",
|
|
28135
|
+
data: storeCreditAccount,
|
|
28136
|
+
sections: {
|
|
28137
|
+
main: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
28138
|
+
/* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountDetailsSection", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
28139
|
+
StoreCreditAccountDetailsSection,
|
|
28140
|
+
{
|
|
28141
|
+
storeCreditAccount
|
|
28142
|
+
}
|
|
28143
|
+
) }),
|
|
28144
|
+
/* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "TransactionsTable", children: /* @__PURE__ */ jsxRuntime.jsx(TransactionsTable, { id: storeCreditAccount.id }) })
|
|
28145
|
+
] }),
|
|
28146
|
+
side: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
28147
|
+
/* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountBalanceSection", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
28148
|
+
StoreCreditAccountBalanceSection,
|
|
28149
|
+
{
|
|
28150
|
+
storeCreditAccount
|
|
28151
|
+
}
|
|
28152
|
+
) }),
|
|
28153
|
+
/* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountCodeSection", children: /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCodeSection, { code: storeCreditAccount.code }) }),
|
|
28154
|
+
/* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountCustomerSection", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
28155
|
+
StoreCreditAccountCustomerSection,
|
|
28156
|
+
{
|
|
28157
|
+
customerId: storeCreditAccount.customer_id
|
|
28158
|
+
}
|
|
28159
|
+
) })
|
|
28160
|
+
] })
|
|
27426
28161
|
}
|
|
27427
|
-
timerId = setTimeout(timerExpired, remainingWait(time2));
|
|
27428
28162
|
}
|
|
27429
|
-
|
|
27430
|
-
|
|
27431
|
-
|
|
27432
|
-
|
|
28163
|
+
);
|
|
28164
|
+
};
|
|
28165
|
+
const handle$c = {
|
|
28166
|
+
permissions: ["store_credit_account:read"]
|
|
28167
|
+
};
|
|
28168
|
+
const KeyboundForm = React__namespace.default.forwardRef(({ onSubmit, onKeyDown, ...rest }, ref) => {
|
|
28169
|
+
const handleSubmit = (event) => {
|
|
28170
|
+
event.preventDefault();
|
|
28171
|
+
onSubmit?.(event);
|
|
28172
|
+
};
|
|
28173
|
+
const handleKeyDown = (event) => {
|
|
28174
|
+
if (event.key === "Enter") {
|
|
28175
|
+
if (event.target instanceof HTMLTextAreaElement && !(event.metaKey || event.ctrlKey)) {
|
|
28176
|
+
return;
|
|
27433
28177
|
}
|
|
27434
|
-
|
|
27435
|
-
|
|
27436
|
-
|
|
27437
|
-
function cancel() {
|
|
27438
|
-
if (timerId !== void 0) {
|
|
27439
|
-
clearTimeout(timerId);
|
|
28178
|
+
event.preventDefault();
|
|
28179
|
+
if (event.metaKey || event.ctrlKey) {
|
|
28180
|
+
handleSubmit(event);
|
|
27440
28181
|
}
|
|
27441
|
-
lastInvokeTime = 0;
|
|
27442
|
-
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
|
27443
|
-
}
|
|
27444
|
-
function flush() {
|
|
27445
|
-
return timerId === void 0 ? result : trailingEdge(now());
|
|
27446
28182
|
}
|
|
27447
|
-
|
|
27448
|
-
|
|
27449
|
-
|
|
27450
|
-
|
|
27451
|
-
|
|
27452
|
-
|
|
27453
|
-
|
|
27454
|
-
|
|
27455
|
-
}
|
|
27456
|
-
if (maxing) {
|
|
27457
|
-
clearTimeout(timerId);
|
|
27458
|
-
timerId = setTimeout(timerExpired, wait);
|
|
27459
|
-
return invokeFunc(lastCallTime);
|
|
27460
|
-
}
|
|
27461
|
-
}
|
|
27462
|
-
if (timerId === void 0) {
|
|
27463
|
-
timerId = setTimeout(timerExpired, wait);
|
|
27464
|
-
}
|
|
27465
|
-
return result;
|
|
28183
|
+
};
|
|
28184
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
28185
|
+
"form",
|
|
28186
|
+
{
|
|
28187
|
+
...rest,
|
|
28188
|
+
onSubmit: handleSubmit,
|
|
28189
|
+
onKeyDown: onKeyDown ?? handleKeyDown,
|
|
28190
|
+
ref
|
|
27466
28191
|
}
|
|
27467
|
-
debounced.cancel = cancel;
|
|
27468
|
-
debounced.flush = flush;
|
|
27469
|
-
return debounced;
|
|
27470
|
-
}
|
|
27471
|
-
debounce_1 = debounce2;
|
|
27472
|
-
return debounce_1;
|
|
27473
|
-
}
|
|
27474
|
-
var debounceExports = requireDebounce();
|
|
27475
|
-
const debounce$1 = /* @__PURE__ */ getDefaultExportFromCjs(debounceExports);
|
|
27476
|
-
const useDebouncedSearch = () => {
|
|
27477
|
-
const [searchValue, onSearchValueChange] = React.useState("");
|
|
27478
|
-
const [debouncedQuery, setDebouncedQuery] = React.useState("");
|
|
27479
|
-
const debouncedUpdate = React.useCallback(
|
|
27480
|
-
debounce$1((query) => setDebouncedQuery(query), 300),
|
|
27481
|
-
[]
|
|
27482
28192
|
);
|
|
27483
|
-
|
|
27484
|
-
|
|
27485
|
-
|
|
27486
|
-
}
|
|
27487
|
-
|
|
27488
|
-
|
|
27489
|
-
|
|
27490
|
-
|
|
27491
|
-
|
|
28193
|
+
});
|
|
28194
|
+
KeyboundForm.displayName = "KeyboundForm";
|
|
28195
|
+
const Note$1 = () => {
|
|
28196
|
+
const { id } = reactRouterDom.useParams();
|
|
28197
|
+
const {
|
|
28198
|
+
store_credit_account: storeCreditAccount,
|
|
28199
|
+
isPending,
|
|
28200
|
+
isError,
|
|
28201
|
+
error: error2
|
|
28202
|
+
} = useStoreCreditAccount(id, {});
|
|
28203
|
+
if (isError) {
|
|
28204
|
+
throw error2;
|
|
28205
|
+
}
|
|
28206
|
+
const isReady = !isPending && !!storeCreditAccount;
|
|
28207
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
28208
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
28209
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Credit store credit account" }) }),
|
|
28210
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Credit the store credit account" }) })
|
|
28211
|
+
] }),
|
|
28212
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCreditForm, { storeCreditAccount })
|
|
28213
|
+
] });
|
|
27492
28214
|
};
|
|
27493
|
-
const
|
|
27494
|
-
|
|
27495
|
-
queryFn,
|
|
27496
|
-
getOptions,
|
|
27497
|
-
defaultValue: defaultValue2,
|
|
27498
|
-
defaultValueKey,
|
|
27499
|
-
pageSize = 10,
|
|
27500
|
-
enabled = true
|
|
28215
|
+
const StoreCreditAccountCreditForm = ({
|
|
28216
|
+
storeCreditAccount
|
|
27501
28217
|
}) => {
|
|
27502
|
-
const
|
|
27503
|
-
|
|
27504
|
-
|
|
27505
|
-
|
|
27506
|
-
|
|
27507
|
-
|
|
27508
|
-
|
|
27509
|
-
limit: Array.isArray(defaultValue2) ? defaultValue2.length : 1
|
|
27510
|
-
});
|
|
27511
|
-
},
|
|
27512
|
-
enabled: enabled && !!defaultValue2
|
|
27513
|
-
});
|
|
27514
|
-
const { data, ...rest } = reactQuery.useInfiniteQuery({
|
|
27515
|
-
queryKey: [...queryKey, query],
|
|
27516
|
-
queryFn: async ({ pageParam = 0 }) => {
|
|
27517
|
-
return await queryFn({
|
|
27518
|
-
q: query,
|
|
27519
|
-
limit: pageSize,
|
|
27520
|
-
offset: pageParam
|
|
27521
|
-
});
|
|
27522
|
-
},
|
|
27523
|
-
initialPageParam: 0,
|
|
27524
|
-
getNextPageParam: (lastPage) => {
|
|
27525
|
-
const moreItemsExist = lastPage.count > lastPage.offset + lastPage.limit;
|
|
27526
|
-
return moreItemsExist ? lastPage.offset + lastPage.limit : void 0;
|
|
28218
|
+
const form = useForm({
|
|
28219
|
+
defaultValues: {
|
|
28220
|
+
amount: {
|
|
28221
|
+
float: 0,
|
|
28222
|
+
value: ""
|
|
28223
|
+
},
|
|
28224
|
+
note: ""
|
|
27527
28225
|
},
|
|
27528
|
-
|
|
27529
|
-
enabled
|
|
28226
|
+
resolver: u(schema$3)
|
|
27530
28227
|
});
|
|
27531
|
-
const
|
|
27532
|
-
|
|
27533
|
-
|
|
27534
|
-
|
|
27535
|
-
|
|
27536
|
-
|
|
27537
|
-
|
|
28228
|
+
const { mutateAsync, isPending } = useCreditStoreCreditAccount(
|
|
28229
|
+
storeCreditAccount.id
|
|
28230
|
+
);
|
|
28231
|
+
const { handleSuccess } = useRouteModal();
|
|
28232
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
28233
|
+
if (data.amount.float <= 0) {
|
|
28234
|
+
form.setError("amount", { message: "Amount must be greater than 0" });
|
|
28235
|
+
return;
|
|
28236
|
+
}
|
|
28237
|
+
await mutateAsync(
|
|
28238
|
+
{ amount: data.amount.float, note: data.note },
|
|
28239
|
+
{
|
|
28240
|
+
onSuccess: () => handleSuccess(),
|
|
28241
|
+
onError: (error2) => ui.toast.error(error2.message)
|
|
27538
28242
|
}
|
|
27539
|
-
|
|
27540
|
-
}
|
|
27541
|
-
return {
|
|
27542
|
-
|
|
27543
|
-
|
|
27544
|
-
|
|
27545
|
-
|
|
27546
|
-
|
|
27547
|
-
|
|
28243
|
+
);
|
|
28244
|
+
});
|
|
28245
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
28246
|
+
KeyboundForm,
|
|
28247
|
+
{
|
|
28248
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
28249
|
+
onSubmit,
|
|
28250
|
+
children: [
|
|
28251
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
28252
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
28253
|
+
Form$2.Field,
|
|
28254
|
+
{
|
|
28255
|
+
control: form.control,
|
|
28256
|
+
name: "amount",
|
|
28257
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
28258
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Amount" }),
|
|
28259
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
28260
|
+
ui.CurrencyInput,
|
|
28261
|
+
{
|
|
28262
|
+
min: 0,
|
|
28263
|
+
placeholder: "0",
|
|
28264
|
+
value: field.value.value,
|
|
28265
|
+
onValueChange: (_value, _name, values) => {
|
|
28266
|
+
field.onChange({
|
|
28267
|
+
value: values?.value,
|
|
28268
|
+
float: values?.float || null
|
|
28269
|
+
});
|
|
28270
|
+
},
|
|
28271
|
+
symbol: currencies[storeCreditAccount.currency_code.toUpperCase()].symbol_native,
|
|
28272
|
+
code: storeCreditAccount.currency_code.toUpperCase()
|
|
28273
|
+
}
|
|
28274
|
+
) }),
|
|
28275
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
28276
|
+
] })
|
|
28277
|
+
}
|
|
28278
|
+
),
|
|
28279
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
28280
|
+
Form$2.Field,
|
|
28281
|
+
{
|
|
28282
|
+
control: form.control,
|
|
28283
|
+
name: "note",
|
|
28284
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
28285
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
|
|
28286
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
|
|
28287
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
28288
|
+
] })
|
|
28289
|
+
}
|
|
28290
|
+
)
|
|
28291
|
+
] }),
|
|
28292
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
28293
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
28294
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
28295
|
+
] }) })
|
|
28296
|
+
]
|
|
28297
|
+
}
|
|
28298
|
+
) });
|
|
27548
28299
|
};
|
|
27549
|
-
const
|
|
27550
|
-
|
|
27551
|
-
|
|
28300
|
+
const schema$3 = zod.z.object({
|
|
28301
|
+
note: zod.z.string(),
|
|
28302
|
+
amount: zod.z.object({
|
|
28303
|
+
float: zod.z.number(),
|
|
28304
|
+
value: zod.z.string()
|
|
28305
|
+
})
|
|
27552
28306
|
});
|
|
27553
|
-
const
|
|
27554
|
-
|
|
27555
|
-
|
|
27556
|
-
|
|
27557
|
-
const {
|
|
27558
|
-
const
|
|
28307
|
+
const handle$b = {
|
|
28308
|
+
permissions: ["store_credit_account:read", "store_credit_account:update"]
|
|
28309
|
+
};
|
|
28310
|
+
const Debit = () => {
|
|
28311
|
+
const { id } = reactRouterDom.useParams();
|
|
28312
|
+
const {
|
|
28313
|
+
store_credit_account: storeCreditAccount,
|
|
28314
|
+
isPending,
|
|
28315
|
+
isError,
|
|
28316
|
+
error: error2
|
|
28317
|
+
} = useStoreCreditAccount(id, {});
|
|
28318
|
+
if (isError) {
|
|
28319
|
+
throw error2;
|
|
28320
|
+
}
|
|
28321
|
+
const isReady = !isPending && !!storeCreditAccount;
|
|
28322
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
28323
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
28324
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Debit store credit account" }) }),
|
|
28325
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Debit the store credit account" }) })
|
|
28326
|
+
] }),
|
|
28327
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountDebitForm, { storeCreditAccount })
|
|
28328
|
+
] });
|
|
28329
|
+
};
|
|
28330
|
+
const StoreCreditAccountDebitForm = ({
|
|
28331
|
+
storeCreditAccount
|
|
28332
|
+
}) => {
|
|
27559
28333
|
const form = useForm({
|
|
27560
28334
|
defaultValues: {
|
|
27561
|
-
|
|
27562
|
-
|
|
28335
|
+
amount: {
|
|
28336
|
+
float: 0,
|
|
28337
|
+
value: ""
|
|
28338
|
+
},
|
|
28339
|
+
note: ""
|
|
27563
28340
|
},
|
|
27564
|
-
resolver: u(
|
|
28341
|
+
resolver: u(schema$2)
|
|
27565
28342
|
});
|
|
27566
|
-
const { mutateAsync
|
|
27567
|
-
|
|
27568
|
-
|
|
27569
|
-
|
|
28343
|
+
const { mutateAsync, isPending } = useDebitStoreCreditAccount(
|
|
28344
|
+
storeCreditAccount.id
|
|
28345
|
+
);
|
|
28346
|
+
const { handleSuccess } = useRouteModal();
|
|
28347
|
+
const balance = storeCreditAccount.balance ?? 0;
|
|
28348
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
28349
|
+
if (data.amount.float <= 0) {
|
|
28350
|
+
form.setError("amount", { message: "Amount must be greater than 0" });
|
|
28351
|
+
return;
|
|
27570
28352
|
}
|
|
27571
|
-
|
|
27572
|
-
|
|
27573
|
-
|
|
27574
|
-
|
|
27575
|
-
|
|
27576
|
-
onError: (error2) => {
|
|
27577
|
-
ui.toast.error(error2.message);
|
|
27578
|
-
}
|
|
27579
|
-
});
|
|
27580
|
-
});
|
|
27581
|
-
const [currencySearchValue, setCurrencySearchValue] = React.useState("");
|
|
27582
|
-
const currencyOptions = React.useMemo(() => {
|
|
27583
|
-
const options = Object.values(currencies).map((currency) => ({
|
|
27584
|
-
label: `${currency.code} - ${currency.name} (${currency.symbol_native})`,
|
|
27585
|
-
value: currency.code.toLowerCase()
|
|
27586
|
-
}));
|
|
27587
|
-
if (!currencySearchValue) {
|
|
27588
|
-
return options;
|
|
28353
|
+
if (data.amount.float > balance) {
|
|
28354
|
+
form.setError("amount", {
|
|
28355
|
+
message: "Amount can't be greater than the current balance"
|
|
28356
|
+
});
|
|
28357
|
+
return;
|
|
27589
28358
|
}
|
|
27590
|
-
|
|
27591
|
-
|
|
28359
|
+
await mutateAsync(
|
|
28360
|
+
{ amount: data.amount.float, note: data.note },
|
|
28361
|
+
{
|
|
28362
|
+
onSuccess: () => handleSuccess(),
|
|
28363
|
+
onError: (error2) => ui.toast.error(error2.message)
|
|
28364
|
+
}
|
|
27592
28365
|
);
|
|
27593
|
-
}, [currencySearchValue]);
|
|
27594
|
-
const {
|
|
27595
|
-
options: customerOptions,
|
|
27596
|
-
fetchNextPage,
|
|
27597
|
-
isFetchingNextPage,
|
|
27598
|
-
searchValue,
|
|
27599
|
-
onSearchValueChange,
|
|
27600
|
-
isLoading
|
|
27601
|
-
} = useComboboxData({
|
|
27602
|
-
queryKey: customersQueryKeys.list(),
|
|
27603
|
-
defaultValue: prefilledCustomerId || void 0,
|
|
27604
|
-
enabled: canReadCustomers,
|
|
27605
|
-
queryFn: async (params) => {
|
|
27606
|
-
return sdk.admin.customer.list(params);
|
|
27607
|
-
},
|
|
27608
|
-
getOptions: (data) => {
|
|
27609
|
-
return data.customers?.map((customer) => {
|
|
27610
|
-
const fullName = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
27611
|
-
const label = fullName ? `${customer.email} (${fullName})` : customer.email;
|
|
27612
|
-
return {
|
|
27613
|
-
label,
|
|
27614
|
-
value: customer.id
|
|
27615
|
-
};
|
|
27616
|
-
}) || [];
|
|
27617
|
-
}
|
|
27618
28366
|
});
|
|
27619
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
27620
|
-
|
|
27621
|
-
|
|
27622
|
-
|
|
27623
|
-
|
|
27624
|
-
|
|
27625
|
-
|
|
27626
|
-
|
|
27627
|
-
|
|
27628
|
-
|
|
27629
|
-
|
|
27630
|
-
|
|
27631
|
-
|
|
27632
|
-
|
|
27633
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
27634
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Currency" }),
|
|
28367
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
28368
|
+
KeyboundForm,
|
|
28369
|
+
{
|
|
28370
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
28371
|
+
onSubmit,
|
|
28372
|
+
children: [
|
|
28373
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
28374
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
28375
|
+
Form$2.Field,
|
|
28376
|
+
{
|
|
28377
|
+
control: form.control,
|
|
28378
|
+
name: "amount",
|
|
28379
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
28380
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Amount" }),
|
|
27635
28381
|
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
27636
|
-
|
|
28382
|
+
ui.CurrencyInput,
|
|
27637
28383
|
{
|
|
27638
|
-
|
|
27639
|
-
|
|
27640
|
-
|
|
27641
|
-
|
|
27642
|
-
|
|
27643
|
-
|
|
28384
|
+
min: 0,
|
|
28385
|
+
placeholder: "0",
|
|
28386
|
+
value: field.value.value,
|
|
28387
|
+
onValueChange: (_value, _name, values) => {
|
|
28388
|
+
field.onChange({
|
|
28389
|
+
value: values?.value,
|
|
28390
|
+
float: values?.float || null
|
|
28391
|
+
});
|
|
28392
|
+
},
|
|
28393
|
+
symbol: currencies[storeCreditAccount.currency_code.toUpperCase()].symbol_native,
|
|
28394
|
+
code: storeCreditAccount.currency_code.toUpperCase()
|
|
27644
28395
|
}
|
|
27645
28396
|
) }),
|
|
27646
28397
|
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
27647
|
-
] })
|
|
28398
|
+
] })
|
|
27648
28399
|
}
|
|
27649
|
-
|
|
27650
|
-
|
|
27651
|
-
|
|
27652
|
-
|
|
27653
|
-
|
|
27654
|
-
|
|
27655
|
-
|
|
27656
|
-
|
|
27657
|
-
|
|
27658
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Customer" }),
|
|
27659
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
27660
|
-
Combobox2,
|
|
27661
|
-
{
|
|
27662
|
-
value: field.value,
|
|
27663
|
-
onChange: field.onChange,
|
|
27664
|
-
searchValue,
|
|
27665
|
-
onSearchValueChange,
|
|
27666
|
-
options: customerOptions,
|
|
27667
|
-
placeholder: "Search for a customer...",
|
|
27668
|
-
fetchNextPage,
|
|
27669
|
-
isFetchingNextPage,
|
|
27670
|
-
noResultsPlaceholder: isLoading ? "Loading customers..." : "No customers found"
|
|
27671
|
-
}
|
|
27672
|
-
) }),
|
|
28400
|
+
),
|
|
28401
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
28402
|
+
Form$2.Field,
|
|
28403
|
+
{
|
|
28404
|
+
control: form.control,
|
|
28405
|
+
name: "note",
|
|
28406
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
28407
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
|
|
28408
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
|
|
27673
28409
|
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
27674
|
-
] })
|
|
28410
|
+
] })
|
|
27675
28411
|
}
|
|
27676
|
-
|
|
27677
|
-
)
|
|
27678
|
-
|
|
27679
|
-
|
|
27680
|
-
|
|
27681
|
-
|
|
27682
|
-
|
|
27683
|
-
|
|
27684
|
-
|
|
27685
|
-
variant: "primary",
|
|
27686
|
-
size: "small",
|
|
27687
|
-
onClick: handleSubmit,
|
|
27688
|
-
disabled: isPending,
|
|
27689
|
-
children: "Create"
|
|
27690
|
-
}
|
|
27691
|
-
)
|
|
27692
|
-
] })
|
|
27693
|
-
] });
|
|
27694
|
-
};
|
|
27695
|
-
const StoreCreditAccountCreate = () => {
|
|
27696
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal, { children: [
|
|
27697
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create Store Credit Account" }) }),
|
|
27698
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create a new store credit account" }) }),
|
|
27699
|
-
/* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCreateForm, {})
|
|
27700
|
-
] });
|
|
28412
|
+
)
|
|
28413
|
+
] }),
|
|
28414
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
28415
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
28416
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
28417
|
+
] }) })
|
|
28418
|
+
]
|
|
28419
|
+
}
|
|
28420
|
+
) });
|
|
27701
28421
|
};
|
|
27702
|
-
const
|
|
27703
|
-
|
|
28422
|
+
const schema$2 = zod.z.object({
|
|
28423
|
+
note: zod.z.string(),
|
|
28424
|
+
amount: zod.z.object({
|
|
28425
|
+
float: zod.z.number(),
|
|
28426
|
+
value: zod.z.string()
|
|
28427
|
+
})
|
|
28428
|
+
});
|
|
28429
|
+
const handle$a = {
|
|
28430
|
+
permissions: ["store_credit_account:read", "store_credit_account:update"]
|
|
27704
28431
|
};
|
|
27705
28432
|
function _extends() {
|
|
27706
28433
|
return _extends = Object.assign ? Object.assign.bind() : function(n2) {
|
|
@@ -30385,299 +31112,6 @@ const GiftCardOrderSection = ({ giftCard }) => {
|
|
|
30385
31112
|
))
|
|
30386
31113
|
] });
|
|
30387
31114
|
};
|
|
30388
|
-
var __create = Object.create;
|
|
30389
|
-
var __defProp = Object.defineProperty;
|
|
30390
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
30391
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
30392
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
30393
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
30394
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
30395
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
30396
|
-
};
|
|
30397
|
-
var __copyProps = (to, from, except, desc) => {
|
|
30398
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
30399
|
-
for (let key2 of __getOwnPropNames(from))
|
|
30400
|
-
if (!__hasOwnProp.call(to, key2) && key2 !== except)
|
|
30401
|
-
__defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });
|
|
30402
|
-
}
|
|
30403
|
-
return to;
|
|
30404
|
-
};
|
|
30405
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30406
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30407
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
30408
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30409
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30410
|
-
__defProp(target, "default", { value: mod, enumerable: true }),
|
|
30411
|
-
mod
|
|
30412
|
-
));
|
|
30413
|
-
var require_toggle_selection = __commonJS({
|
|
30414
|
-
"node_modules/toggle-selection/index.js"(exports2, module2) {
|
|
30415
|
-
module2.exports = function() {
|
|
30416
|
-
var selection = document.getSelection();
|
|
30417
|
-
if (!selection.rangeCount) {
|
|
30418
|
-
return function() {
|
|
30419
|
-
};
|
|
30420
|
-
}
|
|
30421
|
-
var active = document.activeElement;
|
|
30422
|
-
var ranges = [];
|
|
30423
|
-
for (var i2 = 0; i2 < selection.rangeCount; i2++) {
|
|
30424
|
-
ranges.push(selection.getRangeAt(i2));
|
|
30425
|
-
}
|
|
30426
|
-
switch (active.tagName.toUpperCase()) {
|
|
30427
|
-
// .toUpperCase handles XHTML
|
|
30428
|
-
case "INPUT":
|
|
30429
|
-
case "TEXTAREA":
|
|
30430
|
-
active.blur();
|
|
30431
|
-
break;
|
|
30432
|
-
default:
|
|
30433
|
-
active = null;
|
|
30434
|
-
break;
|
|
30435
|
-
}
|
|
30436
|
-
selection.removeAllRanges();
|
|
30437
|
-
return function() {
|
|
30438
|
-
selection.type === "Caret" && selection.removeAllRanges();
|
|
30439
|
-
if (!selection.rangeCount) {
|
|
30440
|
-
ranges.forEach(function(range) {
|
|
30441
|
-
selection.addRange(range);
|
|
30442
|
-
});
|
|
30443
|
-
}
|
|
30444
|
-
active && active.focus();
|
|
30445
|
-
};
|
|
30446
|
-
};
|
|
30447
|
-
}
|
|
30448
|
-
});
|
|
30449
|
-
var import_index = __toESM(require_toggle_selection());
|
|
30450
|
-
var toggle_selection_default = import_index.default;
|
|
30451
|
-
var defaultMessage = "Copy to clipboard: #{key}, Enter";
|
|
30452
|
-
function formatPromptMessage(message2) {
|
|
30453
|
-
var isMac2 = navigator.userAgentData ? /mac/i.test(navigator.userAgentData.platform) : /mac os x/i.test(navigator.userAgent);
|
|
30454
|
-
var copyKey = (isMac2 ? "⌘" : "Ctrl") + "+C";
|
|
30455
|
-
return message2.replace(/#{\s*key\s*}/g, copyKey);
|
|
30456
|
-
}
|
|
30457
|
-
function buildClipboardItem(text2, format2) {
|
|
30458
|
-
var items = {};
|
|
30459
|
-
items["text/plain"] = new Blob([text2], { type: "text/plain" });
|
|
30460
|
-
if (format2 && format2 !== "text/plain") {
|
|
30461
|
-
items[format2] = new Blob([text2], { type: format2 });
|
|
30462
|
-
}
|
|
30463
|
-
return new ClipboardItem(items);
|
|
30464
|
-
}
|
|
30465
|
-
async function copyViaClipboardAPI(text2, options) {
|
|
30466
|
-
if (!options.format && !options.onCopy) {
|
|
30467
|
-
await navigator.clipboard.writeText(text2);
|
|
30468
|
-
return true;
|
|
30469
|
-
}
|
|
30470
|
-
var item = buildClipboardItem(text2, options.format);
|
|
30471
|
-
if (options.onCopy) {
|
|
30472
|
-
item = options.onCopy(item) || item;
|
|
30473
|
-
}
|
|
30474
|
-
await navigator.clipboard.write([item]);
|
|
30475
|
-
return true;
|
|
30476
|
-
}
|
|
30477
|
-
function createHiddenSpan(text2, options) {
|
|
30478
|
-
var mark = document.createElement("span");
|
|
30479
|
-
mark.textContent = text2;
|
|
30480
|
-
mark.ariaHidden = "true";
|
|
30481
|
-
mark.style.all = "unset";
|
|
30482
|
-
mark.style.position = "fixed";
|
|
30483
|
-
mark.style.top = "0";
|
|
30484
|
-
mark.style.clip = "rect(0, 0, 0, 0)";
|
|
30485
|
-
mark.style.whiteSpace = "pre";
|
|
30486
|
-
mark.style.webkitUserSelect = "text";
|
|
30487
|
-
mark.style.MozUserSelect = "text";
|
|
30488
|
-
mark.style.msUserSelect = "text";
|
|
30489
|
-
mark.style.userSelect = "text";
|
|
30490
|
-
mark.addEventListener("copy", function(e) {
|
|
30491
|
-
e.stopPropagation();
|
|
30492
|
-
if (options.format) {
|
|
30493
|
-
e.preventDefault();
|
|
30494
|
-
if (e.clipboardData) {
|
|
30495
|
-
e.clipboardData.setData(options.format, text2);
|
|
30496
|
-
}
|
|
30497
|
-
}
|
|
30498
|
-
if (options.onCopy && e.clipboardData) {
|
|
30499
|
-
options.onCopy(e.clipboardData);
|
|
30500
|
-
}
|
|
30501
|
-
});
|
|
30502
|
-
return mark;
|
|
30503
|
-
}
|
|
30504
|
-
function findOpenedModalDialog() {
|
|
30505
|
-
let element = document.activeElement;
|
|
30506
|
-
while (element) {
|
|
30507
|
-
if (element.tagName === "DIALOG" && element.open) {
|
|
30508
|
-
return element;
|
|
30509
|
-
}
|
|
30510
|
-
element = element.parentElement;
|
|
30511
|
-
}
|
|
30512
|
-
return null;
|
|
30513
|
-
}
|
|
30514
|
-
function copyViaExecCommand(text2, options) {
|
|
30515
|
-
var reselectPrevious = toggle_selection_default();
|
|
30516
|
-
var range = document.createRange();
|
|
30517
|
-
var selection = document.getSelection();
|
|
30518
|
-
var mark = createHiddenSpan(text2, options);
|
|
30519
|
-
var root = findOpenedModalDialog() || document.fullscreenElement || document.body;
|
|
30520
|
-
var success = false;
|
|
30521
|
-
try {
|
|
30522
|
-
root.appendChild(mark);
|
|
30523
|
-
range.selectNodeContents(mark);
|
|
30524
|
-
selection.removeAllRanges();
|
|
30525
|
-
selection.addRange(range);
|
|
30526
|
-
var successful = document.execCommand("copy");
|
|
30527
|
-
if (!successful) {
|
|
30528
|
-
throw new Error("copy command was unsuccessful");
|
|
30529
|
-
}
|
|
30530
|
-
success = true;
|
|
30531
|
-
} finally {
|
|
30532
|
-
if (typeof selection.removeRange == "function") {
|
|
30533
|
-
selection.removeRange(range);
|
|
30534
|
-
} else {
|
|
30535
|
-
selection.removeAllRanges();
|
|
30536
|
-
}
|
|
30537
|
-
root.removeChild(mark);
|
|
30538
|
-
reselectPrevious();
|
|
30539
|
-
}
|
|
30540
|
-
return success;
|
|
30541
|
-
}
|
|
30542
|
-
async function copy$1(text2, options = {}) {
|
|
30543
|
-
var debug2 = options.debug || false;
|
|
30544
|
-
if (window.isSecureContext && navigator.clipboard) {
|
|
30545
|
-
try {
|
|
30546
|
-
return await copyViaClipboardAPI(text2, options);
|
|
30547
|
-
} catch (err) {
|
|
30548
|
-
debug2 && console.error("unable to copy using navigator.clipboard: ", err);
|
|
30549
|
-
debug2 && console.warn("falling back to execCommand");
|
|
30550
|
-
}
|
|
30551
|
-
} else {
|
|
30552
|
-
debug2 && !window.isSecureContext && console.warn("copy-to-clipboard: navigator.clipboard requires a secure context (HTTPS/localhost). Falling back to execCommand.");
|
|
30553
|
-
}
|
|
30554
|
-
try {
|
|
30555
|
-
return copyViaExecCommand(text2, options);
|
|
30556
|
-
} catch (err) {
|
|
30557
|
-
debug2 && console.error("unable to copy using execCommand: ", err);
|
|
30558
|
-
debug2 && console.error("falling back to prompt");
|
|
30559
|
-
if (options.fallbackToPrompt) {
|
|
30560
|
-
var message2 = formatPromptMessage("message" in options ? options.message : defaultMessage);
|
|
30561
|
-
window.prompt(message2, text2);
|
|
30562
|
-
}
|
|
30563
|
-
}
|
|
30564
|
-
return false;
|
|
30565
|
-
}
|
|
30566
|
-
var index_default = copy$1;
|
|
30567
|
-
function DisplayId({ id, className }) {
|
|
30568
|
-
const [open2, setOpen] = React.useState(false);
|
|
30569
|
-
const onClick = () => {
|
|
30570
|
-
index_default(id);
|
|
30571
|
-
ui.toast.success("Copied to clipboard");
|
|
30572
|
-
};
|
|
30573
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { maxWidth: 260, content: id, open: open2, onOpenChange: setOpen, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { onClick, className: ui.clx("cursor-pointer", className), children: [
|
|
30574
|
-
"#",
|
|
30575
|
-
id.slice(-7)
|
|
30576
|
-
] }) });
|
|
30577
|
-
}
|
|
30578
|
-
const columnHelper$8 = ui.createDataTableColumnHelper();
|
|
30579
|
-
const useTransactionsTableColumns = () => {
|
|
30580
|
-
return React.useMemo(() => {
|
|
30581
|
-
return [
|
|
30582
|
-
columnHelper$8.accessor("id", {
|
|
30583
|
-
header: "ID",
|
|
30584
|
-
cell: ({ row }) => {
|
|
30585
|
-
return /* @__PURE__ */ jsxRuntime.jsx(DisplayId, { id: row.original.id });
|
|
30586
|
-
}
|
|
30587
|
-
}),
|
|
30588
|
-
columnHelper$8.accessor("created_at", {
|
|
30589
|
-
header: "Created At",
|
|
30590
|
-
cell: ({ row }) => formatDate(row.original.created_at, false)
|
|
30591
|
-
}),
|
|
30592
|
-
columnHelper$8.accessor("note", {
|
|
30593
|
-
header: "Description",
|
|
30594
|
-
cell: ({ row }) => row.original.note
|
|
30595
|
-
}),
|
|
30596
|
-
columnHelper$8.accessor("note", {
|
|
30597
|
-
header: "Note",
|
|
30598
|
-
cell: ({ row }) => {
|
|
30599
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { title: row.original.note, className: "max-w-[300px] truncate", children: row.original.note || "-" });
|
|
30600
|
-
}
|
|
30601
|
-
}),
|
|
30602
|
-
columnHelper$8.accessor("amount", {
|
|
30603
|
-
header: "Amount",
|
|
30604
|
-
cell: ({ row }) => {
|
|
30605
|
-
const isDebit = row.original.type === "debit";
|
|
30606
|
-
return row.original.account.currency_code && formatAmount(
|
|
30607
|
-
row.original.amount * (isDebit ? -1 : 1),
|
|
30608
|
-
row.original.account.currency_code
|
|
30609
|
-
);
|
|
30610
|
-
}
|
|
30611
|
-
})
|
|
30612
|
-
];
|
|
30613
|
-
}, []);
|
|
30614
|
-
};
|
|
30615
|
-
const useTransactionsTableFilters = ({}) => {
|
|
30616
|
-
const dateFilterOptions = useDataTableDateFilters$1();
|
|
30617
|
-
return React.useMemo(() => {
|
|
30618
|
-
return [...dateFilterOptions];
|
|
30619
|
-
}, [dateFilterOptions]);
|
|
30620
|
-
};
|
|
30621
|
-
const useTransactionsTableQuery = ({
|
|
30622
|
-
prefix,
|
|
30623
|
-
pageSize = 20
|
|
30624
|
-
}) => {
|
|
30625
|
-
const queryObject = useQueryParams(
|
|
30626
|
-
["offset", "limit", "currency_code", "created_at", "updated_at"],
|
|
30627
|
-
prefix
|
|
30628
|
-
);
|
|
30629
|
-
const { offset: offset2, limit, created_at, updated_at, ...rest } = queryObject;
|
|
30630
|
-
const searchParams = {
|
|
30631
|
-
limit: limit ? Number(limit) : pageSize,
|
|
30632
|
-
offset: offset2 ? Number(offset2) : 0,
|
|
30633
|
-
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
30634
|
-
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
30635
|
-
...rest
|
|
30636
|
-
};
|
|
30637
|
-
return searchParams;
|
|
30638
|
-
};
|
|
30639
|
-
const PAGE_SIZE$4 = 10;
|
|
30640
|
-
function TransactionsTable({ id }) {
|
|
30641
|
-
const queryParams = useTransactionsTableQuery({
|
|
30642
|
-
pageSize: PAGE_SIZE$4
|
|
30643
|
-
});
|
|
30644
|
-
const { transactions, isLoading, count: count2 } = useStoreCreditAccountTransactions(
|
|
30645
|
-
id,
|
|
30646
|
-
{
|
|
30647
|
-
...queryParams,
|
|
30648
|
-
order: queryParams.order ?? "-created_at",
|
|
30649
|
-
fields: "*account"
|
|
30650
|
-
}
|
|
30651
|
-
);
|
|
30652
|
-
const columns = useTransactionsTableColumns();
|
|
30653
|
-
const filters = useTransactionsTableFilters({});
|
|
30654
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
30655
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
30656
|
-
DataTable,
|
|
30657
|
-
{
|
|
30658
|
-
data: transactions ?? [],
|
|
30659
|
-
getRowId: (row) => row.id,
|
|
30660
|
-
columns,
|
|
30661
|
-
filters,
|
|
30662
|
-
isLoading,
|
|
30663
|
-
pageSize: PAGE_SIZE$4,
|
|
30664
|
-
rowCount: count2,
|
|
30665
|
-
enableSearch: false,
|
|
30666
|
-
heading: "Transactions",
|
|
30667
|
-
emptyState: {
|
|
30668
|
-
empty: {
|
|
30669
|
-
heading: "No transactions found"
|
|
30670
|
-
},
|
|
30671
|
-
filtered: {
|
|
30672
|
-
heading: "No results found",
|
|
30673
|
-
description: "No transactions match your filter criteria."
|
|
30674
|
-
}
|
|
30675
|
-
}
|
|
30676
|
-
}
|
|
30677
|
-
) }),
|
|
30678
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
30679
|
-
] });
|
|
30680
|
-
}
|
|
30681
31115
|
const GiftCardTransactionsSection = ({
|
|
30682
31116
|
storeCreditAccount
|
|
30683
31117
|
}) => {
|
|
@@ -30729,36 +31163,9 @@ const GiftCardDetailsPage = () => {
|
|
|
30729
31163
|
}
|
|
30730
31164
|
);
|
|
30731
31165
|
};
|
|
30732
|
-
const handle$
|
|
31166
|
+
const handle$9 = {
|
|
30733
31167
|
permissions: ["gift_card:read"]
|
|
30734
31168
|
};
|
|
30735
|
-
const KeyboundForm = React__namespace.default.forwardRef(({ onSubmit, onKeyDown, ...rest }, ref) => {
|
|
30736
|
-
const handleSubmit = (event) => {
|
|
30737
|
-
event.preventDefault();
|
|
30738
|
-
onSubmit?.(event);
|
|
30739
|
-
};
|
|
30740
|
-
const handleKeyDown = (event) => {
|
|
30741
|
-
if (event.key === "Enter") {
|
|
30742
|
-
if (event.target instanceof HTMLTextAreaElement && !(event.metaKey || event.ctrlKey)) {
|
|
30743
|
-
return;
|
|
30744
|
-
}
|
|
30745
|
-
event.preventDefault();
|
|
30746
|
-
if (event.metaKey || event.ctrlKey) {
|
|
30747
|
-
handleSubmit(event);
|
|
30748
|
-
}
|
|
30749
|
-
}
|
|
30750
|
-
};
|
|
30751
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
30752
|
-
"form",
|
|
30753
|
-
{
|
|
30754
|
-
...rest,
|
|
30755
|
-
onSubmit: handleSubmit,
|
|
30756
|
-
onKeyDown: onKeyDown ?? handleKeyDown,
|
|
30757
|
-
ref
|
|
30758
|
-
}
|
|
30759
|
-
);
|
|
30760
|
-
});
|
|
30761
|
-
KeyboundForm.displayName = "KeyboundForm";
|
|
30762
31169
|
const GiftCardExpiration = () => {
|
|
30763
31170
|
const { id } = reactRouterDom.useParams();
|
|
30764
31171
|
const { gift_card: giftCard, isPending, isError, error: error2 } = useGiftCard(id);
|
|
@@ -30779,7 +31186,7 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
30779
31186
|
defaultValues: {
|
|
30780
31187
|
expires_at: giftCard.expires_at ? new Date(giftCard.expires_at) : null
|
|
30781
31188
|
},
|
|
30782
|
-
resolver: u(schema$
|
|
31189
|
+
resolver: u(schema$1)
|
|
30783
31190
|
});
|
|
30784
31191
|
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
30785
31192
|
const { handleSuccess } = useRouteModal();
|
|
@@ -30874,13 +31281,13 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
30874
31281
|
}
|
|
30875
31282
|
) });
|
|
30876
31283
|
};
|
|
30877
|
-
const schema$
|
|
31284
|
+
const schema$1 = zod.z.object({
|
|
30878
31285
|
expires_at: zod.z.date().nullish()
|
|
30879
31286
|
});
|
|
30880
|
-
const handle$
|
|
31287
|
+
const handle$8 = {
|
|
30881
31288
|
permissions: ["gift_card:read", "gift_card:update"]
|
|
30882
31289
|
};
|
|
30883
|
-
const Note
|
|
31290
|
+
const Note = () => {
|
|
30884
31291
|
const { id } = reactRouterDom.useParams();
|
|
30885
31292
|
const {
|
|
30886
31293
|
gift_card: giftCard,
|
|
@@ -30905,7 +31312,7 @@ const GiftCardNoteForm = ({ giftCard }) => {
|
|
|
30905
31312
|
defaultValues: {
|
|
30906
31313
|
note: giftCard.note ?? ""
|
|
30907
31314
|
},
|
|
30908
|
-
resolver: u(schema
|
|
31315
|
+
resolver: u(schema)
|
|
30909
31316
|
});
|
|
30910
31317
|
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
30911
31318
|
const { handleSuccess } = useRouteModal();
|
|
@@ -30944,10 +31351,10 @@ const GiftCardNoteForm = ({ giftCard }) => {
|
|
|
30944
31351
|
}
|
|
30945
31352
|
) });
|
|
30946
31353
|
};
|
|
30947
|
-
const schema
|
|
31354
|
+
const schema = zod.z.object({
|
|
30948
31355
|
note: zod.z.string().optional()
|
|
30949
31356
|
});
|
|
30950
|
-
const handle$
|
|
31357
|
+
const handle$7 = {
|
|
30951
31358
|
permissions: ["gift_card:read", "gift_card:update"]
|
|
30952
31359
|
};
|
|
30953
31360
|
const columnHelper$7 = createColumnHelper();
|
|
@@ -45441,7 +45848,7 @@ const GiftCardProductCreate = () => {
|
|
|
45441
45848
|
isPending: isStorePending,
|
|
45442
45849
|
isError: isStoreError,
|
|
45443
45850
|
error: storeError
|
|
45444
|
-
} = useStore$
|
|
45851
|
+
} = useStore$1({
|
|
45445
45852
|
fields: "+default_sales_channel"
|
|
45446
45853
|
});
|
|
45447
45854
|
const {
|
|
@@ -45493,7 +45900,7 @@ const GiftCardProductCreate = () => {
|
|
|
45493
45900
|
)
|
|
45494
45901
|
] });
|
|
45495
45902
|
};
|
|
45496
|
-
const handle$
|
|
45903
|
+
const handle$6 = {
|
|
45497
45904
|
permissions: [
|
|
45498
45905
|
"product:create",
|
|
45499
45906
|
"store:read",
|
|
@@ -45502,413 +45909,6 @@ const handle$9 = {
|
|
|
45502
45909
|
"price_preference:read"
|
|
45503
45910
|
]
|
|
45504
45911
|
};
|
|
45505
|
-
const StoreCreditAccountBalanceSection = ({
|
|
45506
|
-
storeCreditAccount
|
|
45507
|
-
}) => {
|
|
45508
|
-
if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
|
|
45509
|
-
return;
|
|
45510
|
-
}
|
|
45511
|
-
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: [
|
|
45512
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-ui-tag-green-icon h-8 w-1 rounded-full" }),
|
|
45513
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
45514
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", size: "small", className: "text-ui-fg-subtle", children: "Current Balance" }),
|
|
45515
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
45516
|
-
ui.Text,
|
|
45517
|
-
{
|
|
45518
|
-
weight: "plus",
|
|
45519
|
-
size: "xlarge",
|
|
45520
|
-
className: "tabular-nums text-ui-fg-base",
|
|
45521
|
-
children: formatAmount(
|
|
45522
|
-
storeCreditAccount.balance,
|
|
45523
|
-
storeCreditAccount.currency_code
|
|
45524
|
-
)
|
|
45525
|
-
}
|
|
45526
|
-
)
|
|
45527
|
-
] })
|
|
45528
|
-
] }) });
|
|
45529
|
-
};
|
|
45530
|
-
const StoreCreditAccountDetailsSection = ({
|
|
45531
|
-
storeCreditAccount
|
|
45532
|
-
}) => {
|
|
45533
|
-
const { hasPermission } = hooks.usePermissions();
|
|
45534
|
-
const canUpdate = hasPermission("store_credit_account:update");
|
|
45535
|
-
if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
|
|
45536
|
-
return;
|
|
45537
|
-
}
|
|
45538
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "flex justify-between gap-x-2 px-6 py-6", children: [
|
|
45539
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
45540
|
-
ui.Text,
|
|
45541
|
-
{
|
|
45542
|
-
weight: "plus",
|
|
45543
|
-
size: "xlarge",
|
|
45544
|
-
className: "text-ui-fg-base flex gap-x-4",
|
|
45545
|
-
children: [
|
|
45546
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
45547
|
-
/* @__PURE__ */ jsxRuntime.jsx(CreditCardIcon, { className: "inline" }),
|
|
45548
|
-
" "
|
|
45549
|
-
] }),
|
|
45550
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
45551
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle", children: [
|
|
45552
|
-
storeCreditAccount.currency_code.toUpperCase(),
|
|
45553
|
-
" Account"
|
|
45554
|
-
] }),
|
|
45555
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
45556
|
-
ui.Text,
|
|
45557
|
-
{
|
|
45558
|
-
weight: "regular",
|
|
45559
|
-
size: "small",
|
|
45560
|
-
className: "text-ui-fg-base flex gap-x-4",
|
|
45561
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(DisplayId, { id: storeCreditAccount.id })
|
|
45562
|
-
}
|
|
45563
|
-
) })
|
|
45564
|
-
] })
|
|
45565
|
-
]
|
|
45566
|
-
}
|
|
45567
|
-
),
|
|
45568
|
-
canUpdate && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-x-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
45569
|
-
ActionMenu,
|
|
45570
|
-
{
|
|
45571
|
-
groups: [
|
|
45572
|
-
{
|
|
45573
|
-
actions: [
|
|
45574
|
-
{
|
|
45575
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CreditCard, {}),
|
|
45576
|
-
label: "Credit the account",
|
|
45577
|
-
to: "credit"
|
|
45578
|
-
},
|
|
45579
|
-
{
|
|
45580
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.MinusMini, {}),
|
|
45581
|
-
label: "Debit the account",
|
|
45582
|
-
to: "debit",
|
|
45583
|
-
disabled: !Number(storeCreditAccount.balance)
|
|
45584
|
-
}
|
|
45585
|
-
]
|
|
45586
|
-
}
|
|
45587
|
-
]
|
|
45588
|
-
}
|
|
45589
|
-
) })
|
|
45590
|
-
] });
|
|
45591
|
-
};
|
|
45592
|
-
function StoreCreditAccountCustomerSection({
|
|
45593
|
-
customerId
|
|
45594
|
-
}) {
|
|
45595
|
-
const { hasPermission } = hooks.usePermissions();
|
|
45596
|
-
const canReadCustomer = hasPermission("customer:read");
|
|
45597
|
-
const { customer, isPending } = useCustomer(customerId, void 0, {
|
|
45598
|
-
enabled: !!customerId && canReadCustomer
|
|
45599
|
-
});
|
|
45600
|
-
if (!canReadCustomer || isPending || !customer) {
|
|
45601
|
-
return null;
|
|
45602
|
-
}
|
|
45603
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
45604
|
-
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Customer" }),
|
|
45605
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
45606
|
-
SidebarLink,
|
|
45607
|
-
{
|
|
45608
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {}),
|
|
45609
|
-
labelKey: customer.email || "N/A",
|
|
45610
|
-
descriptionKey: !customer.first_name && !customer.last_name ? "N/A" : `${customer.first_name} ${customer.last_name}`,
|
|
45611
|
-
to: `/customers/${customer.id}`
|
|
45612
|
-
},
|
|
45613
|
-
customer.id
|
|
45614
|
-
)
|
|
45615
|
-
] });
|
|
45616
|
-
}
|
|
45617
|
-
function StoreCreditAccountCodeSection({ code }) {
|
|
45618
|
-
if (!code) {
|
|
45619
|
-
return null;
|
|
45620
|
-
}
|
|
45621
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
45622
|
-
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Account Code" }),
|
|
45623
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-4 px-6 mb-2", children: [
|
|
45624
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.Share, { className: "inline" }),
|
|
45625
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle text-sm", children: code })
|
|
45626
|
-
] })
|
|
45627
|
-
] });
|
|
45628
|
-
}
|
|
45629
|
-
const StoreCreditAccountPage = () => {
|
|
45630
|
-
const { id } = reactRouterDom.useParams();
|
|
45631
|
-
const { store_credit_account: storeCreditAccount } = useStoreCreditAccount(
|
|
45632
|
-
id
|
|
45633
|
-
);
|
|
45634
|
-
if (!storeCreditAccount) {
|
|
45635
|
-
return;
|
|
45636
|
-
}
|
|
45637
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
45638
|
-
components.LayoutComposer,
|
|
45639
|
-
{
|
|
45640
|
-
widgetsZonePrefix: "store_credit_account.details",
|
|
45641
|
-
preferredLayoutId: "core:two-column",
|
|
45642
|
-
data: storeCreditAccount,
|
|
45643
|
-
sections: {
|
|
45644
|
-
main: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
45645
|
-
/* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountDetailsSection", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
45646
|
-
StoreCreditAccountDetailsSection,
|
|
45647
|
-
{
|
|
45648
|
-
storeCreditAccount
|
|
45649
|
-
}
|
|
45650
|
-
) }),
|
|
45651
|
-
/* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "TransactionsTable", children: /* @__PURE__ */ jsxRuntime.jsx(TransactionsTable, { id: storeCreditAccount.id }) })
|
|
45652
|
-
] }),
|
|
45653
|
-
side: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
45654
|
-
/* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountBalanceSection", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
45655
|
-
StoreCreditAccountBalanceSection,
|
|
45656
|
-
{
|
|
45657
|
-
storeCreditAccount
|
|
45658
|
-
}
|
|
45659
|
-
) }),
|
|
45660
|
-
/* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountCodeSection", children: /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCodeSection, { code: storeCreditAccount.code }) }),
|
|
45661
|
-
/* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountCustomerSection", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
45662
|
-
StoreCreditAccountCustomerSection,
|
|
45663
|
-
{
|
|
45664
|
-
customerId: storeCreditAccount.customer_id
|
|
45665
|
-
}
|
|
45666
|
-
) })
|
|
45667
|
-
] })
|
|
45668
|
-
}
|
|
45669
|
-
}
|
|
45670
|
-
);
|
|
45671
|
-
};
|
|
45672
|
-
const handle$8 = {
|
|
45673
|
-
permissions: ["store_credit_account:read"]
|
|
45674
|
-
};
|
|
45675
|
-
const Note = () => {
|
|
45676
|
-
const { id } = reactRouterDom.useParams();
|
|
45677
|
-
const {
|
|
45678
|
-
store_credit_account: storeCreditAccount,
|
|
45679
|
-
isPending,
|
|
45680
|
-
isError,
|
|
45681
|
-
error: error2
|
|
45682
|
-
} = useStoreCreditAccount(id, {});
|
|
45683
|
-
if (isError) {
|
|
45684
|
-
throw error2;
|
|
45685
|
-
}
|
|
45686
|
-
const isReady = !isPending && !!storeCreditAccount;
|
|
45687
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
45688
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
45689
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Credit store credit account" }) }),
|
|
45690
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Credit the store credit account" }) })
|
|
45691
|
-
] }),
|
|
45692
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCreditForm, { storeCreditAccount })
|
|
45693
|
-
] });
|
|
45694
|
-
};
|
|
45695
|
-
const StoreCreditAccountCreditForm = ({
|
|
45696
|
-
storeCreditAccount
|
|
45697
|
-
}) => {
|
|
45698
|
-
const form = useForm({
|
|
45699
|
-
defaultValues: {
|
|
45700
|
-
amount: {
|
|
45701
|
-
float: 0,
|
|
45702
|
-
value: ""
|
|
45703
|
-
},
|
|
45704
|
-
note: ""
|
|
45705
|
-
},
|
|
45706
|
-
resolver: u(schema$1)
|
|
45707
|
-
});
|
|
45708
|
-
const { mutateAsync, isPending } = useCreditStoreCreditAccount(
|
|
45709
|
-
storeCreditAccount.id
|
|
45710
|
-
);
|
|
45711
|
-
const { handleSuccess } = useRouteModal();
|
|
45712
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
45713
|
-
if (data.amount.float <= 0) {
|
|
45714
|
-
form.setError("amount", { message: "Amount must be greater than 0" });
|
|
45715
|
-
return;
|
|
45716
|
-
}
|
|
45717
|
-
await mutateAsync(
|
|
45718
|
-
{ amount: data.amount.float, note: data.note },
|
|
45719
|
-
{
|
|
45720
|
-
onSuccess: () => handleSuccess(),
|
|
45721
|
-
onError: (error2) => ui.toast.error(error2.message)
|
|
45722
|
-
}
|
|
45723
|
-
);
|
|
45724
|
-
});
|
|
45725
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
45726
|
-
KeyboundForm,
|
|
45727
|
-
{
|
|
45728
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
45729
|
-
onSubmit,
|
|
45730
|
-
children: [
|
|
45731
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
45732
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
45733
|
-
Form$2.Field,
|
|
45734
|
-
{
|
|
45735
|
-
control: form.control,
|
|
45736
|
-
name: "amount",
|
|
45737
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
45738
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Amount" }),
|
|
45739
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
45740
|
-
ui.CurrencyInput,
|
|
45741
|
-
{
|
|
45742
|
-
min: 0,
|
|
45743
|
-
placeholder: "0",
|
|
45744
|
-
value: field.value.value,
|
|
45745
|
-
onValueChange: (_value, _name, values) => {
|
|
45746
|
-
field.onChange({
|
|
45747
|
-
value: values?.value,
|
|
45748
|
-
float: values?.float || null
|
|
45749
|
-
});
|
|
45750
|
-
},
|
|
45751
|
-
symbol: currencies[storeCreditAccount.currency_code.toUpperCase()].symbol_native,
|
|
45752
|
-
code: storeCreditAccount.currency_code.toUpperCase()
|
|
45753
|
-
}
|
|
45754
|
-
) }),
|
|
45755
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
45756
|
-
] })
|
|
45757
|
-
}
|
|
45758
|
-
),
|
|
45759
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
45760
|
-
Form$2.Field,
|
|
45761
|
-
{
|
|
45762
|
-
control: form.control,
|
|
45763
|
-
name: "note",
|
|
45764
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
45765
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
|
|
45766
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
|
|
45767
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
45768
|
-
] })
|
|
45769
|
-
}
|
|
45770
|
-
)
|
|
45771
|
-
] }),
|
|
45772
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
45773
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
45774
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
45775
|
-
] }) })
|
|
45776
|
-
]
|
|
45777
|
-
}
|
|
45778
|
-
) });
|
|
45779
|
-
};
|
|
45780
|
-
const schema$1 = zod.z.object({
|
|
45781
|
-
note: zod.z.string(),
|
|
45782
|
-
amount: zod.z.object({
|
|
45783
|
-
float: zod.z.number(),
|
|
45784
|
-
value: zod.z.string()
|
|
45785
|
-
})
|
|
45786
|
-
});
|
|
45787
|
-
const handle$7 = {
|
|
45788
|
-
permissions: ["store_credit_account:read", "store_credit_account:update"]
|
|
45789
|
-
};
|
|
45790
|
-
const Debit = () => {
|
|
45791
|
-
const { id } = reactRouterDom.useParams();
|
|
45792
|
-
const {
|
|
45793
|
-
store_credit_account: storeCreditAccount,
|
|
45794
|
-
isPending,
|
|
45795
|
-
isError,
|
|
45796
|
-
error: error2
|
|
45797
|
-
} = useStoreCreditAccount(id, {});
|
|
45798
|
-
if (isError) {
|
|
45799
|
-
throw error2;
|
|
45800
|
-
}
|
|
45801
|
-
const isReady = !isPending && !!storeCreditAccount;
|
|
45802
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
45803
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
45804
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Debit store credit account" }) }),
|
|
45805
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Debit the store credit account" }) })
|
|
45806
|
-
] }),
|
|
45807
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountDebitForm, { storeCreditAccount })
|
|
45808
|
-
] });
|
|
45809
|
-
};
|
|
45810
|
-
const StoreCreditAccountDebitForm = ({
|
|
45811
|
-
storeCreditAccount
|
|
45812
|
-
}) => {
|
|
45813
|
-
const form = useForm({
|
|
45814
|
-
defaultValues: {
|
|
45815
|
-
amount: {
|
|
45816
|
-
float: 0,
|
|
45817
|
-
value: ""
|
|
45818
|
-
},
|
|
45819
|
-
note: ""
|
|
45820
|
-
},
|
|
45821
|
-
resolver: u(schema)
|
|
45822
|
-
});
|
|
45823
|
-
const { mutateAsync, isPending } = useDebitStoreCreditAccount(
|
|
45824
|
-
storeCreditAccount.id
|
|
45825
|
-
);
|
|
45826
|
-
const { handleSuccess } = useRouteModal();
|
|
45827
|
-
const balance = storeCreditAccount.balance ?? 0;
|
|
45828
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
45829
|
-
if (data.amount.float <= 0) {
|
|
45830
|
-
form.setError("amount", { message: "Amount must be greater than 0" });
|
|
45831
|
-
return;
|
|
45832
|
-
}
|
|
45833
|
-
if (data.amount.float > balance) {
|
|
45834
|
-
form.setError("amount", {
|
|
45835
|
-
message: "Amount can't be greater than the current balance"
|
|
45836
|
-
});
|
|
45837
|
-
return;
|
|
45838
|
-
}
|
|
45839
|
-
await mutateAsync(
|
|
45840
|
-
{ amount: data.amount.float, note: data.note },
|
|
45841
|
-
{
|
|
45842
|
-
onSuccess: () => handleSuccess(),
|
|
45843
|
-
onError: (error2) => ui.toast.error(error2.message)
|
|
45844
|
-
}
|
|
45845
|
-
);
|
|
45846
|
-
});
|
|
45847
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
45848
|
-
KeyboundForm,
|
|
45849
|
-
{
|
|
45850
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
45851
|
-
onSubmit,
|
|
45852
|
-
children: [
|
|
45853
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
45854
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
45855
|
-
Form$2.Field,
|
|
45856
|
-
{
|
|
45857
|
-
control: form.control,
|
|
45858
|
-
name: "amount",
|
|
45859
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
45860
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Amount" }),
|
|
45861
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
45862
|
-
ui.CurrencyInput,
|
|
45863
|
-
{
|
|
45864
|
-
min: 0,
|
|
45865
|
-
placeholder: "0",
|
|
45866
|
-
value: field.value.value,
|
|
45867
|
-
onValueChange: (_value, _name, values) => {
|
|
45868
|
-
field.onChange({
|
|
45869
|
-
value: values?.value,
|
|
45870
|
-
float: values?.float || null
|
|
45871
|
-
});
|
|
45872
|
-
},
|
|
45873
|
-
symbol: currencies[storeCreditAccount.currency_code.toUpperCase()].symbol_native,
|
|
45874
|
-
code: storeCreditAccount.currency_code.toUpperCase()
|
|
45875
|
-
}
|
|
45876
|
-
) }),
|
|
45877
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
45878
|
-
] })
|
|
45879
|
-
}
|
|
45880
|
-
),
|
|
45881
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
45882
|
-
Form$2.Field,
|
|
45883
|
-
{
|
|
45884
|
-
control: form.control,
|
|
45885
|
-
name: "note",
|
|
45886
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
45887
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
|
|
45888
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
|
|
45889
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
45890
|
-
] })
|
|
45891
|
-
}
|
|
45892
|
-
)
|
|
45893
|
-
] }),
|
|
45894
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
45895
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
45896
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
45897
|
-
] }) })
|
|
45898
|
-
]
|
|
45899
|
-
}
|
|
45900
|
-
) });
|
|
45901
|
-
};
|
|
45902
|
-
const schema = zod.z.object({
|
|
45903
|
-
note: zod.z.string(),
|
|
45904
|
-
amount: zod.z.object({
|
|
45905
|
-
float: zod.z.number(),
|
|
45906
|
-
value: zod.z.string()
|
|
45907
|
-
})
|
|
45908
|
-
});
|
|
45909
|
-
const handle$6 = {
|
|
45910
|
-
permissions: ["store_credit_account:read", "store_credit_account:update"]
|
|
45911
|
-
};
|
|
45912
45912
|
const productStatusColor = (status) => {
|
|
45913
45913
|
switch (status) {
|
|
45914
45914
|
case "draft":
|
|
@@ -47406,7 +47406,7 @@ const handle$2 = {
|
|
|
47406
47406
|
};
|
|
47407
47407
|
const VariantPricingForm = ({ form }) => {
|
|
47408
47408
|
const { hasPermission } = hooks.usePermissions();
|
|
47409
|
-
const { store } = useStore$
|
|
47409
|
+
const { store } = useStore$1();
|
|
47410
47410
|
const { regions } = useRegions(
|
|
47411
47411
|
{ limit: 9999 },
|
|
47412
47412
|
{ enabled: hasPermission("region:read") }
|
|
@@ -47697,44 +47697,61 @@ const widgetModule = { widgets: [
|
|
|
47697
47697
|
] };
|
|
47698
47698
|
const routeModule = {
|
|
47699
47699
|
routes: [
|
|
47700
|
+
{
|
|
47701
|
+
Component: StoreCreditAccountsPage,
|
|
47702
|
+
path: "/store-credit-accounts",
|
|
47703
|
+
handle: { label: config$3.label, translationNs: config$3.translationNs, permissions: config$3.permissions },
|
|
47704
|
+
children: [
|
|
47705
|
+
{
|
|
47706
|
+
Component: StoreCreditAccountCreate,
|
|
47707
|
+
path: "/store-credit-accounts/create",
|
|
47708
|
+
handle: handle$e
|
|
47709
|
+
}
|
|
47710
|
+
]
|
|
47711
|
+
},
|
|
47700
47712
|
{
|
|
47701
47713
|
Component: GiftCardsPage,
|
|
47702
47714
|
path: "/gift-cards",
|
|
47703
|
-
handle: { label: config$
|
|
47715
|
+
handle: { label: config$2.label, translationNs: config$2.translationNs, permissions: config$2.permissions },
|
|
47704
47716
|
children: [
|
|
47705
47717
|
{
|
|
47706
47718
|
Component: GiftCardCreate,
|
|
47707
47719
|
path: "/gift-cards/create",
|
|
47708
|
-
handle: handle$
|
|
47720
|
+
handle: handle$d
|
|
47709
47721
|
}
|
|
47710
47722
|
]
|
|
47711
47723
|
},
|
|
47712
47724
|
{
|
|
47713
|
-
Component:
|
|
47714
|
-
path: "/store-credit-accounts",
|
|
47715
|
-
handle:
|
|
47725
|
+
Component: StoreCreditAccountPage,
|
|
47726
|
+
path: "/store-credit-accounts/:id",
|
|
47727
|
+
handle: handle$c,
|
|
47716
47728
|
children: [
|
|
47717
47729
|
{
|
|
47718
|
-
Component:
|
|
47719
|
-
path: "/store-credit-accounts/
|
|
47720
|
-
handle: handle$
|
|
47730
|
+
Component: Note$1,
|
|
47731
|
+
path: "/store-credit-accounts/:id/credit",
|
|
47732
|
+
handle: handle$b
|
|
47733
|
+
},
|
|
47734
|
+
{
|
|
47735
|
+
Component: Debit,
|
|
47736
|
+
path: "/store-credit-accounts/:id/debit",
|
|
47737
|
+
handle: handle$a
|
|
47721
47738
|
}
|
|
47722
47739
|
]
|
|
47723
47740
|
},
|
|
47724
47741
|
{
|
|
47725
47742
|
Component: GiftCardDetailsPage,
|
|
47726
47743
|
path: "/gift-cards/:id",
|
|
47727
|
-
handle: handle$
|
|
47744
|
+
handle: handle$9,
|
|
47728
47745
|
children: [
|
|
47729
47746
|
{
|
|
47730
47747
|
Component: GiftCardExpiration,
|
|
47731
47748
|
path: "/gift-cards/:id/expiration",
|
|
47732
|
-
handle: handle$
|
|
47749
|
+
handle: handle$8
|
|
47733
47750
|
},
|
|
47734
47751
|
{
|
|
47735
|
-
Component: Note
|
|
47752
|
+
Component: Note,
|
|
47736
47753
|
path: "/gift-cards/:id/note",
|
|
47737
|
-
handle: handle$
|
|
47754
|
+
handle: handle$7
|
|
47738
47755
|
}
|
|
47739
47756
|
]
|
|
47740
47757
|
},
|
|
@@ -47746,23 +47763,6 @@ const routeModule = {
|
|
|
47746
47763
|
{
|
|
47747
47764
|
Component: GiftCardProductCreate,
|
|
47748
47765
|
path: "/gift-cards/gift-card-products/create",
|
|
47749
|
-
handle: handle$9
|
|
47750
|
-
}
|
|
47751
|
-
]
|
|
47752
|
-
},
|
|
47753
|
-
{
|
|
47754
|
-
Component: StoreCreditAccountPage,
|
|
47755
|
-
path: "/store-credit-accounts/:id",
|
|
47756
|
-
handle: handle$8,
|
|
47757
|
-
children: [
|
|
47758
|
-
{
|
|
47759
|
-
Component: Note,
|
|
47760
|
-
path: "/store-credit-accounts/:id/credit",
|
|
47761
|
-
handle: handle$7
|
|
47762
|
-
},
|
|
47763
|
-
{
|
|
47764
|
-
Component: Debit,
|
|
47765
|
-
path: "/store-credit-accounts/:id/debit",
|
|
47766
47766
|
handle: handle$6
|
|
47767
47767
|
}
|
|
47768
47768
|
]
|
|
@@ -47804,22 +47804,22 @@ const routeModule = {
|
|
|
47804
47804
|
const menuItemModule = {
|
|
47805
47805
|
menuItems: [
|
|
47806
47806
|
{
|
|
47807
|
-
label: config$
|
|
47808
|
-
icon: config$
|
|
47807
|
+
label: config$2.label,
|
|
47808
|
+
icon: config$2.icon,
|
|
47809
47809
|
path: "/gift-cards",
|
|
47810
47810
|
nested: void 0,
|
|
47811
47811
|
rank: void 0,
|
|
47812
47812
|
translationNs: void 0,
|
|
47813
|
-
permissions: config$
|
|
47813
|
+
permissions: config$2.permissions
|
|
47814
47814
|
},
|
|
47815
47815
|
{
|
|
47816
|
-
label: config$
|
|
47817
|
-
icon: config$
|
|
47816
|
+
label: config$3.label,
|
|
47817
|
+
icon: config$3.icon,
|
|
47818
47818
|
path: "/store-credit-accounts",
|
|
47819
47819
|
nested: void 0,
|
|
47820
47820
|
rank: void 0,
|
|
47821
47821
|
translationNs: void 0,
|
|
47822
|
-
permissions: config$
|
|
47822
|
+
permissions: config$3.permissions
|
|
47823
47823
|
},
|
|
47824
47824
|
{
|
|
47825
47825
|
label: config.label,
|