@medusajs/loyalty-plugin 2.15.1 → 2.15.2-preview-20260512154805
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 +1614 -1614
- package/.medusa/server/src/admin/index.mjs +1616 -1616
- package/package.json +15 -15
|
@@ -10,8 +10,8 @@ const React = require("react");
|
|
|
10
10
|
const icons = require("@medusajs/icons");
|
|
11
11
|
const reactQuery = require("@tanstack/react-query");
|
|
12
12
|
const Medusa = require("@medusajs/js-sdk");
|
|
13
|
-
const zod = require("@medusajs/framework/zod");
|
|
14
13
|
const ReactDOM = require("react-dom");
|
|
14
|
+
const zod = require("@medusajs/framework/zod");
|
|
15
15
|
const _interopDefault = (e2) => e2 && e2.__esModule ? e2 : { default: e2 };
|
|
16
16
|
function _interopNamespace(e2) {
|
|
17
17
|
if (e2 && e2.__esModule) return e2;
|
|
@@ -5756,7 +5756,7 @@ const SalesChannelGiftCardsWidget = () => {
|
|
|
5756
5756
|
adminSdk.defineWidgetConfig({
|
|
5757
5757
|
zone: "sales_channel.details.after"
|
|
5758
5758
|
});
|
|
5759
|
-
const
|
|
5759
|
+
const GiftCardIcon = (props) => {
|
|
5760
5760
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5761
5761
|
"svg",
|
|
5762
5762
|
{
|
|
@@ -5767,49 +5767,206 @@ const StoreCreditIcon = (props) => {
|
|
|
5767
5767
|
xmlns: "http://www.w3.org/2000/svg",
|
|
5768
5768
|
...props,
|
|
5769
5769
|
children: [
|
|
5770
|
-
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#
|
|
5770
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#F97316" }),
|
|
5771
5771
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5772
5772
|
"rect",
|
|
5773
5773
|
{
|
|
5774
5774
|
width: "15",
|
|
5775
5775
|
height: "15",
|
|
5776
|
-
fill: "url(#
|
|
5776
|
+
fill: "url(#paint0_linear_28788_25808)",
|
|
5777
5777
|
fillOpacity: "0.2"
|
|
5778
5778
|
}
|
|
5779
5779
|
),
|
|
5780
|
-
/* @__PURE__ */ jsxRuntime.
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5780
|
+
/* @__PURE__ */ jsxRuntime.jsxs("g", { clipPath: "url(#clip0_28788_25808)", children: [
|
|
5781
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5782
|
+
"path",
|
|
5783
|
+
{
|
|
5784
|
+
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",
|
|
5785
|
+
fill: "white"
|
|
5786
|
+
}
|
|
5787
|
+
),
|
|
5788
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5789
|
+
"path",
|
|
5790
|
+
{
|
|
5791
|
+
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",
|
|
5792
|
+
fill: "white"
|
|
5793
|
+
}
|
|
5794
|
+
),
|
|
5795
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5796
|
+
"path",
|
|
5797
|
+
{
|
|
5798
|
+
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",
|
|
5799
|
+
fill: "white"
|
|
5800
|
+
}
|
|
5801
|
+
),
|
|
5802
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5803
|
+
"path",
|
|
5804
|
+
{
|
|
5805
|
+
d: "M6.938 7.5H3.75V9.563C3.75 10.7 4.675 11.625 5.813 11.625H6.938V7.5Z",
|
|
5806
|
+
fill: "white"
|
|
5807
|
+
}
|
|
5808
|
+
),
|
|
5809
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5810
|
+
"path",
|
|
5811
|
+
{
|
|
5812
|
+
d: "M8.063 7.5V11.625H9.188C10.325 11.625 11.25 10.7 11.25 9.563V7.5H8.063Z",
|
|
5813
|
+
fill: "white"
|
|
5814
|
+
}
|
|
5815
|
+
)
|
|
5816
|
+
] }),
|
|
5817
|
+
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
5818
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5819
|
+
"linearGradient",
|
|
5820
|
+
{
|
|
5821
|
+
id: "paint0_linear_28788_25808",
|
|
5822
|
+
x1: "7.5",
|
|
5823
|
+
y1: "0",
|
|
5824
|
+
x2: "7.5",
|
|
5825
|
+
y2: "15",
|
|
5826
|
+
gradientUnits: "userSpaceOnUse",
|
|
5827
|
+
children: [
|
|
5828
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "white" }),
|
|
5829
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
|
|
5830
|
+
]
|
|
5831
|
+
}
|
|
5832
|
+
),
|
|
5833
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_28788_25808", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "9", height: "9", fill: "white", transform: "translate(3 3)" }) })
|
|
5834
|
+
] })
|
|
5809
5835
|
]
|
|
5810
5836
|
}
|
|
5811
5837
|
);
|
|
5812
5838
|
};
|
|
5839
|
+
const TwoColumnLayout = ({
|
|
5840
|
+
firstCol,
|
|
5841
|
+
secondCol
|
|
5842
|
+
}) => {
|
|
5843
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-x-4 gap-y-3 xl:flex-row xl:items-start", children: [
|
|
5844
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full flex-col gap-y-3", children: firstCol }),
|
|
5845
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full max-w-[100%] flex-col gap-y-3 xl:mt-0 xl:max-w-[440px]", children: secondCol })
|
|
5846
|
+
] });
|
|
5847
|
+
};
|
|
5848
|
+
const GiftCardProductsSection = () => {
|
|
5849
|
+
const { products: giftCardProducts, count: count2 = 0 } = useProducts({
|
|
5850
|
+
is_giftcard: true
|
|
5851
|
+
});
|
|
5852
|
+
const slicedProducts = (giftCardProducts == null ? void 0 : giftCardProducts.slice(0, 3)) ?? [];
|
|
5853
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
5854
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
5855
|
+
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Gift Card Products" }),
|
|
5856
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5857
|
+
reactRouterDom.Link,
|
|
5858
|
+
{
|
|
5859
|
+
to: `/gift-cards/gift-card-products/create`,
|
|
5860
|
+
className: "text-ui-fg-muted text-sm px-6",
|
|
5861
|
+
children: "Create"
|
|
5862
|
+
}
|
|
5863
|
+
)
|
|
5864
|
+
] }),
|
|
5865
|
+
(giftCardProducts == null ? void 0 : giftCardProducts.length) === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5866
|
+
NoRecords,
|
|
5867
|
+
{
|
|
5868
|
+
className: "px-10 py-4 h-[200px]",
|
|
5869
|
+
title: "No gift card products",
|
|
5870
|
+
message: "There are no gift card products to show. Create one to get started.",
|
|
5871
|
+
action: {
|
|
5872
|
+
to: "/gift-cards/gift-card-products/create",
|
|
5873
|
+
label: "Create gift card product"
|
|
5874
|
+
}
|
|
5875
|
+
}
|
|
5876
|
+
),
|
|
5877
|
+
slicedProducts.map((giftCardProduct) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5878
|
+
SidebarLink,
|
|
5879
|
+
{
|
|
5880
|
+
to: `/gift-cards/gift-card-products/${giftCardProduct.id}`,
|
|
5881
|
+
labelKey: giftCardProduct.title,
|
|
5882
|
+
descriptionKey: giftCardProduct.title,
|
|
5883
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Tag, {})
|
|
5884
|
+
}
|
|
5885
|
+
)),
|
|
5886
|
+
count2 > 3 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5887
|
+
reactRouterDom.Link,
|
|
5888
|
+
{
|
|
5889
|
+
to: "/gift-cards/gift-card-products",
|
|
5890
|
+
className: "text-ui-fg-muted text-sm px-6 py-4 flex items-center justify-center",
|
|
5891
|
+
children: "View more"
|
|
5892
|
+
}
|
|
5893
|
+
)
|
|
5894
|
+
] });
|
|
5895
|
+
};
|
|
5896
|
+
const _giftCardQueryKey = queryKeysFactory("gift-card");
|
|
5897
|
+
const giftCardQueryKey = {
|
|
5898
|
+
..._giftCardQueryKey,
|
|
5899
|
+
orders: (id) => [..._giftCardQueryKey.detail(id), "orders"]
|
|
5900
|
+
};
|
|
5901
|
+
const useGiftCards = (query, options) => {
|
|
5902
|
+
const fetchGiftCards = (query2, headers) => sdk.client.fetch(`/admin/gift-cards`, {
|
|
5903
|
+
query: query2,
|
|
5904
|
+
headers
|
|
5905
|
+
});
|
|
5906
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
5907
|
+
...options,
|
|
5908
|
+
queryFn: () => fetchGiftCards(query),
|
|
5909
|
+
queryKey: giftCardQueryKey.list(query)
|
|
5910
|
+
});
|
|
5911
|
+
return { ...data, ...rest };
|
|
5912
|
+
};
|
|
5913
|
+
const useGiftCard = (id, query, options) => {
|
|
5914
|
+
const fetchGiftCard = (id2, query2, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
|
|
5915
|
+
query: query2,
|
|
5916
|
+
headers
|
|
5917
|
+
});
|
|
5918
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
5919
|
+
queryFn: () => fetchGiftCard(id, query),
|
|
5920
|
+
queryKey: giftCardQueryKey.detail(id, query),
|
|
5921
|
+
...options
|
|
5922
|
+
});
|
|
5923
|
+
return { ...data, ...rest };
|
|
5924
|
+
};
|
|
5925
|
+
const useGiftCardOrders = (id, options) => {
|
|
5926
|
+
const fetchGiftCardOrders = (id2, query, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}/orders`, {
|
|
5927
|
+
query,
|
|
5928
|
+
headers
|
|
5929
|
+
});
|
|
5930
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
5931
|
+
queryFn: () => fetchGiftCardOrders(id),
|
|
5932
|
+
queryKey: giftCardQueryKey.orders(id),
|
|
5933
|
+
...options
|
|
5934
|
+
});
|
|
5935
|
+
return { ...data, ...rest };
|
|
5936
|
+
};
|
|
5937
|
+
const useUpdateGiftCard = (id, options) => {
|
|
5938
|
+
const queryClient = reactQuery.useQueryClient();
|
|
5939
|
+
const updateGiftCard = async (id2, body) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
|
|
5940
|
+
body,
|
|
5941
|
+
method: "POST"
|
|
5942
|
+
});
|
|
5943
|
+
return reactQuery.useMutation({
|
|
5944
|
+
mutationFn: async (payload) => updateGiftCard(id, payload),
|
|
5945
|
+
onSuccess: (data, variables, context) => {
|
|
5946
|
+
queryClient.invalidateQueries({
|
|
5947
|
+
queryKey: giftCardQueryKey.detail(id)
|
|
5948
|
+
});
|
|
5949
|
+
queryClient.invalidateQueries({
|
|
5950
|
+
queryKey: giftCardQueryKey.lists()
|
|
5951
|
+
});
|
|
5952
|
+
},
|
|
5953
|
+
...options
|
|
5954
|
+
});
|
|
5955
|
+
};
|
|
5956
|
+
const useCreateGiftCard = (options) => {
|
|
5957
|
+
const queryClient = reactQuery.useQueryClient();
|
|
5958
|
+
const createGiftCard = async (body) => sdk.client.fetch(`/admin/gift-cards`, {
|
|
5959
|
+
body,
|
|
5960
|
+
method: "POST"
|
|
5961
|
+
});
|
|
5962
|
+
return reactQuery.useMutation({
|
|
5963
|
+
mutationFn: (body) => createGiftCard(body),
|
|
5964
|
+
onSuccess: (data, variables, context) => {
|
|
5965
|
+
queryClient.invalidateQueries({ queryKey: giftCardQueryKey.lists() });
|
|
5966
|
+
},
|
|
5967
|
+
...options
|
|
5968
|
+
});
|
|
5969
|
+
};
|
|
5813
5970
|
function getRelativeDate(date2) {
|
|
5814
5971
|
const now2 = /* @__PURE__ */ new Date();
|
|
5815
5972
|
return formatDistance(sub(new Date(date2), { minutes: 0 }), now2, {
|
|
@@ -5827,52 +5984,31 @@ function formatDate(date2, withTime = true) {
|
|
|
5827
5984
|
return format$1(new Date(date2), "dd MMM, yyyy");
|
|
5828
5985
|
}
|
|
5829
5986
|
const columnHelper$a = ui.createDataTableColumnHelper();
|
|
5830
|
-
const
|
|
5987
|
+
const useGiftCardTableColumns = () => {
|
|
5831
5988
|
return React.useMemo(() => {
|
|
5832
5989
|
return [
|
|
5833
|
-
columnHelper$a.accessor("
|
|
5834
|
-
header: "
|
|
5835
|
-
cell: ({ row }) => {
|
|
5836
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { size: "2xsmall", children: row.original.currency_code.toUpperCase() });
|
|
5837
|
-
}
|
|
5838
|
-
}),
|
|
5839
|
-
columnHelper$a.accessor("customer.email", {
|
|
5840
|
-
header: "Customer",
|
|
5990
|
+
columnHelper$a.accessor("code", {
|
|
5991
|
+
header: "Code",
|
|
5841
5992
|
cell: ({ row }) => {
|
|
5842
|
-
|
|
5843
|
-
return ((_a2 = row.original.customer) == null ? void 0 : _a2.email) ?? "N/A";
|
|
5993
|
+
return row.original.code;
|
|
5844
5994
|
}
|
|
5845
5995
|
}),
|
|
5846
|
-
columnHelper$a.accessor("
|
|
5847
|
-
header: "
|
|
5996
|
+
columnHelper$a.accessor("line_item.product.title", {
|
|
5997
|
+
header: "Product",
|
|
5848
5998
|
cell: ({ row }) => {
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
row.original.currency_code
|
|
5852
|
-
);
|
|
5999
|
+
var _a2, _b;
|
|
6000
|
+
return ((_b = (_a2 = row.original.line_item) == null ? void 0 : _a2.product) == null ? void 0 : _b.title) || "Custom Gift Card";
|
|
5853
6001
|
}
|
|
5854
6002
|
}),
|
|
5855
|
-
columnHelper$a.accessor("
|
|
5856
|
-
header: "
|
|
5857
|
-
cell: ({ row }) =>
|
|
5858
|
-
return formatAmount(
|
|
5859
|
-
row.original.credits,
|
|
5860
|
-
row.original.currency_code
|
|
5861
|
-
);
|
|
5862
|
-
}
|
|
6003
|
+
columnHelper$a.accessor("created_at", {
|
|
6004
|
+
header: "Date issued",
|
|
6005
|
+
cell: ({ row }) => getRelativeDate(row.original.created_at)
|
|
5863
6006
|
}),
|
|
5864
|
-
columnHelper$a.accessor("
|
|
5865
|
-
header: "
|
|
6007
|
+
columnHelper$a.accessor("value", {
|
|
6008
|
+
header: "Value",
|
|
5866
6009
|
cell: ({ row }) => {
|
|
5867
|
-
return formatAmount(
|
|
5868
|
-
row.original.debits,
|
|
5869
|
-
row.original.currency_code
|
|
5870
|
-
);
|
|
6010
|
+
return formatAmount(row.original.value, row.original.currency_code);
|
|
5871
6011
|
}
|
|
5872
|
-
}),
|
|
5873
|
-
columnHelper$a.accessor("created_at", {
|
|
5874
|
-
header: "Created at",
|
|
5875
|
-
cell: ({ row }) => getRelativeDate(row.original.created_at)
|
|
5876
6012
|
})
|
|
5877
6013
|
];
|
|
5878
6014
|
}, []);
|
|
@@ -5919,83 +6055,75 @@ const useCustomerFilters = () => {
|
|
|
5919
6055
|
];
|
|
5920
6056
|
}, [customerFilterOptions]);
|
|
5921
6057
|
};
|
|
5922
|
-
const
|
|
6058
|
+
const useGiftCardFilters = () => {
|
|
5923
6059
|
const dateFilterOptions = useDataTableDateFilters$1();
|
|
5924
6060
|
const customerFilterOptions = useCustomerFilters();
|
|
5925
6061
|
return React.useMemo(() => {
|
|
5926
6062
|
return [...dateFilterOptions, ...customerFilterOptions];
|
|
5927
6063
|
}, [dateFilterOptions, customerFilterOptions]);
|
|
5928
6064
|
};
|
|
5929
|
-
const
|
|
6065
|
+
const useGiftCardTableQuery = ({
|
|
5930
6066
|
prefix,
|
|
5931
6067
|
pageSize = 20
|
|
5932
6068
|
}) => {
|
|
5933
6069
|
const queryObject = useQueryParams(
|
|
5934
|
-
["
|
|
6070
|
+
["q", "offset", "customer_id", "created_at", "updated_at"],
|
|
5935
6071
|
prefix
|
|
5936
6072
|
);
|
|
5937
|
-
const {
|
|
5938
|
-
offset: offset2,
|
|
5939
|
-
created_at,
|
|
5940
|
-
updated_at,
|
|
5941
|
-
customer_id,
|
|
5942
|
-
currency_code,
|
|
5943
|
-
...rest
|
|
5944
|
-
} = queryObject;
|
|
6073
|
+
const { offset: offset2, created_at, updated_at, customer_id, ...rest } = queryObject;
|
|
5945
6074
|
const searchParams = {
|
|
5946
6075
|
limit: pageSize,
|
|
5947
6076
|
offset: offset2 ? Number(offset2) : 0,
|
|
5948
6077
|
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
5949
6078
|
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
5950
6079
|
customer_id: customer_id ? JSON.parse(customer_id) : void 0,
|
|
5951
|
-
currency_code: currency_code ? JSON.parse(currency_code) : void 0,
|
|
5952
6080
|
...rest
|
|
5953
6081
|
};
|
|
5954
6082
|
return searchParams;
|
|
5955
6083
|
};
|
|
5956
6084
|
const PAGE_SIZE$6 = 10;
|
|
5957
|
-
function
|
|
5958
|
-
const queryParams =
|
|
6085
|
+
function GiftCardsTable() {
|
|
6086
|
+
const queryParams = useGiftCardTableQuery({
|
|
5959
6087
|
pageSize: PAGE_SIZE$6
|
|
5960
6088
|
});
|
|
5961
6089
|
const {
|
|
5962
|
-
|
|
6090
|
+
gift_cards: giftCards,
|
|
5963
6091
|
isPending,
|
|
5964
6092
|
count: count2
|
|
5965
|
-
} =
|
|
6093
|
+
} = useGiftCards({
|
|
5966
6094
|
...queryParams,
|
|
5967
|
-
order: queryParams.order ?? "-created_at"
|
|
6095
|
+
order: queryParams.order ?? "-created_at",
|
|
6096
|
+
fields: "+line_item.product.title"
|
|
5968
6097
|
});
|
|
5969
|
-
const columns =
|
|
5970
|
-
const filters =
|
|
6098
|
+
const columns = useGiftCardTableColumns();
|
|
6099
|
+
const filters = useGiftCardFilters();
|
|
5971
6100
|
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
5972
6101
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5973
6102
|
DataTable,
|
|
5974
6103
|
{
|
|
5975
|
-
data:
|
|
6104
|
+
data: giftCards,
|
|
5976
6105
|
getRowId: (row) => row.id,
|
|
5977
6106
|
columns,
|
|
5978
6107
|
filters,
|
|
5979
6108
|
isLoading: isPending,
|
|
5980
6109
|
pageSize: PAGE_SIZE$6,
|
|
5981
6110
|
rowCount: count2,
|
|
5982
|
-
|
|
5983
|
-
heading: "Store Credit Accounts",
|
|
6111
|
+
heading: "Gift Cards",
|
|
5984
6112
|
rowHref: (row) => `${row.id}`,
|
|
5985
6113
|
emptyState: {
|
|
5986
6114
|
empty: {
|
|
5987
|
-
heading: "No
|
|
5988
|
-
description: "Create a
|
|
6115
|
+
heading: "No gift cards found",
|
|
6116
|
+
description: "Create a gift card to get started."
|
|
5989
6117
|
},
|
|
5990
6118
|
filtered: {
|
|
5991
6119
|
heading: "No results found",
|
|
5992
|
-
description: "No
|
|
6120
|
+
description: "No gift cards match your filter criteria."
|
|
5993
6121
|
}
|
|
5994
6122
|
},
|
|
5995
6123
|
actions: [
|
|
5996
6124
|
{
|
|
5997
6125
|
label: "Create",
|
|
5998
|
-
to: "
|
|
6126
|
+
to: "create"
|
|
5999
6127
|
}
|
|
6000
6128
|
]
|
|
6001
6129
|
}
|
|
@@ -6003,15 +6131,21 @@ function StoreCreditAccountsTable() {
|
|
|
6003
6131
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
6004
6132
|
] });
|
|
6005
6133
|
}
|
|
6006
|
-
const
|
|
6134
|
+
const GiftCardsPage = () => {
|
|
6007
6135
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6008
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6136
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6137
|
+
TwoColumnLayout,
|
|
6138
|
+
{
|
|
6139
|
+
firstCol: /* @__PURE__ */ jsxRuntime.jsx(GiftCardsTable, {}),
|
|
6140
|
+
secondCol: /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductsSection, {})
|
|
6141
|
+
}
|
|
6142
|
+
),
|
|
6009
6143
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Toaster, {})
|
|
6010
6144
|
] });
|
|
6011
6145
|
};
|
|
6012
6146
|
const config$3 = adminSdk.defineRouteConfig({
|
|
6013
|
-
label: "
|
|
6014
|
-
icon:
|
|
6147
|
+
label: "Gift Cards",
|
|
6148
|
+
icon: GiftCardIcon
|
|
6015
6149
|
});
|
|
6016
6150
|
function setRef$2(ref, value) {
|
|
6017
6151
|
if (typeof ref === "function") {
|
|
@@ -9930,6 +10064,28 @@ const StackedFocusModal = Object.assign(Root, {
|
|
|
9930
10064
|
Description,
|
|
9931
10065
|
Title
|
|
9932
10066
|
});
|
|
10067
|
+
const STORE_QUERY_KEY = "store";
|
|
10068
|
+
const storeQueryKeys = queryKeysFactory(STORE_QUERY_KEY);
|
|
10069
|
+
async function retrieveActiveStore(query) {
|
|
10070
|
+
var _a2;
|
|
10071
|
+
const response = await sdk.admin.store.list(query);
|
|
10072
|
+
const activeStore = (_a2 = response.stores) == null ? void 0 : _a2[0];
|
|
10073
|
+
if (!activeStore) {
|
|
10074
|
+
throw new Medusa.FetchError("No active store found", "Not Found", 404);
|
|
10075
|
+
}
|
|
10076
|
+
return { store: activeStore };
|
|
10077
|
+
}
|
|
10078
|
+
const useStore$2 = (query, options) => {
|
|
10079
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
10080
|
+
queryFn: () => retrieveActiveStore(query),
|
|
10081
|
+
queryKey: storeQueryKeys.details(),
|
|
10082
|
+
...options
|
|
10083
|
+
});
|
|
10084
|
+
return {
|
|
10085
|
+
...data,
|
|
10086
|
+
...rest
|
|
10087
|
+
};
|
|
10088
|
+
};
|
|
9933
10089
|
var t$1 = function(t2, n2, e2) {
|
|
9934
10090
|
if (t2 && "reportValidity" in t2) {
|
|
9935
10091
|
var i2 = get$3(e2, n2);
|
|
@@ -11803,7 +11959,7 @@ function useStoreProps(store, props, key2, setKey) {
|
|
|
11803
11959
|
});
|
|
11804
11960
|
});
|
|
11805
11961
|
}
|
|
11806
|
-
function useStore$
|
|
11962
|
+
function useStore$1(createStore2, props) {
|
|
11807
11963
|
const [store, setStore] = React__namespace.useState(() => createStore2(props));
|
|
11808
11964
|
useSafeLayoutEffect(() => init(store), [store]);
|
|
11809
11965
|
const useState2 = React__namespace.useCallback(
|
|
@@ -12625,7 +12781,7 @@ function useDisclosureStoreProps(store, update, props) {
|
|
|
12625
12781
|
return Object.assign(store, { disclosure: props.disclosure });
|
|
12626
12782
|
}
|
|
12627
12783
|
function useDisclosureStore(props = {}) {
|
|
12628
|
-
const [store, update] = useStore$
|
|
12784
|
+
const [store, update] = useStore$1(createDisclosureStore, props);
|
|
12629
12785
|
return useDisclosureStoreProps(store, update, props);
|
|
12630
12786
|
}
|
|
12631
12787
|
var ctx$2 = createStoreContext(
|
|
@@ -14014,7 +14170,7 @@ function useDialogStoreProps(store, update, props) {
|
|
|
14014
14170
|
return useDisclosureStoreProps(store, update, props);
|
|
14015
14171
|
}
|
|
14016
14172
|
function useDialogStore(props = {}) {
|
|
14017
|
-
const [store, update] = useStore$
|
|
14173
|
+
const [store, update] = useStore$1(createDialogStore, props);
|
|
14018
14174
|
return useDialogStoreProps(store, update, props);
|
|
14019
14175
|
}
|
|
14020
14176
|
var TagName$e = "div";
|
|
@@ -16060,7 +16216,7 @@ function useComboboxStoreProps(store, update, props) {
|
|
|
16060
16216
|
}
|
|
16061
16217
|
function useComboboxStore(props = {}) {
|
|
16062
16218
|
props = useComboboxStoreOptions(props);
|
|
16063
|
-
const [store, update] = useStore$
|
|
16219
|
+
const [store, update] = useStore$1(createComboboxStore, props);
|
|
16064
16220
|
return useComboboxStoreProps(store, update, props);
|
|
16065
16221
|
}
|
|
16066
16222
|
function ComboboxProvider(props = {}) {
|
|
@@ -17166,270 +17322,6 @@ const ComboboxImpl = ({
|
|
|
17166
17322
|
);
|
|
17167
17323
|
};
|
|
17168
17324
|
const Combobox = genericForwardRef(ComboboxImpl);
|
|
17169
|
-
function isObject$6(value) {
|
|
17170
|
-
var type = typeof value;
|
|
17171
|
-
return value != null && (type == "object" || type == "function");
|
|
17172
|
-
}
|
|
17173
|
-
var isObject_1 = isObject$6;
|
|
17174
|
-
var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
17175
|
-
var _freeGlobal = freeGlobal$1;
|
|
17176
|
-
var freeGlobal = _freeGlobal;
|
|
17177
|
-
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
17178
|
-
var root$4 = freeGlobal || freeSelf || Function("return this")();
|
|
17179
|
-
var _root = root$4;
|
|
17180
|
-
var root$3 = _root;
|
|
17181
|
-
var now$1 = function() {
|
|
17182
|
-
return root$3.Date.now();
|
|
17183
|
-
};
|
|
17184
|
-
var now_1 = now$1;
|
|
17185
|
-
var reWhitespace = /\s/;
|
|
17186
|
-
function trimmedEndIndex$1(string2) {
|
|
17187
|
-
var index = string2.length;
|
|
17188
|
-
while (index-- && reWhitespace.test(string2.charAt(index))) {
|
|
17189
|
-
}
|
|
17190
|
-
return index;
|
|
17191
|
-
}
|
|
17192
|
-
var _trimmedEndIndex = trimmedEndIndex$1;
|
|
17193
|
-
var trimmedEndIndex = _trimmedEndIndex;
|
|
17194
|
-
var reTrimStart = /^\s+/;
|
|
17195
|
-
function baseTrim$1(string2) {
|
|
17196
|
-
return string2 ? string2.slice(0, trimmedEndIndex(string2) + 1).replace(reTrimStart, "") : string2;
|
|
17197
|
-
}
|
|
17198
|
-
var _baseTrim = baseTrim$1;
|
|
17199
|
-
var root$2 = _root;
|
|
17200
|
-
var Symbol$4 = root$2.Symbol;
|
|
17201
|
-
var _Symbol = Symbol$4;
|
|
17202
|
-
var Symbol$3 = _Symbol;
|
|
17203
|
-
var objectProto$5 = Object.prototype;
|
|
17204
|
-
var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
|
|
17205
|
-
var nativeObjectToString$1 = objectProto$5.toString;
|
|
17206
|
-
var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
|
|
17207
|
-
function getRawTag$1(value) {
|
|
17208
|
-
var isOwn = hasOwnProperty$4.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
17209
|
-
try {
|
|
17210
|
-
value[symToStringTag$1] = void 0;
|
|
17211
|
-
var unmasked = true;
|
|
17212
|
-
} catch (e2) {
|
|
17213
|
-
}
|
|
17214
|
-
var result = nativeObjectToString$1.call(value);
|
|
17215
|
-
if (unmasked) {
|
|
17216
|
-
if (isOwn) {
|
|
17217
|
-
value[symToStringTag$1] = tag;
|
|
17218
|
-
} else {
|
|
17219
|
-
delete value[symToStringTag$1];
|
|
17220
|
-
}
|
|
17221
|
-
}
|
|
17222
|
-
return result;
|
|
17223
|
-
}
|
|
17224
|
-
var _getRawTag = getRawTag$1;
|
|
17225
|
-
var objectProto$4 = Object.prototype;
|
|
17226
|
-
var nativeObjectToString = objectProto$4.toString;
|
|
17227
|
-
function objectToString$1(value) {
|
|
17228
|
-
return nativeObjectToString.call(value);
|
|
17229
|
-
}
|
|
17230
|
-
var _objectToString = objectToString$1;
|
|
17231
|
-
var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
|
|
17232
|
-
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
|
|
17233
|
-
var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
|
|
17234
|
-
function baseGetTag$2(value) {
|
|
17235
|
-
if (value == null) {
|
|
17236
|
-
return value === void 0 ? undefinedTag : nullTag;
|
|
17237
|
-
}
|
|
17238
|
-
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
17239
|
-
}
|
|
17240
|
-
var _baseGetTag = baseGetTag$2;
|
|
17241
|
-
function isObjectLike$1(value) {
|
|
17242
|
-
return value != null && typeof value == "object";
|
|
17243
|
-
}
|
|
17244
|
-
var isObjectLike_1 = isObjectLike$1;
|
|
17245
|
-
var baseGetTag$1 = _baseGetTag, isObjectLike = isObjectLike_1;
|
|
17246
|
-
var symbolTag = "[object Symbol]";
|
|
17247
|
-
function isSymbol$4(value) {
|
|
17248
|
-
return typeof value == "symbol" || isObjectLike(value) && baseGetTag$1(value) == symbolTag;
|
|
17249
|
-
}
|
|
17250
|
-
var isSymbol_1 = isSymbol$4;
|
|
17251
|
-
var baseTrim = _baseTrim, isObject$5 = isObject_1, isSymbol$3 = isSymbol_1;
|
|
17252
|
-
var NAN = 0 / 0;
|
|
17253
|
-
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
17254
|
-
var reIsBinary = /^0b[01]+$/i;
|
|
17255
|
-
var reIsOctal = /^0o[0-7]+$/i;
|
|
17256
|
-
var freeParseInt = parseInt;
|
|
17257
|
-
function toNumber$1(value) {
|
|
17258
|
-
if (typeof value == "number") {
|
|
17259
|
-
return value;
|
|
17260
|
-
}
|
|
17261
|
-
if (isSymbol$3(value)) {
|
|
17262
|
-
return NAN;
|
|
17263
|
-
}
|
|
17264
|
-
if (isObject$5(value)) {
|
|
17265
|
-
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
17266
|
-
value = isObject$5(other) ? other + "" : other;
|
|
17267
|
-
}
|
|
17268
|
-
if (typeof value != "string") {
|
|
17269
|
-
return value === 0 ? value : +value;
|
|
17270
|
-
}
|
|
17271
|
-
value = baseTrim(value);
|
|
17272
|
-
var isBinary = reIsBinary.test(value);
|
|
17273
|
-
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
|
17274
|
-
}
|
|
17275
|
-
var toNumber_1 = toNumber$1;
|
|
17276
|
-
var isObject$4 = isObject_1, now = now_1, toNumber = toNumber_1;
|
|
17277
|
-
var FUNC_ERROR_TEXT$1 = "Expected a function";
|
|
17278
|
-
var nativeMax = Math.max, nativeMin = Math.min;
|
|
17279
|
-
function debounce$2(func, wait, options) {
|
|
17280
|
-
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
17281
|
-
if (typeof func != "function") {
|
|
17282
|
-
throw new TypeError(FUNC_ERROR_TEXT$1);
|
|
17283
|
-
}
|
|
17284
|
-
wait = toNumber(wait) || 0;
|
|
17285
|
-
if (isObject$4(options)) {
|
|
17286
|
-
leading = !!options.leading;
|
|
17287
|
-
maxing = "maxWait" in options;
|
|
17288
|
-
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
17289
|
-
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
17290
|
-
}
|
|
17291
|
-
function invokeFunc(time2) {
|
|
17292
|
-
var args = lastArgs, thisArg = lastThis;
|
|
17293
|
-
lastArgs = lastThis = void 0;
|
|
17294
|
-
lastInvokeTime = time2;
|
|
17295
|
-
result = func.apply(thisArg, args);
|
|
17296
|
-
return result;
|
|
17297
|
-
}
|
|
17298
|
-
function leadingEdge(time2) {
|
|
17299
|
-
lastInvokeTime = time2;
|
|
17300
|
-
timerId = setTimeout(timerExpired, wait);
|
|
17301
|
-
return leading ? invokeFunc(time2) : result;
|
|
17302
|
-
}
|
|
17303
|
-
function remainingWait(time2) {
|
|
17304
|
-
var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
|
|
17305
|
-
return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
|
|
17306
|
-
}
|
|
17307
|
-
function shouldInvoke(time2) {
|
|
17308
|
-
var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime;
|
|
17309
|
-
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
|
17310
|
-
}
|
|
17311
|
-
function timerExpired() {
|
|
17312
|
-
var time2 = now();
|
|
17313
|
-
if (shouldInvoke(time2)) {
|
|
17314
|
-
return trailingEdge(time2);
|
|
17315
|
-
}
|
|
17316
|
-
timerId = setTimeout(timerExpired, remainingWait(time2));
|
|
17317
|
-
}
|
|
17318
|
-
function trailingEdge(time2) {
|
|
17319
|
-
timerId = void 0;
|
|
17320
|
-
if (trailing && lastArgs) {
|
|
17321
|
-
return invokeFunc(time2);
|
|
17322
|
-
}
|
|
17323
|
-
lastArgs = lastThis = void 0;
|
|
17324
|
-
return result;
|
|
17325
|
-
}
|
|
17326
|
-
function cancel() {
|
|
17327
|
-
if (timerId !== void 0) {
|
|
17328
|
-
clearTimeout(timerId);
|
|
17329
|
-
}
|
|
17330
|
-
lastInvokeTime = 0;
|
|
17331
|
-
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
|
17332
|
-
}
|
|
17333
|
-
function flush() {
|
|
17334
|
-
return timerId === void 0 ? result : trailingEdge(now());
|
|
17335
|
-
}
|
|
17336
|
-
function debounced() {
|
|
17337
|
-
var time2 = now(), isInvoking = shouldInvoke(time2);
|
|
17338
|
-
lastArgs = arguments;
|
|
17339
|
-
lastThis = this;
|
|
17340
|
-
lastCallTime = time2;
|
|
17341
|
-
if (isInvoking) {
|
|
17342
|
-
if (timerId === void 0) {
|
|
17343
|
-
return leadingEdge(lastCallTime);
|
|
17344
|
-
}
|
|
17345
|
-
if (maxing) {
|
|
17346
|
-
clearTimeout(timerId);
|
|
17347
|
-
timerId = setTimeout(timerExpired, wait);
|
|
17348
|
-
return invokeFunc(lastCallTime);
|
|
17349
|
-
}
|
|
17350
|
-
}
|
|
17351
|
-
if (timerId === void 0) {
|
|
17352
|
-
timerId = setTimeout(timerExpired, wait);
|
|
17353
|
-
}
|
|
17354
|
-
return result;
|
|
17355
|
-
}
|
|
17356
|
-
debounced.cancel = cancel;
|
|
17357
|
-
debounced.flush = flush;
|
|
17358
|
-
return debounced;
|
|
17359
|
-
}
|
|
17360
|
-
var debounce_1 = debounce$2;
|
|
17361
|
-
const debounce$1 = /* @__PURE__ */ getDefaultExportFromCjs(debounce_1);
|
|
17362
|
-
const useDebouncedSearch = () => {
|
|
17363
|
-
const [searchValue, onSearchValueChange] = React.useState("");
|
|
17364
|
-
const [debouncedQuery, setDebouncedQuery] = React.useState("");
|
|
17365
|
-
const debouncedUpdate = React.useCallback(
|
|
17366
|
-
debounce$1((query) => setDebouncedQuery(query), 300),
|
|
17367
|
-
[]
|
|
17368
|
-
);
|
|
17369
|
-
React.useEffect(() => {
|
|
17370
|
-
debouncedUpdate(searchValue);
|
|
17371
|
-
return () => debouncedUpdate.cancel();
|
|
17372
|
-
}, [searchValue, debouncedUpdate]);
|
|
17373
|
-
return {
|
|
17374
|
-
searchValue,
|
|
17375
|
-
onSearchValueChange,
|
|
17376
|
-
query: debouncedQuery || void 0
|
|
17377
|
-
};
|
|
17378
|
-
};
|
|
17379
|
-
const useComboboxData = ({
|
|
17380
|
-
queryKey,
|
|
17381
|
-
queryFn,
|
|
17382
|
-
getOptions,
|
|
17383
|
-
defaultValue: defaultValue2,
|
|
17384
|
-
defaultValueKey,
|
|
17385
|
-
pageSize = 10
|
|
17386
|
-
}) => {
|
|
17387
|
-
const { searchValue, onSearchValueChange, query } = useDebouncedSearch();
|
|
17388
|
-
const queryInitialDataBy = defaultValueKey || "id";
|
|
17389
|
-
const { data: initialData } = reactQuery.useQuery({
|
|
17390
|
-
queryKey,
|
|
17391
|
-
queryFn: async () => {
|
|
17392
|
-
return queryFn({
|
|
17393
|
-
[queryInitialDataBy]: defaultValue2,
|
|
17394
|
-
limit: Array.isArray(defaultValue2) ? defaultValue2.length : 1
|
|
17395
|
-
});
|
|
17396
|
-
},
|
|
17397
|
-
enabled: !!defaultValue2
|
|
17398
|
-
});
|
|
17399
|
-
const { data, ...rest } = reactQuery.useInfiniteQuery({
|
|
17400
|
-
queryKey: [...queryKey, query],
|
|
17401
|
-
queryFn: async ({ pageParam = 0 }) => {
|
|
17402
|
-
return await queryFn({
|
|
17403
|
-
q: query,
|
|
17404
|
-
limit: pageSize,
|
|
17405
|
-
offset: pageParam
|
|
17406
|
-
});
|
|
17407
|
-
},
|
|
17408
|
-
initialPageParam: 0,
|
|
17409
|
-
getNextPageParam: (lastPage) => {
|
|
17410
|
-
const moreItemsExist = lastPage.count > lastPage.offset + lastPage.limit;
|
|
17411
|
-
return moreItemsExist ? lastPage.offset + lastPage.limit : void 0;
|
|
17412
|
-
},
|
|
17413
|
-
placeholderData: reactQuery.keepPreviousData
|
|
17414
|
-
});
|
|
17415
|
-
const options = (data == null ? void 0 : data.pages.flatMap((page) => getOptions(page))) ?? [];
|
|
17416
|
-
const defaultOptions2 = initialData ? getOptions(initialData) : [];
|
|
17417
|
-
const disabled = !rest.isPending && !options.length && !searchValue;
|
|
17418
|
-
if (defaultValue2 && defaultOptions2.length && !searchValue) {
|
|
17419
|
-
defaultOptions2.forEach((option) => {
|
|
17420
|
-
if (!options.find((o2) => o2.value === option.value)) {
|
|
17421
|
-
options.unshift(option);
|
|
17422
|
-
}
|
|
17423
|
-
});
|
|
17424
|
-
}
|
|
17425
|
-
return {
|
|
17426
|
-
options,
|
|
17427
|
-
searchValue,
|
|
17428
|
-
onSearchValueChange,
|
|
17429
|
-
disabled,
|
|
17430
|
-
...rest
|
|
17431
|
-
};
|
|
17432
|
-
};
|
|
17433
17325
|
const currencies = {
|
|
17434
17326
|
USD: {
|
|
17435
17327
|
code: "USD",
|
|
@@ -18152,509 +18044,6 @@ const currencies = {
|
|
|
18152
18044
|
decimal_digits: 0
|
|
18153
18045
|
}
|
|
18154
18046
|
};
|
|
18155
|
-
const formSchema = zod.z.object({
|
|
18156
|
-
currency_code: zod.z.string().min(1, "Please select a currency"),
|
|
18157
|
-
customer_id: zod.z.string().optional()
|
|
18158
|
-
});
|
|
18159
|
-
const StoreCreditAccountCreateForm = () => {
|
|
18160
|
-
const { handleSuccess } = useRouteModal();
|
|
18161
|
-
const form = useForm({
|
|
18162
|
-
defaultValues: {
|
|
18163
|
-
currency_code: "",
|
|
18164
|
-
customer_id: ""
|
|
18165
|
-
},
|
|
18166
|
-
resolver: t(formSchema)
|
|
18167
|
-
});
|
|
18168
|
-
const { mutateAsync: createStoreCreditAccount, isPending } = useCreateStoreCreditAccount();
|
|
18169
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
18170
|
-
if (!data.customer_id) {
|
|
18171
|
-
delete data.customer_id;
|
|
18172
|
-
}
|
|
18173
|
-
await createStoreCreditAccount(data, {
|
|
18174
|
-
onSuccess: (data2) => {
|
|
18175
|
-
ui.toast.success(`Store credit account was successfully created.`);
|
|
18176
|
-
handleSuccess(`../${data2.store_credit_account.id}`);
|
|
18177
|
-
},
|
|
18178
|
-
onError: (error) => {
|
|
18179
|
-
ui.toast.error(error.message);
|
|
18180
|
-
}
|
|
18181
|
-
});
|
|
18182
|
-
});
|
|
18183
|
-
const [currencySearchValue, setCurrencySearchValue] = React.useState("");
|
|
18184
|
-
const currencyOptions = React.useMemo(() => {
|
|
18185
|
-
const options = Object.values(currencies).map((currency) => ({
|
|
18186
|
-
label: `${currency.code} - ${currency.name} (${currency.symbol_native})`,
|
|
18187
|
-
value: currency.code.toLowerCase()
|
|
18188
|
-
}));
|
|
18189
|
-
if (!currencySearchValue) {
|
|
18190
|
-
return options;
|
|
18191
|
-
}
|
|
18192
|
-
return options.filter(
|
|
18193
|
-
(option) => option.label.toLowerCase().includes(currencySearchValue.toLowerCase())
|
|
18194
|
-
);
|
|
18195
|
-
}, [currencySearchValue]);
|
|
18196
|
-
const {
|
|
18197
|
-
options: customerOptions,
|
|
18198
|
-
fetchNextPage,
|
|
18199
|
-
isFetchingNextPage,
|
|
18200
|
-
searchValue,
|
|
18201
|
-
onSearchValueChange,
|
|
18202
|
-
isLoading
|
|
18203
|
-
} = useComboboxData({
|
|
18204
|
-
queryKey: customersQueryKeys.list(),
|
|
18205
|
-
queryFn: async (params) => {
|
|
18206
|
-
return sdk.admin.customer.list(params);
|
|
18207
|
-
},
|
|
18208
|
-
getOptions: (data) => {
|
|
18209
|
-
var _a2;
|
|
18210
|
-
return ((_a2 = data.customers) == null ? void 0 : _a2.map((customer) => {
|
|
18211
|
-
const fullName = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
18212
|
-
const label = fullName ? `${customer.email} (${fullName})` : customer.email;
|
|
18213
|
-
return {
|
|
18214
|
-
label,
|
|
18215
|
-
value: customer.id
|
|
18216
|
-
};
|
|
18217
|
-
})) || [];
|
|
18218
|
-
}
|
|
18219
|
-
});
|
|
18220
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Form, { form, children: [
|
|
18221
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "-my-2 w-full border-l" }) }),
|
|
18222
|
-
/* @__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: [
|
|
18223
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
18224
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Create Store Credit Account" }),
|
|
18225
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", size: "small", children: "Create a new store credit account for a customer" })
|
|
18226
|
-
] }),
|
|
18227
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-x-4", children: [
|
|
18228
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18229
|
-
Form$2.Field,
|
|
18230
|
-
{
|
|
18231
|
-
control: form.control,
|
|
18232
|
-
name: "currency_code",
|
|
18233
|
-
render: ({ field }) => {
|
|
18234
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
18235
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Currency" }),
|
|
18236
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
18237
|
-
Combobox,
|
|
18238
|
-
{
|
|
18239
|
-
value: field.value,
|
|
18240
|
-
onChange: field.onChange,
|
|
18241
|
-
searchValue: currencySearchValue,
|
|
18242
|
-
onSearchValueChange: setCurrencySearchValue,
|
|
18243
|
-
options: currencyOptions,
|
|
18244
|
-
placeholder: "Search for a currency..."
|
|
18245
|
-
}
|
|
18246
|
-
) }),
|
|
18247
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
18248
|
-
] });
|
|
18249
|
-
}
|
|
18250
|
-
}
|
|
18251
|
-
),
|
|
18252
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18253
|
-
Form$2.Field,
|
|
18254
|
-
{
|
|
18255
|
-
control: form.control,
|
|
18256
|
-
name: "customer_id",
|
|
18257
|
-
render: ({ field }) => {
|
|
18258
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
18259
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Customer" }),
|
|
18260
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
18261
|
-
Combobox,
|
|
18262
|
-
{
|
|
18263
|
-
value: field.value,
|
|
18264
|
-
onChange: field.onChange,
|
|
18265
|
-
searchValue,
|
|
18266
|
-
onSearchValueChange,
|
|
18267
|
-
options: customerOptions,
|
|
18268
|
-
placeholder: "Search for a customer...",
|
|
18269
|
-
fetchNextPage,
|
|
18270
|
-
isFetchingNextPage,
|
|
18271
|
-
noResultsPlaceholder: isLoading ? "Loading customers..." : "No customers found"
|
|
18272
|
-
}
|
|
18273
|
-
) }),
|
|
18274
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
18275
|
-
] });
|
|
18276
|
-
}
|
|
18277
|
-
}
|
|
18278
|
-
)
|
|
18279
|
-
] })
|
|
18280
|
-
] }) }) }),
|
|
18281
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Footer, { children: [
|
|
18282
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, disabled: isPending, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", disabled: isPending, children: "Cancel" }) }),
|
|
18283
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18284
|
-
ui.Button,
|
|
18285
|
-
{
|
|
18286
|
-
variant: "primary",
|
|
18287
|
-
size: "small",
|
|
18288
|
-
onClick: handleSubmit,
|
|
18289
|
-
disabled: isPending,
|
|
18290
|
-
children: "Create"
|
|
18291
|
-
}
|
|
18292
|
-
)
|
|
18293
|
-
] })
|
|
18294
|
-
] });
|
|
18295
|
-
};
|
|
18296
|
-
const StoreCreditAccountCreate = () => {
|
|
18297
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal, { children: [
|
|
18298
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create Store Credit Account" }) }),
|
|
18299
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create a new store credit account" }) }),
|
|
18300
|
-
/* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCreateForm, {})
|
|
18301
|
-
] });
|
|
18302
|
-
};
|
|
18303
|
-
const GiftCardIcon = (props) => {
|
|
18304
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
18305
|
-
"svg",
|
|
18306
|
-
{
|
|
18307
|
-
width: "15",
|
|
18308
|
-
height: "15",
|
|
18309
|
-
viewBox: "0 0 15 15",
|
|
18310
|
-
fill: "none",
|
|
18311
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
18312
|
-
...props,
|
|
18313
|
-
children: [
|
|
18314
|
-
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#F97316" }),
|
|
18315
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18316
|
-
"rect",
|
|
18317
|
-
{
|
|
18318
|
-
width: "15",
|
|
18319
|
-
height: "15",
|
|
18320
|
-
fill: "url(#paint0_linear_28788_25808)",
|
|
18321
|
-
fillOpacity: "0.2"
|
|
18322
|
-
}
|
|
18323
|
-
),
|
|
18324
|
-
/* @__PURE__ */ jsxRuntime.jsxs("g", { clipPath: "url(#clip0_28788_25808)", children: [
|
|
18325
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18326
|
-
"path",
|
|
18327
|
-
{
|
|
18328
|
-
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",
|
|
18329
|
-
fill: "white"
|
|
18330
|
-
}
|
|
18331
|
-
),
|
|
18332
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18333
|
-
"path",
|
|
18334
|
-
{
|
|
18335
|
-
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",
|
|
18336
|
-
fill: "white"
|
|
18337
|
-
}
|
|
18338
|
-
),
|
|
18339
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18340
|
-
"path",
|
|
18341
|
-
{
|
|
18342
|
-
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",
|
|
18343
|
-
fill: "white"
|
|
18344
|
-
}
|
|
18345
|
-
),
|
|
18346
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18347
|
-
"path",
|
|
18348
|
-
{
|
|
18349
|
-
d: "M6.938 7.5H3.75V9.563C3.75 10.7 4.675 11.625 5.813 11.625H6.938V7.5Z",
|
|
18350
|
-
fill: "white"
|
|
18351
|
-
}
|
|
18352
|
-
),
|
|
18353
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18354
|
-
"path",
|
|
18355
|
-
{
|
|
18356
|
-
d: "M8.063 7.5V11.625H9.188C10.325 11.625 11.25 10.7 11.25 9.563V7.5H8.063Z",
|
|
18357
|
-
fill: "white"
|
|
18358
|
-
}
|
|
18359
|
-
)
|
|
18360
|
-
] }),
|
|
18361
|
-
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
18362
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
18363
|
-
"linearGradient",
|
|
18364
|
-
{
|
|
18365
|
-
id: "paint0_linear_28788_25808",
|
|
18366
|
-
x1: "7.5",
|
|
18367
|
-
y1: "0",
|
|
18368
|
-
x2: "7.5",
|
|
18369
|
-
y2: "15",
|
|
18370
|
-
gradientUnits: "userSpaceOnUse",
|
|
18371
|
-
children: [
|
|
18372
|
-
/* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "white" }),
|
|
18373
|
-
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
|
|
18374
|
-
]
|
|
18375
|
-
}
|
|
18376
|
-
),
|
|
18377
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_28788_25808", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "9", height: "9", fill: "white", transform: "translate(3 3)" }) })
|
|
18378
|
-
] })
|
|
18379
|
-
]
|
|
18380
|
-
}
|
|
18381
|
-
);
|
|
18382
|
-
};
|
|
18383
|
-
const TwoColumnLayout = ({
|
|
18384
|
-
firstCol,
|
|
18385
|
-
secondCol
|
|
18386
|
-
}) => {
|
|
18387
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-x-4 gap-y-3 xl:flex-row xl:items-start", children: [
|
|
18388
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full flex-col gap-y-3", children: firstCol }),
|
|
18389
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full max-w-[100%] flex-col gap-y-3 xl:mt-0 xl:max-w-[440px]", children: secondCol })
|
|
18390
|
-
] });
|
|
18391
|
-
};
|
|
18392
|
-
const GiftCardProductsSection = () => {
|
|
18393
|
-
const { products: giftCardProducts, count: count2 = 0 } = useProducts({
|
|
18394
|
-
is_giftcard: true
|
|
18395
|
-
});
|
|
18396
|
-
const slicedProducts = (giftCardProducts == null ? void 0 : giftCardProducts.slice(0, 3)) ?? [];
|
|
18397
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
18398
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
18399
|
-
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Gift Card Products" }),
|
|
18400
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18401
|
-
reactRouterDom.Link,
|
|
18402
|
-
{
|
|
18403
|
-
to: `/gift-cards/gift-card-products/create`,
|
|
18404
|
-
className: "text-ui-fg-muted text-sm px-6",
|
|
18405
|
-
children: "Create"
|
|
18406
|
-
}
|
|
18407
|
-
)
|
|
18408
|
-
] }),
|
|
18409
|
-
(giftCardProducts == null ? void 0 : giftCardProducts.length) === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
18410
|
-
NoRecords,
|
|
18411
|
-
{
|
|
18412
|
-
className: "px-10 py-4 h-[200px]",
|
|
18413
|
-
title: "No gift card products",
|
|
18414
|
-
message: "There are no gift card products to show. Create one to get started.",
|
|
18415
|
-
action: {
|
|
18416
|
-
to: "/gift-cards/gift-card-products/create",
|
|
18417
|
-
label: "Create gift card product"
|
|
18418
|
-
}
|
|
18419
|
-
}
|
|
18420
|
-
),
|
|
18421
|
-
slicedProducts.map((giftCardProduct) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
18422
|
-
SidebarLink,
|
|
18423
|
-
{
|
|
18424
|
-
to: `/gift-cards/gift-card-products/${giftCardProduct.id}`,
|
|
18425
|
-
labelKey: giftCardProduct.title,
|
|
18426
|
-
descriptionKey: giftCardProduct.title,
|
|
18427
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Tag, {})
|
|
18428
|
-
}
|
|
18429
|
-
)),
|
|
18430
|
-
count2 > 3 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
18431
|
-
reactRouterDom.Link,
|
|
18432
|
-
{
|
|
18433
|
-
to: "/gift-cards/gift-card-products",
|
|
18434
|
-
className: "text-ui-fg-muted text-sm px-6 py-4 flex items-center justify-center",
|
|
18435
|
-
children: "View more"
|
|
18436
|
-
}
|
|
18437
|
-
)
|
|
18438
|
-
] });
|
|
18439
|
-
};
|
|
18440
|
-
const _giftCardQueryKey = queryKeysFactory("gift-card");
|
|
18441
|
-
const giftCardQueryKey = {
|
|
18442
|
-
..._giftCardQueryKey,
|
|
18443
|
-
orders: (id) => [..._giftCardQueryKey.detail(id), "orders"]
|
|
18444
|
-
};
|
|
18445
|
-
const useGiftCards = (query, options) => {
|
|
18446
|
-
const fetchGiftCards = (query2, headers) => sdk.client.fetch(`/admin/gift-cards`, {
|
|
18447
|
-
query: query2,
|
|
18448
|
-
headers
|
|
18449
|
-
});
|
|
18450
|
-
const { data, ...rest } = reactQuery.useQuery({
|
|
18451
|
-
...options,
|
|
18452
|
-
queryFn: () => fetchGiftCards(query),
|
|
18453
|
-
queryKey: giftCardQueryKey.list(query)
|
|
18454
|
-
});
|
|
18455
|
-
return { ...data, ...rest };
|
|
18456
|
-
};
|
|
18457
|
-
const useGiftCard = (id, query, options) => {
|
|
18458
|
-
const fetchGiftCard = (id2, query2, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
|
|
18459
|
-
query: query2,
|
|
18460
|
-
headers
|
|
18461
|
-
});
|
|
18462
|
-
const { data, ...rest } = reactQuery.useQuery({
|
|
18463
|
-
queryFn: () => fetchGiftCard(id, query),
|
|
18464
|
-
queryKey: giftCardQueryKey.detail(id, query),
|
|
18465
|
-
...options
|
|
18466
|
-
});
|
|
18467
|
-
return { ...data, ...rest };
|
|
18468
|
-
};
|
|
18469
|
-
const useGiftCardOrders = (id, options) => {
|
|
18470
|
-
const fetchGiftCardOrders = (id2, query, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}/orders`, {
|
|
18471
|
-
query,
|
|
18472
|
-
headers
|
|
18473
|
-
});
|
|
18474
|
-
const { data, ...rest } = reactQuery.useQuery({
|
|
18475
|
-
queryFn: () => fetchGiftCardOrders(id),
|
|
18476
|
-
queryKey: giftCardQueryKey.orders(id),
|
|
18477
|
-
...options
|
|
18478
|
-
});
|
|
18479
|
-
return { ...data, ...rest };
|
|
18480
|
-
};
|
|
18481
|
-
const useUpdateGiftCard = (id, options) => {
|
|
18482
|
-
const queryClient = reactQuery.useQueryClient();
|
|
18483
|
-
const updateGiftCard = async (id2, body) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
|
|
18484
|
-
body,
|
|
18485
|
-
method: "POST"
|
|
18486
|
-
});
|
|
18487
|
-
return reactQuery.useMutation({
|
|
18488
|
-
mutationFn: async (payload) => updateGiftCard(id, payload),
|
|
18489
|
-
onSuccess: (data, variables, context) => {
|
|
18490
|
-
queryClient.invalidateQueries({
|
|
18491
|
-
queryKey: giftCardQueryKey.detail(id)
|
|
18492
|
-
});
|
|
18493
|
-
queryClient.invalidateQueries({
|
|
18494
|
-
queryKey: giftCardQueryKey.lists()
|
|
18495
|
-
});
|
|
18496
|
-
},
|
|
18497
|
-
...options
|
|
18498
|
-
});
|
|
18499
|
-
};
|
|
18500
|
-
const useCreateGiftCard = (options) => {
|
|
18501
|
-
const queryClient = reactQuery.useQueryClient();
|
|
18502
|
-
const createGiftCard = async (body) => sdk.client.fetch(`/admin/gift-cards`, {
|
|
18503
|
-
body,
|
|
18504
|
-
method: "POST"
|
|
18505
|
-
});
|
|
18506
|
-
return reactQuery.useMutation({
|
|
18507
|
-
mutationFn: (body) => createGiftCard(body),
|
|
18508
|
-
onSuccess: (data, variables, context) => {
|
|
18509
|
-
queryClient.invalidateQueries({ queryKey: giftCardQueryKey.lists() });
|
|
18510
|
-
},
|
|
18511
|
-
...options
|
|
18512
|
-
});
|
|
18513
|
-
};
|
|
18514
|
-
const columnHelper$9 = ui.createDataTableColumnHelper();
|
|
18515
|
-
const useGiftCardTableColumns = () => {
|
|
18516
|
-
return React.useMemo(() => {
|
|
18517
|
-
return [
|
|
18518
|
-
columnHelper$9.accessor("code", {
|
|
18519
|
-
header: "Code",
|
|
18520
|
-
cell: ({ row }) => {
|
|
18521
|
-
return row.original.code;
|
|
18522
|
-
}
|
|
18523
|
-
}),
|
|
18524
|
-
columnHelper$9.accessor("line_item.product.title", {
|
|
18525
|
-
header: "Product",
|
|
18526
|
-
cell: ({ row }) => {
|
|
18527
|
-
var _a2, _b;
|
|
18528
|
-
return ((_b = (_a2 = row.original.line_item) == null ? void 0 : _a2.product) == null ? void 0 : _b.title) || "Custom Gift Card";
|
|
18529
|
-
}
|
|
18530
|
-
}),
|
|
18531
|
-
columnHelper$9.accessor("created_at", {
|
|
18532
|
-
header: "Date issued",
|
|
18533
|
-
cell: ({ row }) => getRelativeDate(row.original.created_at)
|
|
18534
|
-
}),
|
|
18535
|
-
columnHelper$9.accessor("value", {
|
|
18536
|
-
header: "Value",
|
|
18537
|
-
cell: ({ row }) => {
|
|
18538
|
-
return formatAmount(row.original.value, row.original.currency_code);
|
|
18539
|
-
}
|
|
18540
|
-
})
|
|
18541
|
-
];
|
|
18542
|
-
}, []);
|
|
18543
|
-
};
|
|
18544
|
-
const useGiftCardFilters = () => {
|
|
18545
|
-
const dateFilterOptions = useDataTableDateFilters$1();
|
|
18546
|
-
const customerFilterOptions = useCustomerFilters();
|
|
18547
|
-
return React.useMemo(() => {
|
|
18548
|
-
return [...dateFilterOptions, ...customerFilterOptions];
|
|
18549
|
-
}, [dateFilterOptions, customerFilterOptions]);
|
|
18550
|
-
};
|
|
18551
|
-
const useGiftCardTableQuery = ({
|
|
18552
|
-
prefix,
|
|
18553
|
-
pageSize = 20
|
|
18554
|
-
}) => {
|
|
18555
|
-
const queryObject = useQueryParams(
|
|
18556
|
-
["q", "offset", "customer_id", "created_at", "updated_at"],
|
|
18557
|
-
prefix
|
|
18558
|
-
);
|
|
18559
|
-
const { offset: offset2, created_at, updated_at, customer_id, ...rest } = queryObject;
|
|
18560
|
-
const searchParams = {
|
|
18561
|
-
limit: pageSize,
|
|
18562
|
-
offset: offset2 ? Number(offset2) : 0,
|
|
18563
|
-
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
18564
|
-
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
18565
|
-
customer_id: customer_id ? JSON.parse(customer_id) : void 0,
|
|
18566
|
-
...rest
|
|
18567
|
-
};
|
|
18568
|
-
return searchParams;
|
|
18569
|
-
};
|
|
18570
|
-
const PAGE_SIZE$5 = 10;
|
|
18571
|
-
function GiftCardsTable() {
|
|
18572
|
-
const queryParams = useGiftCardTableQuery({
|
|
18573
|
-
pageSize: PAGE_SIZE$5
|
|
18574
|
-
});
|
|
18575
|
-
const {
|
|
18576
|
-
gift_cards: giftCards,
|
|
18577
|
-
isPending,
|
|
18578
|
-
count: count2
|
|
18579
|
-
} = useGiftCards({
|
|
18580
|
-
...queryParams,
|
|
18581
|
-
order: queryParams.order ?? "-created_at",
|
|
18582
|
-
fields: "+line_item.product.title"
|
|
18583
|
-
});
|
|
18584
|
-
const columns = useGiftCardTableColumns();
|
|
18585
|
-
const filters = useGiftCardFilters();
|
|
18586
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
18587
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
18588
|
-
DataTable,
|
|
18589
|
-
{
|
|
18590
|
-
data: giftCards,
|
|
18591
|
-
getRowId: (row) => row.id,
|
|
18592
|
-
columns,
|
|
18593
|
-
filters,
|
|
18594
|
-
isLoading: isPending,
|
|
18595
|
-
pageSize: PAGE_SIZE$5,
|
|
18596
|
-
rowCount: count2,
|
|
18597
|
-
heading: "Gift Cards",
|
|
18598
|
-
rowHref: (row) => `${row.id}`,
|
|
18599
|
-
emptyState: {
|
|
18600
|
-
empty: {
|
|
18601
|
-
heading: "No gift cards found",
|
|
18602
|
-
description: "Create a gift card to get started."
|
|
18603
|
-
},
|
|
18604
|
-
filtered: {
|
|
18605
|
-
heading: "No results found",
|
|
18606
|
-
description: "No gift cards match your filter criteria."
|
|
18607
|
-
}
|
|
18608
|
-
},
|
|
18609
|
-
actions: [
|
|
18610
|
-
{
|
|
18611
|
-
label: "Create",
|
|
18612
|
-
to: "create"
|
|
18613
|
-
}
|
|
18614
|
-
]
|
|
18615
|
-
}
|
|
18616
|
-
) }),
|
|
18617
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
18618
|
-
] });
|
|
18619
|
-
}
|
|
18620
|
-
const GiftCardsPage = () => {
|
|
18621
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
18622
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18623
|
-
TwoColumnLayout,
|
|
18624
|
-
{
|
|
18625
|
-
firstCol: /* @__PURE__ */ jsxRuntime.jsx(GiftCardsTable, {}),
|
|
18626
|
-
secondCol: /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductsSection, {})
|
|
18627
|
-
}
|
|
18628
|
-
),
|
|
18629
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Toaster, {})
|
|
18630
|
-
] });
|
|
18631
|
-
};
|
|
18632
|
-
const config$2 = adminSdk.defineRouteConfig({
|
|
18633
|
-
label: "Gift Cards",
|
|
18634
|
-
icon: GiftCardIcon
|
|
18635
|
-
});
|
|
18636
|
-
const STORE_QUERY_KEY = "store";
|
|
18637
|
-
const storeQueryKeys = queryKeysFactory(STORE_QUERY_KEY);
|
|
18638
|
-
async function retrieveActiveStore(query) {
|
|
18639
|
-
var _a2;
|
|
18640
|
-
const response = await sdk.admin.store.list(query);
|
|
18641
|
-
const activeStore = (_a2 = response.stores) == null ? void 0 : _a2[0];
|
|
18642
|
-
if (!activeStore) {
|
|
18643
|
-
throw new Medusa.FetchError("No active store found", "Not Found", 404);
|
|
18644
|
-
}
|
|
18645
|
-
return { store: activeStore };
|
|
18646
|
-
}
|
|
18647
|
-
const useStore$1 = (query, options) => {
|
|
18648
|
-
const { data, ...rest } = reactQuery.useQuery({
|
|
18649
|
-
queryFn: () => retrieveActiveStore(query),
|
|
18650
|
-
queryKey: storeQueryKeys.details(),
|
|
18651
|
-
...options
|
|
18652
|
-
});
|
|
18653
|
-
return {
|
|
18654
|
-
...data,
|
|
18655
|
-
...rest
|
|
18656
|
-
};
|
|
18657
|
-
};
|
|
18658
18047
|
function $constructor(name, initializer2, params) {
|
|
18659
18048
|
function init2(inst, def) {
|
|
18660
18049
|
if (!inst._zod) {
|
|
@@ -18719,7 +18108,7 @@ class $ZodEncodeError extends Error {
|
|
|
18719
18108
|
}
|
|
18720
18109
|
}
|
|
18721
18110
|
const globalConfig = {};
|
|
18722
|
-
function config$
|
|
18111
|
+
function config$2(newConfig) {
|
|
18723
18112
|
return globalConfig;
|
|
18724
18113
|
}
|
|
18725
18114
|
function getEnumValues(entries) {
|
|
@@ -18813,7 +18202,7 @@ function slugify(input) {
|
|
|
18813
18202
|
}
|
|
18814
18203
|
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
|
|
18815
18204
|
};
|
|
18816
|
-
function isObject$
|
|
18205
|
+
function isObject$6(data) {
|
|
18817
18206
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
18818
18207
|
}
|
|
18819
18208
|
const allowsEval = cached(() => {
|
|
@@ -18830,7 +18219,7 @@ const allowsEval = cached(() => {
|
|
|
18830
18219
|
}
|
|
18831
18220
|
});
|
|
18832
18221
|
function isPlainObject(o2) {
|
|
18833
|
-
if (isObject$
|
|
18222
|
+
if (isObject$6(o2) === false)
|
|
18834
18223
|
return false;
|
|
18835
18224
|
const ctor = o2.constructor;
|
|
18836
18225
|
if (ctor === void 0)
|
|
@@ -18838,7 +18227,7 @@ function isPlainObject(o2) {
|
|
|
18838
18227
|
if (typeof ctor !== "function")
|
|
18839
18228
|
return true;
|
|
18840
18229
|
const prot = ctor.prototype;
|
|
18841
|
-
if (isObject$
|
|
18230
|
+
if (isObject$6(prot) === false)
|
|
18842
18231
|
return false;
|
|
18843
18232
|
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
18844
18233
|
return false;
|
|
@@ -19169,7 +18558,7 @@ const _parse = (_Err) => (schema2, value, _ctx, _params) => {
|
|
|
19169
18558
|
throw new $ZodAsyncError();
|
|
19170
18559
|
}
|
|
19171
18560
|
if (result.issues.length) {
|
|
19172
|
-
const e2 = new ((_params == null ? void 0 : _params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
18561
|
+
const e2 = new ((_params == null ? void 0 : _params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())));
|
|
19173
18562
|
captureStackTrace(e2, _params == null ? void 0 : _params.callee);
|
|
19174
18563
|
throw e2;
|
|
19175
18564
|
}
|
|
@@ -19181,7 +18570,7 @@ const _parseAsync = (_Err) => async (schema2, value, _ctx, params) => {
|
|
|
19181
18570
|
if (result instanceof Promise)
|
|
19182
18571
|
result = await result;
|
|
19183
18572
|
if (result.issues.length) {
|
|
19184
|
-
const e2 = new ((params == null ? void 0 : params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
18573
|
+
const e2 = new ((params == null ? void 0 : params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())));
|
|
19185
18574
|
captureStackTrace(e2, params == null ? void 0 : params.callee);
|
|
19186
18575
|
throw e2;
|
|
19187
18576
|
}
|
|
@@ -19195,7 +18584,7 @@ const _safeParse = (_Err) => (schema2, value, _ctx) => {
|
|
|
19195
18584
|
}
|
|
19196
18585
|
return result.issues.length ? {
|
|
19197
18586
|
success: false,
|
|
19198
|
-
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
18587
|
+
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())))
|
|
19199
18588
|
} : { success: true, data: result.value };
|
|
19200
18589
|
};
|
|
19201
18590
|
const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
@@ -19206,7 +18595,7 @@ const _safeParseAsync = (_Err) => async (schema2, value, _ctx) => {
|
|
|
19206
18595
|
result = await result;
|
|
19207
18596
|
return result.issues.length ? {
|
|
19208
18597
|
success: false,
|
|
19209
|
-
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
18598
|
+
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())))
|
|
19210
18599
|
} : { success: true, data: result.value };
|
|
19211
18600
|
};
|
|
19212
18601
|
const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
@@ -20345,7 +19734,7 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
20345
19734
|
}
|
|
20346
19735
|
return propValues;
|
|
20347
19736
|
});
|
|
20348
|
-
const isObject2 = isObject$
|
|
19737
|
+
const isObject2 = isObject$6;
|
|
20349
19738
|
const catchall = def.catchall;
|
|
20350
19739
|
let value;
|
|
20351
19740
|
inst._zod.parse = (payload, ctx2) => {
|
|
@@ -20425,7 +19814,7 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
|
|
|
20425
19814
|
return (payload, ctx2) => fn(shape, payload, ctx2);
|
|
20426
19815
|
};
|
|
20427
19816
|
let fastpass;
|
|
20428
|
-
const isObject2 = isObject$
|
|
19817
|
+
const isObject2 = isObject$6;
|
|
20429
19818
|
const jit = !globalConfig.jitless;
|
|
20430
19819
|
const allowsEval$1 = allowsEval;
|
|
20431
19820
|
const fastEnabled = jit && allowsEval$1.value;
|
|
@@ -20470,7 +19859,7 @@ function handleUnionResults(results, final, inst, ctx2) {
|
|
|
20470
19859
|
code: "invalid_union",
|
|
20471
19860
|
input: final.value,
|
|
20472
19861
|
inst,
|
|
20473
|
-
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
19862
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())))
|
|
20474
19863
|
});
|
|
20475
19864
|
return final;
|
|
20476
19865
|
}
|
|
@@ -20663,7 +20052,7 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
20663
20052
|
payload.issues.push({
|
|
20664
20053
|
code: "invalid_key",
|
|
20665
20054
|
origin: "record",
|
|
20666
|
-
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
20055
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())),
|
|
20667
20056
|
input: key2,
|
|
20668
20057
|
path: [key2],
|
|
20669
20058
|
inst
|
|
@@ -20862,7 +20251,7 @@ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
|
20862
20251
|
payload.value = def.catchValue({
|
|
20863
20252
|
...payload,
|
|
20864
20253
|
error: {
|
|
20865
|
-
issues: result2.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
20254
|
+
issues: result2.issues.map((iss) => finalizeIssue(iss, ctx2, config$2()))
|
|
20866
20255
|
},
|
|
20867
20256
|
input: payload.value
|
|
20868
20257
|
});
|
|
@@ -20876,7 +20265,7 @@ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
|
20876
20265
|
payload.value = def.catchValue({
|
|
20877
20266
|
...payload,
|
|
20878
20267
|
error: {
|
|
20879
|
-
issues: result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
20268
|
+
issues: result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2()))
|
|
20880
20269
|
},
|
|
20881
20270
|
input: payload.value
|
|
20882
20271
|
});
|
|
@@ -22936,541 +22325,624 @@ const GiftCardCreateForm = ({
|
|
|
22936
22325
|
] });
|
|
22937
22326
|
};
|
|
22938
22327
|
const GiftCardCreate = () => {
|
|
22939
|
-
const { store, isLoading } = useStore$
|
|
22328
|
+
const { store, isLoading } = useStore$2({});
|
|
22940
22329
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal, { children: [
|
|
22941
22330
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create Gift Card" }) }),
|
|
22942
22331
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create a new gift card" }) }),
|
|
22943
22332
|
!isLoading && /* @__PURE__ */ jsxRuntime.jsx(GiftCardCreateForm, { store })
|
|
22944
22333
|
] });
|
|
22945
22334
|
};
|
|
22946
|
-
const
|
|
22947
|
-
|
|
22948
|
-
|
|
22949
|
-
|
|
22950
|
-
|
|
22951
|
-
|
|
22952
|
-
|
|
22953
|
-
|
|
22954
|
-
|
|
22955
|
-
|
|
22956
|
-
|
|
22957
|
-
|
|
22958
|
-
|
|
22959
|
-
|
|
22960
|
-
size: "xlarge",
|
|
22961
|
-
className: "tabular-nums text-ui-fg-base",
|
|
22962
|
-
children: formatAmount(
|
|
22963
|
-
storeCreditAccount.balance,
|
|
22964
|
-
storeCreditAccount.currency_code
|
|
22965
|
-
)
|
|
22966
|
-
}
|
|
22967
|
-
)
|
|
22968
|
-
] })
|
|
22969
|
-
] }) });
|
|
22970
|
-
};
|
|
22971
|
-
var toggleSelection = function() {
|
|
22972
|
-
var selection = document.getSelection();
|
|
22973
|
-
if (!selection.rangeCount) {
|
|
22974
|
-
return function() {
|
|
22975
|
-
};
|
|
22976
|
-
}
|
|
22977
|
-
var active = document.activeElement;
|
|
22978
|
-
var ranges = [];
|
|
22979
|
-
for (var i2 = 0; i2 < selection.rangeCount; i2++) {
|
|
22980
|
-
ranges.push(selection.getRangeAt(i2));
|
|
22981
|
-
}
|
|
22982
|
-
switch (active.tagName.toUpperCase()) {
|
|
22983
|
-
// .toUpperCase handles XHTML
|
|
22984
|
-
case "INPUT":
|
|
22985
|
-
case "TEXTAREA":
|
|
22986
|
-
active.blur();
|
|
22987
|
-
break;
|
|
22988
|
-
default:
|
|
22989
|
-
active = null;
|
|
22990
|
-
break;
|
|
22991
|
-
}
|
|
22992
|
-
selection.removeAllRanges();
|
|
22993
|
-
return function() {
|
|
22994
|
-
selection.type === "Caret" && selection.removeAllRanges();
|
|
22995
|
-
if (!selection.rangeCount) {
|
|
22996
|
-
ranges.forEach(function(range) {
|
|
22997
|
-
selection.addRange(range);
|
|
22998
|
-
});
|
|
22999
|
-
}
|
|
23000
|
-
active && active.focus();
|
|
23001
|
-
};
|
|
23002
|
-
};
|
|
23003
|
-
var deselectCurrent = toggleSelection;
|
|
23004
|
-
var clipboardToIE11Formatting = {
|
|
23005
|
-
"text/plain": "Text",
|
|
23006
|
-
"text/html": "Url",
|
|
23007
|
-
"default": "Text"
|
|
23008
|
-
};
|
|
23009
|
-
var defaultMessage = "Copy to clipboard: #{key}, Enter";
|
|
23010
|
-
function format(message2) {
|
|
23011
|
-
var copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C";
|
|
23012
|
-
return message2.replace(/#{\s*key\s*}/g, copyKey);
|
|
23013
|
-
}
|
|
23014
|
-
function copy$2(text2, options) {
|
|
23015
|
-
var debug2, message2, reselectPrevious, range, selection, mark, success = false;
|
|
23016
|
-
if (!options) {
|
|
23017
|
-
options = {};
|
|
23018
|
-
}
|
|
23019
|
-
debug2 = options.debug || false;
|
|
23020
|
-
try {
|
|
23021
|
-
reselectPrevious = deselectCurrent();
|
|
23022
|
-
range = document.createRange();
|
|
23023
|
-
selection = document.getSelection();
|
|
23024
|
-
mark = document.createElement("span");
|
|
23025
|
-
mark.textContent = text2;
|
|
23026
|
-
mark.ariaHidden = "true";
|
|
23027
|
-
mark.style.all = "unset";
|
|
23028
|
-
mark.style.position = "fixed";
|
|
23029
|
-
mark.style.top = 0;
|
|
23030
|
-
mark.style.clip = "rect(0, 0, 0, 0)";
|
|
23031
|
-
mark.style.whiteSpace = "pre";
|
|
23032
|
-
mark.style.webkitUserSelect = "text";
|
|
23033
|
-
mark.style.MozUserSelect = "text";
|
|
23034
|
-
mark.style.msUserSelect = "text";
|
|
23035
|
-
mark.style.userSelect = "text";
|
|
23036
|
-
mark.addEventListener("copy", function(e2) {
|
|
23037
|
-
e2.stopPropagation();
|
|
23038
|
-
if (options.format) {
|
|
23039
|
-
e2.preventDefault();
|
|
23040
|
-
if (typeof e2.clipboardData === "undefined") {
|
|
23041
|
-
debug2 && console.warn("unable to use e.clipboardData");
|
|
23042
|
-
debug2 && console.warn("trying IE specific stuff");
|
|
23043
|
-
window.clipboardData.clearData();
|
|
23044
|
-
var format2 = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting["default"];
|
|
23045
|
-
window.clipboardData.setData(format2, text2);
|
|
23046
|
-
} else {
|
|
23047
|
-
e2.clipboardData.clearData();
|
|
23048
|
-
e2.clipboardData.setData(options.format, text2);
|
|
23049
|
-
}
|
|
23050
|
-
}
|
|
23051
|
-
if (options.onCopy) {
|
|
23052
|
-
e2.preventDefault();
|
|
23053
|
-
options.onCopy(e2.clipboardData);
|
|
23054
|
-
}
|
|
23055
|
-
});
|
|
23056
|
-
document.body.appendChild(mark);
|
|
23057
|
-
range.selectNodeContents(mark);
|
|
23058
|
-
selection.addRange(range);
|
|
23059
|
-
var successful = document.execCommand("copy");
|
|
23060
|
-
if (!successful) {
|
|
23061
|
-
throw new Error("copy command was unsuccessful");
|
|
23062
|
-
}
|
|
23063
|
-
success = true;
|
|
23064
|
-
} catch (err) {
|
|
23065
|
-
debug2 && console.error("unable to copy using execCommand: ", err);
|
|
23066
|
-
debug2 && console.warn("trying IE specific stuff");
|
|
23067
|
-
try {
|
|
23068
|
-
window.clipboardData.setData(options.format || "text", text2);
|
|
23069
|
-
options.onCopy && options.onCopy(window.clipboardData);
|
|
23070
|
-
success = true;
|
|
23071
|
-
} catch (err2) {
|
|
23072
|
-
debug2 && console.error("unable to copy using clipboardData: ", err2);
|
|
23073
|
-
debug2 && console.error("falling back to prompt");
|
|
23074
|
-
message2 = format("message" in options ? options.message : defaultMessage);
|
|
23075
|
-
window.prompt(message2, text2);
|
|
23076
|
-
}
|
|
23077
|
-
} finally {
|
|
23078
|
-
if (selection) {
|
|
23079
|
-
if (typeof selection.removeRange == "function") {
|
|
23080
|
-
selection.removeRange(range);
|
|
23081
|
-
} else {
|
|
23082
|
-
selection.removeAllRanges();
|
|
23083
|
-
}
|
|
23084
|
-
}
|
|
23085
|
-
if (mark) {
|
|
23086
|
-
document.body.removeChild(mark);
|
|
23087
|
-
}
|
|
23088
|
-
reselectPrevious();
|
|
23089
|
-
}
|
|
23090
|
-
return success;
|
|
23091
|
-
}
|
|
23092
|
-
var copyToClipboard = copy$2;
|
|
23093
|
-
const copy$1 = /* @__PURE__ */ getDefaultExportFromCjs(copyToClipboard);
|
|
23094
|
-
function DisplayId({ id, className }) {
|
|
23095
|
-
const [open, setOpen] = React.useState(false);
|
|
23096
|
-
const onClick = () => {
|
|
23097
|
-
copy$1(id);
|
|
23098
|
-
ui.toast.success("Copied to clipboard");
|
|
23099
|
-
};
|
|
23100
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { maxWidth: 260, content: id, open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { onClick, className: ui.clx("cursor-pointer", className), children: [
|
|
23101
|
-
"#",
|
|
23102
|
-
id.slice(-7)
|
|
23103
|
-
] }) });
|
|
23104
|
-
}
|
|
23105
|
-
const StoreCreditAccountDetailsSection = ({
|
|
23106
|
-
storeCreditAccount
|
|
23107
|
-
}) => {
|
|
23108
|
-
if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
|
|
23109
|
-
return;
|
|
23110
|
-
}
|
|
23111
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "flex justify-between gap-x-2 px-6 py-6", children: [
|
|
23112
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
23113
|
-
ui.Text,
|
|
23114
|
-
{
|
|
23115
|
-
weight: "plus",
|
|
23116
|
-
size: "xlarge",
|
|
23117
|
-
className: "text-ui-fg-base flex gap-x-4",
|
|
23118
|
-
children: [
|
|
23119
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
23120
|
-
/* @__PURE__ */ jsxRuntime.jsx(CreditCardIcon, { className: "inline" }),
|
|
23121
|
-
" "
|
|
23122
|
-
] }),
|
|
23123
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
23124
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle", children: [
|
|
23125
|
-
storeCreditAccount.currency_code.toUpperCase(),
|
|
23126
|
-
" Account"
|
|
23127
|
-
] }),
|
|
23128
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
23129
|
-
ui.Text,
|
|
23130
|
-
{
|
|
23131
|
-
weight: "regular",
|
|
23132
|
-
size: "small",
|
|
23133
|
-
className: "text-ui-fg-base flex gap-x-4",
|
|
23134
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(DisplayId, { id: storeCreditAccount.id })
|
|
23135
|
-
}
|
|
23136
|
-
) })
|
|
23137
|
-
] })
|
|
23138
|
-
]
|
|
23139
|
-
}
|
|
23140
|
-
),
|
|
23141
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-x-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
23142
|
-
ActionMenu,
|
|
23143
|
-
{
|
|
23144
|
-
groups: [
|
|
22335
|
+
const StoreCreditIcon = (props) => {
|
|
22336
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
22337
|
+
"svg",
|
|
22338
|
+
{
|
|
22339
|
+
width: "15",
|
|
22340
|
+
height: "15",
|
|
22341
|
+
viewBox: "0 0 15 15",
|
|
22342
|
+
fill: "none",
|
|
22343
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
22344
|
+
...props,
|
|
22345
|
+
children: [
|
|
22346
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#8B5CF6" }),
|
|
22347
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
22348
|
+
"rect",
|
|
23145
22349
|
{
|
|
23146
|
-
|
|
23147
|
-
|
|
23148
|
-
|
|
23149
|
-
|
|
23150
|
-
|
|
23151
|
-
|
|
22350
|
+
width: "15",
|
|
22351
|
+
height: "15",
|
|
22352
|
+
fill: "url(#paint0_linear_29181_44790)",
|
|
22353
|
+
fillOpacity: "0.2"
|
|
22354
|
+
}
|
|
22355
|
+
),
|
|
22356
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
22357
|
+
"path",
|
|
22358
|
+
{
|
|
22359
|
+
d: "M12 6V5.813C12 4.675 11.075 3.75 9.938 3.75H5.063C3.925 3.75 3 4.675 3 5.813V6H12Z",
|
|
22360
|
+
fill: "white"
|
|
22361
|
+
}
|
|
22362
|
+
),
|
|
22363
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
22364
|
+
"path",
|
|
22365
|
+
{
|
|
22366
|
+
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",
|
|
22367
|
+
fill: "white"
|
|
22368
|
+
}
|
|
22369
|
+
),
|
|
22370
|
+
/* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
22371
|
+
"linearGradient",
|
|
22372
|
+
{
|
|
22373
|
+
id: "paint0_linear_29181_44790",
|
|
22374
|
+
x1: "7.5",
|
|
22375
|
+
y1: "0",
|
|
22376
|
+
x2: "7.5",
|
|
22377
|
+
y2: "15",
|
|
22378
|
+
gradientUnits: "userSpaceOnUse",
|
|
22379
|
+
children: [
|
|
22380
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "white" }),
|
|
22381
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
|
|
23152
22382
|
]
|
|
23153
22383
|
}
|
|
23154
|
-
|
|
23155
|
-
|
|
23156
|
-
|
|
23157
|
-
|
|
22384
|
+
) })
|
|
22385
|
+
]
|
|
22386
|
+
}
|
|
22387
|
+
);
|
|
23158
22388
|
};
|
|
23159
|
-
|
|
23160
|
-
|
|
23161
|
-
}) {
|
|
23162
|
-
const { customer, isPending } = useCustomer(customerId, void 0, {
|
|
23163
|
-
enabled: !!customerId
|
|
23164
|
-
});
|
|
23165
|
-
if (isPending || !customer) {
|
|
23166
|
-
return null;
|
|
23167
|
-
}
|
|
23168
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
23169
|
-
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Customer" }),
|
|
23170
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
23171
|
-
SidebarLink,
|
|
23172
|
-
{
|
|
23173
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {}),
|
|
23174
|
-
labelKey: customer.email || "N/A",
|
|
23175
|
-
descriptionKey: !customer.first_name && !customer.last_name ? "N/A" : `${customer.first_name} ${customer.last_name}`,
|
|
23176
|
-
to: `/customers/${customer.id}`
|
|
23177
|
-
},
|
|
23178
|
-
customer.id
|
|
23179
|
-
)
|
|
23180
|
-
] });
|
|
23181
|
-
}
|
|
23182
|
-
const columnHelper$8 = ui.createDataTableColumnHelper();
|
|
23183
|
-
const useTransactionsTableColumns = () => {
|
|
22389
|
+
const columnHelper$9 = ui.createDataTableColumnHelper();
|
|
22390
|
+
const useStoreCreditAccountTableColumns = () => {
|
|
23184
22391
|
return React.useMemo(() => {
|
|
23185
22392
|
return [
|
|
23186
|
-
columnHelper$
|
|
23187
|
-
header: "
|
|
22393
|
+
columnHelper$9.accessor("currency_code", {
|
|
22394
|
+
header: "Currency",
|
|
23188
22395
|
cell: ({ row }) => {
|
|
23189
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
22396
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { size: "2xsmall", children: row.original.currency_code.toUpperCase() });
|
|
23190
22397
|
}
|
|
23191
22398
|
}),
|
|
23192
|
-
columnHelper$
|
|
23193
|
-
header: "
|
|
23194
|
-
cell: ({ row }) =>
|
|
22399
|
+
columnHelper$9.accessor("customer.email", {
|
|
22400
|
+
header: "Customer",
|
|
22401
|
+
cell: ({ row }) => {
|
|
22402
|
+
var _a2;
|
|
22403
|
+
return ((_a2 = row.original.customer) == null ? void 0 : _a2.email) ?? "N/A";
|
|
22404
|
+
}
|
|
23195
22405
|
}),
|
|
23196
|
-
columnHelper$
|
|
23197
|
-
header: "
|
|
23198
|
-
cell: ({ row }) =>
|
|
22406
|
+
columnHelper$9.accessor("balance", {
|
|
22407
|
+
header: "Balance",
|
|
22408
|
+
cell: ({ row }) => {
|
|
22409
|
+
return formatAmount(
|
|
22410
|
+
row.original.balance,
|
|
22411
|
+
row.original.currency_code
|
|
22412
|
+
);
|
|
22413
|
+
}
|
|
23199
22414
|
}),
|
|
23200
|
-
columnHelper$
|
|
23201
|
-
header: "
|
|
22415
|
+
columnHelper$9.accessor("credits", {
|
|
22416
|
+
header: "Credits",
|
|
23202
22417
|
cell: ({ row }) => {
|
|
23203
|
-
return
|
|
22418
|
+
return formatAmount(
|
|
22419
|
+
row.original.credits,
|
|
22420
|
+
row.original.currency_code
|
|
22421
|
+
);
|
|
23204
22422
|
}
|
|
23205
22423
|
}),
|
|
23206
|
-
columnHelper$
|
|
23207
|
-
header: "
|
|
22424
|
+
columnHelper$9.accessor("debits", {
|
|
22425
|
+
header: "Debits",
|
|
23208
22426
|
cell: ({ row }) => {
|
|
23209
|
-
|
|
23210
|
-
|
|
23211
|
-
row.original.
|
|
23212
|
-
row.original.account.currency_code
|
|
22427
|
+
return formatAmount(
|
|
22428
|
+
row.original.debits,
|
|
22429
|
+
row.original.currency_code
|
|
23213
22430
|
);
|
|
23214
22431
|
}
|
|
22432
|
+
}),
|
|
22433
|
+
columnHelper$9.accessor("created_at", {
|
|
22434
|
+
header: "Created at",
|
|
22435
|
+
cell: ({ row }) => getRelativeDate(row.original.created_at)
|
|
23215
22436
|
})
|
|
23216
22437
|
];
|
|
23217
22438
|
}, []);
|
|
23218
22439
|
};
|
|
23219
|
-
const
|
|
22440
|
+
const useStoreCreditAccountFilters = () => {
|
|
23220
22441
|
const dateFilterOptions = useDataTableDateFilters$1();
|
|
22442
|
+
const customerFilterOptions = useCustomerFilters();
|
|
23221
22443
|
return React.useMemo(() => {
|
|
23222
|
-
return [...dateFilterOptions];
|
|
23223
|
-
}, [dateFilterOptions]);
|
|
22444
|
+
return [...dateFilterOptions, ...customerFilterOptions];
|
|
22445
|
+
}, [dateFilterOptions, customerFilterOptions]);
|
|
23224
22446
|
};
|
|
23225
|
-
const
|
|
22447
|
+
const useStoreCreditAccountsTableQuery = ({
|
|
23226
22448
|
prefix,
|
|
23227
22449
|
pageSize = 20
|
|
23228
22450
|
}) => {
|
|
23229
22451
|
const queryObject = useQueryParams(
|
|
23230
|
-
["offset", "
|
|
22452
|
+
["offset", "customer_id", "currency_code", "created_at", "updated_at"],
|
|
23231
22453
|
prefix
|
|
23232
22454
|
);
|
|
23233
|
-
const {
|
|
22455
|
+
const {
|
|
22456
|
+
offset: offset2,
|
|
22457
|
+
created_at,
|
|
22458
|
+
updated_at,
|
|
22459
|
+
customer_id,
|
|
22460
|
+
currency_code,
|
|
22461
|
+
...rest
|
|
22462
|
+
} = queryObject;
|
|
23234
22463
|
const searchParams = {
|
|
23235
|
-
limit:
|
|
22464
|
+
limit: pageSize,
|
|
23236
22465
|
offset: offset2 ? Number(offset2) : 0,
|
|
23237
22466
|
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
23238
22467
|
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
22468
|
+
customer_id: customer_id ? JSON.parse(customer_id) : void 0,
|
|
22469
|
+
currency_code: currency_code ? JSON.parse(currency_code) : void 0,
|
|
23239
22470
|
...rest
|
|
23240
22471
|
};
|
|
23241
22472
|
return searchParams;
|
|
23242
22473
|
};
|
|
23243
|
-
const PAGE_SIZE$
|
|
23244
|
-
function
|
|
23245
|
-
const queryParams =
|
|
23246
|
-
pageSize: PAGE_SIZE$
|
|
22474
|
+
const PAGE_SIZE$5 = 10;
|
|
22475
|
+
function StoreCreditAccountsTable() {
|
|
22476
|
+
const queryParams = useStoreCreditAccountsTableQuery({
|
|
22477
|
+
pageSize: PAGE_SIZE$5
|
|
23247
22478
|
});
|
|
23248
|
-
const {
|
|
23249
|
-
|
|
23250
|
-
|
|
23251
|
-
|
|
23252
|
-
|
|
23253
|
-
|
|
23254
|
-
|
|
23255
|
-
);
|
|
23256
|
-
const columns =
|
|
23257
|
-
const filters =
|
|
22479
|
+
const {
|
|
22480
|
+
store_credit_accounts: storeCreditAccounts,
|
|
22481
|
+
isPending,
|
|
22482
|
+
count: count2
|
|
22483
|
+
} = useStoreCreditAccounts({
|
|
22484
|
+
...queryParams,
|
|
22485
|
+
order: queryParams.order ?? "-created_at"
|
|
22486
|
+
});
|
|
22487
|
+
const columns = useStoreCreditAccountTableColumns();
|
|
22488
|
+
const filters = useStoreCreditAccountFilters();
|
|
23258
22489
|
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
23259
22490
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
23260
22491
|
DataTable,
|
|
23261
22492
|
{
|
|
23262
|
-
data:
|
|
22493
|
+
data: storeCreditAccounts ?? [],
|
|
23263
22494
|
getRowId: (row) => row.id,
|
|
23264
22495
|
columns,
|
|
23265
22496
|
filters,
|
|
23266
|
-
isLoading,
|
|
23267
|
-
pageSize: PAGE_SIZE$
|
|
22497
|
+
isLoading: isPending,
|
|
22498
|
+
pageSize: PAGE_SIZE$5,
|
|
23268
22499
|
rowCount: count2,
|
|
23269
22500
|
enableSearch: false,
|
|
23270
|
-
heading: "
|
|
22501
|
+
heading: "Store Credit Accounts",
|
|
22502
|
+
rowHref: (row) => `${row.id}`,
|
|
23271
22503
|
emptyState: {
|
|
23272
22504
|
empty: {
|
|
23273
|
-
heading: "No
|
|
22505
|
+
heading: "No store credit accounts found",
|
|
22506
|
+
description: "Create a new store credit account to get started."
|
|
23274
22507
|
},
|
|
23275
22508
|
filtered: {
|
|
23276
22509
|
heading: "No results found",
|
|
23277
|
-
description: "No
|
|
22510
|
+
description: "No store credit accounts match your filter criteria."
|
|
23278
22511
|
}
|
|
23279
|
-
}
|
|
22512
|
+
},
|
|
22513
|
+
actions: [
|
|
22514
|
+
{
|
|
22515
|
+
label: "Create",
|
|
22516
|
+
to: "/store-credit-accounts/create"
|
|
22517
|
+
}
|
|
22518
|
+
]
|
|
23280
22519
|
}
|
|
23281
22520
|
) }),
|
|
23282
22521
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
23283
22522
|
] });
|
|
23284
22523
|
}
|
|
23285
|
-
|
|
23286
|
-
|
|
23287
|
-
|
|
23288
|
-
|
|
23289
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
23290
|
-
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Account Code" }),
|
|
23291
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-4 px-6 mb-2", children: [
|
|
23292
|
-
/* @__PURE__ */ jsxRuntime.jsx(icons.Share, { className: "inline" }),
|
|
23293
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle text-sm", children: code })
|
|
23294
|
-
] })
|
|
22524
|
+
const StoreCreditAccountsPage = () => {
|
|
22525
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
22526
|
+
/* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountsTable, {}),
|
|
22527
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Toaster, {})
|
|
23295
22528
|
] });
|
|
22529
|
+
};
|
|
22530
|
+
const config$1 = adminSdk.defineRouteConfig({
|
|
22531
|
+
label: "Store Credits",
|
|
22532
|
+
icon: StoreCreditIcon
|
|
22533
|
+
});
|
|
22534
|
+
function isObject$5(value) {
|
|
22535
|
+
var type = typeof value;
|
|
22536
|
+
return value != null && (type == "object" || type == "function");
|
|
23296
22537
|
}
|
|
23297
|
-
|
|
23298
|
-
|
|
23299
|
-
|
|
23300
|
-
|
|
23301
|
-
|
|
23302
|
-
|
|
23303
|
-
|
|
22538
|
+
var isObject_1 = isObject$5;
|
|
22539
|
+
var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
22540
|
+
var _freeGlobal = freeGlobal$1;
|
|
22541
|
+
var freeGlobal = _freeGlobal;
|
|
22542
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
22543
|
+
var root$4 = freeGlobal || freeSelf || Function("return this")();
|
|
22544
|
+
var _root = root$4;
|
|
22545
|
+
var root$3 = _root;
|
|
22546
|
+
var now$1 = function() {
|
|
22547
|
+
return root$3.Date.now();
|
|
22548
|
+
};
|
|
22549
|
+
var now_1 = now$1;
|
|
22550
|
+
var reWhitespace = /\s/;
|
|
22551
|
+
function trimmedEndIndex$1(string2) {
|
|
22552
|
+
var index = string2.length;
|
|
22553
|
+
while (index-- && reWhitespace.test(string2.charAt(index))) {
|
|
23304
22554
|
}
|
|
23305
|
-
return
|
|
23306
|
-
|
|
23307
|
-
|
|
23308
|
-
|
|
23309
|
-
|
|
23310
|
-
|
|
23311
|
-
|
|
23312
|
-
|
|
23313
|
-
|
|
23314
|
-
|
|
23315
|
-
|
|
23316
|
-
|
|
23317
|
-
|
|
23318
|
-
|
|
23319
|
-
|
|
23320
|
-
|
|
23321
|
-
|
|
23322
|
-
|
|
23323
|
-
|
|
23324
|
-
|
|
23325
|
-
|
|
23326
|
-
|
|
23327
|
-
|
|
23328
|
-
|
|
23329
|
-
|
|
23330
|
-
|
|
23331
|
-
|
|
22555
|
+
return index;
|
|
22556
|
+
}
|
|
22557
|
+
var _trimmedEndIndex = trimmedEndIndex$1;
|
|
22558
|
+
var trimmedEndIndex = _trimmedEndIndex;
|
|
22559
|
+
var reTrimStart = /^\s+/;
|
|
22560
|
+
function baseTrim$1(string2) {
|
|
22561
|
+
return string2 ? string2.slice(0, trimmedEndIndex(string2) + 1).replace(reTrimStart, "") : string2;
|
|
22562
|
+
}
|
|
22563
|
+
var _baseTrim = baseTrim$1;
|
|
22564
|
+
var root$2 = _root;
|
|
22565
|
+
var Symbol$4 = root$2.Symbol;
|
|
22566
|
+
var _Symbol = Symbol$4;
|
|
22567
|
+
var Symbol$3 = _Symbol;
|
|
22568
|
+
var objectProto$5 = Object.prototype;
|
|
22569
|
+
var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
|
|
22570
|
+
var nativeObjectToString$1 = objectProto$5.toString;
|
|
22571
|
+
var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
|
|
22572
|
+
function getRawTag$1(value) {
|
|
22573
|
+
var isOwn = hasOwnProperty$4.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
22574
|
+
try {
|
|
22575
|
+
value[symToStringTag$1] = void 0;
|
|
22576
|
+
var unmasked = true;
|
|
22577
|
+
} catch (e2) {
|
|
22578
|
+
}
|
|
22579
|
+
var result = nativeObjectToString$1.call(value);
|
|
22580
|
+
if (unmasked) {
|
|
22581
|
+
if (isOwn) {
|
|
22582
|
+
value[symToStringTag$1] = tag;
|
|
22583
|
+
} else {
|
|
22584
|
+
delete value[symToStringTag$1];
|
|
23332
22585
|
}
|
|
23333
|
-
|
|
23334
|
-
|
|
23335
|
-
|
|
23336
|
-
|
|
23337
|
-
|
|
23338
|
-
|
|
23339
|
-
|
|
23340
|
-
|
|
23341
|
-
|
|
23342
|
-
|
|
23343
|
-
|
|
22586
|
+
}
|
|
22587
|
+
return result;
|
|
22588
|
+
}
|
|
22589
|
+
var _getRawTag = getRawTag$1;
|
|
22590
|
+
var objectProto$4 = Object.prototype;
|
|
22591
|
+
var nativeObjectToString = objectProto$4.toString;
|
|
22592
|
+
function objectToString$1(value) {
|
|
22593
|
+
return nativeObjectToString.call(value);
|
|
22594
|
+
}
|
|
22595
|
+
var _objectToString = objectToString$1;
|
|
22596
|
+
var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
|
|
22597
|
+
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
|
|
22598
|
+
var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
|
|
22599
|
+
function baseGetTag$2(value) {
|
|
22600
|
+
if (value == null) {
|
|
22601
|
+
return value === void 0 ? undefinedTag : nullTag;
|
|
22602
|
+
}
|
|
22603
|
+
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
22604
|
+
}
|
|
22605
|
+
var _baseGetTag = baseGetTag$2;
|
|
22606
|
+
function isObjectLike$1(value) {
|
|
22607
|
+
return value != null && typeof value == "object";
|
|
22608
|
+
}
|
|
22609
|
+
var isObjectLike_1 = isObjectLike$1;
|
|
22610
|
+
var baseGetTag$1 = _baseGetTag, isObjectLike = isObjectLike_1;
|
|
22611
|
+
var symbolTag = "[object Symbol]";
|
|
22612
|
+
function isSymbol$4(value) {
|
|
22613
|
+
return typeof value == "symbol" || isObjectLike(value) && baseGetTag$1(value) == symbolTag;
|
|
22614
|
+
}
|
|
22615
|
+
var isSymbol_1 = isSymbol$4;
|
|
22616
|
+
var baseTrim = _baseTrim, isObject$4 = isObject_1, isSymbol$3 = isSymbol_1;
|
|
22617
|
+
var NAN = 0 / 0;
|
|
22618
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
22619
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
22620
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
22621
|
+
var freeParseInt = parseInt;
|
|
22622
|
+
function toNumber$1(value) {
|
|
22623
|
+
if (typeof value == "number") {
|
|
22624
|
+
return value;
|
|
22625
|
+
}
|
|
22626
|
+
if (isSymbol$3(value)) {
|
|
22627
|
+
return NAN;
|
|
22628
|
+
}
|
|
22629
|
+
if (isObject$4(value)) {
|
|
22630
|
+
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
22631
|
+
value = isObject$4(other) ? other + "" : other;
|
|
22632
|
+
}
|
|
22633
|
+
if (typeof value != "string") {
|
|
22634
|
+
return value === 0 ? value : +value;
|
|
22635
|
+
}
|
|
22636
|
+
value = baseTrim(value);
|
|
22637
|
+
var isBinary = reIsBinary.test(value);
|
|
22638
|
+
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
|
22639
|
+
}
|
|
22640
|
+
var toNumber_1 = toNumber$1;
|
|
22641
|
+
var isObject$3 = isObject_1, now = now_1, toNumber = toNumber_1;
|
|
22642
|
+
var FUNC_ERROR_TEXT$1 = "Expected a function";
|
|
22643
|
+
var nativeMax = Math.max, nativeMin = Math.min;
|
|
22644
|
+
function debounce$2(func, wait, options) {
|
|
22645
|
+
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
22646
|
+
if (typeof func != "function") {
|
|
22647
|
+
throw new TypeError(FUNC_ERROR_TEXT$1);
|
|
22648
|
+
}
|
|
22649
|
+
wait = toNumber(wait) || 0;
|
|
22650
|
+
if (isObject$3(options)) {
|
|
22651
|
+
leading = !!options.leading;
|
|
22652
|
+
maxing = "maxWait" in options;
|
|
22653
|
+
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
22654
|
+
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
22655
|
+
}
|
|
22656
|
+
function invokeFunc(time2) {
|
|
22657
|
+
var args = lastArgs, thisArg = lastThis;
|
|
22658
|
+
lastArgs = lastThis = void 0;
|
|
22659
|
+
lastInvokeTime = time2;
|
|
22660
|
+
result = func.apply(thisArg, args);
|
|
22661
|
+
return result;
|
|
22662
|
+
}
|
|
22663
|
+
function leadingEdge(time2) {
|
|
22664
|
+
lastInvokeTime = time2;
|
|
22665
|
+
timerId = setTimeout(timerExpired, wait);
|
|
22666
|
+
return leading ? invokeFunc(time2) : result;
|
|
22667
|
+
}
|
|
22668
|
+
function remainingWait(time2) {
|
|
22669
|
+
var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
|
|
22670
|
+
return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
|
|
22671
|
+
}
|
|
22672
|
+
function shouldInvoke(time2) {
|
|
22673
|
+
var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime;
|
|
22674
|
+
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
|
22675
|
+
}
|
|
22676
|
+
function timerExpired() {
|
|
22677
|
+
var time2 = now();
|
|
22678
|
+
if (shouldInvoke(time2)) {
|
|
22679
|
+
return trailingEdge(time2);
|
|
22680
|
+
}
|
|
22681
|
+
timerId = setTimeout(timerExpired, remainingWait(time2));
|
|
22682
|
+
}
|
|
22683
|
+
function trailingEdge(time2) {
|
|
22684
|
+
timerId = void 0;
|
|
22685
|
+
if (trailing && lastArgs) {
|
|
22686
|
+
return invokeFunc(time2);
|
|
22687
|
+
}
|
|
22688
|
+
lastArgs = lastThis = void 0;
|
|
22689
|
+
return result;
|
|
22690
|
+
}
|
|
22691
|
+
function cancel() {
|
|
22692
|
+
if (timerId !== void 0) {
|
|
22693
|
+
clearTimeout(timerId);
|
|
22694
|
+
}
|
|
22695
|
+
lastInvokeTime = 0;
|
|
22696
|
+
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
|
22697
|
+
}
|
|
22698
|
+
function flush() {
|
|
22699
|
+
return timerId === void 0 ? result : trailingEdge(now());
|
|
22700
|
+
}
|
|
22701
|
+
function debounced() {
|
|
22702
|
+
var time2 = now(), isInvoking = shouldInvoke(time2);
|
|
22703
|
+
lastArgs = arguments;
|
|
22704
|
+
lastThis = this;
|
|
22705
|
+
lastCallTime = time2;
|
|
22706
|
+
if (isInvoking) {
|
|
22707
|
+
if (timerId === void 0) {
|
|
22708
|
+
return leadingEdge(lastCallTime);
|
|
23344
22709
|
}
|
|
23345
|
-
|
|
23346
|
-
|
|
23347
|
-
|
|
22710
|
+
if (maxing) {
|
|
22711
|
+
clearTimeout(timerId);
|
|
22712
|
+
timerId = setTimeout(timerExpired, wait);
|
|
22713
|
+
return invokeFunc(lastCallTime);
|
|
23348
22714
|
}
|
|
23349
22715
|
}
|
|
23350
|
-
|
|
23351
|
-
|
|
23352
|
-
"form",
|
|
23353
|
-
{
|
|
23354
|
-
...rest,
|
|
23355
|
-
onSubmit: handleSubmit,
|
|
23356
|
-
onKeyDown: onKeyDown ?? handleKeyDown,
|
|
23357
|
-
ref
|
|
22716
|
+
if (timerId === void 0) {
|
|
22717
|
+
timerId = setTimeout(timerExpired, wait);
|
|
23358
22718
|
}
|
|
23359
|
-
|
|
23360
|
-
});
|
|
23361
|
-
KeyboundForm.displayName = "KeyboundForm";
|
|
23362
|
-
const Note$1 = () => {
|
|
23363
|
-
const { id } = reactRouterDom.useParams();
|
|
23364
|
-
const {
|
|
23365
|
-
store_credit_account: storeCreditAccount,
|
|
23366
|
-
isPending,
|
|
23367
|
-
isError,
|
|
23368
|
-
error
|
|
23369
|
-
} = useStoreCreditAccount(id, {});
|
|
23370
|
-
if (isError) {
|
|
23371
|
-
throw error;
|
|
22719
|
+
return result;
|
|
23372
22720
|
}
|
|
23373
|
-
|
|
23374
|
-
|
|
23375
|
-
|
|
23376
|
-
|
|
23377
|
-
|
|
23378
|
-
|
|
23379
|
-
|
|
23380
|
-
]
|
|
22721
|
+
debounced.cancel = cancel;
|
|
22722
|
+
debounced.flush = flush;
|
|
22723
|
+
return debounced;
|
|
22724
|
+
}
|
|
22725
|
+
var debounce_1 = debounce$2;
|
|
22726
|
+
const debounce$1 = /* @__PURE__ */ getDefaultExportFromCjs(debounce_1);
|
|
22727
|
+
const useDebouncedSearch = () => {
|
|
22728
|
+
const [searchValue, onSearchValueChange] = React.useState("");
|
|
22729
|
+
const [debouncedQuery, setDebouncedQuery] = React.useState("");
|
|
22730
|
+
const debouncedUpdate = React.useCallback(
|
|
22731
|
+
debounce$1((query) => setDebouncedQuery(query), 300),
|
|
22732
|
+
[]
|
|
22733
|
+
);
|
|
22734
|
+
React.useEffect(() => {
|
|
22735
|
+
debouncedUpdate(searchValue);
|
|
22736
|
+
return () => debouncedUpdate.cancel();
|
|
22737
|
+
}, [searchValue, debouncedUpdate]);
|
|
22738
|
+
return {
|
|
22739
|
+
searchValue,
|
|
22740
|
+
onSearchValueChange,
|
|
22741
|
+
query: debouncedQuery || void 0
|
|
22742
|
+
};
|
|
23381
22743
|
};
|
|
23382
|
-
const
|
|
23383
|
-
|
|
22744
|
+
const useComboboxData = ({
|
|
22745
|
+
queryKey,
|
|
22746
|
+
queryFn,
|
|
22747
|
+
getOptions,
|
|
22748
|
+
defaultValue: defaultValue2,
|
|
22749
|
+
defaultValueKey,
|
|
22750
|
+
pageSize = 10
|
|
23384
22751
|
}) => {
|
|
22752
|
+
const { searchValue, onSearchValueChange, query } = useDebouncedSearch();
|
|
22753
|
+
const queryInitialDataBy = defaultValueKey || "id";
|
|
22754
|
+
const { data: initialData } = reactQuery.useQuery({
|
|
22755
|
+
queryKey,
|
|
22756
|
+
queryFn: async () => {
|
|
22757
|
+
return queryFn({
|
|
22758
|
+
[queryInitialDataBy]: defaultValue2,
|
|
22759
|
+
limit: Array.isArray(defaultValue2) ? defaultValue2.length : 1
|
|
22760
|
+
});
|
|
22761
|
+
},
|
|
22762
|
+
enabled: !!defaultValue2
|
|
22763
|
+
});
|
|
22764
|
+
const { data, ...rest } = reactQuery.useInfiniteQuery({
|
|
22765
|
+
queryKey: [...queryKey, query],
|
|
22766
|
+
queryFn: async ({ pageParam = 0 }) => {
|
|
22767
|
+
return await queryFn({
|
|
22768
|
+
q: query,
|
|
22769
|
+
limit: pageSize,
|
|
22770
|
+
offset: pageParam
|
|
22771
|
+
});
|
|
22772
|
+
},
|
|
22773
|
+
initialPageParam: 0,
|
|
22774
|
+
getNextPageParam: (lastPage) => {
|
|
22775
|
+
const moreItemsExist = lastPage.count > lastPage.offset + lastPage.limit;
|
|
22776
|
+
return moreItemsExist ? lastPage.offset + lastPage.limit : void 0;
|
|
22777
|
+
},
|
|
22778
|
+
placeholderData: reactQuery.keepPreviousData
|
|
22779
|
+
});
|
|
22780
|
+
const options = (data == null ? void 0 : data.pages.flatMap((page) => getOptions(page))) ?? [];
|
|
22781
|
+
const defaultOptions2 = initialData ? getOptions(initialData) : [];
|
|
22782
|
+
const disabled = !rest.isPending && !options.length && !searchValue;
|
|
22783
|
+
if (defaultValue2 && defaultOptions2.length && !searchValue) {
|
|
22784
|
+
defaultOptions2.forEach((option) => {
|
|
22785
|
+
if (!options.find((o2) => o2.value === option.value)) {
|
|
22786
|
+
options.unshift(option);
|
|
22787
|
+
}
|
|
22788
|
+
});
|
|
22789
|
+
}
|
|
22790
|
+
return {
|
|
22791
|
+
options,
|
|
22792
|
+
searchValue,
|
|
22793
|
+
onSearchValueChange,
|
|
22794
|
+
disabled,
|
|
22795
|
+
...rest
|
|
22796
|
+
};
|
|
22797
|
+
};
|
|
22798
|
+
const formSchema = zod.z.object({
|
|
22799
|
+
currency_code: zod.z.string().min(1, "Please select a currency"),
|
|
22800
|
+
customer_id: zod.z.string().optional()
|
|
22801
|
+
});
|
|
22802
|
+
const StoreCreditAccountCreateForm = () => {
|
|
22803
|
+
const { handleSuccess } = useRouteModal();
|
|
23385
22804
|
const form = useForm({
|
|
23386
22805
|
defaultValues: {
|
|
23387
|
-
|
|
23388
|
-
|
|
23389
|
-
value: ""
|
|
23390
|
-
},
|
|
23391
|
-
note: ""
|
|
22806
|
+
currency_code: "",
|
|
22807
|
+
customer_id: ""
|
|
23392
22808
|
},
|
|
23393
|
-
resolver: t(
|
|
22809
|
+
resolver: t(formSchema)
|
|
23394
22810
|
});
|
|
23395
|
-
const { mutateAsync, isPending } =
|
|
23396
|
-
|
|
23397
|
-
|
|
23398
|
-
|
|
23399
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
23400
|
-
if (data.amount.float <= 0) {
|
|
23401
|
-
form.setError("amount", { message: "Amount must be greater than 0" });
|
|
23402
|
-
return;
|
|
22811
|
+
const { mutateAsync: createStoreCreditAccount, isPending } = useCreateStoreCreditAccount();
|
|
22812
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
22813
|
+
if (!data.customer_id) {
|
|
22814
|
+
delete data.customer_id;
|
|
23403
22815
|
}
|
|
23404
|
-
await
|
|
23405
|
-
|
|
23406
|
-
|
|
23407
|
-
|
|
23408
|
-
|
|
22816
|
+
await createStoreCreditAccount(data, {
|
|
22817
|
+
onSuccess: (data2) => {
|
|
22818
|
+
ui.toast.success(`Store credit account was successfully created.`);
|
|
22819
|
+
handleSuccess(`../${data2.store_credit_account.id}`);
|
|
22820
|
+
},
|
|
22821
|
+
onError: (error) => {
|
|
22822
|
+
ui.toast.error(error.message);
|
|
23409
22823
|
}
|
|
22824
|
+
});
|
|
22825
|
+
});
|
|
22826
|
+
const [currencySearchValue, setCurrencySearchValue] = React.useState("");
|
|
22827
|
+
const currencyOptions = React.useMemo(() => {
|
|
22828
|
+
const options = Object.values(currencies).map((currency) => ({
|
|
22829
|
+
label: `${currency.code} - ${currency.name} (${currency.symbol_native})`,
|
|
22830
|
+
value: currency.code.toLowerCase()
|
|
22831
|
+
}));
|
|
22832
|
+
if (!currencySearchValue) {
|
|
22833
|
+
return options;
|
|
22834
|
+
}
|
|
22835
|
+
return options.filter(
|
|
22836
|
+
(option) => option.label.toLowerCase().includes(currencySearchValue.toLowerCase())
|
|
23410
22837
|
);
|
|
22838
|
+
}, [currencySearchValue]);
|
|
22839
|
+
const {
|
|
22840
|
+
options: customerOptions,
|
|
22841
|
+
fetchNextPage,
|
|
22842
|
+
isFetchingNextPage,
|
|
22843
|
+
searchValue,
|
|
22844
|
+
onSearchValueChange,
|
|
22845
|
+
isLoading
|
|
22846
|
+
} = useComboboxData({
|
|
22847
|
+
queryKey: customersQueryKeys.list(),
|
|
22848
|
+
queryFn: async (params) => {
|
|
22849
|
+
return sdk.admin.customer.list(params);
|
|
22850
|
+
},
|
|
22851
|
+
getOptions: (data) => {
|
|
22852
|
+
var _a2;
|
|
22853
|
+
return ((_a2 = data.customers) == null ? void 0 : _a2.map((customer) => {
|
|
22854
|
+
const fullName = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
22855
|
+
const label = fullName ? `${customer.email} (${fullName})` : customer.email;
|
|
22856
|
+
return {
|
|
22857
|
+
label,
|
|
22858
|
+
value: customer.id
|
|
22859
|
+
};
|
|
22860
|
+
})) || [];
|
|
22861
|
+
}
|
|
23411
22862
|
});
|
|
23412
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
23413
|
-
|
|
23414
|
-
{
|
|
23415
|
-
className: "flex flex-
|
|
23416
|
-
|
|
23417
|
-
|
|
23418
|
-
|
|
23419
|
-
|
|
23420
|
-
|
|
23421
|
-
|
|
23422
|
-
|
|
23423
|
-
|
|
23424
|
-
|
|
23425
|
-
|
|
22863
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Form, { form, children: [
|
|
22864
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "-my-2 w-full border-l" }) }),
|
|
22865
|
+
/* @__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: [
|
|
22866
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
22867
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Create Store Credit Account" }),
|
|
22868
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", size: "small", children: "Create a new store credit account for a customer" })
|
|
22869
|
+
] }),
|
|
22870
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-x-4", children: [
|
|
22871
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
22872
|
+
Form$2.Field,
|
|
22873
|
+
{
|
|
22874
|
+
control: form.control,
|
|
22875
|
+
name: "currency_code",
|
|
22876
|
+
render: ({ field }) => {
|
|
22877
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
22878
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Currency" }),
|
|
23426
22879
|
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
23427
|
-
|
|
22880
|
+
Combobox,
|
|
23428
22881
|
{
|
|
23429
|
-
|
|
23430
|
-
|
|
23431
|
-
|
|
23432
|
-
|
|
23433
|
-
|
|
23434
|
-
|
|
23435
|
-
float: (values == null ? void 0 : values.float) || null
|
|
23436
|
-
});
|
|
23437
|
-
},
|
|
23438
|
-
symbol: currencies[storeCreditAccount.currency_code.toUpperCase()].symbol_native,
|
|
23439
|
-
code: storeCreditAccount.currency_code.toUpperCase()
|
|
22882
|
+
value: field.value,
|
|
22883
|
+
onChange: field.onChange,
|
|
22884
|
+
searchValue: currencySearchValue,
|
|
22885
|
+
onSearchValueChange: setCurrencySearchValue,
|
|
22886
|
+
options: currencyOptions,
|
|
22887
|
+
placeholder: "Search for a currency..."
|
|
23440
22888
|
}
|
|
23441
22889
|
) }),
|
|
23442
22890
|
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
23443
|
-
] })
|
|
22891
|
+
] });
|
|
23444
22892
|
}
|
|
23445
|
-
|
|
23446
|
-
|
|
23447
|
-
|
|
23448
|
-
|
|
23449
|
-
|
|
23450
|
-
|
|
23451
|
-
|
|
23452
|
-
|
|
23453
|
-
|
|
22893
|
+
}
|
|
22894
|
+
),
|
|
22895
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
22896
|
+
Form$2.Field,
|
|
22897
|
+
{
|
|
22898
|
+
control: form.control,
|
|
22899
|
+
name: "customer_id",
|
|
22900
|
+
render: ({ field }) => {
|
|
22901
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
22902
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Customer" }),
|
|
22903
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
22904
|
+
Combobox,
|
|
22905
|
+
{
|
|
22906
|
+
value: field.value,
|
|
22907
|
+
onChange: field.onChange,
|
|
22908
|
+
searchValue,
|
|
22909
|
+
onSearchValueChange,
|
|
22910
|
+
options: customerOptions,
|
|
22911
|
+
placeholder: "Search for a customer...",
|
|
22912
|
+
fetchNextPage,
|
|
22913
|
+
isFetchingNextPage,
|
|
22914
|
+
noResultsPlaceholder: isLoading ? "Loading customers..." : "No customers found"
|
|
22915
|
+
}
|
|
22916
|
+
) }),
|
|
23454
22917
|
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
23455
|
-
] })
|
|
22918
|
+
] });
|
|
23456
22919
|
}
|
|
23457
|
-
|
|
23458
|
-
|
|
23459
|
-
|
|
23460
|
-
|
|
23461
|
-
|
|
23462
|
-
|
|
23463
|
-
|
|
23464
|
-
|
|
23465
|
-
|
|
22920
|
+
}
|
|
22921
|
+
)
|
|
22922
|
+
] })
|
|
22923
|
+
] }) }) }),
|
|
22924
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Footer, { children: [
|
|
22925
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, disabled: isPending, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", disabled: isPending, children: "Cancel" }) }),
|
|
22926
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
22927
|
+
ui.Button,
|
|
22928
|
+
{
|
|
22929
|
+
variant: "primary",
|
|
22930
|
+
size: "small",
|
|
22931
|
+
onClick: handleSubmit,
|
|
22932
|
+
disabled: isPending,
|
|
22933
|
+
children: "Create"
|
|
22934
|
+
}
|
|
22935
|
+
)
|
|
22936
|
+
] })
|
|
22937
|
+
] });
|
|
22938
|
+
};
|
|
22939
|
+
const StoreCreditAccountCreate = () => {
|
|
22940
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal, { children: [
|
|
22941
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create Store Credit Account" }) }),
|
|
22942
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create a new store credit account" }) }),
|
|
22943
|
+
/* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCreateForm, {})
|
|
22944
|
+
] });
|
|
23466
22945
|
};
|
|
23467
|
-
const schema$2 = zod.z.object({
|
|
23468
|
-
note: zod.z.string(),
|
|
23469
|
-
amount: zod.z.object({
|
|
23470
|
-
float: zod.z.number(),
|
|
23471
|
-
value: zod.z.string()
|
|
23472
|
-
})
|
|
23473
|
-
});
|
|
23474
22946
|
function _extends() {
|
|
23475
22947
|
return _extends = Object.assign ? Object.assign.bind() : function(n2) {
|
|
23476
22948
|
for (var e2 = 1; e2 < arguments.length; e2++) {
|
|
@@ -26151,6 +25623,243 @@ const GiftCardOrderSection = ({ giftCard }) => {
|
|
|
26151
25623
|
))
|
|
26152
25624
|
] });
|
|
26153
25625
|
};
|
|
25626
|
+
var toggleSelection = function() {
|
|
25627
|
+
var selection = document.getSelection();
|
|
25628
|
+
if (!selection.rangeCount) {
|
|
25629
|
+
return function() {
|
|
25630
|
+
};
|
|
25631
|
+
}
|
|
25632
|
+
var active = document.activeElement;
|
|
25633
|
+
var ranges = [];
|
|
25634
|
+
for (var i2 = 0; i2 < selection.rangeCount; i2++) {
|
|
25635
|
+
ranges.push(selection.getRangeAt(i2));
|
|
25636
|
+
}
|
|
25637
|
+
switch (active.tagName.toUpperCase()) {
|
|
25638
|
+
// .toUpperCase handles XHTML
|
|
25639
|
+
case "INPUT":
|
|
25640
|
+
case "TEXTAREA":
|
|
25641
|
+
active.blur();
|
|
25642
|
+
break;
|
|
25643
|
+
default:
|
|
25644
|
+
active = null;
|
|
25645
|
+
break;
|
|
25646
|
+
}
|
|
25647
|
+
selection.removeAllRanges();
|
|
25648
|
+
return function() {
|
|
25649
|
+
selection.type === "Caret" && selection.removeAllRanges();
|
|
25650
|
+
if (!selection.rangeCount) {
|
|
25651
|
+
ranges.forEach(function(range) {
|
|
25652
|
+
selection.addRange(range);
|
|
25653
|
+
});
|
|
25654
|
+
}
|
|
25655
|
+
active && active.focus();
|
|
25656
|
+
};
|
|
25657
|
+
};
|
|
25658
|
+
var deselectCurrent = toggleSelection;
|
|
25659
|
+
var clipboardToIE11Formatting = {
|
|
25660
|
+
"text/plain": "Text",
|
|
25661
|
+
"text/html": "Url",
|
|
25662
|
+
"default": "Text"
|
|
25663
|
+
};
|
|
25664
|
+
var defaultMessage = "Copy to clipboard: #{key}, Enter";
|
|
25665
|
+
function format(message2) {
|
|
25666
|
+
var copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C";
|
|
25667
|
+
return message2.replace(/#{\s*key\s*}/g, copyKey);
|
|
25668
|
+
}
|
|
25669
|
+
function copy$2(text2, options) {
|
|
25670
|
+
var debug2, message2, reselectPrevious, range, selection, mark, success = false;
|
|
25671
|
+
if (!options) {
|
|
25672
|
+
options = {};
|
|
25673
|
+
}
|
|
25674
|
+
debug2 = options.debug || false;
|
|
25675
|
+
try {
|
|
25676
|
+
reselectPrevious = deselectCurrent();
|
|
25677
|
+
range = document.createRange();
|
|
25678
|
+
selection = document.getSelection();
|
|
25679
|
+
mark = document.createElement("span");
|
|
25680
|
+
mark.textContent = text2;
|
|
25681
|
+
mark.ariaHidden = "true";
|
|
25682
|
+
mark.style.all = "unset";
|
|
25683
|
+
mark.style.position = "fixed";
|
|
25684
|
+
mark.style.top = 0;
|
|
25685
|
+
mark.style.clip = "rect(0, 0, 0, 0)";
|
|
25686
|
+
mark.style.whiteSpace = "pre";
|
|
25687
|
+
mark.style.webkitUserSelect = "text";
|
|
25688
|
+
mark.style.MozUserSelect = "text";
|
|
25689
|
+
mark.style.msUserSelect = "text";
|
|
25690
|
+
mark.style.userSelect = "text";
|
|
25691
|
+
mark.addEventListener("copy", function(e2) {
|
|
25692
|
+
e2.stopPropagation();
|
|
25693
|
+
if (options.format) {
|
|
25694
|
+
e2.preventDefault();
|
|
25695
|
+
if (typeof e2.clipboardData === "undefined") {
|
|
25696
|
+
debug2 && console.warn("unable to use e.clipboardData");
|
|
25697
|
+
debug2 && console.warn("trying IE specific stuff");
|
|
25698
|
+
window.clipboardData.clearData();
|
|
25699
|
+
var format2 = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting["default"];
|
|
25700
|
+
window.clipboardData.setData(format2, text2);
|
|
25701
|
+
} else {
|
|
25702
|
+
e2.clipboardData.clearData();
|
|
25703
|
+
e2.clipboardData.setData(options.format, text2);
|
|
25704
|
+
}
|
|
25705
|
+
}
|
|
25706
|
+
if (options.onCopy) {
|
|
25707
|
+
e2.preventDefault();
|
|
25708
|
+
options.onCopy(e2.clipboardData);
|
|
25709
|
+
}
|
|
25710
|
+
});
|
|
25711
|
+
document.body.appendChild(mark);
|
|
25712
|
+
range.selectNodeContents(mark);
|
|
25713
|
+
selection.addRange(range);
|
|
25714
|
+
var successful = document.execCommand("copy");
|
|
25715
|
+
if (!successful) {
|
|
25716
|
+
throw new Error("copy command was unsuccessful");
|
|
25717
|
+
}
|
|
25718
|
+
success = true;
|
|
25719
|
+
} catch (err) {
|
|
25720
|
+
debug2 && console.error("unable to copy using execCommand: ", err);
|
|
25721
|
+
debug2 && console.warn("trying IE specific stuff");
|
|
25722
|
+
try {
|
|
25723
|
+
window.clipboardData.setData(options.format || "text", text2);
|
|
25724
|
+
options.onCopy && options.onCopy(window.clipboardData);
|
|
25725
|
+
success = true;
|
|
25726
|
+
} catch (err2) {
|
|
25727
|
+
debug2 && console.error("unable to copy using clipboardData: ", err2);
|
|
25728
|
+
debug2 && console.error("falling back to prompt");
|
|
25729
|
+
message2 = format("message" in options ? options.message : defaultMessage);
|
|
25730
|
+
window.prompt(message2, text2);
|
|
25731
|
+
}
|
|
25732
|
+
} finally {
|
|
25733
|
+
if (selection) {
|
|
25734
|
+
if (typeof selection.removeRange == "function") {
|
|
25735
|
+
selection.removeRange(range);
|
|
25736
|
+
} else {
|
|
25737
|
+
selection.removeAllRanges();
|
|
25738
|
+
}
|
|
25739
|
+
}
|
|
25740
|
+
if (mark) {
|
|
25741
|
+
document.body.removeChild(mark);
|
|
25742
|
+
}
|
|
25743
|
+
reselectPrevious();
|
|
25744
|
+
}
|
|
25745
|
+
return success;
|
|
25746
|
+
}
|
|
25747
|
+
var copyToClipboard = copy$2;
|
|
25748
|
+
const copy$1 = /* @__PURE__ */ getDefaultExportFromCjs(copyToClipboard);
|
|
25749
|
+
function DisplayId({ id, className }) {
|
|
25750
|
+
const [open, setOpen] = React.useState(false);
|
|
25751
|
+
const onClick = () => {
|
|
25752
|
+
copy$1(id);
|
|
25753
|
+
ui.toast.success("Copied to clipboard");
|
|
25754
|
+
};
|
|
25755
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { maxWidth: 260, content: id, open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { onClick, className: ui.clx("cursor-pointer", className), children: [
|
|
25756
|
+
"#",
|
|
25757
|
+
id.slice(-7)
|
|
25758
|
+
] }) });
|
|
25759
|
+
}
|
|
25760
|
+
const columnHelper$8 = ui.createDataTableColumnHelper();
|
|
25761
|
+
const useTransactionsTableColumns = () => {
|
|
25762
|
+
return React.useMemo(() => {
|
|
25763
|
+
return [
|
|
25764
|
+
columnHelper$8.accessor("id", {
|
|
25765
|
+
header: "ID",
|
|
25766
|
+
cell: ({ row }) => {
|
|
25767
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DisplayId, { id: row.original.id });
|
|
25768
|
+
}
|
|
25769
|
+
}),
|
|
25770
|
+
columnHelper$8.accessor("created_at", {
|
|
25771
|
+
header: "Created At",
|
|
25772
|
+
cell: ({ row }) => formatDate(row.original.created_at, false)
|
|
25773
|
+
}),
|
|
25774
|
+
columnHelper$8.accessor("note", {
|
|
25775
|
+
header: "Description",
|
|
25776
|
+
cell: ({ row }) => row.original.note
|
|
25777
|
+
}),
|
|
25778
|
+
columnHelper$8.accessor("note", {
|
|
25779
|
+
header: "Note",
|
|
25780
|
+
cell: ({ row }) => {
|
|
25781
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { title: row.original.note, className: "max-w-[300px] truncate", children: row.original.note || "-" });
|
|
25782
|
+
}
|
|
25783
|
+
}),
|
|
25784
|
+
columnHelper$8.accessor("amount", {
|
|
25785
|
+
header: "Amount",
|
|
25786
|
+
cell: ({ row }) => {
|
|
25787
|
+
const isDebit = row.original.type === "debit";
|
|
25788
|
+
return row.original.account.currency_code && formatAmount(
|
|
25789
|
+
row.original.amount * (isDebit ? -1 : 1),
|
|
25790
|
+
row.original.account.currency_code
|
|
25791
|
+
);
|
|
25792
|
+
}
|
|
25793
|
+
})
|
|
25794
|
+
];
|
|
25795
|
+
}, []);
|
|
25796
|
+
};
|
|
25797
|
+
const useTransactionsTableFilters = ({}) => {
|
|
25798
|
+
const dateFilterOptions = useDataTableDateFilters$1();
|
|
25799
|
+
return React.useMemo(() => {
|
|
25800
|
+
return [...dateFilterOptions];
|
|
25801
|
+
}, [dateFilterOptions]);
|
|
25802
|
+
};
|
|
25803
|
+
const useTransactionsTableQuery = ({
|
|
25804
|
+
prefix,
|
|
25805
|
+
pageSize = 20
|
|
25806
|
+
}) => {
|
|
25807
|
+
const queryObject = useQueryParams(
|
|
25808
|
+
["offset", "limit", "currency_code", "created_at", "updated_at"],
|
|
25809
|
+
prefix
|
|
25810
|
+
);
|
|
25811
|
+
const { offset: offset2, limit, created_at, updated_at, ...rest } = queryObject;
|
|
25812
|
+
const searchParams = {
|
|
25813
|
+
limit: limit ? Number(limit) : pageSize,
|
|
25814
|
+
offset: offset2 ? Number(offset2) : 0,
|
|
25815
|
+
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
25816
|
+
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
25817
|
+
...rest
|
|
25818
|
+
};
|
|
25819
|
+
return searchParams;
|
|
25820
|
+
};
|
|
25821
|
+
const PAGE_SIZE$4 = 10;
|
|
25822
|
+
function TransactionsTable({ id }) {
|
|
25823
|
+
const queryParams = useTransactionsTableQuery({
|
|
25824
|
+
pageSize: PAGE_SIZE$4
|
|
25825
|
+
});
|
|
25826
|
+
const { transactions, isLoading, count: count2 } = useStoreCreditAccountTransactions(
|
|
25827
|
+
id,
|
|
25828
|
+
{
|
|
25829
|
+
...queryParams,
|
|
25830
|
+
order: queryParams.order ?? "-created_at",
|
|
25831
|
+
fields: "*account"
|
|
25832
|
+
}
|
|
25833
|
+
);
|
|
25834
|
+
const columns = useTransactionsTableColumns();
|
|
25835
|
+
const filters = useTransactionsTableFilters({});
|
|
25836
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
25837
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
25838
|
+
DataTable,
|
|
25839
|
+
{
|
|
25840
|
+
data: transactions ?? [],
|
|
25841
|
+
getRowId: (row) => row.id,
|
|
25842
|
+
columns,
|
|
25843
|
+
filters,
|
|
25844
|
+
isLoading,
|
|
25845
|
+
pageSize: PAGE_SIZE$4,
|
|
25846
|
+
rowCount: count2,
|
|
25847
|
+
enableSearch: false,
|
|
25848
|
+
heading: "Transactions",
|
|
25849
|
+
emptyState: {
|
|
25850
|
+
empty: {
|
|
25851
|
+
heading: "No transactions found"
|
|
25852
|
+
},
|
|
25853
|
+
filtered: {
|
|
25854
|
+
heading: "No results found",
|
|
25855
|
+
description: "No transactions match your filter criteria."
|
|
25856
|
+
}
|
|
25857
|
+
}
|
|
25858
|
+
}
|
|
25859
|
+
) }),
|
|
25860
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
25861
|
+
] });
|
|
25862
|
+
}
|
|
26154
25863
|
const GiftCardTransactionsSection = ({
|
|
26155
25864
|
storeCreditAccount
|
|
26156
25865
|
}) => {
|
|
@@ -26198,6 +25907,33 @@ const GiftCardDetailsPage = () => {
|
|
|
26198
25907
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
26199
25908
|
] });
|
|
26200
25909
|
};
|
|
25910
|
+
const KeyboundForm = React__namespace.default.forwardRef(({ onSubmit, onKeyDown, ...rest }, ref) => {
|
|
25911
|
+
const handleSubmit = (event) => {
|
|
25912
|
+
event.preventDefault();
|
|
25913
|
+
onSubmit == null ? void 0 : onSubmit(event);
|
|
25914
|
+
};
|
|
25915
|
+
const handleKeyDown = (event) => {
|
|
25916
|
+
if (event.key === "Enter") {
|
|
25917
|
+
if (event.target instanceof HTMLTextAreaElement && !(event.metaKey || event.ctrlKey)) {
|
|
25918
|
+
return;
|
|
25919
|
+
}
|
|
25920
|
+
event.preventDefault();
|
|
25921
|
+
if (event.metaKey || event.ctrlKey) {
|
|
25922
|
+
handleSubmit(event);
|
|
25923
|
+
}
|
|
25924
|
+
}
|
|
25925
|
+
};
|
|
25926
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
25927
|
+
"form",
|
|
25928
|
+
{
|
|
25929
|
+
...rest,
|
|
25930
|
+
onSubmit: handleSubmit,
|
|
25931
|
+
onKeyDown: onKeyDown ?? handleKeyDown,
|
|
25932
|
+
ref
|
|
25933
|
+
}
|
|
25934
|
+
);
|
|
25935
|
+
});
|
|
25936
|
+
KeyboundForm.displayName = "KeyboundForm";
|
|
26201
25937
|
const GiftCardExpiration = () => {
|
|
26202
25938
|
const { id } = reactRouterDom.useParams();
|
|
26203
25939
|
const { gift_card: giftCard, isPending, isError, error } = useGiftCard(id);
|
|
@@ -26218,7 +25954,7 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
26218
25954
|
defaultValues: {
|
|
26219
25955
|
expires_at: giftCard.expires_at ? new Date(giftCard.expires_at) : null
|
|
26220
25956
|
},
|
|
26221
|
-
resolver: t(schema$
|
|
25957
|
+
resolver: t(schema$2)
|
|
26222
25958
|
});
|
|
26223
25959
|
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
26224
25960
|
const { handleSuccess } = useRouteModal();
|
|
@@ -26313,10 +26049,10 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
26313
26049
|
}
|
|
26314
26050
|
) });
|
|
26315
26051
|
};
|
|
26316
|
-
const schema$
|
|
26052
|
+
const schema$2 = zod.z.object({
|
|
26317
26053
|
expires_at: zod.z.date().nullish()
|
|
26318
26054
|
});
|
|
26319
|
-
const Note = () => {
|
|
26055
|
+
const Note$1 = () => {
|
|
26320
26056
|
const { id } = reactRouterDom.useParams();
|
|
26321
26057
|
const {
|
|
26322
26058
|
gift_card: giftCard,
|
|
@@ -26341,7 +26077,7 @@ const GiftCardNoteForm = ({ giftCard }) => {
|
|
|
26341
26077
|
defaultValues: {
|
|
26342
26078
|
note: giftCard.note ?? ""
|
|
26343
26079
|
},
|
|
26344
|
-
resolver: t(schema)
|
|
26080
|
+
resolver: t(schema$1)
|
|
26345
26081
|
});
|
|
26346
26082
|
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
26347
26083
|
const { handleSuccess } = useRouteModal();
|
|
@@ -26380,7 +26116,7 @@ const GiftCardNoteForm = ({ giftCard }) => {
|
|
|
26380
26116
|
}
|
|
26381
26117
|
) });
|
|
26382
26118
|
};
|
|
26383
|
-
const schema = zod.z.object({
|
|
26119
|
+
const schema$1 = zod.z.object({
|
|
26384
26120
|
note: zod.z.string().optional()
|
|
26385
26121
|
});
|
|
26386
26122
|
const columnHelper$7 = createColumnHelper();
|
|
@@ -39712,7 +39448,7 @@ const GiftCardProductCreate = () => {
|
|
|
39712
39448
|
isPending: isStorePending,
|
|
39713
39449
|
isError: isStoreError,
|
|
39714
39450
|
error: storeError
|
|
39715
|
-
} = useStore$
|
|
39451
|
+
} = useStore$2({
|
|
39716
39452
|
fields: "+default_sales_channel"
|
|
39717
39453
|
});
|
|
39718
39454
|
const {
|
|
@@ -39764,6 +39500,270 @@ const GiftCardProductCreate = () => {
|
|
|
39764
39500
|
)
|
|
39765
39501
|
] });
|
|
39766
39502
|
};
|
|
39503
|
+
const StoreCreditAccountBalanceSection = ({
|
|
39504
|
+
storeCreditAccount
|
|
39505
|
+
}) => {
|
|
39506
|
+
if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
|
|
39507
|
+
return;
|
|
39508
|
+
}
|
|
39509
|
+
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: [
|
|
39510
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-ui-tag-green-icon h-8 w-1 rounded-full" }),
|
|
39511
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
39512
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", size: "small", className: "text-ui-fg-subtle", children: "Current Balance" }),
|
|
39513
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
39514
|
+
ui.Text,
|
|
39515
|
+
{
|
|
39516
|
+
weight: "plus",
|
|
39517
|
+
size: "xlarge",
|
|
39518
|
+
className: "tabular-nums text-ui-fg-base",
|
|
39519
|
+
children: formatAmount(
|
|
39520
|
+
storeCreditAccount.balance,
|
|
39521
|
+
storeCreditAccount.currency_code
|
|
39522
|
+
)
|
|
39523
|
+
}
|
|
39524
|
+
)
|
|
39525
|
+
] })
|
|
39526
|
+
] }) });
|
|
39527
|
+
};
|
|
39528
|
+
const StoreCreditAccountDetailsSection = ({
|
|
39529
|
+
storeCreditAccount
|
|
39530
|
+
}) => {
|
|
39531
|
+
if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
|
|
39532
|
+
return;
|
|
39533
|
+
}
|
|
39534
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "flex justify-between gap-x-2 px-6 py-6", children: [
|
|
39535
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
39536
|
+
ui.Text,
|
|
39537
|
+
{
|
|
39538
|
+
weight: "plus",
|
|
39539
|
+
size: "xlarge",
|
|
39540
|
+
className: "text-ui-fg-base flex gap-x-4",
|
|
39541
|
+
children: [
|
|
39542
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
39543
|
+
/* @__PURE__ */ jsxRuntime.jsx(CreditCardIcon, { className: "inline" }),
|
|
39544
|
+
" "
|
|
39545
|
+
] }),
|
|
39546
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
39547
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle", children: [
|
|
39548
|
+
storeCreditAccount.currency_code.toUpperCase(),
|
|
39549
|
+
" Account"
|
|
39550
|
+
] }),
|
|
39551
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
39552
|
+
ui.Text,
|
|
39553
|
+
{
|
|
39554
|
+
weight: "regular",
|
|
39555
|
+
size: "small",
|
|
39556
|
+
className: "text-ui-fg-base flex gap-x-4",
|
|
39557
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(DisplayId, { id: storeCreditAccount.id })
|
|
39558
|
+
}
|
|
39559
|
+
) })
|
|
39560
|
+
] })
|
|
39561
|
+
]
|
|
39562
|
+
}
|
|
39563
|
+
),
|
|
39564
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-x-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
39565
|
+
ActionMenu,
|
|
39566
|
+
{
|
|
39567
|
+
groups: [
|
|
39568
|
+
{
|
|
39569
|
+
actions: [
|
|
39570
|
+
{
|
|
39571
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CreditCard, {}),
|
|
39572
|
+
label: "Credit the account",
|
|
39573
|
+
to: "credit"
|
|
39574
|
+
}
|
|
39575
|
+
]
|
|
39576
|
+
}
|
|
39577
|
+
]
|
|
39578
|
+
}
|
|
39579
|
+
) })
|
|
39580
|
+
] });
|
|
39581
|
+
};
|
|
39582
|
+
function StoreCreditAccountCustomerSection({
|
|
39583
|
+
customerId
|
|
39584
|
+
}) {
|
|
39585
|
+
const { customer, isPending } = useCustomer(customerId, void 0, {
|
|
39586
|
+
enabled: !!customerId
|
|
39587
|
+
});
|
|
39588
|
+
if (isPending || !customer) {
|
|
39589
|
+
return null;
|
|
39590
|
+
}
|
|
39591
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
39592
|
+
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Customer" }),
|
|
39593
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
39594
|
+
SidebarLink,
|
|
39595
|
+
{
|
|
39596
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {}),
|
|
39597
|
+
labelKey: customer.email || "N/A",
|
|
39598
|
+
descriptionKey: !customer.first_name && !customer.last_name ? "N/A" : `${customer.first_name} ${customer.last_name}`,
|
|
39599
|
+
to: `/customers/${customer.id}`
|
|
39600
|
+
},
|
|
39601
|
+
customer.id
|
|
39602
|
+
)
|
|
39603
|
+
] });
|
|
39604
|
+
}
|
|
39605
|
+
function StoreCreditAccountCodeSection({ code }) {
|
|
39606
|
+
if (!code) {
|
|
39607
|
+
return null;
|
|
39608
|
+
}
|
|
39609
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
39610
|
+
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Account Code" }),
|
|
39611
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-4 px-6 mb-2", children: [
|
|
39612
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Share, { className: "inline" }),
|
|
39613
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle text-sm", children: code })
|
|
39614
|
+
] })
|
|
39615
|
+
] });
|
|
39616
|
+
}
|
|
39617
|
+
const StoreCreditAccountPage = () => {
|
|
39618
|
+
const { id } = reactRouterDom.useParams();
|
|
39619
|
+
const { store_credit_account: storeCreditAccount } = useStoreCreditAccount(
|
|
39620
|
+
id
|
|
39621
|
+
);
|
|
39622
|
+
if (!storeCreditAccount) {
|
|
39623
|
+
return;
|
|
39624
|
+
}
|
|
39625
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
39626
|
+
TwoColumnLayout,
|
|
39627
|
+
{
|
|
39628
|
+
firstCol: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
39629
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
39630
|
+
StoreCreditAccountDetailsSection,
|
|
39631
|
+
{
|
|
39632
|
+
storeCreditAccount
|
|
39633
|
+
}
|
|
39634
|
+
),
|
|
39635
|
+
/* @__PURE__ */ jsxRuntime.jsx(TransactionsTable, { id: storeCreditAccount.id })
|
|
39636
|
+
] }),
|
|
39637
|
+
secondCol: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
39638
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
39639
|
+
StoreCreditAccountBalanceSection,
|
|
39640
|
+
{
|
|
39641
|
+
storeCreditAccount
|
|
39642
|
+
}
|
|
39643
|
+
),
|
|
39644
|
+
/* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCodeSection, { code: storeCreditAccount.code }),
|
|
39645
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
39646
|
+
StoreCreditAccountCustomerSection,
|
|
39647
|
+
{
|
|
39648
|
+
customerId: storeCreditAccount.customer_id
|
|
39649
|
+
}
|
|
39650
|
+
)
|
|
39651
|
+
] })
|
|
39652
|
+
}
|
|
39653
|
+
) });
|
|
39654
|
+
};
|
|
39655
|
+
const Note = () => {
|
|
39656
|
+
const { id } = reactRouterDom.useParams();
|
|
39657
|
+
const {
|
|
39658
|
+
store_credit_account: storeCreditAccount,
|
|
39659
|
+
isPending,
|
|
39660
|
+
isError,
|
|
39661
|
+
error
|
|
39662
|
+
} = useStoreCreditAccount(id, {});
|
|
39663
|
+
if (isError) {
|
|
39664
|
+
throw error;
|
|
39665
|
+
}
|
|
39666
|
+
const isReady = !isPending && !!storeCreditAccount;
|
|
39667
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
39668
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
39669
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Credit store credit account" }) }),
|
|
39670
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Credit the store credit account" }) })
|
|
39671
|
+
] }),
|
|
39672
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCreditForm, { storeCreditAccount })
|
|
39673
|
+
] });
|
|
39674
|
+
};
|
|
39675
|
+
const StoreCreditAccountCreditForm = ({
|
|
39676
|
+
storeCreditAccount
|
|
39677
|
+
}) => {
|
|
39678
|
+
const form = useForm({
|
|
39679
|
+
defaultValues: {
|
|
39680
|
+
amount: {
|
|
39681
|
+
float: 0,
|
|
39682
|
+
value: ""
|
|
39683
|
+
},
|
|
39684
|
+
note: ""
|
|
39685
|
+
},
|
|
39686
|
+
resolver: t(schema)
|
|
39687
|
+
});
|
|
39688
|
+
const { mutateAsync, isPending } = useCreditStoreCreditAccount(
|
|
39689
|
+
storeCreditAccount.id
|
|
39690
|
+
);
|
|
39691
|
+
const { handleSuccess } = useRouteModal();
|
|
39692
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
39693
|
+
if (data.amount.float <= 0) {
|
|
39694
|
+
form.setError("amount", { message: "Amount must be greater than 0" });
|
|
39695
|
+
return;
|
|
39696
|
+
}
|
|
39697
|
+
await mutateAsync(
|
|
39698
|
+
{ amount: data.amount.float, note: data.note },
|
|
39699
|
+
{
|
|
39700
|
+
onSuccess: () => handleSuccess(),
|
|
39701
|
+
onError: (error) => ui.toast.error(error.message)
|
|
39702
|
+
}
|
|
39703
|
+
);
|
|
39704
|
+
});
|
|
39705
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
39706
|
+
KeyboundForm,
|
|
39707
|
+
{
|
|
39708
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
39709
|
+
onSubmit,
|
|
39710
|
+
children: [
|
|
39711
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
39712
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
39713
|
+
Form$2.Field,
|
|
39714
|
+
{
|
|
39715
|
+
control: form.control,
|
|
39716
|
+
name: "amount",
|
|
39717
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
39718
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Amount" }),
|
|
39719
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
39720
|
+
ui.CurrencyInput,
|
|
39721
|
+
{
|
|
39722
|
+
min: 0,
|
|
39723
|
+
placeholder: "0",
|
|
39724
|
+
value: field.value.value,
|
|
39725
|
+
onValueChange: (_value, _name, values) => {
|
|
39726
|
+
field.onChange({
|
|
39727
|
+
value: values == null ? void 0 : values.value,
|
|
39728
|
+
float: (values == null ? void 0 : values.float) || null
|
|
39729
|
+
});
|
|
39730
|
+
},
|
|
39731
|
+
symbol: currencies[storeCreditAccount.currency_code.toUpperCase()].symbol_native,
|
|
39732
|
+
code: storeCreditAccount.currency_code.toUpperCase()
|
|
39733
|
+
}
|
|
39734
|
+
) }),
|
|
39735
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
39736
|
+
] })
|
|
39737
|
+
}
|
|
39738
|
+
),
|
|
39739
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
39740
|
+
Form$2.Field,
|
|
39741
|
+
{
|
|
39742
|
+
control: form.control,
|
|
39743
|
+
name: "note",
|
|
39744
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
39745
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
|
|
39746
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
|
|
39747
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
39748
|
+
] })
|
|
39749
|
+
}
|
|
39750
|
+
)
|
|
39751
|
+
] }),
|
|
39752
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
39753
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
39754
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
39755
|
+
] }) })
|
|
39756
|
+
]
|
|
39757
|
+
}
|
|
39758
|
+
) });
|
|
39759
|
+
};
|
|
39760
|
+
const schema = zod.z.object({
|
|
39761
|
+
note: zod.z.string(),
|
|
39762
|
+
amount: zod.z.object({
|
|
39763
|
+
float: zod.z.number(),
|
|
39764
|
+
value: zod.z.string()
|
|
39765
|
+
})
|
|
39766
|
+
});
|
|
39767
39767
|
const productStatusColor = (status) => {
|
|
39768
39768
|
switch (status) {
|
|
39769
39769
|
case "draft":
|
|
@@ -40239,6 +40239,153 @@ const ProductDetail = () => {
|
|
|
40239
40239
|
] });
|
|
40240
40240
|
};
|
|
40241
40241
|
const EditProductSchema$1 = zod.z.object({
|
|
40242
|
+
denominations: zod.z.array(
|
|
40243
|
+
zod.z.object({
|
|
40244
|
+
id: zod.z.string().optional(),
|
|
40245
|
+
value: zod.z.string().min(1),
|
|
40246
|
+
prices: zod.z.record(zod.z.string(), optionalFloat).optional()
|
|
40247
|
+
})
|
|
40248
|
+
).min(1)
|
|
40249
|
+
});
|
|
40250
|
+
const GiftCardProductEditDenominationsForm = ({
|
|
40251
|
+
product
|
|
40252
|
+
}) => {
|
|
40253
|
+
var _a2;
|
|
40254
|
+
const { handleSuccess } = useRouteModal();
|
|
40255
|
+
const form = useForm({
|
|
40256
|
+
defaultValues: {
|
|
40257
|
+
denominations: (_a2 = product.variants) == null ? void 0 : _a2.map((variant) => ({
|
|
40258
|
+
id: variant.id,
|
|
40259
|
+
value: variant.title
|
|
40260
|
+
}))
|
|
40261
|
+
},
|
|
40262
|
+
resolver: t(EditProductSchema$1)
|
|
40263
|
+
});
|
|
40264
|
+
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40265
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
40266
|
+
const optionValues = data.denominations.map(
|
|
40267
|
+
(denomination) => denomination.value
|
|
40268
|
+
);
|
|
40269
|
+
const options = [
|
|
40270
|
+
{
|
|
40271
|
+
title: "denomination",
|
|
40272
|
+
values: optionValues
|
|
40273
|
+
}
|
|
40274
|
+
];
|
|
40275
|
+
await mutateAsync(
|
|
40276
|
+
{
|
|
40277
|
+
options,
|
|
40278
|
+
variants: data.denominations.map((denomination) => ({
|
|
40279
|
+
id: denomination.id,
|
|
40280
|
+
title: denomination.value,
|
|
40281
|
+
manage_inventory: false,
|
|
40282
|
+
options: {
|
|
40283
|
+
denomination: denomination.value
|
|
40284
|
+
}
|
|
40285
|
+
}))
|
|
40286
|
+
},
|
|
40287
|
+
{
|
|
40288
|
+
onSuccess: () => {
|
|
40289
|
+
ui.toast.success(`Denominations updated successfully`);
|
|
40290
|
+
handleSuccess();
|
|
40291
|
+
},
|
|
40292
|
+
onError: (e2) => {
|
|
40293
|
+
ui.toast.error(e2.message);
|
|
40294
|
+
}
|
|
40295
|
+
}
|
|
40296
|
+
);
|
|
40297
|
+
});
|
|
40298
|
+
const {
|
|
40299
|
+
fields: denominationsFields,
|
|
40300
|
+
append: addDenomination,
|
|
40301
|
+
remove: removeDenomination
|
|
40302
|
+
} = useFieldArray({
|
|
40303
|
+
name: "denominations",
|
|
40304
|
+
control: form.control
|
|
40305
|
+
});
|
|
40306
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
40307
|
+
KeyboundForm,
|
|
40308
|
+
{
|
|
40309
|
+
onSubmit: handleSubmit,
|
|
40310
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
40311
|
+
children: [
|
|
40312
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
40313
|
+
denominationsFields.map((denominationField, index) => {
|
|
40314
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
40315
|
+
"div",
|
|
40316
|
+
{
|
|
40317
|
+
className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg flex items-center justify-between rounded-md px-4 py-2",
|
|
40318
|
+
children: [
|
|
40319
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40320
|
+
Form$2.Field,
|
|
40321
|
+
{
|
|
40322
|
+
control: form.control,
|
|
40323
|
+
name: `denominations.${index}.value`,
|
|
40324
|
+
render: ({ field }) => {
|
|
40325
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
40326
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field, placeholder: "100" }) }),
|
|
40327
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
40328
|
+
] });
|
|
40329
|
+
}
|
|
40330
|
+
},
|
|
40331
|
+
denominationField.id
|
|
40332
|
+
),
|
|
40333
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
40334
|
+
ui.Button,
|
|
40335
|
+
{
|
|
40336
|
+
size: "small",
|
|
40337
|
+
variant: "secondary",
|
|
40338
|
+
type: "button",
|
|
40339
|
+
className: "ml-4 rounded-full p-0",
|
|
40340
|
+
onClick: () => {
|
|
40341
|
+
removeDenomination(index);
|
|
40342
|
+
},
|
|
40343
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XCircleSolid, { className: "rounded-full" })
|
|
40344
|
+
}
|
|
40345
|
+
) })
|
|
40346
|
+
]
|
|
40347
|
+
},
|
|
40348
|
+
denominationField.id
|
|
40349
|
+
);
|
|
40350
|
+
}),
|
|
40351
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40352
|
+
ui.Button,
|
|
40353
|
+
{
|
|
40354
|
+
size: "small",
|
|
40355
|
+
variant: "secondary",
|
|
40356
|
+
type: "button",
|
|
40357
|
+
className: "w-full",
|
|
40358
|
+
onClick: () => {
|
|
40359
|
+
addDenomination({ value: "", prices: {} });
|
|
40360
|
+
},
|
|
40361
|
+
children: "Add denomination"
|
|
40362
|
+
}
|
|
40363
|
+
),
|
|
40364
|
+
form.formState.errors.denominations && /* @__PURE__ */ jsxRuntime.jsx(ui.Alert, { variant: "error", children: "Please add at least one denomination." })
|
|
40365
|
+
] }) }) }) }),
|
|
40366
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
40367
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
40368
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
40369
|
+
] }) })
|
|
40370
|
+
]
|
|
40371
|
+
}
|
|
40372
|
+
) });
|
|
40373
|
+
};
|
|
40374
|
+
const GiftCardProductEdit$1 = () => {
|
|
40375
|
+
const { id } = reactRouterDom.useParams();
|
|
40376
|
+
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40377
|
+
if (isError) {
|
|
40378
|
+
throw error;
|
|
40379
|
+
}
|
|
40380
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
40381
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
40382
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift cards denominations" }) }),
|
|
40383
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
|
|
40384
|
+
] }),
|
|
40385
|
+
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditDenominationsForm, { product })
|
|
40386
|
+
] });
|
|
40387
|
+
};
|
|
40388
|
+
const EditProductSchema = zod.z.object({
|
|
40242
40389
|
status: zod.z.enum(["draft", "published", "proposed", "rejected"]),
|
|
40243
40390
|
title: zod.z.string().min(1),
|
|
40244
40391
|
subtitle: zod.z.string().optional(),
|
|
@@ -40257,7 +40404,7 @@ const GiftCardProductEditForm = ({
|
|
|
40257
40404
|
handle: product.handle || "",
|
|
40258
40405
|
description: product.description || ""
|
|
40259
40406
|
},
|
|
40260
|
-
resolver: t(EditProductSchema
|
|
40407
|
+
resolver: t(EditProductSchema)
|
|
40261
40408
|
});
|
|
40262
40409
|
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40263
40410
|
const handleSubmit = form.handleSubmit(async (data) => {
|
|
@@ -40398,7 +40545,7 @@ const GiftCardProductEditForm = ({
|
|
|
40398
40545
|
}
|
|
40399
40546
|
) });
|
|
40400
40547
|
};
|
|
40401
|
-
const GiftCardProductEdit
|
|
40548
|
+
const GiftCardProductEdit = () => {
|
|
40402
40549
|
const { id } = reactRouterDom.useParams();
|
|
40403
40550
|
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40404
40551
|
if (isError) {
|
|
@@ -40412,153 +40559,6 @@ const GiftCardProductEdit$1 = () => {
|
|
|
40412
40559
|
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditForm, { product })
|
|
40413
40560
|
] });
|
|
40414
40561
|
};
|
|
40415
|
-
const EditProductSchema = zod.z.object({
|
|
40416
|
-
denominations: zod.z.array(
|
|
40417
|
-
zod.z.object({
|
|
40418
|
-
id: zod.z.string().optional(),
|
|
40419
|
-
value: zod.z.string().min(1),
|
|
40420
|
-
prices: zod.z.record(zod.z.string(), optionalFloat).optional()
|
|
40421
|
-
})
|
|
40422
|
-
).min(1)
|
|
40423
|
-
});
|
|
40424
|
-
const GiftCardProductEditDenominationsForm = ({
|
|
40425
|
-
product
|
|
40426
|
-
}) => {
|
|
40427
|
-
var _a2;
|
|
40428
|
-
const { handleSuccess } = useRouteModal();
|
|
40429
|
-
const form = useForm({
|
|
40430
|
-
defaultValues: {
|
|
40431
|
-
denominations: (_a2 = product.variants) == null ? void 0 : _a2.map((variant) => ({
|
|
40432
|
-
id: variant.id,
|
|
40433
|
-
value: variant.title
|
|
40434
|
-
}))
|
|
40435
|
-
},
|
|
40436
|
-
resolver: t(EditProductSchema)
|
|
40437
|
-
});
|
|
40438
|
-
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
40439
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
40440
|
-
const optionValues = data.denominations.map(
|
|
40441
|
-
(denomination) => denomination.value
|
|
40442
|
-
);
|
|
40443
|
-
const options = [
|
|
40444
|
-
{
|
|
40445
|
-
title: "denomination",
|
|
40446
|
-
values: optionValues
|
|
40447
|
-
}
|
|
40448
|
-
];
|
|
40449
|
-
await mutateAsync(
|
|
40450
|
-
{
|
|
40451
|
-
options,
|
|
40452
|
-
variants: data.denominations.map((denomination) => ({
|
|
40453
|
-
id: denomination.id,
|
|
40454
|
-
title: denomination.value,
|
|
40455
|
-
manage_inventory: false,
|
|
40456
|
-
options: {
|
|
40457
|
-
denomination: denomination.value
|
|
40458
|
-
}
|
|
40459
|
-
}))
|
|
40460
|
-
},
|
|
40461
|
-
{
|
|
40462
|
-
onSuccess: () => {
|
|
40463
|
-
ui.toast.success(`Denominations updated successfully`);
|
|
40464
|
-
handleSuccess();
|
|
40465
|
-
},
|
|
40466
|
-
onError: (e2) => {
|
|
40467
|
-
ui.toast.error(e2.message);
|
|
40468
|
-
}
|
|
40469
|
-
}
|
|
40470
|
-
);
|
|
40471
|
-
});
|
|
40472
|
-
const {
|
|
40473
|
-
fields: denominationsFields,
|
|
40474
|
-
append: addDenomination,
|
|
40475
|
-
remove: removeDenomination
|
|
40476
|
-
} = useFieldArray({
|
|
40477
|
-
name: "denominations",
|
|
40478
|
-
control: form.control
|
|
40479
|
-
});
|
|
40480
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
40481
|
-
KeyboundForm,
|
|
40482
|
-
{
|
|
40483
|
-
onSubmit: handleSubmit,
|
|
40484
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
40485
|
-
children: [
|
|
40486
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
40487
|
-
denominationsFields.map((denominationField, index) => {
|
|
40488
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
40489
|
-
"div",
|
|
40490
|
-
{
|
|
40491
|
-
className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg flex items-center justify-between rounded-md px-4 py-2",
|
|
40492
|
-
children: [
|
|
40493
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40494
|
-
Form$2.Field,
|
|
40495
|
-
{
|
|
40496
|
-
control: form.control,
|
|
40497
|
-
name: `denominations.${index}.value`,
|
|
40498
|
-
render: ({ field }) => {
|
|
40499
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
40500
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field, placeholder: "100" }) }),
|
|
40501
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
40502
|
-
] });
|
|
40503
|
-
}
|
|
40504
|
-
},
|
|
40505
|
-
denominationField.id
|
|
40506
|
-
),
|
|
40507
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
40508
|
-
ui.Button,
|
|
40509
|
-
{
|
|
40510
|
-
size: "small",
|
|
40511
|
-
variant: "secondary",
|
|
40512
|
-
type: "button",
|
|
40513
|
-
className: "ml-4 rounded-full p-0",
|
|
40514
|
-
onClick: () => {
|
|
40515
|
-
removeDenomination(index);
|
|
40516
|
-
},
|
|
40517
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XCircleSolid, { className: "rounded-full" })
|
|
40518
|
-
}
|
|
40519
|
-
) })
|
|
40520
|
-
]
|
|
40521
|
-
},
|
|
40522
|
-
denominationField.id
|
|
40523
|
-
);
|
|
40524
|
-
}),
|
|
40525
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40526
|
-
ui.Button,
|
|
40527
|
-
{
|
|
40528
|
-
size: "small",
|
|
40529
|
-
variant: "secondary",
|
|
40530
|
-
type: "button",
|
|
40531
|
-
className: "w-full",
|
|
40532
|
-
onClick: () => {
|
|
40533
|
-
addDenomination({ value: "", prices: {} });
|
|
40534
|
-
},
|
|
40535
|
-
children: "Add denomination"
|
|
40536
|
-
}
|
|
40537
|
-
),
|
|
40538
|
-
form.formState.errors.denominations && /* @__PURE__ */ jsxRuntime.jsx(ui.Alert, { variant: "error", children: "Please add at least one denomination." })
|
|
40539
|
-
] }) }) }) }),
|
|
40540
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
40541
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
40542
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
40543
|
-
] }) })
|
|
40544
|
-
]
|
|
40545
|
-
}
|
|
40546
|
-
) });
|
|
40547
|
-
};
|
|
40548
|
-
const GiftCardProductEdit = () => {
|
|
40549
|
-
const { id } = reactRouterDom.useParams();
|
|
40550
|
-
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
40551
|
-
if (isError) {
|
|
40552
|
-
throw error;
|
|
40553
|
-
}
|
|
40554
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
40555
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
40556
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift cards denominations" }) }),
|
|
40557
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
|
|
40558
|
-
] }),
|
|
40559
|
-
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditDenominationsForm, { product })
|
|
40560
|
-
] });
|
|
40561
|
-
};
|
|
40562
40562
|
const EditProductMediaForm = ({ product }) => {
|
|
40563
40563
|
const [selection, setSelection] = React.useState({});
|
|
40564
40564
|
const { handleSuccess } = useRouteModal();
|
|
@@ -41172,114 +41172,8 @@ const ProductMedia = () => {
|
|
|
41172
41172
|
ready && /* @__PURE__ */ jsxRuntime.jsx(ProductMediaView, { product })
|
|
41173
41173
|
] });
|
|
41174
41174
|
};
|
|
41175
|
-
const EditSalesChannelsSchema = zod__namespace.object({
|
|
41176
|
-
sales_channels: zod__namespace.array(zod__namespace.string()).optional()
|
|
41177
|
-
});
|
|
41178
|
-
const PAGE_SIZE = 50;
|
|
41179
|
-
const PREFIX = "sc";
|
|
41180
|
-
const EditSalesChannelsForm = ({
|
|
41181
|
-
product
|
|
41182
|
-
}) => {
|
|
41183
|
-
var _a2, _b;
|
|
41184
|
-
const { handleSuccess } = useRouteModal();
|
|
41185
|
-
const form = useForm({
|
|
41186
|
-
defaultValues: {
|
|
41187
|
-
sales_channels: ((_a2 = product.sales_channels) == null ? void 0 : _a2.map((sc) => sc.id)) ?? []
|
|
41188
|
-
},
|
|
41189
|
-
resolver: t(EditSalesChannelsSchema)
|
|
41190
|
-
});
|
|
41191
|
-
const { setValue: setValue2 } = form;
|
|
41192
|
-
const initialState2 = ((_b = product.sales_channels) == null ? void 0 : _b.reduce((acc, curr) => {
|
|
41193
|
-
acc[curr.id] = true;
|
|
41194
|
-
return acc;
|
|
41195
|
-
}, {})) ?? {};
|
|
41196
|
-
const [rowSelection, setRowSelection] = React.useState(initialState2);
|
|
41197
|
-
React.useEffect(() => {
|
|
41198
|
-
const ids2 = Object.keys(rowSelection);
|
|
41199
|
-
setValue2("sales_channels", ids2, {
|
|
41200
|
-
shouldDirty: true,
|
|
41201
|
-
shouldTouch: true
|
|
41202
|
-
});
|
|
41203
|
-
}, [rowSelection, setValue2]);
|
|
41204
|
-
const searchParams = useSalesChannelTableQuery({
|
|
41205
|
-
pageSize: PAGE_SIZE,
|
|
41206
|
-
prefix: PREFIX
|
|
41207
|
-
});
|
|
41208
|
-
const { sales_channels, count: count2, isLoading, isError, error } = useSalesChannels(
|
|
41209
|
-
{
|
|
41210
|
-
...searchParams
|
|
41211
|
-
},
|
|
41212
|
-
{
|
|
41213
|
-
placeholderData: reactQuery.keepPreviousData
|
|
41214
|
-
}
|
|
41215
|
-
);
|
|
41216
|
-
const filters = useSalesChannelTableFilters();
|
|
41217
|
-
const emptyState = useSalesChannelTableEmptyState();
|
|
41218
|
-
const columns = useColumns();
|
|
41219
|
-
const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
|
|
41220
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
41221
|
-
const arr = data.sales_channels ?? [];
|
|
41222
|
-
const sales_channels2 = arr.map((id) => {
|
|
41223
|
-
return {
|
|
41224
|
-
id
|
|
41225
|
-
};
|
|
41226
|
-
});
|
|
41227
|
-
await mutateAsync(
|
|
41228
|
-
{
|
|
41229
|
-
sales_channels: sales_channels2
|
|
41230
|
-
},
|
|
41231
|
-
{
|
|
41232
|
-
onSuccess: () => {
|
|
41233
|
-
handleSuccess();
|
|
41234
|
-
}
|
|
41235
|
-
}
|
|
41236
|
-
);
|
|
41237
|
-
});
|
|
41238
|
-
if (isError) {
|
|
41239
|
-
throw error;
|
|
41240
|
-
}
|
|
41241
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
41242
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
41243
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
41244
|
-
DataTable,
|
|
41245
|
-
{
|
|
41246
|
-
data: sales_channels,
|
|
41247
|
-
columns,
|
|
41248
|
-
getRowId: (row) => row.id,
|
|
41249
|
-
rowCount: count2,
|
|
41250
|
-
isLoading,
|
|
41251
|
-
filters,
|
|
41252
|
-
rowSelection: {
|
|
41253
|
-
state: rowSelection,
|
|
41254
|
-
onRowSelectionChange: setRowSelection
|
|
41255
|
-
},
|
|
41256
|
-
autoFocusSearch: true,
|
|
41257
|
-
layout: "fill",
|
|
41258
|
-
emptyState,
|
|
41259
|
-
prefix: PREFIX
|
|
41260
|
-
}
|
|
41261
|
-
) }),
|
|
41262
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
41263
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
41264
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", isLoading: isMutating, onClick: handleSubmit, children: "Save" })
|
|
41265
|
-
] }) })
|
|
41266
|
-
] }) });
|
|
41267
|
-
};
|
|
41268
|
-
const columnHelper$1 = ui.createDataTableColumnHelper();
|
|
41269
|
-
const useColumns = () => {
|
|
41270
|
-
const columns = useSalesChannelTableColumns();
|
|
41271
|
-
return React.useMemo(() => [columnHelper$1.select(), ...columns], [columns]);
|
|
41272
|
-
};
|
|
41273
|
-
const ProductSalesChannels = () => {
|
|
41274
|
-
const { id } = reactRouterDom.useParams();
|
|
41275
|
-
const { product, isLoading, isError, error } = useProduct(id);
|
|
41276
|
-
if (isError) {
|
|
41277
|
-
throw error;
|
|
41278
|
-
}
|
|
41279
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(EditSalesChannelsForm, { product }) });
|
|
41280
|
-
};
|
|
41281
41175
|
const VariantPricingForm = ({ form }) => {
|
|
41282
|
-
const { store } = useStore$
|
|
41176
|
+
const { store } = useStore$2();
|
|
41283
41177
|
const { regions } = useRegions({ limit: 9999 });
|
|
41284
41178
|
const { price_preferences: pricePreferences } = usePricePreferences({});
|
|
41285
41179
|
const { setCloseOnEscape } = useRouteModal();
|
|
@@ -41302,7 +41196,7 @@ const VariantPricingForm = ({ form }) => {
|
|
|
41302
41196
|
}
|
|
41303
41197
|
);
|
|
41304
41198
|
};
|
|
41305
|
-
const columnHelper = createDataGridHelper();
|
|
41199
|
+
const columnHelper$1 = createDataGridHelper();
|
|
41306
41200
|
const useVariantPriceGridColumns = ({
|
|
41307
41201
|
currencies: currencies2 = [],
|
|
41308
41202
|
regions = [],
|
|
@@ -41310,7 +41204,7 @@ const useVariantPriceGridColumns = ({
|
|
|
41310
41204
|
}) => {
|
|
41311
41205
|
return React.useMemo(() => {
|
|
41312
41206
|
return [
|
|
41313
|
-
columnHelper.column({
|
|
41207
|
+
columnHelper$1.column({
|
|
41314
41208
|
id: "Title",
|
|
41315
41209
|
header: "Title",
|
|
41316
41210
|
cell: (context) => {
|
|
@@ -41436,6 +41330,112 @@ const ProductPrices = () => {
|
|
|
41436
41330
|
}
|
|
41437
41331
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(PricingEdit, { product, variantId: variant_id }) });
|
|
41438
41332
|
};
|
|
41333
|
+
const EditSalesChannelsSchema = zod__namespace.object({
|
|
41334
|
+
sales_channels: zod__namespace.array(zod__namespace.string()).optional()
|
|
41335
|
+
});
|
|
41336
|
+
const PAGE_SIZE = 50;
|
|
41337
|
+
const PREFIX = "sc";
|
|
41338
|
+
const EditSalesChannelsForm = ({
|
|
41339
|
+
product
|
|
41340
|
+
}) => {
|
|
41341
|
+
var _a2, _b;
|
|
41342
|
+
const { handleSuccess } = useRouteModal();
|
|
41343
|
+
const form = useForm({
|
|
41344
|
+
defaultValues: {
|
|
41345
|
+
sales_channels: ((_a2 = product.sales_channels) == null ? void 0 : _a2.map((sc) => sc.id)) ?? []
|
|
41346
|
+
},
|
|
41347
|
+
resolver: t(EditSalesChannelsSchema)
|
|
41348
|
+
});
|
|
41349
|
+
const { setValue: setValue2 } = form;
|
|
41350
|
+
const initialState2 = ((_b = product.sales_channels) == null ? void 0 : _b.reduce((acc, curr) => {
|
|
41351
|
+
acc[curr.id] = true;
|
|
41352
|
+
return acc;
|
|
41353
|
+
}, {})) ?? {};
|
|
41354
|
+
const [rowSelection, setRowSelection] = React.useState(initialState2);
|
|
41355
|
+
React.useEffect(() => {
|
|
41356
|
+
const ids2 = Object.keys(rowSelection);
|
|
41357
|
+
setValue2("sales_channels", ids2, {
|
|
41358
|
+
shouldDirty: true,
|
|
41359
|
+
shouldTouch: true
|
|
41360
|
+
});
|
|
41361
|
+
}, [rowSelection, setValue2]);
|
|
41362
|
+
const searchParams = useSalesChannelTableQuery({
|
|
41363
|
+
pageSize: PAGE_SIZE,
|
|
41364
|
+
prefix: PREFIX
|
|
41365
|
+
});
|
|
41366
|
+
const { sales_channels, count: count2, isLoading, isError, error } = useSalesChannels(
|
|
41367
|
+
{
|
|
41368
|
+
...searchParams
|
|
41369
|
+
},
|
|
41370
|
+
{
|
|
41371
|
+
placeholderData: reactQuery.keepPreviousData
|
|
41372
|
+
}
|
|
41373
|
+
);
|
|
41374
|
+
const filters = useSalesChannelTableFilters();
|
|
41375
|
+
const emptyState = useSalesChannelTableEmptyState();
|
|
41376
|
+
const columns = useColumns();
|
|
41377
|
+
const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
|
|
41378
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
41379
|
+
const arr = data.sales_channels ?? [];
|
|
41380
|
+
const sales_channels2 = arr.map((id) => {
|
|
41381
|
+
return {
|
|
41382
|
+
id
|
|
41383
|
+
};
|
|
41384
|
+
});
|
|
41385
|
+
await mutateAsync(
|
|
41386
|
+
{
|
|
41387
|
+
sales_channels: sales_channels2
|
|
41388
|
+
},
|
|
41389
|
+
{
|
|
41390
|
+
onSuccess: () => {
|
|
41391
|
+
handleSuccess();
|
|
41392
|
+
}
|
|
41393
|
+
}
|
|
41394
|
+
);
|
|
41395
|
+
});
|
|
41396
|
+
if (isError) {
|
|
41397
|
+
throw error;
|
|
41398
|
+
}
|
|
41399
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
41400
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
41401
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
41402
|
+
DataTable,
|
|
41403
|
+
{
|
|
41404
|
+
data: sales_channels,
|
|
41405
|
+
columns,
|
|
41406
|
+
getRowId: (row) => row.id,
|
|
41407
|
+
rowCount: count2,
|
|
41408
|
+
isLoading,
|
|
41409
|
+
filters,
|
|
41410
|
+
rowSelection: {
|
|
41411
|
+
state: rowSelection,
|
|
41412
|
+
onRowSelectionChange: setRowSelection
|
|
41413
|
+
},
|
|
41414
|
+
autoFocusSearch: true,
|
|
41415
|
+
layout: "fill",
|
|
41416
|
+
emptyState,
|
|
41417
|
+
prefix: PREFIX
|
|
41418
|
+
}
|
|
41419
|
+
) }),
|
|
41420
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
41421
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
41422
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", isLoading: isMutating, onClick: handleSubmit, children: "Save" })
|
|
41423
|
+
] }) })
|
|
41424
|
+
] }) });
|
|
41425
|
+
};
|
|
41426
|
+
const columnHelper = ui.createDataTableColumnHelper();
|
|
41427
|
+
const useColumns = () => {
|
|
41428
|
+
const columns = useSalesChannelTableColumns();
|
|
41429
|
+
return React.useMemo(() => [columnHelper.select(), ...columns], [columns]);
|
|
41430
|
+
};
|
|
41431
|
+
const ProductSalesChannels = () => {
|
|
41432
|
+
const { id } = reactRouterDom.useParams();
|
|
41433
|
+
const { product, isLoading, isError, error } = useProduct(id);
|
|
41434
|
+
if (isError) {
|
|
41435
|
+
throw error;
|
|
41436
|
+
}
|
|
41437
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(EditSalesChannelsForm, { product }) });
|
|
41438
|
+
};
|
|
41439
41439
|
const widgetModule = { widgets: [
|
|
41440
41440
|
{
|
|
41441
41441
|
Component: CustomerStoreCreditWidget,
|
|
@@ -41452,16 +41452,6 @@ const widgetModule = { widgets: [
|
|
|
41452
41452
|
] };
|
|
41453
41453
|
const routeModule = {
|
|
41454
41454
|
routes: [
|
|
41455
|
-
{
|
|
41456
|
-
Component: StoreCreditAccountsPage,
|
|
41457
|
-
path: "/store-credit-accounts",
|
|
41458
|
-
children: [
|
|
41459
|
-
{
|
|
41460
|
-
Component: StoreCreditAccountCreate,
|
|
41461
|
-
path: "/store-credit-accounts/create"
|
|
41462
|
-
}
|
|
41463
|
-
]
|
|
41464
|
-
},
|
|
41465
41455
|
{
|
|
41466
41456
|
Component: GiftCardsPage,
|
|
41467
41457
|
path: "/gift-cards",
|
|
@@ -41473,12 +41463,12 @@ const routeModule = {
|
|
|
41473
41463
|
]
|
|
41474
41464
|
},
|
|
41475
41465
|
{
|
|
41476
|
-
Component:
|
|
41477
|
-
path: "/store-credit-accounts
|
|
41466
|
+
Component: StoreCreditAccountsPage,
|
|
41467
|
+
path: "/store-credit-accounts",
|
|
41478
41468
|
children: [
|
|
41479
41469
|
{
|
|
41480
|
-
Component:
|
|
41481
|
-
path: "/store-credit-accounts
|
|
41470
|
+
Component: StoreCreditAccountCreate,
|
|
41471
|
+
path: "/store-credit-accounts/create"
|
|
41482
41472
|
}
|
|
41483
41473
|
]
|
|
41484
41474
|
},
|
|
@@ -41491,7 +41481,7 @@ const routeModule = {
|
|
|
41491
41481
|
path: "/gift-cards/:id/expiration"
|
|
41492
41482
|
},
|
|
41493
41483
|
{
|
|
41494
|
-
Component: Note,
|
|
41484
|
+
Component: Note$1,
|
|
41495
41485
|
path: "/gift-cards/:id/note"
|
|
41496
41486
|
}
|
|
41497
41487
|
]
|
|
@@ -41506,17 +41496,27 @@ const routeModule = {
|
|
|
41506
41496
|
}
|
|
41507
41497
|
]
|
|
41508
41498
|
},
|
|
41499
|
+
{
|
|
41500
|
+
Component: StoreCreditAccountPage,
|
|
41501
|
+
path: "/store-credit-accounts/:id",
|
|
41502
|
+
children: [
|
|
41503
|
+
{
|
|
41504
|
+
Component: Note,
|
|
41505
|
+
path: "/store-credit-accounts/:id/credit"
|
|
41506
|
+
}
|
|
41507
|
+
]
|
|
41508
|
+
},
|
|
41509
41509
|
{
|
|
41510
41510
|
Component: ProductDetail,
|
|
41511
41511
|
path: "/gift-cards/gift-card-products/:id",
|
|
41512
41512
|
children: [
|
|
41513
41513
|
{
|
|
41514
41514
|
Component: GiftCardProductEdit$1,
|
|
41515
|
-
path: "/gift-cards/gift-card-products/:id/
|
|
41515
|
+
path: "/gift-cards/gift-card-products/:id/denominations"
|
|
41516
41516
|
},
|
|
41517
41517
|
{
|
|
41518
41518
|
Component: GiftCardProductEdit,
|
|
41519
|
-
path: "/gift-cards/gift-card-products/:id/
|
|
41519
|
+
path: "/gift-cards/gift-card-products/:id/edit"
|
|
41520
41520
|
}
|
|
41521
41521
|
]
|
|
41522
41522
|
},
|
|
@@ -41524,29 +41524,29 @@ const routeModule = {
|
|
|
41524
41524
|
Component: ProductMedia,
|
|
41525
41525
|
path: "/gift-cards/gift-card-products/:id/media"
|
|
41526
41526
|
},
|
|
41527
|
-
{
|
|
41528
|
-
Component: ProductSalesChannels,
|
|
41529
|
-
path: "/gift-cards/gift-card-products/:id/sales-channels"
|
|
41530
|
-
},
|
|
41531
41527
|
{
|
|
41532
41528
|
Component: ProductPrices,
|
|
41533
41529
|
path: "/gift-cards/gift-card-products/:id/prices"
|
|
41530
|
+
},
|
|
41531
|
+
{
|
|
41532
|
+
Component: ProductSalesChannels,
|
|
41533
|
+
path: "/gift-cards/gift-card-products/:id/sales-channels"
|
|
41534
41534
|
}
|
|
41535
41535
|
]
|
|
41536
41536
|
};
|
|
41537
41537
|
const menuItemModule = {
|
|
41538
41538
|
menuItems: [
|
|
41539
41539
|
{
|
|
41540
|
-
label: config$
|
|
41541
|
-
icon: config$
|
|
41540
|
+
label: config$3.label,
|
|
41541
|
+
icon: config$3.icon,
|
|
41542
41542
|
path: "/gift-cards",
|
|
41543
41543
|
nested: void 0,
|
|
41544
41544
|
rank: void 0,
|
|
41545
41545
|
translationNs: void 0
|
|
41546
41546
|
},
|
|
41547
41547
|
{
|
|
41548
|
-
label: config$
|
|
41549
|
-
icon: config$
|
|
41548
|
+
label: config$1.label,
|
|
41549
|
+
icon: config$1.icon,
|
|
41550
41550
|
path: "/store-credit-accounts",
|
|
41551
41551
|
nested: void 0,
|
|
41552
41552
|
rank: void 0,
|