@medusajs/loyalty-plugin 2.22.3 → 2.22.4-preview-20261106081111
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 +1672 -1672
- package/.medusa/server/src/admin/index.mjs +1674 -1674
- package/.medusa/server/src/api/admin/gift-cards/validators.d.ts +1 -1
- package/.medusa/server/src/api/admin/store-credit-accounts/validators.d.ts +2 -2
- package/.medusa/server/src/api/store/store-credit-accounts/validators.d.ts +1 -1
- package/package.json +21 -21
|
@@ -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 zod = require("@medusajs/framework/zod");
|
|
13
12
|
const ReactDOM = require("react-dom");
|
|
13
|
+
const zod = require("@medusajs/framework/zod");
|
|
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 GiftCardIcon = (props) => {
|
|
5798
5798
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5799
5799
|
"svg",
|
|
5800
5800
|
{
|
|
@@ -5805,49 +5805,199 @@ const StoreCreditIcon = (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: "#F97316" }),
|
|
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_28788_25808)",
|
|
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
|
-
|
|
5818
|
+
/* @__PURE__ */ jsxRuntime.jsxs("g", { clipPath: "url(#clip0_28788_25808)", children: [
|
|
5819
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5820
|
+
"path",
|
|
5821
|
+
{
|
|
5822
|
+
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",
|
|
5823
|
+
fill: "white"
|
|
5824
|
+
}
|
|
5825
|
+
),
|
|
5826
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5827
|
+
"path",
|
|
5828
|
+
{
|
|
5829
|
+
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",
|
|
5830
|
+
fill: "white"
|
|
5831
|
+
}
|
|
5832
|
+
),
|
|
5833
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5834
|
+
"path",
|
|
5835
|
+
{
|
|
5836
|
+
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",
|
|
5837
|
+
fill: "white"
|
|
5838
|
+
}
|
|
5839
|
+
),
|
|
5840
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5841
|
+
"path",
|
|
5842
|
+
{
|
|
5843
|
+
d: "M6.938 7.5H3.75V9.563C3.75 10.7 4.675 11.625 5.813 11.625H6.938V7.5Z",
|
|
5844
|
+
fill: "white"
|
|
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
|
+
] })
|
|
5847
5873
|
]
|
|
5848
5874
|
}
|
|
5849
5875
|
);
|
|
5850
5876
|
};
|
|
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
|
+
};
|
|
5851
6001
|
function getRelativeDate(date2) {
|
|
5852
6002
|
const now = /* @__PURE__ */ new Date();
|
|
5853
6003
|
return formatDistance(sub(new Date(date2), { minutes: 0 }), now, {
|
|
@@ -5865,51 +6015,30 @@ function formatDate(date2, withTime = true) {
|
|
|
5865
6015
|
return format(new Date(date2), "dd MMM, yyyy");
|
|
5866
6016
|
}
|
|
5867
6017
|
const columnHelper$a = ui.createDataTableColumnHelper();
|
|
5868
|
-
const
|
|
6018
|
+
const useGiftCardTableColumns = () => {
|
|
5869
6019
|
return React.useMemo(() => {
|
|
5870
6020
|
return [
|
|
5871
|
-
columnHelper$a.accessor("
|
|
5872
|
-
header: "
|
|
5873
|
-
cell: ({ row }) => {
|
|
5874
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { size: "2xsmall", children: row.original.currency_code.toUpperCase() });
|
|
5875
|
-
}
|
|
5876
|
-
}),
|
|
5877
|
-
columnHelper$a.accessor("customer.email", {
|
|
5878
|
-
header: "Customer",
|
|
6021
|
+
columnHelper$a.accessor("code", {
|
|
6022
|
+
header: "Code",
|
|
5879
6023
|
cell: ({ row }) => {
|
|
5880
|
-
return row.original.
|
|
6024
|
+
return row.original.code;
|
|
5881
6025
|
}
|
|
5882
6026
|
}),
|
|
5883
|
-
columnHelper$a.accessor("
|
|
5884
|
-
header: "
|
|
6027
|
+
columnHelper$a.accessor("line_item.product.title", {
|
|
6028
|
+
header: "Product",
|
|
5885
6029
|
cell: ({ row }) => {
|
|
5886
|
-
return
|
|
5887
|
-
row.original.balance,
|
|
5888
|
-
row.original.currency_code
|
|
5889
|
-
);
|
|
6030
|
+
return row.original.line_item?.product?.title || "Custom Gift Card";
|
|
5890
6031
|
}
|
|
5891
6032
|
}),
|
|
5892
|
-
columnHelper$a.accessor("
|
|
5893
|
-
header: "
|
|
5894
|
-
cell: ({ row }) =>
|
|
5895
|
-
return formatAmount(
|
|
5896
|
-
row.original.credits,
|
|
5897
|
-
row.original.currency_code
|
|
5898
|
-
);
|
|
5899
|
-
}
|
|
6033
|
+
columnHelper$a.accessor("created_at", {
|
|
6034
|
+
header: "Date issued",
|
|
6035
|
+
cell: ({ row }) => getRelativeDate(row.original.created_at)
|
|
5900
6036
|
}),
|
|
5901
|
-
columnHelper$a.accessor("
|
|
5902
|
-
header: "
|
|
6037
|
+
columnHelper$a.accessor("value", {
|
|
6038
|
+
header: "Value",
|
|
5903
6039
|
cell: ({ row }) => {
|
|
5904
|
-
return formatAmount(
|
|
5905
|
-
row.original.debits,
|
|
5906
|
-
row.original.currency_code
|
|
5907
|
-
);
|
|
6040
|
+
return formatAmount(row.original.value, row.original.currency_code);
|
|
5908
6041
|
}
|
|
5909
|
-
}),
|
|
5910
|
-
columnHelper$a.accessor("created_at", {
|
|
5911
|
-
header: "Created at",
|
|
5912
|
-
cell: ({ row }) => getRelativeDate(row.original.created_at)
|
|
5913
6042
|
})
|
|
5914
6043
|
];
|
|
5915
6044
|
}, []);
|
|
@@ -5961,85 +6090,77 @@ const useCustomerFilters = () => {
|
|
|
5961
6090
|
];
|
|
5962
6091
|
}, [canReadCustomers, customerFilterOptions]);
|
|
5963
6092
|
};
|
|
5964
|
-
const
|
|
6093
|
+
const useGiftCardFilters = () => {
|
|
5965
6094
|
const dateFilterOptions = useDataTableDateFilters$1();
|
|
5966
6095
|
const customerFilterOptions = useCustomerFilters();
|
|
5967
6096
|
return React.useMemo(() => {
|
|
5968
6097
|
return [...dateFilterOptions, ...customerFilterOptions];
|
|
5969
6098
|
}, [dateFilterOptions, customerFilterOptions]);
|
|
5970
6099
|
};
|
|
5971
|
-
const
|
|
6100
|
+
const useGiftCardTableQuery = ({
|
|
5972
6101
|
prefix,
|
|
5973
6102
|
pageSize = 20
|
|
5974
6103
|
}) => {
|
|
5975
6104
|
const queryObject = useQueryParams(
|
|
5976
|
-
["
|
|
6105
|
+
["q", "offset", "customer_id", "created_at", "updated_at"],
|
|
5977
6106
|
prefix
|
|
5978
6107
|
);
|
|
5979
|
-
const {
|
|
5980
|
-
offset: offset2,
|
|
5981
|
-
created_at,
|
|
5982
|
-
updated_at,
|
|
5983
|
-
customer_id,
|
|
5984
|
-
currency_code,
|
|
5985
|
-
...rest
|
|
5986
|
-
} = queryObject;
|
|
6108
|
+
const { offset: offset2, created_at, updated_at, customer_id, ...rest } = queryObject;
|
|
5987
6109
|
const searchParams = {
|
|
5988
6110
|
limit: pageSize,
|
|
5989
6111
|
offset: offset2 ? Number(offset2) : 0,
|
|
5990
6112
|
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
5991
6113
|
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
5992
6114
|
customer_id: customer_id ? JSON.parse(customer_id) : void 0,
|
|
5993
|
-
currency_code: currency_code ? JSON.parse(currency_code) : void 0,
|
|
5994
6115
|
...rest
|
|
5995
6116
|
};
|
|
5996
6117
|
return searchParams;
|
|
5997
6118
|
};
|
|
5998
6119
|
const PAGE_SIZE$6 = 10;
|
|
5999
|
-
function
|
|
6000
|
-
const queryParams =
|
|
6120
|
+
function GiftCardsTable() {
|
|
6121
|
+
const queryParams = useGiftCardTableQuery({
|
|
6001
6122
|
pageSize: PAGE_SIZE$6
|
|
6002
6123
|
});
|
|
6003
6124
|
const {
|
|
6004
|
-
|
|
6125
|
+
gift_cards: giftCards,
|
|
6005
6126
|
isPending,
|
|
6006
6127
|
count: count2
|
|
6007
|
-
} =
|
|
6128
|
+
} = useGiftCards({
|
|
6008
6129
|
...queryParams,
|
|
6009
|
-
order: queryParams.order ?? "-created_at"
|
|
6130
|
+
order: queryParams.order ?? "-created_at",
|
|
6131
|
+
fields: "+line_item.product.title"
|
|
6010
6132
|
});
|
|
6011
|
-
const columns =
|
|
6012
|
-
const filters =
|
|
6133
|
+
const columns = useGiftCardTableColumns();
|
|
6134
|
+
const filters = useGiftCardFilters();
|
|
6013
6135
|
const { hasPermission } = hooks.usePermissions();
|
|
6014
|
-
const canCreate = hasPermission("
|
|
6136
|
+
const canCreate = hasPermission("gift_card:create");
|
|
6015
6137
|
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
6016
6138
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6017
6139
|
DataTable,
|
|
6018
6140
|
{
|
|
6019
|
-
data:
|
|
6141
|
+
data: giftCards,
|
|
6020
6142
|
getRowId: (row) => row.id,
|
|
6021
6143
|
columns,
|
|
6022
6144
|
filters,
|
|
6023
6145
|
isLoading: isPending,
|
|
6024
6146
|
pageSize: PAGE_SIZE$6,
|
|
6025
6147
|
rowCount: count2,
|
|
6026
|
-
|
|
6027
|
-
heading: "Store Credit Accounts",
|
|
6148
|
+
heading: "Gift Cards",
|
|
6028
6149
|
rowHref: (row) => `${row.id}`,
|
|
6029
6150
|
emptyState: {
|
|
6030
6151
|
empty: {
|
|
6031
|
-
heading: "No
|
|
6032
|
-
description: "Create a
|
|
6152
|
+
heading: "No gift cards found",
|
|
6153
|
+
description: "Create a gift card to get started."
|
|
6033
6154
|
},
|
|
6034
6155
|
filtered: {
|
|
6035
6156
|
heading: "No results found",
|
|
6036
|
-
description: "No
|
|
6157
|
+
description: "No gift cards match your filter criteria."
|
|
6037
6158
|
}
|
|
6038
6159
|
},
|
|
6039
6160
|
actions: canCreate ? [
|
|
6040
6161
|
{
|
|
6041
6162
|
label: "Create",
|
|
6042
|
-
to: "
|
|
6163
|
+
to: "create"
|
|
6043
6164
|
}
|
|
6044
6165
|
] : []
|
|
6045
6166
|
}
|
|
@@ -6047,15 +6168,16 @@ function StoreCreditAccountsTable() {
|
|
|
6047
6168
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
6048
6169
|
] });
|
|
6049
6170
|
}
|
|
6050
|
-
const
|
|
6171
|
+
const GiftCardsPage = () => {
|
|
6051
6172
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6052
6173
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6053
6174
|
components.LayoutComposer,
|
|
6054
6175
|
{
|
|
6055
|
-
widgetsZonePrefix: "
|
|
6056
|
-
preferredLayoutId: "core:
|
|
6176
|
+
widgetsZonePrefix: "gift_card.list",
|
|
6177
|
+
preferredLayoutId: "core:two-column",
|
|
6057
6178
|
sections: {
|
|
6058
|
-
main: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "
|
|
6179
|
+
main: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardsTable", children: /* @__PURE__ */ jsxRuntime.jsx(GiftCardsTable, {}) }),
|
|
6180
|
+
side: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardProductsSection", children: /* @__PURE__ */ jsxRuntime.jsx(hooks.PermissionGuard, { permission: "product:read", children: /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductsSection, {}) }) })
|
|
6059
6181
|
}
|
|
6060
6182
|
}
|
|
6061
6183
|
),
|
|
@@ -6063,9 +6185,9 @@ const StoreCreditAccountsPage = () => {
|
|
|
6063
6185
|
] });
|
|
6064
6186
|
};
|
|
6065
6187
|
const config$3 = adminSdk.defineRouteConfig({
|
|
6066
|
-
label: "
|
|
6067
|
-
icon:
|
|
6068
|
-
permissions: ["
|
|
6188
|
+
label: "Gift Cards",
|
|
6189
|
+
icon: GiftCardIcon,
|
|
6190
|
+
permissions: ["gift_card:read"]
|
|
6069
6191
|
});
|
|
6070
6192
|
function setRef$2(ref, value) {
|
|
6071
6193
|
if (typeof ref === "function") {
|
|
@@ -10760,6 +10882,27 @@ const StackedFocusModal = Object.assign(Root, {
|
|
|
10760
10882
|
Description,
|
|
10761
10883
|
Title
|
|
10762
10884
|
});
|
|
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
|
+
};
|
|
10763
10906
|
const t$1 = (r, t2, s2) => {
|
|
10764
10907
|
if (r && "reportValidity" in r) {
|
|
10765
10908
|
const o2 = get$2(s2, t2);
|
|
@@ -13805,7 +13948,7 @@ function useStoreProps(store, props, key2, setKey) {
|
|
|
13805
13948
|
});
|
|
13806
13949
|
});
|
|
13807
13950
|
}
|
|
13808
|
-
function useStore$
|
|
13951
|
+
function useStore$1(createStore2, props) {
|
|
13809
13952
|
const [store, setStore] = React__namespace.useState(() => createStore2(props));
|
|
13810
13953
|
useSafeLayoutEffect(() => init(store), [store]);
|
|
13811
13954
|
const useState = React__namespace.useCallback((keyOrSelector) => useStoreState(store, keyOrSelector), [store]);
|
|
@@ -14762,7 +14905,7 @@ function useDisclosureStoreProps(store, update, props) {
|
|
|
14762
14905
|
return Object.assign(store, { disclosure: props.disclosure });
|
|
14763
14906
|
}
|
|
14764
14907
|
function useDisclosureStore(props = {}) {
|
|
14765
|
-
const [store, update] = useStore$
|
|
14908
|
+
const [store, update] = useStore$1(createDisclosureStore, props);
|
|
14766
14909
|
return useDisclosureStoreProps(store, update, props);
|
|
14767
14910
|
}
|
|
14768
14911
|
const ctx$2 = createStoreContext([DialogContextProvider], [DialogScopedContextProvider]);
|
|
@@ -15571,7 +15714,7 @@ function useDialogStoreProps(store, update, props) {
|
|
|
15571
15714
|
return useDisclosureStoreProps(store, update, props);
|
|
15572
15715
|
}
|
|
15573
15716
|
function useDialogStore(props = {}) {
|
|
15574
|
-
const [store, update] = useStore$
|
|
15717
|
+
const [store, update] = useStore$1(createDialogStore, props);
|
|
15575
15718
|
return useDialogStoreProps(store, update, props);
|
|
15576
15719
|
}
|
|
15577
15720
|
function isHiddenDismiss(element, ...ids2) {
|
|
@@ -18887,7 +19030,7 @@ function useComboboxStoreProps(store, update, props) {
|
|
|
18887
19030
|
}
|
|
18888
19031
|
function useComboboxStore(props = {}) {
|
|
18889
19032
|
props = useComboboxStoreOptions(props);
|
|
18890
|
-
const [store, update] = useStore$
|
|
19033
|
+
const [store, update] = useStore$1(createComboboxStore, props);
|
|
18891
19034
|
return useComboboxStoreProps(store, update, props);
|
|
18892
19035
|
}
|
|
18893
19036
|
function ComboboxProvider(props = {}) {
|
|
@@ -20006,371 +20149,6 @@ const ComboboxImpl = ({
|
|
|
20006
20149
|
);
|
|
20007
20150
|
};
|
|
20008
20151
|
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
|
-
};
|
|
20374
20152
|
const currencies = {
|
|
20375
20153
|
USD: {
|
|
20376
20154
|
code: "USD",
|
|
@@ -21123,515 +20901,6 @@ const currencies = {
|
|
|
21123
20901
|
decimal_digits: 0
|
|
21124
20902
|
}
|
|
21125
20903
|
};
|
|
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
|
-
};
|
|
21635
20904
|
function getEnumValues(entries) {
|
|
21636
20905
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
21637
20906
|
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
@@ -22298,7 +21567,7 @@ class $ZodEncodeError extends Error {
|
|
|
22298
21567
|
}
|
|
22299
21568
|
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
|
|
22300
21569
|
const globalConfig = globalThis.__zod_globalConfig;
|
|
22301
|
-
function config$
|
|
21570
|
+
function config$2(newConfig) {
|
|
22302
21571
|
if (newConfig)
|
|
22303
21572
|
Object.assign(globalConfig, newConfig);
|
|
22304
21573
|
return globalConfig;
|
|
@@ -22424,7 +21693,7 @@ const _parse = (_Err) => {
|
|
|
22424
21693
|
throw new $ZodAsyncError();
|
|
22425
21694
|
}
|
|
22426
21695
|
if (result.issues.length) {
|
|
22427
|
-
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
21696
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())));
|
|
22428
21697
|
captureStackTrace(e, _params?.callee ?? fn);
|
|
22429
21698
|
throw e;
|
|
22430
21699
|
}
|
|
@@ -22439,7 +21708,7 @@ const _parseAsync = (_Err) => {
|
|
|
22439
21708
|
if (result instanceof Promise)
|
|
22440
21709
|
result = await result;
|
|
22441
21710
|
if (result.issues.length) {
|
|
22442
|
-
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
21711
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())));
|
|
22443
21712
|
captureStackTrace(e, params?.callee ?? fn);
|
|
22444
21713
|
throw e;
|
|
22445
21714
|
}
|
|
@@ -22461,7 +21730,7 @@ function failure(Err, issues, ctx2) {
|
|
|
22461
21730
|
success: false,
|
|
22462
21731
|
get error() {
|
|
22463
21732
|
if (!error2) {
|
|
22464
|
-
error2 = new Err(issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
21733
|
+
error2 = new Err(issues.map((iss) => finalizeIssue(iss, ctx2, config$2())));
|
|
22465
21734
|
issues = void 0;
|
|
22466
21735
|
ctx2 = void 0;
|
|
22467
21736
|
}
|
|
@@ -23086,7 +22355,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
23086
22355
|
own(this, "~standard", value);
|
|
23087
22356
|
}
|
|
23088
22357
|
});
|
|
23089
|
-
const toStandardResult = (r, ctx2) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
22358
|
+
const toStandardResult = (r, ctx2) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())) } : { value: r.value };
|
|
23090
22359
|
async function validateAsync(inst, value) {
|
|
23091
22360
|
const ctx2 = { async: true };
|
|
23092
22361
|
return toStandardResult(await inst._zod.run({ value, issues: [] }, ctx2), ctx2);
|
|
@@ -23948,7 +23217,7 @@ function handleUnionResults(results, final, inst, ctx2) {
|
|
|
23948
23217
|
code: "invalid_union",
|
|
23949
23218
|
input: final.value,
|
|
23950
23219
|
inst,
|
|
23951
|
-
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
23220
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())))
|
|
23952
23221
|
});
|
|
23953
23222
|
return final;
|
|
23954
23223
|
}
|
|
@@ -24144,7 +23413,7 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
24144
23413
|
payload.issues.push({
|
|
24145
23414
|
code: "invalid_key",
|
|
24146
23415
|
origin: "record",
|
|
24147
|
-
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
23416
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())),
|
|
24148
23417
|
input: key2,
|
|
24149
23418
|
path: [key2],
|
|
24150
23419
|
inst
|
|
@@ -24224,7 +23493,7 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
24224
23493
|
payload.issues.push({
|
|
24225
23494
|
code: "invalid_key",
|
|
24226
23495
|
origin: "record",
|
|
24227
|
-
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
23496
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())),
|
|
24228
23497
|
input: key2,
|
|
24229
23498
|
path: [key2],
|
|
24230
23499
|
inst
|
|
@@ -24440,7 +23709,7 @@ function handleCatchResult(payload, result, def, ctx2) {
|
|
|
24440
23709
|
...result,
|
|
24441
23710
|
value: payload.value,
|
|
24442
23711
|
error: {
|
|
24443
|
-
issues: result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
23712
|
+
issues: result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2()))
|
|
24444
23713
|
},
|
|
24445
23714
|
input: payload.value
|
|
24446
23715
|
});
|
|
@@ -26584,11 +25853,11 @@ const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
|
26584
25853
|
const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
26585
25854
|
function _ensureDefaultLocale() {
|
|
26586
25855
|
if (!globalConfig.localeError)
|
|
26587
|
-
config$
|
|
25856
|
+
config$2(en());
|
|
26588
25857
|
}
|
|
26589
25858
|
function _ensureDefaultMemoizer() {
|
|
26590
25859
|
if (!globalConfig.memoizer)
|
|
26591
|
-
config$
|
|
25860
|
+
config$2({ memoizer: memoizer() });
|
|
26592
25861
|
}
|
|
26593
25862
|
const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
26594
25863
|
_ensureDefaultLocale();
|
|
@@ -27692,742 +26961,746 @@ const GiftCardCreateForm = ({
|
|
|
27692
26961
|
] });
|
|
27693
26962
|
};
|
|
27694
26963
|
const GiftCardCreate = () => {
|
|
27695
|
-
const { store, isLoading } = useStore$
|
|
26964
|
+
const { store, isLoading } = useStore$2({});
|
|
27696
26965
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal, { children: [
|
|
27697
26966
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create Gift Card" }) }),
|
|
27698
26967
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create a new gift card" }) }),
|
|
27699
26968
|
!isLoading && /* @__PURE__ */ jsxRuntime.jsx(GiftCardCreateForm, { store })
|
|
27700
26969
|
] });
|
|
27701
26970
|
};
|
|
27702
|
-
const handle$
|
|
26971
|
+
const handle$e = {
|
|
27703
26972
|
permissions: ["gift_card:create", "store:read"]
|
|
27704
26973
|
};
|
|
27705
|
-
const
|
|
27706
|
-
|
|
27707
|
-
|
|
27708
|
-
|
|
27709
|
-
|
|
27710
|
-
|
|
27711
|
-
|
|
27712
|
-
|
|
27713
|
-
|
|
27714
|
-
|
|
27715
|
-
|
|
27716
|
-
|
|
27717
|
-
|
|
27718
|
-
|
|
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: [
|
|
26974
|
+
const StoreCreditIcon = (props) => {
|
|
26975
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
26976
|
+
"svg",
|
|
26977
|
+
{
|
|
26978
|
+
width: "15",
|
|
26979
|
+
height: "15",
|
|
26980
|
+
viewBox: "0 0 15 15",
|
|
26981
|
+
fill: "none",
|
|
26982
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
26983
|
+
...props,
|
|
26984
|
+
children: [
|
|
26985
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#8B5CF6" }),
|
|
26986
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
26987
|
+
"rect",
|
|
27962
26988
|
{
|
|
27963
|
-
|
|
27964
|
-
|
|
27965
|
-
|
|
27966
|
-
|
|
27967
|
-
|
|
27968
|
-
|
|
27969
|
-
|
|
27970
|
-
|
|
27971
|
-
|
|
27972
|
-
|
|
27973
|
-
|
|
27974
|
-
|
|
26989
|
+
width: "15",
|
|
26990
|
+
height: "15",
|
|
26991
|
+
fill: "url(#paint0_linear_29181_44790)",
|
|
26992
|
+
fillOpacity: "0.2"
|
|
26993
|
+
}
|
|
26994
|
+
),
|
|
26995
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
26996
|
+
"path",
|
|
26997
|
+
{
|
|
26998
|
+
d: "M12 6V5.813C12 4.675 11.075 3.75 9.938 3.75H5.063C3.925 3.75 3 4.675 3 5.813V6H12Z",
|
|
26999
|
+
fill: "white"
|
|
27000
|
+
}
|
|
27001
|
+
),
|
|
27002
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
27003
|
+
"path",
|
|
27004
|
+
{
|
|
27005
|
+
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",
|
|
27006
|
+
fill: "white"
|
|
27007
|
+
}
|
|
27008
|
+
),
|
|
27009
|
+
/* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
27010
|
+
"linearGradient",
|
|
27011
|
+
{
|
|
27012
|
+
id: "paint0_linear_29181_44790",
|
|
27013
|
+
x1: "7.5",
|
|
27014
|
+
y1: "0",
|
|
27015
|
+
x2: "7.5",
|
|
27016
|
+
y2: "15",
|
|
27017
|
+
gradientUnits: "userSpaceOnUse",
|
|
27018
|
+
children: [
|
|
27019
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "white" }),
|
|
27020
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
|
|
27975
27021
|
]
|
|
27976
27022
|
}
|
|
27977
|
-
|
|
27978
|
-
|
|
27979
|
-
|
|
27980
|
-
|
|
27023
|
+
) })
|
|
27024
|
+
]
|
|
27025
|
+
}
|
|
27026
|
+
);
|
|
27981
27027
|
};
|
|
27982
|
-
|
|
27983
|
-
|
|
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 = () => {
|
|
27028
|
+
const columnHelper$9 = ui.createDataTableColumnHelper();
|
|
27029
|
+
const useStoreCreditAccountTableColumns = () => {
|
|
28009
27030
|
return React.useMemo(() => {
|
|
28010
27031
|
return [
|
|
28011
|
-
columnHelper$
|
|
28012
|
-
header: "
|
|
27032
|
+
columnHelper$9.accessor("currency_code", {
|
|
27033
|
+
header: "Currency",
|
|
28013
27034
|
cell: ({ row }) => {
|
|
28014
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
27035
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { size: "2xsmall", children: row.original.currency_code.toUpperCase() });
|
|
28015
27036
|
}
|
|
28016
27037
|
}),
|
|
28017
|
-
columnHelper$
|
|
28018
|
-
header: "
|
|
28019
|
-
cell: ({ row }) =>
|
|
27038
|
+
columnHelper$9.accessor("customer.email", {
|
|
27039
|
+
header: "Customer",
|
|
27040
|
+
cell: ({ row }) => {
|
|
27041
|
+
return row.original.customer?.email ?? "N/A";
|
|
27042
|
+
}
|
|
28020
27043
|
}),
|
|
28021
|
-
columnHelper$
|
|
28022
|
-
header: "
|
|
28023
|
-
cell: ({ row }) =>
|
|
27044
|
+
columnHelper$9.accessor("balance", {
|
|
27045
|
+
header: "Balance",
|
|
27046
|
+
cell: ({ row }) => {
|
|
27047
|
+
return formatAmount(
|
|
27048
|
+
row.original.balance,
|
|
27049
|
+
row.original.currency_code
|
|
27050
|
+
);
|
|
27051
|
+
}
|
|
28024
27052
|
}),
|
|
28025
|
-
columnHelper$
|
|
28026
|
-
header: "
|
|
27053
|
+
columnHelper$9.accessor("credits", {
|
|
27054
|
+
header: "Credits",
|
|
28027
27055
|
cell: ({ row }) => {
|
|
28028
|
-
return
|
|
27056
|
+
return formatAmount(
|
|
27057
|
+
row.original.credits,
|
|
27058
|
+
row.original.currency_code
|
|
27059
|
+
);
|
|
28029
27060
|
}
|
|
28030
27061
|
}),
|
|
28031
|
-
columnHelper$
|
|
28032
|
-
header: "
|
|
27062
|
+
columnHelper$9.accessor("debits", {
|
|
27063
|
+
header: "Debits",
|
|
28033
27064
|
cell: ({ row }) => {
|
|
28034
|
-
|
|
28035
|
-
|
|
28036
|
-
row.original.
|
|
28037
|
-
row.original.account.currency_code
|
|
27065
|
+
return formatAmount(
|
|
27066
|
+
row.original.debits,
|
|
27067
|
+
row.original.currency_code
|
|
28038
27068
|
);
|
|
28039
27069
|
}
|
|
27070
|
+
}),
|
|
27071
|
+
columnHelper$9.accessor("created_at", {
|
|
27072
|
+
header: "Created at",
|
|
27073
|
+
cell: ({ row }) => getRelativeDate(row.original.created_at)
|
|
28040
27074
|
})
|
|
28041
27075
|
];
|
|
28042
27076
|
}, []);
|
|
28043
27077
|
};
|
|
28044
|
-
const
|
|
27078
|
+
const useStoreCreditAccountFilters = () => {
|
|
28045
27079
|
const dateFilterOptions = useDataTableDateFilters$1();
|
|
27080
|
+
const customerFilterOptions = useCustomerFilters();
|
|
28046
27081
|
return React.useMemo(() => {
|
|
28047
|
-
return [...dateFilterOptions];
|
|
28048
|
-
}, [dateFilterOptions]);
|
|
27082
|
+
return [...dateFilterOptions, ...customerFilterOptions];
|
|
27083
|
+
}, [dateFilterOptions, customerFilterOptions]);
|
|
28049
27084
|
};
|
|
28050
|
-
const
|
|
27085
|
+
const useStoreCreditAccountsTableQuery = ({
|
|
28051
27086
|
prefix,
|
|
28052
27087
|
pageSize = 20
|
|
28053
27088
|
}) => {
|
|
28054
27089
|
const queryObject = useQueryParams(
|
|
28055
|
-
["offset", "
|
|
27090
|
+
["offset", "customer_id", "currency_code", "created_at", "updated_at"],
|
|
28056
27091
|
prefix
|
|
28057
27092
|
);
|
|
28058
|
-
const {
|
|
27093
|
+
const {
|
|
27094
|
+
offset: offset2,
|
|
27095
|
+
created_at,
|
|
27096
|
+
updated_at,
|
|
27097
|
+
customer_id,
|
|
27098
|
+
currency_code,
|
|
27099
|
+
...rest
|
|
27100
|
+
} = queryObject;
|
|
28059
27101
|
const searchParams = {
|
|
28060
|
-
limit:
|
|
27102
|
+
limit: pageSize,
|
|
28061
27103
|
offset: offset2 ? Number(offset2) : 0,
|
|
28062
27104
|
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
28063
27105
|
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,
|
|
28064
27108
|
...rest
|
|
28065
27109
|
};
|
|
28066
27110
|
return searchParams;
|
|
28067
27111
|
};
|
|
28068
|
-
const PAGE_SIZE$
|
|
28069
|
-
function
|
|
28070
|
-
const queryParams =
|
|
28071
|
-
pageSize: PAGE_SIZE$
|
|
27112
|
+
const PAGE_SIZE$5 = 10;
|
|
27113
|
+
function StoreCreditAccountsTable() {
|
|
27114
|
+
const queryParams = useStoreCreditAccountsTableQuery({
|
|
27115
|
+
pageSize: PAGE_SIZE$5
|
|
28072
27116
|
});
|
|
28073
|
-
const {
|
|
28074
|
-
|
|
28075
|
-
|
|
28076
|
-
|
|
28077
|
-
|
|
28078
|
-
|
|
28079
|
-
|
|
28080
|
-
);
|
|
28081
|
-
const columns =
|
|
28082
|
-
const filters =
|
|
27117
|
+
const {
|
|
27118
|
+
store_credit_accounts: storeCreditAccounts,
|
|
27119
|
+
isPending,
|
|
27120
|
+
count: count2
|
|
27121
|
+
} = useStoreCreditAccounts({
|
|
27122
|
+
...queryParams,
|
|
27123
|
+
order: queryParams.order ?? "-created_at"
|
|
27124
|
+
});
|
|
27125
|
+
const columns = useStoreCreditAccountTableColumns();
|
|
27126
|
+
const filters = useStoreCreditAccountFilters();
|
|
27127
|
+
const { hasPermission } = hooks.usePermissions();
|
|
27128
|
+
const canCreate = hasPermission("store_credit_account:create");
|
|
28083
27129
|
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
28084
27130
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
28085
27131
|
DataTable,
|
|
28086
27132
|
{
|
|
28087
|
-
data:
|
|
27133
|
+
data: storeCreditAccounts ?? [],
|
|
28088
27134
|
getRowId: (row) => row.id,
|
|
28089
27135
|
columns,
|
|
28090
27136
|
filters,
|
|
28091
|
-
isLoading,
|
|
28092
|
-
pageSize: PAGE_SIZE$
|
|
27137
|
+
isLoading: isPending,
|
|
27138
|
+
pageSize: PAGE_SIZE$5,
|
|
28093
27139
|
rowCount: count2,
|
|
28094
27140
|
enableSearch: false,
|
|
28095
|
-
heading: "
|
|
27141
|
+
heading: "Store Credit Accounts",
|
|
27142
|
+
rowHref: (row) => `${row.id}`,
|
|
28096
27143
|
emptyState: {
|
|
28097
27144
|
empty: {
|
|
28098
|
-
heading: "No
|
|
27145
|
+
heading: "No store credit accounts found",
|
|
27146
|
+
description: "Create a new store credit account to get started."
|
|
28099
27147
|
},
|
|
28100
27148
|
filtered: {
|
|
28101
27149
|
heading: "No results found",
|
|
28102
|
-
description: "No
|
|
27150
|
+
description: "No store credit accounts match your filter criteria."
|
|
28103
27151
|
}
|
|
28104
|
-
}
|
|
27152
|
+
},
|
|
27153
|
+
actions: canCreate ? [
|
|
27154
|
+
{
|
|
27155
|
+
label: "Create",
|
|
27156
|
+
to: "/store-credit-accounts/create"
|
|
27157
|
+
}
|
|
27158
|
+
] : []
|
|
28105
27159
|
}
|
|
28106
27160
|
) }),
|
|
28107
27161
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
28108
27162
|
] });
|
|
28109
27163
|
}
|
|
28110
|
-
|
|
28111
|
-
|
|
28112
|
-
|
|
28113
|
-
|
|
28114
|
-
|
|
28115
|
-
|
|
28116
|
-
|
|
28117
|
-
|
|
28118
|
-
|
|
28119
|
-
|
|
27164
|
+
const StoreCreditAccountsPage = () => {
|
|
27165
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
27166
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
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, {})
|
|
28120
27177
|
] });
|
|
28121
|
-
}
|
|
28122
|
-
const StoreCreditAccountPage = () => {
|
|
28123
|
-
const { id } = reactRouterDom.useParams();
|
|
28124
|
-
const { store_credit_account: storeCreditAccount } = useStoreCreditAccount(
|
|
28125
|
-
id
|
|
28126
|
-
);
|
|
28127
|
-
if (!storeCreditAccount) {
|
|
28128
|
-
return;
|
|
28129
|
-
}
|
|
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
|
-
] })
|
|
28161
|
-
}
|
|
28162
|
-
}
|
|
28163
|
-
);
|
|
28164
27178
|
};
|
|
28165
|
-
const
|
|
27179
|
+
const config$1 = adminSdk.defineRouteConfig({
|
|
27180
|
+
label: "Store Credits",
|
|
27181
|
+
icon: StoreCreditIcon,
|
|
28166
27182
|
permissions: ["store_credit_account:read"]
|
|
28167
|
-
};
|
|
28168
|
-
|
|
28169
|
-
|
|
28170
|
-
|
|
28171
|
-
|
|
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");
|
|
27192
|
+
}
|
|
27193
|
+
isObject_1 = isObject2;
|
|
27194
|
+
return isObject_1;
|
|
27195
|
+
}
|
|
27196
|
+
var _freeGlobal;
|
|
27197
|
+
var hasRequired_freeGlobal;
|
|
27198
|
+
function require_freeGlobal() {
|
|
27199
|
+
if (hasRequired_freeGlobal) return _freeGlobal;
|
|
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();
|
|
28172
27224
|
};
|
|
28173
|
-
|
|
28174
|
-
|
|
28175
|
-
|
|
28176
|
-
|
|
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];
|
|
28177
27289
|
}
|
|
28178
|
-
|
|
28179
|
-
|
|
28180
|
-
|
|
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;
|
|
27349
|
+
}
|
|
27350
|
+
var toNumber_1;
|
|
27351
|
+
var hasRequiredToNumber;
|
|
27352
|
+
function requireToNumber() {
|
|
27353
|
+
if (hasRequiredToNumber) return toNumber_1;
|
|
27354
|
+
hasRequiredToNumber = 1;
|
|
27355
|
+
var baseTrim = require_baseTrim(), isObject2 = requireIsObject(), isSymbol = requireIsSymbol();
|
|
27356
|
+
var NAN = 0 / 0;
|
|
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;
|
|
27378
|
+
}
|
|
27379
|
+
toNumber_1 = toNumber;
|
|
27380
|
+
return toNumber_1;
|
|
27381
|
+
}
|
|
27382
|
+
var debounce_1;
|
|
27383
|
+
var hasRequiredDebounce;
|
|
27384
|
+
function requireDebounce() {
|
|
27385
|
+
if (hasRequiredDebounce) return debounce_1;
|
|
27386
|
+
hasRequiredDebounce = 1;
|
|
27387
|
+
var isObject2 = requireIsObject(), now = requireNow(), toNumber = requireToNumber();
|
|
27388
|
+
var FUNC_ERROR_TEXT = "Expected a function";
|
|
27389
|
+
var nativeMax = Math.max, nativeMin = Math.min;
|
|
27390
|
+
function debounce2(func, wait, options) {
|
|
27391
|
+
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
27392
|
+
if (typeof func != "function") {
|
|
27393
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
27394
|
+
}
|
|
27395
|
+
wait = toNumber(wait) || 0;
|
|
27396
|
+
if (isObject2(options)) {
|
|
27397
|
+
leading = !!options.leading;
|
|
27398
|
+
maxing = "maxWait" in options;
|
|
27399
|
+
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
27400
|
+
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
27401
|
+
}
|
|
27402
|
+
function invokeFunc(time2) {
|
|
27403
|
+
var args = lastArgs, thisArg = lastThis;
|
|
27404
|
+
lastArgs = lastThis = void 0;
|
|
27405
|
+
lastInvokeTime = time2;
|
|
27406
|
+
result = func.apply(thisArg, args);
|
|
27407
|
+
return result;
|
|
27408
|
+
}
|
|
27409
|
+
function leadingEdge(time2) {
|
|
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);
|
|
28181
27426
|
}
|
|
27427
|
+
timerId = setTimeout(timerExpired, remainingWait(time2));
|
|
28182
27428
|
}
|
|
28183
|
-
|
|
28184
|
-
|
|
28185
|
-
|
|
28186
|
-
|
|
28187
|
-
|
|
28188
|
-
|
|
28189
|
-
|
|
28190
|
-
ref
|
|
27429
|
+
function trailingEdge(time2) {
|
|
27430
|
+
timerId = void 0;
|
|
27431
|
+
if (trailing && lastArgs) {
|
|
27432
|
+
return invokeFunc(time2);
|
|
27433
|
+
}
|
|
27434
|
+
lastArgs = lastThis = void 0;
|
|
27435
|
+
return result;
|
|
28191
27436
|
}
|
|
28192
|
-
|
|
28193
|
-
|
|
28194
|
-
|
|
28195
|
-
|
|
28196
|
-
|
|
28197
|
-
|
|
28198
|
-
|
|
28199
|
-
|
|
28200
|
-
|
|
28201
|
-
|
|
28202
|
-
|
|
28203
|
-
|
|
28204
|
-
|
|
27437
|
+
function cancel() {
|
|
27438
|
+
if (timerId !== void 0) {
|
|
27439
|
+
clearTimeout(timerId);
|
|
27440
|
+
}
|
|
27441
|
+
lastInvokeTime = 0;
|
|
27442
|
+
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
|
27443
|
+
}
|
|
27444
|
+
function flush() {
|
|
27445
|
+
return timerId === void 0 ? result : trailingEdge(now());
|
|
27446
|
+
}
|
|
27447
|
+
function debounced() {
|
|
27448
|
+
var time2 = now(), isInvoking = shouldInvoke(time2);
|
|
27449
|
+
lastArgs = arguments;
|
|
27450
|
+
lastThis = this;
|
|
27451
|
+
lastCallTime = time2;
|
|
27452
|
+
if (isInvoking) {
|
|
27453
|
+
if (timerId === void 0) {
|
|
27454
|
+
return leadingEdge(lastCallTime);
|
|
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;
|
|
27466
|
+
}
|
|
27467
|
+
debounced.cancel = cancel;
|
|
27468
|
+
debounced.flush = flush;
|
|
27469
|
+
return debounced;
|
|
28205
27470
|
}
|
|
28206
|
-
|
|
28207
|
-
return
|
|
28208
|
-
|
|
28209
|
-
|
|
28210
|
-
|
|
28211
|
-
|
|
28212
|
-
|
|
28213
|
-
]
|
|
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
|
+
);
|
|
27483
|
+
React.useEffect(() => {
|
|
27484
|
+
debouncedUpdate(searchValue);
|
|
27485
|
+
return () => debouncedUpdate.cancel();
|
|
27486
|
+
}, [searchValue, debouncedUpdate]);
|
|
27487
|
+
return {
|
|
27488
|
+
searchValue,
|
|
27489
|
+
onSearchValueChange,
|
|
27490
|
+
query: debouncedQuery || void 0
|
|
27491
|
+
};
|
|
28214
27492
|
};
|
|
28215
|
-
const
|
|
28216
|
-
|
|
27493
|
+
const useComboboxData = ({
|
|
27494
|
+
queryKey,
|
|
27495
|
+
queryFn,
|
|
27496
|
+
getOptions,
|
|
27497
|
+
defaultValue: defaultValue2,
|
|
27498
|
+
defaultValueKey,
|
|
27499
|
+
pageSize = 10,
|
|
27500
|
+
enabled = true
|
|
28217
27501
|
}) => {
|
|
28218
|
-
const
|
|
28219
|
-
|
|
28220
|
-
|
|
28221
|
-
|
|
28222
|
-
|
|
28223
|
-
|
|
28224
|
-
|
|
27502
|
+
const { searchValue, onSearchValueChange, query } = useDebouncedSearch();
|
|
27503
|
+
const queryInitialDataBy = defaultValueKey || "id";
|
|
27504
|
+
const { data: initialData } = reactQuery.useQuery({
|
|
27505
|
+
queryKey,
|
|
27506
|
+
queryFn: async () => {
|
|
27507
|
+
return queryFn({
|
|
27508
|
+
[queryInitialDataBy]: defaultValue2,
|
|
27509
|
+
limit: Array.isArray(defaultValue2) ? defaultValue2.length : 1
|
|
27510
|
+
});
|
|
28225
27511
|
},
|
|
28226
|
-
|
|
27512
|
+
enabled: enabled && !!defaultValue2
|
|
28227
27513
|
});
|
|
28228
|
-
const {
|
|
28229
|
-
|
|
28230
|
-
|
|
28231
|
-
|
|
28232
|
-
|
|
28233
|
-
|
|
28234
|
-
|
|
28235
|
-
|
|
28236
|
-
}
|
|
28237
|
-
|
|
28238
|
-
|
|
28239
|
-
|
|
28240
|
-
|
|
28241
|
-
|
|
28242
|
-
|
|
28243
|
-
|
|
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;
|
|
27527
|
+
},
|
|
27528
|
+
placeholderData: reactQuery.keepPreviousData,
|
|
27529
|
+
enabled
|
|
28244
27530
|
});
|
|
28245
|
-
|
|
28246
|
-
|
|
28247
|
-
|
|
28248
|
-
|
|
28249
|
-
|
|
28250
|
-
|
|
28251
|
-
|
|
28252
|
-
|
|
28253
|
-
|
|
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
|
-
) });
|
|
28299
|
-
};
|
|
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
|
-
})
|
|
28306
|
-
});
|
|
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;
|
|
27531
|
+
const options = data?.pages.flatMap((page) => getOptions(page)) ?? [];
|
|
27532
|
+
const defaultOptions2 = initialData ? getOptions(initialData) : [];
|
|
27533
|
+
const disabled = !rest.isPending && !options.length && !searchValue;
|
|
27534
|
+
if (defaultValue2 && defaultOptions2.length && !searchValue) {
|
|
27535
|
+
defaultOptions2.forEach((option) => {
|
|
27536
|
+
if (!options.find((o2) => o2.value === option.value)) {
|
|
27537
|
+
options.unshift(option);
|
|
27538
|
+
}
|
|
27539
|
+
});
|
|
28320
27540
|
}
|
|
28321
|
-
|
|
28322
|
-
|
|
28323
|
-
|
|
28324
|
-
|
|
28325
|
-
|
|
28326
|
-
|
|
28327
|
-
|
|
28328
|
-
] });
|
|
27541
|
+
return {
|
|
27542
|
+
options,
|
|
27543
|
+
searchValue,
|
|
27544
|
+
onSearchValueChange,
|
|
27545
|
+
disabled,
|
|
27546
|
+
...rest
|
|
27547
|
+
};
|
|
28329
27548
|
};
|
|
28330
|
-
const
|
|
28331
|
-
|
|
28332
|
-
|
|
27549
|
+
const formSchema = zod.z.object({
|
|
27550
|
+
currency_code: zod.z.string().min(1, "Please select a currency"),
|
|
27551
|
+
customer_id: zod.z.string().optional()
|
|
27552
|
+
});
|
|
27553
|
+
const StoreCreditAccountCreateForm = () => {
|
|
27554
|
+
const { handleSuccess } = useRouteModal();
|
|
27555
|
+
const [searchParams] = reactRouterDom.useSearchParams();
|
|
27556
|
+
const prefilledCustomerId = searchParams.get("prefill_customer_id") ?? "";
|
|
27557
|
+
const { hasPermission } = hooks.usePermissions();
|
|
27558
|
+
const canReadCustomers = hasPermission("customer:read");
|
|
28333
27559
|
const form = useForm({
|
|
28334
27560
|
defaultValues: {
|
|
28335
|
-
|
|
28336
|
-
|
|
28337
|
-
value: ""
|
|
28338
|
-
},
|
|
28339
|
-
note: ""
|
|
27561
|
+
currency_code: "",
|
|
27562
|
+
customer_id: prefilledCustomerId
|
|
28340
27563
|
},
|
|
28341
|
-
resolver: u(
|
|
27564
|
+
resolver: u(formSchema)
|
|
28342
27565
|
});
|
|
28343
|
-
const { mutateAsync, isPending } =
|
|
28344
|
-
|
|
28345
|
-
|
|
28346
|
-
|
|
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;
|
|
28352
|
-
}
|
|
28353
|
-
if (data.amount.float > balance) {
|
|
28354
|
-
form.setError("amount", {
|
|
28355
|
-
message: "Amount can't be greater than the current balance"
|
|
28356
|
-
});
|
|
28357
|
-
return;
|
|
27566
|
+
const { mutateAsync: createStoreCreditAccount, isPending } = useCreateStoreCreditAccount();
|
|
27567
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
27568
|
+
if (!data.customer_id) {
|
|
27569
|
+
delete data.customer_id;
|
|
28358
27570
|
}
|
|
28359
|
-
await
|
|
28360
|
-
|
|
28361
|
-
|
|
28362
|
-
|
|
28363
|
-
|
|
27571
|
+
await createStoreCreditAccount(data, {
|
|
27572
|
+
onSuccess: (data2) => {
|
|
27573
|
+
ui.toast.success(`Store credit account was successfully created.`);
|
|
27574
|
+
handleSuccess(`../${data2.store_credit_account.id}`);
|
|
27575
|
+
},
|
|
27576
|
+
onError: (error2) => {
|
|
27577
|
+
ui.toast.error(error2.message);
|
|
28364
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;
|
|
27589
|
+
}
|
|
27590
|
+
return options.filter(
|
|
27591
|
+
(option) => option.label.toLowerCase().includes(currencySearchValue.toLowerCase())
|
|
28365
27592
|
);
|
|
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
|
+
}
|
|
28366
27618
|
});
|
|
28367
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
28368
|
-
|
|
28369
|
-
{
|
|
28370
|
-
className: "flex flex-
|
|
28371
|
-
|
|
28372
|
-
|
|
28373
|
-
|
|
28374
|
-
|
|
28375
|
-
|
|
28376
|
-
|
|
28377
|
-
|
|
28378
|
-
|
|
28379
|
-
|
|
28380
|
-
|
|
27619
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Form, { form, children: [
|
|
27620
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "-my-2 w-full border-l" }) }),
|
|
27621
|
+
/* @__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: [
|
|
27622
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
27623
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Create Store Credit Account" }),
|
|
27624
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", size: "small", children: "Create a new store credit account for a customer" })
|
|
27625
|
+
] }),
|
|
27626
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-x-4", children: [
|
|
27627
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
27628
|
+
Form$2.Field,
|
|
27629
|
+
{
|
|
27630
|
+
control: form.control,
|
|
27631
|
+
name: "currency_code",
|
|
27632
|
+
render: ({ field }) => {
|
|
27633
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
27634
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Currency" }),
|
|
28381
27635
|
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
28382
|
-
|
|
27636
|
+
Combobox2,
|
|
28383
27637
|
{
|
|
28384
|
-
|
|
28385
|
-
|
|
28386
|
-
|
|
28387
|
-
|
|
28388
|
-
|
|
28389
|
-
|
|
28390
|
-
float: values?.float || null
|
|
28391
|
-
});
|
|
28392
|
-
},
|
|
28393
|
-
symbol: currencies[storeCreditAccount.currency_code.toUpperCase()].symbol_native,
|
|
28394
|
-
code: storeCreditAccount.currency_code.toUpperCase()
|
|
27638
|
+
value: field.value,
|
|
27639
|
+
onChange: field.onChange,
|
|
27640
|
+
searchValue: currencySearchValue,
|
|
27641
|
+
onSearchValueChange: setCurrencySearchValue,
|
|
27642
|
+
options: currencyOptions,
|
|
27643
|
+
placeholder: "Search for a currency..."
|
|
28395
27644
|
}
|
|
28396
27645
|
) }),
|
|
28397
27646
|
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
28398
|
-
] })
|
|
27647
|
+
] });
|
|
28399
27648
|
}
|
|
28400
|
-
|
|
28401
|
-
|
|
28402
|
-
|
|
28403
|
-
|
|
28404
|
-
|
|
28405
|
-
|
|
28406
|
-
|
|
28407
|
-
|
|
28408
|
-
|
|
27649
|
+
}
|
|
27650
|
+
),
|
|
27651
|
+
canReadCustomers && /* @__PURE__ */ jsxRuntime.jsx(
|
|
27652
|
+
Form$2.Field,
|
|
27653
|
+
{
|
|
27654
|
+
control: form.control,
|
|
27655
|
+
name: "customer_id",
|
|
27656
|
+
render: ({ field }) => {
|
|
27657
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
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
|
+
) }),
|
|
28409
27673
|
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
28410
|
-
] })
|
|
27674
|
+
] });
|
|
28411
27675
|
}
|
|
28412
|
-
|
|
28413
|
-
|
|
28414
|
-
|
|
28415
|
-
|
|
28416
|
-
|
|
28417
|
-
|
|
28418
|
-
|
|
28419
|
-
|
|
28420
|
-
|
|
27676
|
+
}
|
|
27677
|
+
)
|
|
27678
|
+
] })
|
|
27679
|
+
] }) }) }),
|
|
27680
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Footer, { children: [
|
|
27681
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, disabled: isPending, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", disabled: isPending, children: "Cancel" }) }),
|
|
27682
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
27683
|
+
ui.Button,
|
|
27684
|
+
{
|
|
27685
|
+
variant: "primary",
|
|
27686
|
+
size: "small",
|
|
27687
|
+
onClick: handleSubmit,
|
|
27688
|
+
disabled: isPending,
|
|
27689
|
+
children: "Create"
|
|
27690
|
+
}
|
|
27691
|
+
)
|
|
27692
|
+
] })
|
|
27693
|
+
] });
|
|
28421
27694
|
};
|
|
28422
|
-
const
|
|
28423
|
-
|
|
28424
|
-
|
|
28425
|
-
|
|
28426
|
-
|
|
28427
|
-
})
|
|
28428
|
-
}
|
|
28429
|
-
const handle$
|
|
28430
|
-
permissions: ["store_credit_account:
|
|
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
|
+
] });
|
|
27701
|
+
};
|
|
27702
|
+
const handle$d = {
|
|
27703
|
+
permissions: ["store_credit_account:create"]
|
|
28431
27704
|
};
|
|
28432
27705
|
function _extends() {
|
|
28433
27706
|
return _extends = Object.assign ? Object.assign.bind() : function(n2) {
|
|
@@ -31112,6 +30385,299 @@ const GiftCardOrderSection = ({ giftCard }) => {
|
|
|
31112
30385
|
))
|
|
31113
30386
|
] });
|
|
31114
30387
|
};
|
|
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
|
+
}
|
|
31115
30681
|
const GiftCardTransactionsSection = ({
|
|
31116
30682
|
storeCreditAccount
|
|
31117
30683
|
}) => {
|
|
@@ -31163,9 +30729,36 @@ const GiftCardDetailsPage = () => {
|
|
|
31163
30729
|
}
|
|
31164
30730
|
);
|
|
31165
30731
|
};
|
|
31166
|
-
const handle$
|
|
30732
|
+
const handle$c = {
|
|
31167
30733
|
permissions: ["gift_card:read"]
|
|
31168
30734
|
};
|
|
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";
|
|
31169
30762
|
const GiftCardExpiration = () => {
|
|
31170
30763
|
const { id } = reactRouterDom.useParams();
|
|
31171
30764
|
const { gift_card: giftCard, isPending, isError, error: error2 } = useGiftCard(id);
|
|
@@ -31186,7 +30779,7 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
31186
30779
|
defaultValues: {
|
|
31187
30780
|
expires_at: giftCard.expires_at ? new Date(giftCard.expires_at) : null
|
|
31188
30781
|
},
|
|
31189
|
-
resolver: u(schema$
|
|
30782
|
+
resolver: u(schema$3)
|
|
31190
30783
|
});
|
|
31191
30784
|
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
31192
30785
|
const { handleSuccess } = useRouteModal();
|
|
@@ -31281,13 +30874,13 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
31281
30874
|
}
|
|
31282
30875
|
) });
|
|
31283
30876
|
};
|
|
31284
|
-
const schema$
|
|
30877
|
+
const schema$3 = zod.z.object({
|
|
31285
30878
|
expires_at: zod.z.date().nullish()
|
|
31286
30879
|
});
|
|
31287
|
-
const handle$
|
|
30880
|
+
const handle$b = {
|
|
31288
30881
|
permissions: ["gift_card:read", "gift_card:update"]
|
|
31289
30882
|
};
|
|
31290
|
-
const Note = () => {
|
|
30883
|
+
const Note$1 = () => {
|
|
31291
30884
|
const { id } = reactRouterDom.useParams();
|
|
31292
30885
|
const {
|
|
31293
30886
|
gift_card: giftCard,
|
|
@@ -31312,7 +30905,7 @@ const GiftCardNoteForm = ({ giftCard }) => {
|
|
|
31312
30905
|
defaultValues: {
|
|
31313
30906
|
note: giftCard.note ?? ""
|
|
31314
30907
|
},
|
|
31315
|
-
resolver: u(schema)
|
|
30908
|
+
resolver: u(schema$2)
|
|
31316
30909
|
});
|
|
31317
30910
|
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
31318
30911
|
const { handleSuccess } = useRouteModal();
|
|
@@ -31351,10 +30944,10 @@ const GiftCardNoteForm = ({ giftCard }) => {
|
|
|
31351
30944
|
}
|
|
31352
30945
|
) });
|
|
31353
30946
|
};
|
|
31354
|
-
const schema = zod.z.object({
|
|
30947
|
+
const schema$2 = zod.z.object({
|
|
31355
30948
|
note: zod.z.string().optional()
|
|
31356
30949
|
});
|
|
31357
|
-
const handle$
|
|
30950
|
+
const handle$a = {
|
|
31358
30951
|
permissions: ["gift_card:read", "gift_card:update"]
|
|
31359
30952
|
};
|
|
31360
30953
|
const columnHelper$7 = createColumnHelper();
|
|
@@ -45848,7 +45441,7 @@ const GiftCardProductCreate = () => {
|
|
|
45848
45441
|
isPending: isStorePending,
|
|
45849
45442
|
isError: isStoreError,
|
|
45850
45443
|
error: storeError
|
|
45851
|
-
} = useStore$
|
|
45444
|
+
} = useStore$2({
|
|
45852
45445
|
fields: "+default_sales_channel"
|
|
45853
45446
|
});
|
|
45854
45447
|
const {
|
|
@@ -45900,7 +45493,7 @@ const GiftCardProductCreate = () => {
|
|
|
45900
45493
|
)
|
|
45901
45494
|
] });
|
|
45902
45495
|
};
|
|
45903
|
-
const handle$
|
|
45496
|
+
const handle$9 = {
|
|
45904
45497
|
permissions: [
|
|
45905
45498
|
"product:create",
|
|
45906
45499
|
"store:read",
|
|
@@ -45909,6 +45502,413 @@ const handle$6 = {
|
|
|
45909
45502
|
"price_preference:read"
|
|
45910
45503
|
]
|
|
45911
45504
|
};
|
|
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$2();
|
|
47410
47410
|
const { regions } = useRegions(
|
|
47411
47411
|
{ limit: 9999 },
|
|
47412
47412
|
{ enabled: hasPermission("region:read") }
|
|
@@ -47697,61 +47697,44 @@ 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
|
-
},
|
|
47712
47700
|
{
|
|
47713
47701
|
Component: GiftCardsPage,
|
|
47714
47702
|
path: "/gift-cards",
|
|
47715
|
-
handle: { label: config$
|
|
47703
|
+
handle: { label: config$3.label, translationNs: config$3.translationNs, permissions: config$3.permissions },
|
|
47716
47704
|
children: [
|
|
47717
47705
|
{
|
|
47718
47706
|
Component: GiftCardCreate,
|
|
47719
47707
|
path: "/gift-cards/create",
|
|
47720
|
-
handle: handle$
|
|
47708
|
+
handle: handle$e
|
|
47721
47709
|
}
|
|
47722
47710
|
]
|
|
47723
47711
|
},
|
|
47724
47712
|
{
|
|
47725
|
-
Component:
|
|
47726
|
-
path: "/store-credit-accounts
|
|
47727
|
-
handle:
|
|
47713
|
+
Component: StoreCreditAccountsPage,
|
|
47714
|
+
path: "/store-credit-accounts",
|
|
47715
|
+
handle: { label: config$1.label, translationNs: config$1.translationNs, permissions: config$1.permissions },
|
|
47728
47716
|
children: [
|
|
47729
47717
|
{
|
|
47730
|
-
Component:
|
|
47731
|
-
path: "/store-credit-accounts
|
|
47732
|
-
handle: handle$
|
|
47733
|
-
},
|
|
47734
|
-
{
|
|
47735
|
-
Component: Debit,
|
|
47736
|
-
path: "/store-credit-accounts/:id/debit",
|
|
47737
|
-
handle: handle$a
|
|
47718
|
+
Component: StoreCreditAccountCreate,
|
|
47719
|
+
path: "/store-credit-accounts/create",
|
|
47720
|
+
handle: handle$d
|
|
47738
47721
|
}
|
|
47739
47722
|
]
|
|
47740
47723
|
},
|
|
47741
47724
|
{
|
|
47742
47725
|
Component: GiftCardDetailsPage,
|
|
47743
47726
|
path: "/gift-cards/:id",
|
|
47744
|
-
handle: handle$
|
|
47727
|
+
handle: handle$c,
|
|
47745
47728
|
children: [
|
|
47746
47729
|
{
|
|
47747
47730
|
Component: GiftCardExpiration,
|
|
47748
47731
|
path: "/gift-cards/:id/expiration",
|
|
47749
|
-
handle: handle$
|
|
47732
|
+
handle: handle$b
|
|
47750
47733
|
},
|
|
47751
47734
|
{
|
|
47752
|
-
Component: Note,
|
|
47735
|
+
Component: Note$1,
|
|
47753
47736
|
path: "/gift-cards/:id/note",
|
|
47754
|
-
handle: handle$
|
|
47737
|
+
handle: handle$a
|
|
47755
47738
|
}
|
|
47756
47739
|
]
|
|
47757
47740
|
},
|
|
@@ -47763,6 +47746,23 @@ const routeModule = {
|
|
|
47763
47746
|
{
|
|
47764
47747
|
Component: GiftCardProductCreate,
|
|
47765
47748
|
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$3.label,
|
|
47808
|
+
icon: config$3.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$3.permissions
|
|
47814
47814
|
},
|
|
47815
47815
|
{
|
|
47816
|
-
label: config$
|
|
47817
|
-
icon: config$
|
|
47816
|
+
label: config$1.label,
|
|
47817
|
+
icon: config$1.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$1.permissions
|
|
47823
47823
|
},
|
|
47824
47824
|
{
|
|
47825
47825
|
label: config.label,
|