@medusajs/loyalty-plugin 2.17.2 → 2.17.3-preview-20260702081944
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 +1620 -1620
- package/.medusa/server/src/admin/index.mjs +1622 -1622
- package/package.json +17 -17
|
@@ -11,8 +11,8 @@ const icons = require("@medusajs/icons");
|
|
|
11
11
|
const reactQuery = require("@tanstack/react-query");
|
|
12
12
|
const Medusa = require("@medusajs/js-sdk");
|
|
13
13
|
const components = require("@medusajs/dashboard/components");
|
|
14
|
-
const zod = require("@medusajs/framework/zod");
|
|
15
14
|
const ReactDOM = require("react-dom");
|
|
15
|
+
const zod = require("@medusajs/framework/zod");
|
|
16
16
|
const _interopDefault = (e2) => e2 && e2.__esModule ? e2 : { default: e2 };
|
|
17
17
|
function _interopNamespace(e2) {
|
|
18
18
|
if (e2 && e2.__esModule) return e2;
|
|
@@ -5760,7 +5760,7 @@ adminSdk.defineWidgetConfig({
|
|
|
5760
5760
|
zone: "sales_channel.details.after",
|
|
5761
5761
|
id: "medusa:sales-channel-gift-cards-widget"
|
|
5762
5762
|
});
|
|
5763
|
-
const
|
|
5763
|
+
const GiftCardIcon = (props) => {
|
|
5764
5764
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5765
5765
|
"svg",
|
|
5766
5766
|
{
|
|
@@ -5771,49 +5771,197 @@ const StoreCreditIcon = (props) => {
|
|
|
5771
5771
|
xmlns: "http://www.w3.org/2000/svg",
|
|
5772
5772
|
...props,
|
|
5773
5773
|
children: [
|
|
5774
|
-
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#
|
|
5774
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#F97316" }),
|
|
5775
5775
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5776
5776
|
"rect",
|
|
5777
5777
|
{
|
|
5778
5778
|
width: "15",
|
|
5779
5779
|
height: "15",
|
|
5780
|
-
fill: "url(#
|
|
5780
|
+
fill: "url(#paint0_linear_28788_25808)",
|
|
5781
5781
|
fillOpacity: "0.2"
|
|
5782
5782
|
}
|
|
5783
5783
|
),
|
|
5784
|
-
/* @__PURE__ */ jsxRuntime.
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5784
|
+
/* @__PURE__ */ jsxRuntime.jsxs("g", { clipPath: "url(#clip0_28788_25808)", children: [
|
|
5785
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5786
|
+
"path",
|
|
5787
|
+
{
|
|
5788
|
+
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",
|
|
5789
|
+
fill: "white"
|
|
5790
|
+
}
|
|
5791
|
+
),
|
|
5792
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5793
|
+
"path",
|
|
5794
|
+
{
|
|
5795
|
+
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",
|
|
5796
|
+
fill: "white"
|
|
5797
|
+
}
|
|
5798
|
+
),
|
|
5799
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5800
|
+
"path",
|
|
5801
|
+
{
|
|
5802
|
+
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",
|
|
5803
|
+
fill: "white"
|
|
5804
|
+
}
|
|
5805
|
+
),
|
|
5806
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5807
|
+
"path",
|
|
5808
|
+
{
|
|
5809
|
+
d: "M6.938 7.5H3.75V9.563C3.75 10.7 4.675 11.625 5.813 11.625H6.938V7.5Z",
|
|
5810
|
+
fill: "white"
|
|
5811
|
+
}
|
|
5812
|
+
),
|
|
5813
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5814
|
+
"path",
|
|
5815
|
+
{
|
|
5816
|
+
d: "M8.063 7.5V11.625H9.188C10.325 11.625 11.25 10.7 11.25 9.563V7.5H8.063Z",
|
|
5817
|
+
fill: "white"
|
|
5818
|
+
}
|
|
5819
|
+
)
|
|
5820
|
+
] }),
|
|
5821
|
+
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
5822
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5823
|
+
"linearGradient",
|
|
5824
|
+
{
|
|
5825
|
+
id: "paint0_linear_28788_25808",
|
|
5826
|
+
x1: "7.5",
|
|
5827
|
+
y1: "0",
|
|
5828
|
+
x2: "7.5",
|
|
5829
|
+
y2: "15",
|
|
5830
|
+
gradientUnits: "userSpaceOnUse",
|
|
5831
|
+
children: [
|
|
5832
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "white" }),
|
|
5833
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
|
|
5834
|
+
]
|
|
5835
|
+
}
|
|
5836
|
+
),
|
|
5837
|
+
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_28788_25808", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "9", height: "9", fill: "white", transform: "translate(3 3)" }) })
|
|
5838
|
+
] })
|
|
5813
5839
|
]
|
|
5814
5840
|
}
|
|
5815
5841
|
);
|
|
5816
5842
|
};
|
|
5843
|
+
const GiftCardProductsSection = () => {
|
|
5844
|
+
const { products: giftCardProducts, count: count2 = 0 } = useProducts({
|
|
5845
|
+
is_giftcard: true
|
|
5846
|
+
});
|
|
5847
|
+
const slicedProducts = (giftCardProducts == null ? void 0 : giftCardProducts.slice(0, 3)) ?? [];
|
|
5848
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
5849
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
5850
|
+
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Gift Card Products" }),
|
|
5851
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5852
|
+
reactRouterDom.Link,
|
|
5853
|
+
{
|
|
5854
|
+
to: `/gift-cards/gift-card-products/create`,
|
|
5855
|
+
className: "text-ui-fg-muted text-sm px-6",
|
|
5856
|
+
children: "Create"
|
|
5857
|
+
}
|
|
5858
|
+
)
|
|
5859
|
+
] }),
|
|
5860
|
+
(giftCardProducts == null ? void 0 : giftCardProducts.length) === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5861
|
+
NoRecords,
|
|
5862
|
+
{
|
|
5863
|
+
className: "px-10 py-4 h-[200px]",
|
|
5864
|
+
title: "No gift card products",
|
|
5865
|
+
message: "There are no gift card products to show. Create one to get started.",
|
|
5866
|
+
action: {
|
|
5867
|
+
to: "/gift-cards/gift-card-products/create",
|
|
5868
|
+
label: "Create gift card product"
|
|
5869
|
+
}
|
|
5870
|
+
}
|
|
5871
|
+
),
|
|
5872
|
+
slicedProducts.map((giftCardProduct) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5873
|
+
SidebarLink,
|
|
5874
|
+
{
|
|
5875
|
+
to: `/gift-cards/gift-card-products/${giftCardProduct.id}`,
|
|
5876
|
+
labelKey: giftCardProduct.title,
|
|
5877
|
+
descriptionKey: giftCardProduct.title,
|
|
5878
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Tag, {})
|
|
5879
|
+
}
|
|
5880
|
+
)),
|
|
5881
|
+
count2 > 3 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5882
|
+
reactRouterDom.Link,
|
|
5883
|
+
{
|
|
5884
|
+
to: "/gift-cards/gift-card-products",
|
|
5885
|
+
className: "text-ui-fg-muted text-sm px-6 py-4 flex items-center justify-center",
|
|
5886
|
+
children: "View more"
|
|
5887
|
+
}
|
|
5888
|
+
)
|
|
5889
|
+
] });
|
|
5890
|
+
};
|
|
5891
|
+
const _giftCardQueryKey = queryKeysFactory("gift-card");
|
|
5892
|
+
const giftCardQueryKey = {
|
|
5893
|
+
..._giftCardQueryKey,
|
|
5894
|
+
orders: (id) => [..._giftCardQueryKey.detail(id), "orders"]
|
|
5895
|
+
};
|
|
5896
|
+
const useGiftCards = (query, options) => {
|
|
5897
|
+
const fetchGiftCards = (query2, headers) => sdk.client.fetch(`/admin/gift-cards`, {
|
|
5898
|
+
query: query2,
|
|
5899
|
+
headers
|
|
5900
|
+
});
|
|
5901
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
5902
|
+
...options,
|
|
5903
|
+
queryFn: () => fetchGiftCards(query),
|
|
5904
|
+
queryKey: giftCardQueryKey.list(query)
|
|
5905
|
+
});
|
|
5906
|
+
return { ...data, ...rest };
|
|
5907
|
+
};
|
|
5908
|
+
const useGiftCard = (id, query, options) => {
|
|
5909
|
+
const fetchGiftCard = (id2, query2, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
|
|
5910
|
+
query: query2,
|
|
5911
|
+
headers
|
|
5912
|
+
});
|
|
5913
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
5914
|
+
queryFn: () => fetchGiftCard(id, query),
|
|
5915
|
+
queryKey: giftCardQueryKey.detail(id, query),
|
|
5916
|
+
...options
|
|
5917
|
+
});
|
|
5918
|
+
return { ...data, ...rest };
|
|
5919
|
+
};
|
|
5920
|
+
const useGiftCardOrders = (id, options) => {
|
|
5921
|
+
const fetchGiftCardOrders = (id2, query, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}/orders`, {
|
|
5922
|
+
query,
|
|
5923
|
+
headers
|
|
5924
|
+
});
|
|
5925
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
5926
|
+
queryFn: () => fetchGiftCardOrders(id),
|
|
5927
|
+
queryKey: giftCardQueryKey.orders(id),
|
|
5928
|
+
...options
|
|
5929
|
+
});
|
|
5930
|
+
return { ...data, ...rest };
|
|
5931
|
+
};
|
|
5932
|
+
const useUpdateGiftCard = (id, options) => {
|
|
5933
|
+
const queryClient = reactQuery.useQueryClient();
|
|
5934
|
+
const updateGiftCard = async (id2, body) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
|
|
5935
|
+
body,
|
|
5936
|
+
method: "POST"
|
|
5937
|
+
});
|
|
5938
|
+
return reactQuery.useMutation({
|
|
5939
|
+
mutationFn: async (payload) => updateGiftCard(id, payload),
|
|
5940
|
+
onSuccess: (data, variables, context) => {
|
|
5941
|
+
queryClient.invalidateQueries({
|
|
5942
|
+
queryKey: giftCardQueryKey.detail(id)
|
|
5943
|
+
});
|
|
5944
|
+
queryClient.invalidateQueries({
|
|
5945
|
+
queryKey: giftCardQueryKey.lists()
|
|
5946
|
+
});
|
|
5947
|
+
},
|
|
5948
|
+
...options
|
|
5949
|
+
});
|
|
5950
|
+
};
|
|
5951
|
+
const useCreateGiftCard = (options) => {
|
|
5952
|
+
const queryClient = reactQuery.useQueryClient();
|
|
5953
|
+
const createGiftCard = async (body) => sdk.client.fetch(`/admin/gift-cards`, {
|
|
5954
|
+
body,
|
|
5955
|
+
method: "POST"
|
|
5956
|
+
});
|
|
5957
|
+
return reactQuery.useMutation({
|
|
5958
|
+
mutationFn: (body) => createGiftCard(body),
|
|
5959
|
+
onSuccess: (data, variables, context) => {
|
|
5960
|
+
queryClient.invalidateQueries({ queryKey: giftCardQueryKey.lists() });
|
|
5961
|
+
},
|
|
5962
|
+
...options
|
|
5963
|
+
});
|
|
5964
|
+
};
|
|
5817
5965
|
function getRelativeDate(date2) {
|
|
5818
5966
|
const now2 = /* @__PURE__ */ new Date();
|
|
5819
5967
|
return formatDistance(sub(new Date(date2), { minutes: 0 }), now2, {
|
|
@@ -5831,52 +5979,31 @@ function formatDate(date2, withTime = true) {
|
|
|
5831
5979
|
return format$1(new Date(date2), "dd MMM, yyyy");
|
|
5832
5980
|
}
|
|
5833
5981
|
const columnHelper$a = ui.createDataTableColumnHelper();
|
|
5834
|
-
const
|
|
5982
|
+
const useGiftCardTableColumns = () => {
|
|
5835
5983
|
return React.useMemo(() => {
|
|
5836
5984
|
return [
|
|
5837
|
-
columnHelper$a.accessor("
|
|
5838
|
-
header: "
|
|
5839
|
-
cell: ({ row }) => {
|
|
5840
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { size: "2xsmall", children: row.original.currency_code.toUpperCase() });
|
|
5841
|
-
}
|
|
5842
|
-
}),
|
|
5843
|
-
columnHelper$a.accessor("customer.email", {
|
|
5844
|
-
header: "Customer",
|
|
5985
|
+
columnHelper$a.accessor("code", {
|
|
5986
|
+
header: "Code",
|
|
5845
5987
|
cell: ({ row }) => {
|
|
5846
|
-
|
|
5847
|
-
return ((_a2 = row.original.customer) == null ? void 0 : _a2.email) ?? "N/A";
|
|
5988
|
+
return row.original.code;
|
|
5848
5989
|
}
|
|
5849
5990
|
}),
|
|
5850
|
-
columnHelper$a.accessor("
|
|
5851
|
-
header: "
|
|
5991
|
+
columnHelper$a.accessor("line_item.product.title", {
|
|
5992
|
+
header: "Product",
|
|
5852
5993
|
cell: ({ row }) => {
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
row.original.currency_code
|
|
5856
|
-
);
|
|
5994
|
+
var _a2, _b;
|
|
5995
|
+
return ((_b = (_a2 = row.original.line_item) == null ? void 0 : _a2.product) == null ? void 0 : _b.title) || "Custom Gift Card";
|
|
5857
5996
|
}
|
|
5858
5997
|
}),
|
|
5859
|
-
columnHelper$a.accessor("
|
|
5860
|
-
header: "
|
|
5861
|
-
cell: ({ row }) =>
|
|
5862
|
-
return formatAmount(
|
|
5863
|
-
row.original.credits,
|
|
5864
|
-
row.original.currency_code
|
|
5865
|
-
);
|
|
5866
|
-
}
|
|
5998
|
+
columnHelper$a.accessor("created_at", {
|
|
5999
|
+
header: "Date issued",
|
|
6000
|
+
cell: ({ row }) => getRelativeDate(row.original.created_at)
|
|
5867
6001
|
}),
|
|
5868
|
-
columnHelper$a.accessor("
|
|
5869
|
-
header: "
|
|
6002
|
+
columnHelper$a.accessor("value", {
|
|
6003
|
+
header: "Value",
|
|
5870
6004
|
cell: ({ row }) => {
|
|
5871
|
-
return formatAmount(
|
|
5872
|
-
row.original.debits,
|
|
5873
|
-
row.original.currency_code
|
|
5874
|
-
);
|
|
6005
|
+
return formatAmount(row.original.value, row.original.currency_code);
|
|
5875
6006
|
}
|
|
5876
|
-
}),
|
|
5877
|
-
columnHelper$a.accessor("created_at", {
|
|
5878
|
-
header: "Created at",
|
|
5879
|
-
cell: ({ row }) => getRelativeDate(row.original.created_at)
|
|
5880
6007
|
})
|
|
5881
6008
|
];
|
|
5882
6009
|
}, []);
|
|
@@ -5923,83 +6050,75 @@ const useCustomerFilters = () => {
|
|
|
5923
6050
|
];
|
|
5924
6051
|
}, [customerFilterOptions]);
|
|
5925
6052
|
};
|
|
5926
|
-
const
|
|
6053
|
+
const useGiftCardFilters = () => {
|
|
5927
6054
|
const dateFilterOptions = useDataTableDateFilters$1();
|
|
5928
6055
|
const customerFilterOptions = useCustomerFilters();
|
|
5929
6056
|
return React.useMemo(() => {
|
|
5930
6057
|
return [...dateFilterOptions, ...customerFilterOptions];
|
|
5931
6058
|
}, [dateFilterOptions, customerFilterOptions]);
|
|
5932
6059
|
};
|
|
5933
|
-
const
|
|
6060
|
+
const useGiftCardTableQuery = ({
|
|
5934
6061
|
prefix,
|
|
5935
6062
|
pageSize = 20
|
|
5936
6063
|
}) => {
|
|
5937
6064
|
const queryObject = useQueryParams(
|
|
5938
|
-
["
|
|
6065
|
+
["q", "offset", "customer_id", "created_at", "updated_at"],
|
|
5939
6066
|
prefix
|
|
5940
6067
|
);
|
|
5941
|
-
const {
|
|
5942
|
-
offset: offset2,
|
|
5943
|
-
created_at,
|
|
5944
|
-
updated_at,
|
|
5945
|
-
customer_id,
|
|
5946
|
-
currency_code,
|
|
5947
|
-
...rest
|
|
5948
|
-
} = queryObject;
|
|
6068
|
+
const { offset: offset2, created_at, updated_at, customer_id, ...rest } = queryObject;
|
|
5949
6069
|
const searchParams = {
|
|
5950
6070
|
limit: pageSize,
|
|
5951
6071
|
offset: offset2 ? Number(offset2) : 0,
|
|
5952
6072
|
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
5953
6073
|
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
5954
6074
|
customer_id: customer_id ? JSON.parse(customer_id) : void 0,
|
|
5955
|
-
currency_code: currency_code ? JSON.parse(currency_code) : void 0,
|
|
5956
6075
|
...rest
|
|
5957
6076
|
};
|
|
5958
6077
|
return searchParams;
|
|
5959
6078
|
};
|
|
5960
6079
|
const PAGE_SIZE$6 = 10;
|
|
5961
|
-
function
|
|
5962
|
-
const queryParams =
|
|
6080
|
+
function GiftCardsTable() {
|
|
6081
|
+
const queryParams = useGiftCardTableQuery({
|
|
5963
6082
|
pageSize: PAGE_SIZE$6
|
|
5964
6083
|
});
|
|
5965
6084
|
const {
|
|
5966
|
-
|
|
6085
|
+
gift_cards: giftCards,
|
|
5967
6086
|
isPending,
|
|
5968
6087
|
count: count2
|
|
5969
|
-
} =
|
|
6088
|
+
} = useGiftCards({
|
|
5970
6089
|
...queryParams,
|
|
5971
|
-
order: queryParams.order ?? "-created_at"
|
|
6090
|
+
order: queryParams.order ?? "-created_at",
|
|
6091
|
+
fields: "+line_item.product.title"
|
|
5972
6092
|
});
|
|
5973
|
-
const columns =
|
|
5974
|
-
const filters =
|
|
6093
|
+
const columns = useGiftCardTableColumns();
|
|
6094
|
+
const filters = useGiftCardFilters();
|
|
5975
6095
|
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
5976
6096
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5977
6097
|
DataTable,
|
|
5978
6098
|
{
|
|
5979
|
-
data:
|
|
6099
|
+
data: giftCards,
|
|
5980
6100
|
getRowId: (row) => row.id,
|
|
5981
6101
|
columns,
|
|
5982
6102
|
filters,
|
|
5983
6103
|
isLoading: isPending,
|
|
5984
6104
|
pageSize: PAGE_SIZE$6,
|
|
5985
6105
|
rowCount: count2,
|
|
5986
|
-
|
|
5987
|
-
heading: "Store Credit Accounts",
|
|
6106
|
+
heading: "Gift Cards",
|
|
5988
6107
|
rowHref: (row) => `${row.id}`,
|
|
5989
6108
|
emptyState: {
|
|
5990
6109
|
empty: {
|
|
5991
|
-
heading: "No
|
|
5992
|
-
description: "Create a
|
|
6110
|
+
heading: "No gift cards found",
|
|
6111
|
+
description: "Create a gift card to get started."
|
|
5993
6112
|
},
|
|
5994
6113
|
filtered: {
|
|
5995
6114
|
heading: "No results found",
|
|
5996
|
-
description: "No
|
|
6115
|
+
description: "No gift cards match your filter criteria."
|
|
5997
6116
|
}
|
|
5998
6117
|
},
|
|
5999
6118
|
actions: [
|
|
6000
6119
|
{
|
|
6001
6120
|
label: "Create",
|
|
6002
|
-
to: "
|
|
6121
|
+
to: "create"
|
|
6003
6122
|
}
|
|
6004
6123
|
]
|
|
6005
6124
|
}
|
|
@@ -6007,15 +6126,16 @@ function StoreCreditAccountsTable() {
|
|
|
6007
6126
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
6008
6127
|
] });
|
|
6009
6128
|
}
|
|
6010
|
-
const
|
|
6129
|
+
const GiftCardsPage = () => {
|
|
6011
6130
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
6012
6131
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6013
6132
|
components.LayoutComposer,
|
|
6014
6133
|
{
|
|
6015
|
-
widgetsZonePrefix: "
|
|
6016
|
-
preferredLayoutId: "core:
|
|
6134
|
+
widgetsZonePrefix: "gift_card.list",
|
|
6135
|
+
preferredLayoutId: "core:two-column",
|
|
6017
6136
|
sections: {
|
|
6018
|
-
main: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "
|
|
6137
|
+
main: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardsTable", children: /* @__PURE__ */ jsxRuntime.jsx(GiftCardsTable, {}) }),
|
|
6138
|
+
side: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardProductsSection", children: /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductsSection, {}) })
|
|
6019
6139
|
}
|
|
6020
6140
|
}
|
|
6021
6141
|
),
|
|
@@ -6023,8 +6143,8 @@ const StoreCreditAccountsPage = () => {
|
|
|
6023
6143
|
] });
|
|
6024
6144
|
};
|
|
6025
6145
|
const config$3 = adminSdk.defineRouteConfig({
|
|
6026
|
-
label: "
|
|
6027
|
-
icon:
|
|
6146
|
+
label: "Gift Cards",
|
|
6147
|
+
icon: GiftCardIcon
|
|
6028
6148
|
});
|
|
6029
6149
|
function setRef$2(ref, value) {
|
|
6030
6150
|
if (typeof ref === "function") {
|
|
@@ -9943,6 +10063,28 @@ const StackedFocusModal = Object.assign(Root, {
|
|
|
9943
10063
|
Description,
|
|
9944
10064
|
Title
|
|
9945
10065
|
});
|
|
10066
|
+
const STORE_QUERY_KEY = "store";
|
|
10067
|
+
const storeQueryKeys = queryKeysFactory(STORE_QUERY_KEY);
|
|
10068
|
+
async function retrieveActiveStore(query) {
|
|
10069
|
+
var _a2;
|
|
10070
|
+
const response = await sdk.admin.store.list(query);
|
|
10071
|
+
const activeStore = (_a2 = response.stores) == null ? void 0 : _a2[0];
|
|
10072
|
+
if (!activeStore) {
|
|
10073
|
+
throw new Medusa.FetchError("No active store found", "Not Found", 404);
|
|
10074
|
+
}
|
|
10075
|
+
return { store: activeStore };
|
|
10076
|
+
}
|
|
10077
|
+
const useStore$2 = (query, options) => {
|
|
10078
|
+
const { data, ...rest } = reactQuery.useQuery({
|
|
10079
|
+
queryFn: () => retrieveActiveStore(query),
|
|
10080
|
+
queryKey: storeQueryKeys.details(),
|
|
10081
|
+
...options
|
|
10082
|
+
});
|
|
10083
|
+
return {
|
|
10084
|
+
...data,
|
|
10085
|
+
...rest
|
|
10086
|
+
};
|
|
10087
|
+
};
|
|
9946
10088
|
var t$1 = function(t2, n2, e2) {
|
|
9947
10089
|
if (t2 && "reportValidity" in t2) {
|
|
9948
10090
|
var i2 = get$3(e2, n2);
|
|
@@ -11816,7 +11958,7 @@ function useStoreProps(store, props, key2, setKey) {
|
|
|
11816
11958
|
});
|
|
11817
11959
|
});
|
|
11818
11960
|
}
|
|
11819
|
-
function useStore$
|
|
11961
|
+
function useStore$1(createStore2, props) {
|
|
11820
11962
|
const [store, setStore] = React__namespace.useState(() => createStore2(props));
|
|
11821
11963
|
useSafeLayoutEffect(() => init(store), [store]);
|
|
11822
11964
|
const useState2 = React__namespace.useCallback(
|
|
@@ -12638,7 +12780,7 @@ function useDisclosureStoreProps(store, update, props) {
|
|
|
12638
12780
|
return Object.assign(store, { disclosure: props.disclosure });
|
|
12639
12781
|
}
|
|
12640
12782
|
function useDisclosureStore(props = {}) {
|
|
12641
|
-
const [store, update] = useStore$
|
|
12783
|
+
const [store, update] = useStore$1(createDisclosureStore, props);
|
|
12642
12784
|
return useDisclosureStoreProps(store, update, props);
|
|
12643
12785
|
}
|
|
12644
12786
|
var ctx$2 = createStoreContext(
|
|
@@ -14027,7 +14169,7 @@ function useDialogStoreProps(store, update, props) {
|
|
|
14027
14169
|
return useDisclosureStoreProps(store, update, props);
|
|
14028
14170
|
}
|
|
14029
14171
|
function useDialogStore(props = {}) {
|
|
14030
|
-
const [store, update] = useStore$
|
|
14172
|
+
const [store, update] = useStore$1(createDialogStore, props);
|
|
14031
14173
|
return useDialogStoreProps(store, update, props);
|
|
14032
14174
|
}
|
|
14033
14175
|
var TagName$e = "div";
|
|
@@ -16073,7 +16215,7 @@ function useComboboxStoreProps(store, update, props) {
|
|
|
16073
16215
|
}
|
|
16074
16216
|
function useComboboxStore(props = {}) {
|
|
16075
16217
|
props = useComboboxStoreOptions(props);
|
|
16076
|
-
const [store, update] = useStore$
|
|
16218
|
+
const [store, update] = useStore$1(createComboboxStore, props);
|
|
16077
16219
|
return useComboboxStoreProps(store, update, props);
|
|
16078
16220
|
}
|
|
16079
16221
|
function ComboboxProvider(props = {}) {
|
|
@@ -17179,270 +17321,6 @@ const ComboboxImpl = ({
|
|
|
17179
17321
|
);
|
|
17180
17322
|
};
|
|
17181
17323
|
const Combobox = genericForwardRef(ComboboxImpl);
|
|
17182
|
-
function isObject$6(value) {
|
|
17183
|
-
var type = typeof value;
|
|
17184
|
-
return value != null && (type == "object" || type == "function");
|
|
17185
|
-
}
|
|
17186
|
-
var isObject_1 = isObject$6;
|
|
17187
|
-
var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
17188
|
-
var _freeGlobal = freeGlobal$1;
|
|
17189
|
-
var freeGlobal = _freeGlobal;
|
|
17190
|
-
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
17191
|
-
var root$4 = freeGlobal || freeSelf || Function("return this")();
|
|
17192
|
-
var _root = root$4;
|
|
17193
|
-
var root$3 = _root;
|
|
17194
|
-
var now$1 = function() {
|
|
17195
|
-
return root$3.Date.now();
|
|
17196
|
-
};
|
|
17197
|
-
var now_1 = now$1;
|
|
17198
|
-
var reWhitespace = /\s/;
|
|
17199
|
-
function trimmedEndIndex$1(string2) {
|
|
17200
|
-
var index = string2.length;
|
|
17201
|
-
while (index-- && reWhitespace.test(string2.charAt(index))) {
|
|
17202
|
-
}
|
|
17203
|
-
return index;
|
|
17204
|
-
}
|
|
17205
|
-
var _trimmedEndIndex = trimmedEndIndex$1;
|
|
17206
|
-
var trimmedEndIndex = _trimmedEndIndex;
|
|
17207
|
-
var reTrimStart = /^\s+/;
|
|
17208
|
-
function baseTrim$1(string2) {
|
|
17209
|
-
return string2 ? string2.slice(0, trimmedEndIndex(string2) + 1).replace(reTrimStart, "") : string2;
|
|
17210
|
-
}
|
|
17211
|
-
var _baseTrim = baseTrim$1;
|
|
17212
|
-
var root$2 = _root;
|
|
17213
|
-
var Symbol$4 = root$2.Symbol;
|
|
17214
|
-
var _Symbol = Symbol$4;
|
|
17215
|
-
var Symbol$3 = _Symbol;
|
|
17216
|
-
var objectProto$5 = Object.prototype;
|
|
17217
|
-
var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
|
|
17218
|
-
var nativeObjectToString$1 = objectProto$5.toString;
|
|
17219
|
-
var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
|
|
17220
|
-
function getRawTag$1(value) {
|
|
17221
|
-
var isOwn = hasOwnProperty$4.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
17222
|
-
try {
|
|
17223
|
-
value[symToStringTag$1] = void 0;
|
|
17224
|
-
var unmasked = true;
|
|
17225
|
-
} catch (e2) {
|
|
17226
|
-
}
|
|
17227
|
-
var result = nativeObjectToString$1.call(value);
|
|
17228
|
-
if (unmasked) {
|
|
17229
|
-
if (isOwn) {
|
|
17230
|
-
value[symToStringTag$1] = tag;
|
|
17231
|
-
} else {
|
|
17232
|
-
delete value[symToStringTag$1];
|
|
17233
|
-
}
|
|
17234
|
-
}
|
|
17235
|
-
return result;
|
|
17236
|
-
}
|
|
17237
|
-
var _getRawTag = getRawTag$1;
|
|
17238
|
-
var objectProto$4 = Object.prototype;
|
|
17239
|
-
var nativeObjectToString = objectProto$4.toString;
|
|
17240
|
-
function objectToString$1(value) {
|
|
17241
|
-
return nativeObjectToString.call(value);
|
|
17242
|
-
}
|
|
17243
|
-
var _objectToString = objectToString$1;
|
|
17244
|
-
var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
|
|
17245
|
-
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
|
|
17246
|
-
var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
|
|
17247
|
-
function baseGetTag$2(value) {
|
|
17248
|
-
if (value == null) {
|
|
17249
|
-
return value === void 0 ? undefinedTag : nullTag;
|
|
17250
|
-
}
|
|
17251
|
-
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
17252
|
-
}
|
|
17253
|
-
var _baseGetTag = baseGetTag$2;
|
|
17254
|
-
function isObjectLike$1(value) {
|
|
17255
|
-
return value != null && typeof value == "object";
|
|
17256
|
-
}
|
|
17257
|
-
var isObjectLike_1 = isObjectLike$1;
|
|
17258
|
-
var baseGetTag$1 = _baseGetTag, isObjectLike = isObjectLike_1;
|
|
17259
|
-
var symbolTag = "[object Symbol]";
|
|
17260
|
-
function isSymbol$4(value) {
|
|
17261
|
-
return typeof value == "symbol" || isObjectLike(value) && baseGetTag$1(value) == symbolTag;
|
|
17262
|
-
}
|
|
17263
|
-
var isSymbol_1 = isSymbol$4;
|
|
17264
|
-
var baseTrim = _baseTrim, isObject$5 = isObject_1, isSymbol$3 = isSymbol_1;
|
|
17265
|
-
var NAN = 0 / 0;
|
|
17266
|
-
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
17267
|
-
var reIsBinary = /^0b[01]+$/i;
|
|
17268
|
-
var reIsOctal = /^0o[0-7]+$/i;
|
|
17269
|
-
var freeParseInt = parseInt;
|
|
17270
|
-
function toNumber$1(value) {
|
|
17271
|
-
if (typeof value == "number") {
|
|
17272
|
-
return value;
|
|
17273
|
-
}
|
|
17274
|
-
if (isSymbol$3(value)) {
|
|
17275
|
-
return NAN;
|
|
17276
|
-
}
|
|
17277
|
-
if (isObject$5(value)) {
|
|
17278
|
-
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
17279
|
-
value = isObject$5(other) ? other + "" : other;
|
|
17280
|
-
}
|
|
17281
|
-
if (typeof value != "string") {
|
|
17282
|
-
return value === 0 ? value : +value;
|
|
17283
|
-
}
|
|
17284
|
-
value = baseTrim(value);
|
|
17285
|
-
var isBinary = reIsBinary.test(value);
|
|
17286
|
-
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
|
17287
|
-
}
|
|
17288
|
-
var toNumber_1 = toNumber$1;
|
|
17289
|
-
var isObject$4 = isObject_1, now = now_1, toNumber = toNumber_1;
|
|
17290
|
-
var FUNC_ERROR_TEXT$1 = "Expected a function";
|
|
17291
|
-
var nativeMax = Math.max, nativeMin = Math.min;
|
|
17292
|
-
function debounce$2(func, wait, options) {
|
|
17293
|
-
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
17294
|
-
if (typeof func != "function") {
|
|
17295
|
-
throw new TypeError(FUNC_ERROR_TEXT$1);
|
|
17296
|
-
}
|
|
17297
|
-
wait = toNumber(wait) || 0;
|
|
17298
|
-
if (isObject$4(options)) {
|
|
17299
|
-
leading = !!options.leading;
|
|
17300
|
-
maxing = "maxWait" in options;
|
|
17301
|
-
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
17302
|
-
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
17303
|
-
}
|
|
17304
|
-
function invokeFunc(time2) {
|
|
17305
|
-
var args = lastArgs, thisArg = lastThis;
|
|
17306
|
-
lastArgs = lastThis = void 0;
|
|
17307
|
-
lastInvokeTime = time2;
|
|
17308
|
-
result = func.apply(thisArg, args);
|
|
17309
|
-
return result;
|
|
17310
|
-
}
|
|
17311
|
-
function leadingEdge(time2) {
|
|
17312
|
-
lastInvokeTime = time2;
|
|
17313
|
-
timerId = setTimeout(timerExpired, wait);
|
|
17314
|
-
return leading ? invokeFunc(time2) : result;
|
|
17315
|
-
}
|
|
17316
|
-
function remainingWait(time2) {
|
|
17317
|
-
var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
|
|
17318
|
-
return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
|
|
17319
|
-
}
|
|
17320
|
-
function shouldInvoke(time2) {
|
|
17321
|
-
var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime;
|
|
17322
|
-
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
|
17323
|
-
}
|
|
17324
|
-
function timerExpired() {
|
|
17325
|
-
var time2 = now();
|
|
17326
|
-
if (shouldInvoke(time2)) {
|
|
17327
|
-
return trailingEdge(time2);
|
|
17328
|
-
}
|
|
17329
|
-
timerId = setTimeout(timerExpired, remainingWait(time2));
|
|
17330
|
-
}
|
|
17331
|
-
function trailingEdge(time2) {
|
|
17332
|
-
timerId = void 0;
|
|
17333
|
-
if (trailing && lastArgs) {
|
|
17334
|
-
return invokeFunc(time2);
|
|
17335
|
-
}
|
|
17336
|
-
lastArgs = lastThis = void 0;
|
|
17337
|
-
return result;
|
|
17338
|
-
}
|
|
17339
|
-
function cancel() {
|
|
17340
|
-
if (timerId !== void 0) {
|
|
17341
|
-
clearTimeout(timerId);
|
|
17342
|
-
}
|
|
17343
|
-
lastInvokeTime = 0;
|
|
17344
|
-
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
|
17345
|
-
}
|
|
17346
|
-
function flush() {
|
|
17347
|
-
return timerId === void 0 ? result : trailingEdge(now());
|
|
17348
|
-
}
|
|
17349
|
-
function debounced() {
|
|
17350
|
-
var time2 = now(), isInvoking = shouldInvoke(time2);
|
|
17351
|
-
lastArgs = arguments;
|
|
17352
|
-
lastThis = this;
|
|
17353
|
-
lastCallTime = time2;
|
|
17354
|
-
if (isInvoking) {
|
|
17355
|
-
if (timerId === void 0) {
|
|
17356
|
-
return leadingEdge(lastCallTime);
|
|
17357
|
-
}
|
|
17358
|
-
if (maxing) {
|
|
17359
|
-
clearTimeout(timerId);
|
|
17360
|
-
timerId = setTimeout(timerExpired, wait);
|
|
17361
|
-
return invokeFunc(lastCallTime);
|
|
17362
|
-
}
|
|
17363
|
-
}
|
|
17364
|
-
if (timerId === void 0) {
|
|
17365
|
-
timerId = setTimeout(timerExpired, wait);
|
|
17366
|
-
}
|
|
17367
|
-
return result;
|
|
17368
|
-
}
|
|
17369
|
-
debounced.cancel = cancel;
|
|
17370
|
-
debounced.flush = flush;
|
|
17371
|
-
return debounced;
|
|
17372
|
-
}
|
|
17373
|
-
var debounce_1 = debounce$2;
|
|
17374
|
-
const debounce$1 = /* @__PURE__ */ getDefaultExportFromCjs(debounce_1);
|
|
17375
|
-
const useDebouncedSearch = () => {
|
|
17376
|
-
const [searchValue, onSearchValueChange] = React.useState("");
|
|
17377
|
-
const [debouncedQuery, setDebouncedQuery] = React.useState("");
|
|
17378
|
-
const debouncedUpdate = React.useCallback(
|
|
17379
|
-
debounce$1((query) => setDebouncedQuery(query), 300),
|
|
17380
|
-
[]
|
|
17381
|
-
);
|
|
17382
|
-
React.useEffect(() => {
|
|
17383
|
-
debouncedUpdate(searchValue);
|
|
17384
|
-
return () => debouncedUpdate.cancel();
|
|
17385
|
-
}, [searchValue, debouncedUpdate]);
|
|
17386
|
-
return {
|
|
17387
|
-
searchValue,
|
|
17388
|
-
onSearchValueChange,
|
|
17389
|
-
query: debouncedQuery || void 0
|
|
17390
|
-
};
|
|
17391
|
-
};
|
|
17392
|
-
const useComboboxData = ({
|
|
17393
|
-
queryKey,
|
|
17394
|
-
queryFn,
|
|
17395
|
-
getOptions,
|
|
17396
|
-
defaultValue: defaultValue2,
|
|
17397
|
-
defaultValueKey,
|
|
17398
|
-
pageSize = 10
|
|
17399
|
-
}) => {
|
|
17400
|
-
const { searchValue, onSearchValueChange, query } = useDebouncedSearch();
|
|
17401
|
-
const queryInitialDataBy = defaultValueKey || "id";
|
|
17402
|
-
const { data: initialData } = reactQuery.useQuery({
|
|
17403
|
-
queryKey,
|
|
17404
|
-
queryFn: async () => {
|
|
17405
|
-
return queryFn({
|
|
17406
|
-
[queryInitialDataBy]: defaultValue2,
|
|
17407
|
-
limit: Array.isArray(defaultValue2) ? defaultValue2.length : 1
|
|
17408
|
-
});
|
|
17409
|
-
},
|
|
17410
|
-
enabled: !!defaultValue2
|
|
17411
|
-
});
|
|
17412
|
-
const { data, ...rest } = reactQuery.useInfiniteQuery({
|
|
17413
|
-
queryKey: [...queryKey, query],
|
|
17414
|
-
queryFn: async ({ pageParam = 0 }) => {
|
|
17415
|
-
return await queryFn({
|
|
17416
|
-
q: query,
|
|
17417
|
-
limit: pageSize,
|
|
17418
|
-
offset: pageParam
|
|
17419
|
-
});
|
|
17420
|
-
},
|
|
17421
|
-
initialPageParam: 0,
|
|
17422
|
-
getNextPageParam: (lastPage) => {
|
|
17423
|
-
const moreItemsExist = lastPage.count > lastPage.offset + lastPage.limit;
|
|
17424
|
-
return moreItemsExist ? lastPage.offset + lastPage.limit : void 0;
|
|
17425
|
-
},
|
|
17426
|
-
placeholderData: reactQuery.keepPreviousData
|
|
17427
|
-
});
|
|
17428
|
-
const options = (data == null ? void 0 : data.pages.flatMap((page) => getOptions(page))) ?? [];
|
|
17429
|
-
const defaultOptions2 = initialData ? getOptions(initialData) : [];
|
|
17430
|
-
const disabled = !rest.isPending && !options.length && !searchValue;
|
|
17431
|
-
if (defaultValue2 && defaultOptions2.length && !searchValue) {
|
|
17432
|
-
defaultOptions2.forEach((option) => {
|
|
17433
|
-
if (!options.find((o2) => o2.value === option.value)) {
|
|
17434
|
-
options.unshift(option);
|
|
17435
|
-
}
|
|
17436
|
-
});
|
|
17437
|
-
}
|
|
17438
|
-
return {
|
|
17439
|
-
options,
|
|
17440
|
-
searchValue,
|
|
17441
|
-
onSearchValueChange,
|
|
17442
|
-
disabled,
|
|
17443
|
-
...rest
|
|
17444
|
-
};
|
|
17445
|
-
};
|
|
17446
17324
|
const currencies = {
|
|
17447
17325
|
USD: {
|
|
17448
17326
|
code: "USD",
|
|
@@ -18171,504 +18049,6 @@ const currencies = {
|
|
|
18171
18049
|
decimal_digits: 0
|
|
18172
18050
|
}
|
|
18173
18051
|
};
|
|
18174
|
-
const formSchema = zod.z.object({
|
|
18175
|
-
currency_code: zod.z.string().min(1, "Please select a currency"),
|
|
18176
|
-
customer_id: zod.z.string().optional()
|
|
18177
|
-
});
|
|
18178
|
-
const StoreCreditAccountCreateForm = () => {
|
|
18179
|
-
const { handleSuccess } = useRouteModal();
|
|
18180
|
-
const form = useForm({
|
|
18181
|
-
defaultValues: {
|
|
18182
|
-
currency_code: "",
|
|
18183
|
-
customer_id: ""
|
|
18184
|
-
},
|
|
18185
|
-
resolver: t(formSchema)
|
|
18186
|
-
});
|
|
18187
|
-
const { mutateAsync: createStoreCreditAccount, isPending } = useCreateStoreCreditAccount();
|
|
18188
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
18189
|
-
if (!data.customer_id) {
|
|
18190
|
-
delete data.customer_id;
|
|
18191
|
-
}
|
|
18192
|
-
await createStoreCreditAccount(data, {
|
|
18193
|
-
onSuccess: (data2) => {
|
|
18194
|
-
ui.toast.success(`Store credit account was successfully created.`);
|
|
18195
|
-
handleSuccess(`../${data2.store_credit_account.id}`);
|
|
18196
|
-
},
|
|
18197
|
-
onError: (error) => {
|
|
18198
|
-
ui.toast.error(error.message);
|
|
18199
|
-
}
|
|
18200
|
-
});
|
|
18201
|
-
});
|
|
18202
|
-
const [currencySearchValue, setCurrencySearchValue] = React.useState("");
|
|
18203
|
-
const currencyOptions = React.useMemo(() => {
|
|
18204
|
-
const options = Object.values(currencies).map((currency) => ({
|
|
18205
|
-
label: `${currency.code} - ${currency.name} (${currency.symbol_native})`,
|
|
18206
|
-
value: currency.code.toLowerCase()
|
|
18207
|
-
}));
|
|
18208
|
-
if (!currencySearchValue) {
|
|
18209
|
-
return options;
|
|
18210
|
-
}
|
|
18211
|
-
return options.filter(
|
|
18212
|
-
(option) => option.label.toLowerCase().includes(currencySearchValue.toLowerCase())
|
|
18213
|
-
);
|
|
18214
|
-
}, [currencySearchValue]);
|
|
18215
|
-
const {
|
|
18216
|
-
options: customerOptions,
|
|
18217
|
-
fetchNextPage,
|
|
18218
|
-
isFetchingNextPage,
|
|
18219
|
-
searchValue,
|
|
18220
|
-
onSearchValueChange,
|
|
18221
|
-
isLoading
|
|
18222
|
-
} = useComboboxData({
|
|
18223
|
-
queryKey: customersQueryKeys.list(),
|
|
18224
|
-
queryFn: async (params) => {
|
|
18225
|
-
return sdk.admin.customer.list(params);
|
|
18226
|
-
},
|
|
18227
|
-
getOptions: (data) => {
|
|
18228
|
-
var _a2;
|
|
18229
|
-
return ((_a2 = data.customers) == null ? void 0 : _a2.map((customer) => {
|
|
18230
|
-
const fullName = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
18231
|
-
const label = fullName ? `${customer.email} (${fullName})` : customer.email;
|
|
18232
|
-
return {
|
|
18233
|
-
label,
|
|
18234
|
-
value: customer.id
|
|
18235
|
-
};
|
|
18236
|
-
})) || [];
|
|
18237
|
-
}
|
|
18238
|
-
});
|
|
18239
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Form, { form, children: [
|
|
18240
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "-my-2 w-full border-l" }) }),
|
|
18241
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "size-full overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col items-center p-16", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full max-w-[720px] flex-col gap-y-8", children: [
|
|
18242
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
18243
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Create Store Credit Account" }),
|
|
18244
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", size: "small", children: "Create a new store credit account for a customer" })
|
|
18245
|
-
] }),
|
|
18246
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-x-4", children: [
|
|
18247
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18248
|
-
Form$2.Field,
|
|
18249
|
-
{
|
|
18250
|
-
control: form.control,
|
|
18251
|
-
name: "currency_code",
|
|
18252
|
-
render: ({ field }) => {
|
|
18253
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
18254
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Currency" }),
|
|
18255
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
18256
|
-
Combobox,
|
|
18257
|
-
{
|
|
18258
|
-
value: field.value,
|
|
18259
|
-
onChange: field.onChange,
|
|
18260
|
-
searchValue: currencySearchValue,
|
|
18261
|
-
onSearchValueChange: setCurrencySearchValue,
|
|
18262
|
-
options: currencyOptions,
|
|
18263
|
-
placeholder: "Search for a currency..."
|
|
18264
|
-
}
|
|
18265
|
-
) }),
|
|
18266
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
18267
|
-
] });
|
|
18268
|
-
}
|
|
18269
|
-
}
|
|
18270
|
-
),
|
|
18271
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18272
|
-
Form$2.Field,
|
|
18273
|
-
{
|
|
18274
|
-
control: form.control,
|
|
18275
|
-
name: "customer_id",
|
|
18276
|
-
render: ({ field }) => {
|
|
18277
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
18278
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Customer" }),
|
|
18279
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
18280
|
-
Combobox,
|
|
18281
|
-
{
|
|
18282
|
-
value: field.value,
|
|
18283
|
-
onChange: field.onChange,
|
|
18284
|
-
searchValue,
|
|
18285
|
-
onSearchValueChange,
|
|
18286
|
-
options: customerOptions,
|
|
18287
|
-
placeholder: "Search for a customer...",
|
|
18288
|
-
fetchNextPage,
|
|
18289
|
-
isFetchingNextPage,
|
|
18290
|
-
noResultsPlaceholder: isLoading ? "Loading customers..." : "No customers found"
|
|
18291
|
-
}
|
|
18292
|
-
) }),
|
|
18293
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
18294
|
-
] });
|
|
18295
|
-
}
|
|
18296
|
-
}
|
|
18297
|
-
)
|
|
18298
|
-
] })
|
|
18299
|
-
] }) }) }),
|
|
18300
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Footer, { children: [
|
|
18301
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, disabled: isPending, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", disabled: isPending, children: "Cancel" }) }),
|
|
18302
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18303
|
-
ui.Button,
|
|
18304
|
-
{
|
|
18305
|
-
variant: "primary",
|
|
18306
|
-
size: "small",
|
|
18307
|
-
onClick: handleSubmit,
|
|
18308
|
-
disabled: isPending,
|
|
18309
|
-
children: "Create"
|
|
18310
|
-
}
|
|
18311
|
-
)
|
|
18312
|
-
] })
|
|
18313
|
-
] });
|
|
18314
|
-
};
|
|
18315
|
-
const StoreCreditAccountCreate = () => {
|
|
18316
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal, { children: [
|
|
18317
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create Store Credit Account" }) }),
|
|
18318
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create a new store credit account" }) }),
|
|
18319
|
-
/* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCreateForm, {})
|
|
18320
|
-
] });
|
|
18321
|
-
};
|
|
18322
|
-
const GiftCardIcon = (props) => {
|
|
18323
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
18324
|
-
"svg",
|
|
18325
|
-
{
|
|
18326
|
-
width: "15",
|
|
18327
|
-
height: "15",
|
|
18328
|
-
viewBox: "0 0 15 15",
|
|
18329
|
-
fill: "none",
|
|
18330
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
18331
|
-
...props,
|
|
18332
|
-
children: [
|
|
18333
|
-
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#F97316" }),
|
|
18334
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18335
|
-
"rect",
|
|
18336
|
-
{
|
|
18337
|
-
width: "15",
|
|
18338
|
-
height: "15",
|
|
18339
|
-
fill: "url(#paint0_linear_28788_25808)",
|
|
18340
|
-
fillOpacity: "0.2"
|
|
18341
|
-
}
|
|
18342
|
-
),
|
|
18343
|
-
/* @__PURE__ */ jsxRuntime.jsxs("g", { clipPath: "url(#clip0_28788_25808)", children: [
|
|
18344
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18345
|
-
"path",
|
|
18346
|
-
{
|
|
18347
|
-
d: "M7.5 6.375H5.375C4.479 6.375 3.75 5.618 3.75 4.688C3.75 3.757 4.479 3 5.375 3C7.365 3 8.019 5.569 8.047 5.678C8.088 5.846 8.05 6.023 7.943 6.16C7.836 6.296 7.673 6.375 7.5 6.375ZM5.375 4.125C5.099 4.125 4.875 4.377 4.875 4.688C4.875 4.998 5.099 5.25 5.375 5.25H6.688C6.439 4.736 6.011 4.125 5.375 4.125Z",
|
|
18348
|
-
fill: "white"
|
|
18349
|
-
}
|
|
18350
|
-
),
|
|
18351
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18352
|
-
"path",
|
|
18353
|
-
{
|
|
18354
|
-
d: "M9.625 6.375H7.5C7.328 6.375 7.164 6.296 7.058 6.16C6.95 6.023 6.913 5.846 6.953 5.678C6.98 5.569 7.634 3 9.625 3C10.521 3 11.25 3.757 11.25 4.688C11.25 5.618 10.521 6.375 9.625 6.375ZM8.312 5.25H9.625C9.901 5.25 10.125 4.998 10.125 4.688C10.125 4.377 9.901 4.125 9.625 4.125C8.99 4.125 8.561 4.736 8.312 5.25Z",
|
|
18355
|
-
fill: "white"
|
|
18356
|
-
}
|
|
18357
|
-
),
|
|
18358
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18359
|
-
"path",
|
|
18360
|
-
{
|
|
18361
|
-
d: "M11.438 6.375H3.562C3.252 6.375 3 6.123 3 5.813C3 5.502 3.252 5.25 3.562 5.25H11.438C11.748 5.25 12 5.502 12 5.813C12 6.123 11.748 6.375 11.438 6.375Z",
|
|
18362
|
-
fill: "white"
|
|
18363
|
-
}
|
|
18364
|
-
),
|
|
18365
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18366
|
-
"path",
|
|
18367
|
-
{
|
|
18368
|
-
d: "M6.938 7.5H3.75V9.563C3.75 10.7 4.675 11.625 5.813 11.625H6.938V7.5Z",
|
|
18369
|
-
fill: "white"
|
|
18370
|
-
}
|
|
18371
|
-
),
|
|
18372
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18373
|
-
"path",
|
|
18374
|
-
{
|
|
18375
|
-
d: "M8.063 7.5V11.625H9.188C10.325 11.625 11.25 10.7 11.25 9.563V7.5H8.063Z",
|
|
18376
|
-
fill: "white"
|
|
18377
|
-
}
|
|
18378
|
-
)
|
|
18379
|
-
] }),
|
|
18380
|
-
/* @__PURE__ */ jsxRuntime.jsxs("defs", { children: [
|
|
18381
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
18382
|
-
"linearGradient",
|
|
18383
|
-
{
|
|
18384
|
-
id: "paint0_linear_28788_25808",
|
|
18385
|
-
x1: "7.5",
|
|
18386
|
-
y1: "0",
|
|
18387
|
-
x2: "7.5",
|
|
18388
|
-
y2: "15",
|
|
18389
|
-
gradientUnits: "userSpaceOnUse",
|
|
18390
|
-
children: [
|
|
18391
|
-
/* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "white" }),
|
|
18392
|
-
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
|
|
18393
|
-
]
|
|
18394
|
-
}
|
|
18395
|
-
),
|
|
18396
|
-
/* @__PURE__ */ jsxRuntime.jsx("clipPath", { id: "clip0_28788_25808", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { width: "9", height: "9", fill: "white", transform: "translate(3 3)" }) })
|
|
18397
|
-
] })
|
|
18398
|
-
]
|
|
18399
|
-
}
|
|
18400
|
-
);
|
|
18401
|
-
};
|
|
18402
|
-
const GiftCardProductsSection = () => {
|
|
18403
|
-
const { products: giftCardProducts, count: count2 = 0 } = useProducts({
|
|
18404
|
-
is_giftcard: true
|
|
18405
|
-
});
|
|
18406
|
-
const slicedProducts = (giftCardProducts == null ? void 0 : giftCardProducts.slice(0, 3)) ?? [];
|
|
18407
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
18408
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
18409
|
-
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Gift Card Products" }),
|
|
18410
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18411
|
-
reactRouterDom.Link,
|
|
18412
|
-
{
|
|
18413
|
-
to: `/gift-cards/gift-card-products/create`,
|
|
18414
|
-
className: "text-ui-fg-muted text-sm px-6",
|
|
18415
|
-
children: "Create"
|
|
18416
|
-
}
|
|
18417
|
-
)
|
|
18418
|
-
] }),
|
|
18419
|
-
(giftCardProducts == null ? void 0 : giftCardProducts.length) === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
18420
|
-
NoRecords,
|
|
18421
|
-
{
|
|
18422
|
-
className: "px-10 py-4 h-[200px]",
|
|
18423
|
-
title: "No gift card products",
|
|
18424
|
-
message: "There are no gift card products to show. Create one to get started.",
|
|
18425
|
-
action: {
|
|
18426
|
-
to: "/gift-cards/gift-card-products/create",
|
|
18427
|
-
label: "Create gift card product"
|
|
18428
|
-
}
|
|
18429
|
-
}
|
|
18430
|
-
),
|
|
18431
|
-
slicedProducts.map((giftCardProduct) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
18432
|
-
SidebarLink,
|
|
18433
|
-
{
|
|
18434
|
-
to: `/gift-cards/gift-card-products/${giftCardProduct.id}`,
|
|
18435
|
-
labelKey: giftCardProduct.title,
|
|
18436
|
-
descriptionKey: giftCardProduct.title,
|
|
18437
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.Tag, {})
|
|
18438
|
-
}
|
|
18439
|
-
)),
|
|
18440
|
-
count2 > 3 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
18441
|
-
reactRouterDom.Link,
|
|
18442
|
-
{
|
|
18443
|
-
to: "/gift-cards/gift-card-products",
|
|
18444
|
-
className: "text-ui-fg-muted text-sm px-6 py-4 flex items-center justify-center",
|
|
18445
|
-
children: "View more"
|
|
18446
|
-
}
|
|
18447
|
-
)
|
|
18448
|
-
] });
|
|
18449
|
-
};
|
|
18450
|
-
const _giftCardQueryKey = queryKeysFactory("gift-card");
|
|
18451
|
-
const giftCardQueryKey = {
|
|
18452
|
-
..._giftCardQueryKey,
|
|
18453
|
-
orders: (id) => [..._giftCardQueryKey.detail(id), "orders"]
|
|
18454
|
-
};
|
|
18455
|
-
const useGiftCards = (query, options) => {
|
|
18456
|
-
const fetchGiftCards = (query2, headers) => sdk.client.fetch(`/admin/gift-cards`, {
|
|
18457
|
-
query: query2,
|
|
18458
|
-
headers
|
|
18459
|
-
});
|
|
18460
|
-
const { data, ...rest } = reactQuery.useQuery({
|
|
18461
|
-
...options,
|
|
18462
|
-
queryFn: () => fetchGiftCards(query),
|
|
18463
|
-
queryKey: giftCardQueryKey.list(query)
|
|
18464
|
-
});
|
|
18465
|
-
return { ...data, ...rest };
|
|
18466
|
-
};
|
|
18467
|
-
const useGiftCard = (id, query, options) => {
|
|
18468
|
-
const fetchGiftCard = (id2, query2, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
|
|
18469
|
-
query: query2,
|
|
18470
|
-
headers
|
|
18471
|
-
});
|
|
18472
|
-
const { data, ...rest } = reactQuery.useQuery({
|
|
18473
|
-
queryFn: () => fetchGiftCard(id, query),
|
|
18474
|
-
queryKey: giftCardQueryKey.detail(id, query),
|
|
18475
|
-
...options
|
|
18476
|
-
});
|
|
18477
|
-
return { ...data, ...rest };
|
|
18478
|
-
};
|
|
18479
|
-
const useGiftCardOrders = (id, options) => {
|
|
18480
|
-
const fetchGiftCardOrders = (id2, query, headers) => sdk.client.fetch(`/admin/gift-cards/${id2}/orders`, {
|
|
18481
|
-
query,
|
|
18482
|
-
headers
|
|
18483
|
-
});
|
|
18484
|
-
const { data, ...rest } = reactQuery.useQuery({
|
|
18485
|
-
queryFn: () => fetchGiftCardOrders(id),
|
|
18486
|
-
queryKey: giftCardQueryKey.orders(id),
|
|
18487
|
-
...options
|
|
18488
|
-
});
|
|
18489
|
-
return { ...data, ...rest };
|
|
18490
|
-
};
|
|
18491
|
-
const useUpdateGiftCard = (id, options) => {
|
|
18492
|
-
const queryClient = reactQuery.useQueryClient();
|
|
18493
|
-
const updateGiftCard = async (id2, body) => sdk.client.fetch(`/admin/gift-cards/${id2}`, {
|
|
18494
|
-
body,
|
|
18495
|
-
method: "POST"
|
|
18496
|
-
});
|
|
18497
|
-
return reactQuery.useMutation({
|
|
18498
|
-
mutationFn: async (payload) => updateGiftCard(id, payload),
|
|
18499
|
-
onSuccess: (data, variables, context) => {
|
|
18500
|
-
queryClient.invalidateQueries({
|
|
18501
|
-
queryKey: giftCardQueryKey.detail(id)
|
|
18502
|
-
});
|
|
18503
|
-
queryClient.invalidateQueries({
|
|
18504
|
-
queryKey: giftCardQueryKey.lists()
|
|
18505
|
-
});
|
|
18506
|
-
},
|
|
18507
|
-
...options
|
|
18508
|
-
});
|
|
18509
|
-
};
|
|
18510
|
-
const useCreateGiftCard = (options) => {
|
|
18511
|
-
const queryClient = reactQuery.useQueryClient();
|
|
18512
|
-
const createGiftCard = async (body) => sdk.client.fetch(`/admin/gift-cards`, {
|
|
18513
|
-
body,
|
|
18514
|
-
method: "POST"
|
|
18515
|
-
});
|
|
18516
|
-
return reactQuery.useMutation({
|
|
18517
|
-
mutationFn: (body) => createGiftCard(body),
|
|
18518
|
-
onSuccess: (data, variables, context) => {
|
|
18519
|
-
queryClient.invalidateQueries({ queryKey: giftCardQueryKey.lists() });
|
|
18520
|
-
},
|
|
18521
|
-
...options
|
|
18522
|
-
});
|
|
18523
|
-
};
|
|
18524
|
-
const columnHelper$9 = ui.createDataTableColumnHelper();
|
|
18525
|
-
const useGiftCardTableColumns = () => {
|
|
18526
|
-
return React.useMemo(() => {
|
|
18527
|
-
return [
|
|
18528
|
-
columnHelper$9.accessor("code", {
|
|
18529
|
-
header: "Code",
|
|
18530
|
-
cell: ({ row }) => {
|
|
18531
|
-
return row.original.code;
|
|
18532
|
-
}
|
|
18533
|
-
}),
|
|
18534
|
-
columnHelper$9.accessor("line_item.product.title", {
|
|
18535
|
-
header: "Product",
|
|
18536
|
-
cell: ({ row }) => {
|
|
18537
|
-
var _a2, _b;
|
|
18538
|
-
return ((_b = (_a2 = row.original.line_item) == null ? void 0 : _a2.product) == null ? void 0 : _b.title) || "Custom Gift Card";
|
|
18539
|
-
}
|
|
18540
|
-
}),
|
|
18541
|
-
columnHelper$9.accessor("created_at", {
|
|
18542
|
-
header: "Date issued",
|
|
18543
|
-
cell: ({ row }) => getRelativeDate(row.original.created_at)
|
|
18544
|
-
}),
|
|
18545
|
-
columnHelper$9.accessor("value", {
|
|
18546
|
-
header: "Value",
|
|
18547
|
-
cell: ({ row }) => {
|
|
18548
|
-
return formatAmount(row.original.value, row.original.currency_code);
|
|
18549
|
-
}
|
|
18550
|
-
})
|
|
18551
|
-
];
|
|
18552
|
-
}, []);
|
|
18553
|
-
};
|
|
18554
|
-
const useGiftCardFilters = () => {
|
|
18555
|
-
const dateFilterOptions = useDataTableDateFilters$1();
|
|
18556
|
-
const customerFilterOptions = useCustomerFilters();
|
|
18557
|
-
return React.useMemo(() => {
|
|
18558
|
-
return [...dateFilterOptions, ...customerFilterOptions];
|
|
18559
|
-
}, [dateFilterOptions, customerFilterOptions]);
|
|
18560
|
-
};
|
|
18561
|
-
const useGiftCardTableQuery = ({
|
|
18562
|
-
prefix,
|
|
18563
|
-
pageSize = 20
|
|
18564
|
-
}) => {
|
|
18565
|
-
const queryObject = useQueryParams(
|
|
18566
|
-
["q", "offset", "customer_id", "created_at", "updated_at"],
|
|
18567
|
-
prefix
|
|
18568
|
-
);
|
|
18569
|
-
const { offset: offset2, created_at, updated_at, customer_id, ...rest } = queryObject;
|
|
18570
|
-
const searchParams = {
|
|
18571
|
-
limit: pageSize,
|
|
18572
|
-
offset: offset2 ? Number(offset2) : 0,
|
|
18573
|
-
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
18574
|
-
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
18575
|
-
customer_id: customer_id ? JSON.parse(customer_id) : void 0,
|
|
18576
|
-
...rest
|
|
18577
|
-
};
|
|
18578
|
-
return searchParams;
|
|
18579
|
-
};
|
|
18580
|
-
const PAGE_SIZE$5 = 10;
|
|
18581
|
-
function GiftCardsTable() {
|
|
18582
|
-
const queryParams = useGiftCardTableQuery({
|
|
18583
|
-
pageSize: PAGE_SIZE$5
|
|
18584
|
-
});
|
|
18585
|
-
const {
|
|
18586
|
-
gift_cards: giftCards,
|
|
18587
|
-
isPending,
|
|
18588
|
-
count: count2
|
|
18589
|
-
} = useGiftCards({
|
|
18590
|
-
...queryParams,
|
|
18591
|
-
order: queryParams.order ?? "-created_at",
|
|
18592
|
-
fields: "+line_item.product.title"
|
|
18593
|
-
});
|
|
18594
|
-
const columns = useGiftCardTableColumns();
|
|
18595
|
-
const filters = useGiftCardFilters();
|
|
18596
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
18597
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
18598
|
-
DataTable,
|
|
18599
|
-
{
|
|
18600
|
-
data: giftCards,
|
|
18601
|
-
getRowId: (row) => row.id,
|
|
18602
|
-
columns,
|
|
18603
|
-
filters,
|
|
18604
|
-
isLoading: isPending,
|
|
18605
|
-
pageSize: PAGE_SIZE$5,
|
|
18606
|
-
rowCount: count2,
|
|
18607
|
-
heading: "Gift Cards",
|
|
18608
|
-
rowHref: (row) => `${row.id}`,
|
|
18609
|
-
emptyState: {
|
|
18610
|
-
empty: {
|
|
18611
|
-
heading: "No gift cards found",
|
|
18612
|
-
description: "Create a gift card to get started."
|
|
18613
|
-
},
|
|
18614
|
-
filtered: {
|
|
18615
|
-
heading: "No results found",
|
|
18616
|
-
description: "No gift cards match your filter criteria."
|
|
18617
|
-
}
|
|
18618
|
-
},
|
|
18619
|
-
actions: [
|
|
18620
|
-
{
|
|
18621
|
-
label: "Create",
|
|
18622
|
-
to: "create"
|
|
18623
|
-
}
|
|
18624
|
-
]
|
|
18625
|
-
}
|
|
18626
|
-
) }),
|
|
18627
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
18628
|
-
] });
|
|
18629
|
-
}
|
|
18630
|
-
const GiftCardsPage = () => {
|
|
18631
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
18632
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18633
|
-
components.LayoutComposer,
|
|
18634
|
-
{
|
|
18635
|
-
widgetsZonePrefix: "gift_card.list",
|
|
18636
|
-
preferredLayoutId: "core:two-column",
|
|
18637
|
-
sections: {
|
|
18638
|
-
main: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardsTable", children: /* @__PURE__ */ jsxRuntime.jsx(GiftCardsTable, {}) }),
|
|
18639
|
-
side: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "GiftCardProductsSection", children: /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductsSection, {}) })
|
|
18640
|
-
}
|
|
18641
|
-
}
|
|
18642
|
-
),
|
|
18643
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Toaster, {})
|
|
18644
|
-
] });
|
|
18645
|
-
};
|
|
18646
|
-
const config$2 = adminSdk.defineRouteConfig({
|
|
18647
|
-
label: "Gift Cards",
|
|
18648
|
-
icon: GiftCardIcon
|
|
18649
|
-
});
|
|
18650
|
-
const STORE_QUERY_KEY = "store";
|
|
18651
|
-
const storeQueryKeys = queryKeysFactory(STORE_QUERY_KEY);
|
|
18652
|
-
async function retrieveActiveStore(query) {
|
|
18653
|
-
var _a2;
|
|
18654
|
-
const response = await sdk.admin.store.list(query);
|
|
18655
|
-
const activeStore = (_a2 = response.stores) == null ? void 0 : _a2[0];
|
|
18656
|
-
if (!activeStore) {
|
|
18657
|
-
throw new Medusa.FetchError("No active store found", "Not Found", 404);
|
|
18658
|
-
}
|
|
18659
|
-
return { store: activeStore };
|
|
18660
|
-
}
|
|
18661
|
-
const useStore$1 = (query, options) => {
|
|
18662
|
-
const { data, ...rest } = reactQuery.useQuery({
|
|
18663
|
-
queryFn: () => retrieveActiveStore(query),
|
|
18664
|
-
queryKey: storeQueryKeys.details(),
|
|
18665
|
-
...options
|
|
18666
|
-
});
|
|
18667
|
-
return {
|
|
18668
|
-
...data,
|
|
18669
|
-
...rest
|
|
18670
|
-
};
|
|
18671
|
-
};
|
|
18672
18052
|
function $constructor(name, initializer2, params) {
|
|
18673
18053
|
function init2(inst, def) {
|
|
18674
18054
|
if (!inst._zod) {
|
|
@@ -18733,7 +18113,7 @@ class $ZodEncodeError extends Error {
|
|
|
18733
18113
|
}
|
|
18734
18114
|
}
|
|
18735
18115
|
const globalConfig = {};
|
|
18736
|
-
function config$
|
|
18116
|
+
function config$2(newConfig) {
|
|
18737
18117
|
return globalConfig;
|
|
18738
18118
|
}
|
|
18739
18119
|
function getEnumValues(entries) {
|
|
@@ -18827,7 +18207,7 @@ function slugify(input) {
|
|
|
18827
18207
|
}
|
|
18828
18208
|
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
|
|
18829
18209
|
};
|
|
18830
|
-
function isObject$
|
|
18210
|
+
function isObject$6(data) {
|
|
18831
18211
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
18832
18212
|
}
|
|
18833
18213
|
const allowsEval = cached(() => {
|
|
@@ -18844,7 +18224,7 @@ const allowsEval = cached(() => {
|
|
|
18844
18224
|
}
|
|
18845
18225
|
});
|
|
18846
18226
|
function isPlainObject(o2) {
|
|
18847
|
-
if (isObject$
|
|
18227
|
+
if (isObject$6(o2) === false)
|
|
18848
18228
|
return false;
|
|
18849
18229
|
const ctor = o2.constructor;
|
|
18850
18230
|
if (ctor === void 0)
|
|
@@ -18852,7 +18232,7 @@ function isPlainObject(o2) {
|
|
|
18852
18232
|
if (typeof ctor !== "function")
|
|
18853
18233
|
return true;
|
|
18854
18234
|
const prot = ctor.prototype;
|
|
18855
|
-
if (isObject$
|
|
18235
|
+
if (isObject$6(prot) === false)
|
|
18856
18236
|
return false;
|
|
18857
18237
|
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
18858
18238
|
return false;
|
|
@@ -19183,7 +18563,7 @@ const _parse = (_Err) => (schema2, value, _ctx, _params) => {
|
|
|
19183
18563
|
throw new $ZodAsyncError();
|
|
19184
18564
|
}
|
|
19185
18565
|
if (result.issues.length) {
|
|
19186
|
-
const e2 = new ((_params == null ? void 0 : _params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
18566
|
+
const e2 = new ((_params == null ? void 0 : _params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())));
|
|
19187
18567
|
captureStackTrace(e2, _params == null ? void 0 : _params.callee);
|
|
19188
18568
|
throw e2;
|
|
19189
18569
|
}
|
|
@@ -19195,7 +18575,7 @@ const _parseAsync = (_Err) => async (schema2, value, _ctx, params) => {
|
|
|
19195
18575
|
if (result instanceof Promise)
|
|
19196
18576
|
result = await result;
|
|
19197
18577
|
if (result.issues.length) {
|
|
19198
|
-
const e2 = new ((params == null ? void 0 : params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
18578
|
+
const e2 = new ((params == null ? void 0 : params.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())));
|
|
19199
18579
|
captureStackTrace(e2, params == null ? void 0 : params.callee);
|
|
19200
18580
|
throw e2;
|
|
19201
18581
|
}
|
|
@@ -19209,7 +18589,7 @@ const _safeParse = (_Err) => (schema2, value, _ctx) => {
|
|
|
19209
18589
|
}
|
|
19210
18590
|
return result.issues.length ? {
|
|
19211
18591
|
success: false,
|
|
19212
|
-
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
18592
|
+
error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())))
|
|
19213
18593
|
} : { success: true, data: result.value };
|
|
19214
18594
|
};
|
|
19215
18595
|
const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
@@ -19220,7 +18600,7 @@ const _safeParseAsync = (_Err) => async (schema2, value, _ctx) => {
|
|
|
19220
18600
|
result = await result;
|
|
19221
18601
|
return result.issues.length ? {
|
|
19222
18602
|
success: false,
|
|
19223
|
-
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
18603
|
+
error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())))
|
|
19224
18604
|
} : { success: true, data: result.value };
|
|
19225
18605
|
};
|
|
19226
18606
|
const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
@@ -20359,7 +19739,7 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
20359
19739
|
}
|
|
20360
19740
|
return propValues;
|
|
20361
19741
|
});
|
|
20362
|
-
const isObject2 = isObject$
|
|
19742
|
+
const isObject2 = isObject$6;
|
|
20363
19743
|
const catchall = def.catchall;
|
|
20364
19744
|
let value;
|
|
20365
19745
|
inst._zod.parse = (payload, ctx2) => {
|
|
@@ -20439,7 +19819,7 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
|
|
|
20439
19819
|
return (payload, ctx2) => fn(shape, payload, ctx2);
|
|
20440
19820
|
};
|
|
20441
19821
|
let fastpass;
|
|
20442
|
-
const isObject2 = isObject$
|
|
19822
|
+
const isObject2 = isObject$6;
|
|
20443
19823
|
const jit = !globalConfig.jitless;
|
|
20444
19824
|
const allowsEval$1 = allowsEval;
|
|
20445
19825
|
const fastEnabled = jit && allowsEval$1.value;
|
|
@@ -20484,7 +19864,7 @@ function handleUnionResults(results, final, inst, ctx2) {
|
|
|
20484
19864
|
code: "invalid_union",
|
|
20485
19865
|
input: final.value,
|
|
20486
19866
|
inst,
|
|
20487
|
-
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
19867
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())))
|
|
20488
19868
|
});
|
|
20489
19869
|
return final;
|
|
20490
19870
|
}
|
|
@@ -20677,7 +20057,7 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
20677
20057
|
payload.issues.push({
|
|
20678
20058
|
code: "invalid_key",
|
|
20679
20059
|
origin: "record",
|
|
20680
|
-
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
20060
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx2, config$2())),
|
|
20681
20061
|
input: key2,
|
|
20682
20062
|
path: [key2],
|
|
20683
20063
|
inst
|
|
@@ -20876,7 +20256,7 @@ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
|
20876
20256
|
payload.value = def.catchValue({
|
|
20877
20257
|
...payload,
|
|
20878
20258
|
error: {
|
|
20879
|
-
issues: result2.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
20259
|
+
issues: result2.issues.map((iss) => finalizeIssue(iss, ctx2, config$2()))
|
|
20880
20260
|
},
|
|
20881
20261
|
input: payload.value
|
|
20882
20262
|
});
|
|
@@ -20890,7 +20270,7 @@ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
|
20890
20270
|
payload.value = def.catchValue({
|
|
20891
20271
|
...payload,
|
|
20892
20272
|
error: {
|
|
20893
|
-
issues: result.issues.map((iss) => finalizeIssue(iss, ctx2, config$
|
|
20273
|
+
issues: result.issues.map((iss) => finalizeIssue(iss, ctx2, config$2()))
|
|
20894
20274
|
},
|
|
20895
20275
|
input: payload.value
|
|
20896
20276
|
});
|
|
@@ -22950,546 +22330,633 @@ const GiftCardCreateForm = ({
|
|
|
22950
22330
|
] });
|
|
22951
22331
|
};
|
|
22952
22332
|
const GiftCardCreate = () => {
|
|
22953
|
-
const { store, isLoading } = useStore$
|
|
22333
|
+
const { store, isLoading } = useStore$2({});
|
|
22954
22334
|
return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal, { children: [
|
|
22955
22335
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create Gift Card" }) }),
|
|
22956
22336
|
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create a new gift card" }) }),
|
|
22957
22337
|
!isLoading && /* @__PURE__ */ jsxRuntime.jsx(GiftCardCreateForm, { store })
|
|
22958
22338
|
] });
|
|
22959
22339
|
};
|
|
22960
|
-
const
|
|
22961
|
-
|
|
22962
|
-
|
|
22963
|
-
|
|
22964
|
-
|
|
22965
|
-
|
|
22966
|
-
|
|
22967
|
-
|
|
22968
|
-
|
|
22969
|
-
|
|
22970
|
-
|
|
22971
|
-
|
|
22972
|
-
|
|
22973
|
-
|
|
22974
|
-
size: "xlarge",
|
|
22975
|
-
className: "tabular-nums text-ui-fg-base",
|
|
22976
|
-
children: formatAmount(
|
|
22977
|
-
storeCreditAccount.balance,
|
|
22978
|
-
storeCreditAccount.currency_code
|
|
22979
|
-
)
|
|
22980
|
-
}
|
|
22981
|
-
)
|
|
22982
|
-
] })
|
|
22983
|
-
] }) });
|
|
22984
|
-
};
|
|
22985
|
-
var toggleSelection = function() {
|
|
22986
|
-
var selection = document.getSelection();
|
|
22987
|
-
if (!selection.rangeCount) {
|
|
22988
|
-
return function() {
|
|
22989
|
-
};
|
|
22990
|
-
}
|
|
22991
|
-
var active = document.activeElement;
|
|
22992
|
-
var ranges = [];
|
|
22993
|
-
for (var i2 = 0; i2 < selection.rangeCount; i2++) {
|
|
22994
|
-
ranges.push(selection.getRangeAt(i2));
|
|
22995
|
-
}
|
|
22996
|
-
switch (active.tagName.toUpperCase()) {
|
|
22997
|
-
// .toUpperCase handles XHTML
|
|
22998
|
-
case "INPUT":
|
|
22999
|
-
case "TEXTAREA":
|
|
23000
|
-
active.blur();
|
|
23001
|
-
break;
|
|
23002
|
-
default:
|
|
23003
|
-
active = null;
|
|
23004
|
-
break;
|
|
23005
|
-
}
|
|
23006
|
-
selection.removeAllRanges();
|
|
23007
|
-
return function() {
|
|
23008
|
-
selection.type === "Caret" && selection.removeAllRanges();
|
|
23009
|
-
if (!selection.rangeCount) {
|
|
23010
|
-
ranges.forEach(function(range) {
|
|
23011
|
-
selection.addRange(range);
|
|
23012
|
-
});
|
|
23013
|
-
}
|
|
23014
|
-
active && active.focus();
|
|
23015
|
-
};
|
|
23016
|
-
};
|
|
23017
|
-
var deselectCurrent = toggleSelection;
|
|
23018
|
-
var clipboardToIE11Formatting = {
|
|
23019
|
-
"text/plain": "Text",
|
|
23020
|
-
"text/html": "Url",
|
|
23021
|
-
"default": "Text"
|
|
23022
|
-
};
|
|
23023
|
-
var defaultMessage = "Copy to clipboard: #{key}, Enter";
|
|
23024
|
-
function format(message2) {
|
|
23025
|
-
var copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C";
|
|
23026
|
-
return message2.replace(/#{\s*key\s*}/g, copyKey);
|
|
23027
|
-
}
|
|
23028
|
-
function copy$2(text2, options) {
|
|
23029
|
-
var debug2, message2, reselectPrevious, range, selection, mark, success = false;
|
|
23030
|
-
if (!options) {
|
|
23031
|
-
options = {};
|
|
23032
|
-
}
|
|
23033
|
-
debug2 = options.debug || false;
|
|
23034
|
-
try {
|
|
23035
|
-
reselectPrevious = deselectCurrent();
|
|
23036
|
-
range = document.createRange();
|
|
23037
|
-
selection = document.getSelection();
|
|
23038
|
-
mark = document.createElement("span");
|
|
23039
|
-
mark.textContent = text2;
|
|
23040
|
-
mark.ariaHidden = "true";
|
|
23041
|
-
mark.style.all = "unset";
|
|
23042
|
-
mark.style.position = "fixed";
|
|
23043
|
-
mark.style.top = 0;
|
|
23044
|
-
mark.style.clip = "rect(0, 0, 0, 0)";
|
|
23045
|
-
mark.style.whiteSpace = "pre";
|
|
23046
|
-
mark.style.webkitUserSelect = "text";
|
|
23047
|
-
mark.style.MozUserSelect = "text";
|
|
23048
|
-
mark.style.msUserSelect = "text";
|
|
23049
|
-
mark.style.userSelect = "text";
|
|
23050
|
-
mark.addEventListener("copy", function(e2) {
|
|
23051
|
-
e2.stopPropagation();
|
|
23052
|
-
if (options.format) {
|
|
23053
|
-
e2.preventDefault();
|
|
23054
|
-
if (typeof e2.clipboardData === "undefined") {
|
|
23055
|
-
debug2 && console.warn("unable to use e.clipboardData");
|
|
23056
|
-
debug2 && console.warn("trying IE specific stuff");
|
|
23057
|
-
window.clipboardData.clearData();
|
|
23058
|
-
var format2 = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting["default"];
|
|
23059
|
-
window.clipboardData.setData(format2, text2);
|
|
23060
|
-
} else {
|
|
23061
|
-
e2.clipboardData.clearData();
|
|
23062
|
-
e2.clipboardData.setData(options.format, text2);
|
|
23063
|
-
}
|
|
23064
|
-
}
|
|
23065
|
-
if (options.onCopy) {
|
|
23066
|
-
e2.preventDefault();
|
|
23067
|
-
options.onCopy(e2.clipboardData);
|
|
23068
|
-
}
|
|
23069
|
-
});
|
|
23070
|
-
document.body.appendChild(mark);
|
|
23071
|
-
range.selectNodeContents(mark);
|
|
23072
|
-
selection.addRange(range);
|
|
23073
|
-
var successful = document.execCommand("copy");
|
|
23074
|
-
if (!successful) {
|
|
23075
|
-
throw new Error("copy command was unsuccessful");
|
|
23076
|
-
}
|
|
23077
|
-
success = true;
|
|
23078
|
-
} catch (err) {
|
|
23079
|
-
debug2 && console.error("unable to copy using execCommand: ", err);
|
|
23080
|
-
debug2 && console.warn("trying IE specific stuff");
|
|
23081
|
-
try {
|
|
23082
|
-
window.clipboardData.setData(options.format || "text", text2);
|
|
23083
|
-
options.onCopy && options.onCopy(window.clipboardData);
|
|
23084
|
-
success = true;
|
|
23085
|
-
} catch (err2) {
|
|
23086
|
-
debug2 && console.error("unable to copy using clipboardData: ", err2);
|
|
23087
|
-
debug2 && console.error("falling back to prompt");
|
|
23088
|
-
message2 = format("message" in options ? options.message : defaultMessage);
|
|
23089
|
-
window.prompt(message2, text2);
|
|
23090
|
-
}
|
|
23091
|
-
} finally {
|
|
23092
|
-
if (selection) {
|
|
23093
|
-
if (typeof selection.removeRange == "function") {
|
|
23094
|
-
selection.removeRange(range);
|
|
23095
|
-
} else {
|
|
23096
|
-
selection.removeAllRanges();
|
|
23097
|
-
}
|
|
23098
|
-
}
|
|
23099
|
-
if (mark) {
|
|
23100
|
-
document.body.removeChild(mark);
|
|
23101
|
-
}
|
|
23102
|
-
reselectPrevious();
|
|
23103
|
-
}
|
|
23104
|
-
return success;
|
|
23105
|
-
}
|
|
23106
|
-
var copyToClipboard = copy$2;
|
|
23107
|
-
const copy$1 = /* @__PURE__ */ getDefaultExportFromCjs(copyToClipboard);
|
|
23108
|
-
function DisplayId({ id, className }) {
|
|
23109
|
-
const [open, setOpen] = React.useState(false);
|
|
23110
|
-
const onClick = () => {
|
|
23111
|
-
copy$1(id);
|
|
23112
|
-
ui.toast.success("Copied to clipboard");
|
|
23113
|
-
};
|
|
23114
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { maxWidth: 260, content: id, open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxRuntime.jsxs("span", { onClick, className: ui.clx("cursor-pointer", className), children: [
|
|
23115
|
-
"#",
|
|
23116
|
-
id.slice(-7)
|
|
23117
|
-
] }) });
|
|
23118
|
-
}
|
|
23119
|
-
const StoreCreditAccountDetailsSection = ({
|
|
23120
|
-
storeCreditAccount
|
|
23121
|
-
}) => {
|
|
23122
|
-
if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
|
|
23123
|
-
return;
|
|
23124
|
-
}
|
|
23125
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "flex justify-between gap-x-2 px-6 py-6", children: [
|
|
23126
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
23127
|
-
ui.Text,
|
|
23128
|
-
{
|
|
23129
|
-
weight: "plus",
|
|
23130
|
-
size: "xlarge",
|
|
23131
|
-
className: "text-ui-fg-base flex gap-x-4",
|
|
23132
|
-
children: [
|
|
23133
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
23134
|
-
/* @__PURE__ */ jsxRuntime.jsx(CreditCardIcon, { className: "inline" }),
|
|
23135
|
-
" "
|
|
23136
|
-
] }),
|
|
23137
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
23138
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle", children: [
|
|
23139
|
-
storeCreditAccount.currency_code.toUpperCase(),
|
|
23140
|
-
" Account"
|
|
23141
|
-
] }),
|
|
23142
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
23143
|
-
ui.Text,
|
|
23144
|
-
{
|
|
23145
|
-
weight: "regular",
|
|
23146
|
-
size: "small",
|
|
23147
|
-
className: "text-ui-fg-base flex gap-x-4",
|
|
23148
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(DisplayId, { id: storeCreditAccount.id })
|
|
23149
|
-
}
|
|
23150
|
-
) })
|
|
23151
|
-
] })
|
|
23152
|
-
]
|
|
23153
|
-
}
|
|
23154
|
-
),
|
|
23155
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-x-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
23156
|
-
ActionMenu,
|
|
23157
|
-
{
|
|
23158
|
-
groups: [
|
|
22340
|
+
const StoreCreditIcon = (props) => {
|
|
22341
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
22342
|
+
"svg",
|
|
22343
|
+
{
|
|
22344
|
+
width: "15",
|
|
22345
|
+
height: "15",
|
|
22346
|
+
viewBox: "0 0 15 15",
|
|
22347
|
+
fill: "none",
|
|
22348
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
22349
|
+
...props,
|
|
22350
|
+
children: [
|
|
22351
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { width: "15", height: "15", fill: "#8B5CF6" }),
|
|
22352
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
22353
|
+
"rect",
|
|
23159
22354
|
{
|
|
23160
|
-
|
|
23161
|
-
|
|
23162
|
-
|
|
23163
|
-
|
|
23164
|
-
|
|
23165
|
-
|
|
22355
|
+
width: "15",
|
|
22356
|
+
height: "15",
|
|
22357
|
+
fill: "url(#paint0_linear_29181_44790)",
|
|
22358
|
+
fillOpacity: "0.2"
|
|
22359
|
+
}
|
|
22360
|
+
),
|
|
22361
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
22362
|
+
"path",
|
|
22363
|
+
{
|
|
22364
|
+
d: "M12 6V5.813C12 4.675 11.075 3.75 9.938 3.75H5.063C3.925 3.75 3 4.675 3 5.813V6H12Z",
|
|
22365
|
+
fill: "white"
|
|
22366
|
+
}
|
|
22367
|
+
),
|
|
22368
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
22369
|
+
"path",
|
|
22370
|
+
{
|
|
22371
|
+
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",
|
|
22372
|
+
fill: "white"
|
|
22373
|
+
}
|
|
22374
|
+
),
|
|
22375
|
+
/* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
22376
|
+
"linearGradient",
|
|
22377
|
+
{
|
|
22378
|
+
id: "paint0_linear_29181_44790",
|
|
22379
|
+
x1: "7.5",
|
|
22380
|
+
y1: "0",
|
|
22381
|
+
x2: "7.5",
|
|
22382
|
+
y2: "15",
|
|
22383
|
+
gradientUnits: "userSpaceOnUse",
|
|
22384
|
+
children: [
|
|
22385
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { stopColor: "white" }),
|
|
22386
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "1", stopColor: "white", stopOpacity: "0" })
|
|
23166
22387
|
]
|
|
23167
22388
|
}
|
|
23168
|
-
|
|
23169
|
-
|
|
23170
|
-
|
|
23171
|
-
|
|
22389
|
+
) })
|
|
22390
|
+
]
|
|
22391
|
+
}
|
|
22392
|
+
);
|
|
23172
22393
|
};
|
|
23173
|
-
|
|
23174
|
-
|
|
23175
|
-
}) {
|
|
23176
|
-
const { customer, isPending } = useCustomer(customerId, void 0, {
|
|
23177
|
-
enabled: !!customerId
|
|
23178
|
-
});
|
|
23179
|
-
if (isPending || !customer) {
|
|
23180
|
-
return null;
|
|
23181
|
-
}
|
|
23182
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
23183
|
-
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Customer" }),
|
|
23184
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
23185
|
-
SidebarLink,
|
|
23186
|
-
{
|
|
23187
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {}),
|
|
23188
|
-
labelKey: customer.email || "N/A",
|
|
23189
|
-
descriptionKey: !customer.first_name && !customer.last_name ? "N/A" : `${customer.first_name} ${customer.last_name}`,
|
|
23190
|
-
to: `/customers/${customer.id}`
|
|
23191
|
-
},
|
|
23192
|
-
customer.id
|
|
23193
|
-
)
|
|
23194
|
-
] });
|
|
23195
|
-
}
|
|
23196
|
-
const columnHelper$8 = ui.createDataTableColumnHelper();
|
|
23197
|
-
const useTransactionsTableColumns = () => {
|
|
22394
|
+
const columnHelper$9 = ui.createDataTableColumnHelper();
|
|
22395
|
+
const useStoreCreditAccountTableColumns = () => {
|
|
23198
22396
|
return React.useMemo(() => {
|
|
23199
22397
|
return [
|
|
23200
|
-
columnHelper$
|
|
23201
|
-
header: "
|
|
22398
|
+
columnHelper$9.accessor("currency_code", {
|
|
22399
|
+
header: "Currency",
|
|
23202
22400
|
cell: ({ row }) => {
|
|
23203
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
22401
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { size: "2xsmall", children: row.original.currency_code.toUpperCase() });
|
|
23204
22402
|
}
|
|
23205
22403
|
}),
|
|
23206
|
-
columnHelper$
|
|
23207
|
-
header: "
|
|
23208
|
-
cell: ({ row }) =>
|
|
22404
|
+
columnHelper$9.accessor("customer.email", {
|
|
22405
|
+
header: "Customer",
|
|
22406
|
+
cell: ({ row }) => {
|
|
22407
|
+
var _a2;
|
|
22408
|
+
return ((_a2 = row.original.customer) == null ? void 0 : _a2.email) ?? "N/A";
|
|
22409
|
+
}
|
|
23209
22410
|
}),
|
|
23210
|
-
columnHelper$
|
|
23211
|
-
header: "
|
|
23212
|
-
cell: ({ row }) =>
|
|
22411
|
+
columnHelper$9.accessor("balance", {
|
|
22412
|
+
header: "Balance",
|
|
22413
|
+
cell: ({ row }) => {
|
|
22414
|
+
return formatAmount(
|
|
22415
|
+
row.original.balance,
|
|
22416
|
+
row.original.currency_code
|
|
22417
|
+
);
|
|
22418
|
+
}
|
|
23213
22419
|
}),
|
|
23214
|
-
columnHelper$
|
|
23215
|
-
header: "
|
|
22420
|
+
columnHelper$9.accessor("credits", {
|
|
22421
|
+
header: "Credits",
|
|
23216
22422
|
cell: ({ row }) => {
|
|
23217
|
-
return
|
|
22423
|
+
return formatAmount(
|
|
22424
|
+
row.original.credits,
|
|
22425
|
+
row.original.currency_code
|
|
22426
|
+
);
|
|
23218
22427
|
}
|
|
23219
22428
|
}),
|
|
23220
|
-
columnHelper$
|
|
23221
|
-
header: "
|
|
22429
|
+
columnHelper$9.accessor("debits", {
|
|
22430
|
+
header: "Debits",
|
|
23222
22431
|
cell: ({ row }) => {
|
|
23223
|
-
|
|
23224
|
-
|
|
23225
|
-
row.original.
|
|
23226
|
-
row.original.account.currency_code
|
|
22432
|
+
return formatAmount(
|
|
22433
|
+
row.original.debits,
|
|
22434
|
+
row.original.currency_code
|
|
23227
22435
|
);
|
|
23228
22436
|
}
|
|
22437
|
+
}),
|
|
22438
|
+
columnHelper$9.accessor("created_at", {
|
|
22439
|
+
header: "Created at",
|
|
22440
|
+
cell: ({ row }) => getRelativeDate(row.original.created_at)
|
|
23229
22441
|
})
|
|
23230
22442
|
];
|
|
23231
22443
|
}, []);
|
|
23232
22444
|
};
|
|
23233
|
-
const
|
|
22445
|
+
const useStoreCreditAccountFilters = () => {
|
|
23234
22446
|
const dateFilterOptions = useDataTableDateFilters$1();
|
|
22447
|
+
const customerFilterOptions = useCustomerFilters();
|
|
23235
22448
|
return React.useMemo(() => {
|
|
23236
|
-
return [...dateFilterOptions];
|
|
23237
|
-
}, [dateFilterOptions]);
|
|
22449
|
+
return [...dateFilterOptions, ...customerFilterOptions];
|
|
22450
|
+
}, [dateFilterOptions, customerFilterOptions]);
|
|
23238
22451
|
};
|
|
23239
|
-
const
|
|
22452
|
+
const useStoreCreditAccountsTableQuery = ({
|
|
23240
22453
|
prefix,
|
|
23241
22454
|
pageSize = 20
|
|
23242
22455
|
}) => {
|
|
23243
22456
|
const queryObject = useQueryParams(
|
|
23244
|
-
["offset", "
|
|
22457
|
+
["offset", "customer_id", "currency_code", "created_at", "updated_at"],
|
|
23245
22458
|
prefix
|
|
23246
22459
|
);
|
|
23247
|
-
const {
|
|
22460
|
+
const {
|
|
22461
|
+
offset: offset2,
|
|
22462
|
+
created_at,
|
|
22463
|
+
updated_at,
|
|
22464
|
+
customer_id,
|
|
22465
|
+
currency_code,
|
|
22466
|
+
...rest
|
|
22467
|
+
} = queryObject;
|
|
23248
22468
|
const searchParams = {
|
|
23249
|
-
limit:
|
|
22469
|
+
limit: pageSize,
|
|
23250
22470
|
offset: offset2 ? Number(offset2) : 0,
|
|
23251
22471
|
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
23252
22472
|
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
22473
|
+
customer_id: customer_id ? JSON.parse(customer_id) : void 0,
|
|
22474
|
+
currency_code: currency_code ? JSON.parse(currency_code) : void 0,
|
|
23253
22475
|
...rest
|
|
23254
22476
|
};
|
|
23255
22477
|
return searchParams;
|
|
23256
22478
|
};
|
|
23257
|
-
const PAGE_SIZE$
|
|
23258
|
-
function
|
|
23259
|
-
const queryParams =
|
|
23260
|
-
pageSize: PAGE_SIZE$
|
|
22479
|
+
const PAGE_SIZE$5 = 10;
|
|
22480
|
+
function StoreCreditAccountsTable() {
|
|
22481
|
+
const queryParams = useStoreCreditAccountsTableQuery({
|
|
22482
|
+
pageSize: PAGE_SIZE$5
|
|
23261
22483
|
});
|
|
23262
|
-
const {
|
|
23263
|
-
|
|
23264
|
-
|
|
23265
|
-
|
|
23266
|
-
|
|
23267
|
-
|
|
23268
|
-
|
|
23269
|
-
);
|
|
23270
|
-
const columns =
|
|
23271
|
-
const filters =
|
|
22484
|
+
const {
|
|
22485
|
+
store_credit_accounts: storeCreditAccounts,
|
|
22486
|
+
isPending,
|
|
22487
|
+
count: count2
|
|
22488
|
+
} = useStoreCreditAccounts({
|
|
22489
|
+
...queryParams,
|
|
22490
|
+
order: queryParams.order ?? "-created_at"
|
|
22491
|
+
});
|
|
22492
|
+
const columns = useStoreCreditAccountTableColumns();
|
|
22493
|
+
const filters = useStoreCreditAccountFilters();
|
|
23272
22494
|
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
23273
22495
|
/* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
23274
22496
|
DataTable,
|
|
23275
22497
|
{
|
|
23276
|
-
data:
|
|
22498
|
+
data: storeCreditAccounts ?? [],
|
|
23277
22499
|
getRowId: (row) => row.id,
|
|
23278
22500
|
columns,
|
|
23279
22501
|
filters,
|
|
23280
|
-
isLoading,
|
|
23281
|
-
pageSize: PAGE_SIZE$
|
|
22502
|
+
isLoading: isPending,
|
|
22503
|
+
pageSize: PAGE_SIZE$5,
|
|
23282
22504
|
rowCount: count2,
|
|
23283
22505
|
enableSearch: false,
|
|
23284
|
-
heading: "
|
|
22506
|
+
heading: "Store Credit Accounts",
|
|
22507
|
+
rowHref: (row) => `${row.id}`,
|
|
23285
22508
|
emptyState: {
|
|
23286
22509
|
empty: {
|
|
23287
|
-
heading: "No
|
|
22510
|
+
heading: "No store credit accounts found",
|
|
22511
|
+
description: "Create a new store credit account to get started."
|
|
23288
22512
|
},
|
|
23289
22513
|
filtered: {
|
|
23290
22514
|
heading: "No results found",
|
|
23291
|
-
description: "No
|
|
22515
|
+
description: "No store credit accounts match your filter criteria."
|
|
23292
22516
|
}
|
|
23293
|
-
}
|
|
22517
|
+
},
|
|
22518
|
+
actions: [
|
|
22519
|
+
{
|
|
22520
|
+
label: "Create",
|
|
22521
|
+
to: "/store-credit-accounts/create"
|
|
22522
|
+
}
|
|
22523
|
+
]
|
|
23294
22524
|
}
|
|
23295
22525
|
) }),
|
|
23296
22526
|
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
23297
22527
|
] });
|
|
23298
22528
|
}
|
|
23299
|
-
|
|
23300
|
-
|
|
23301
|
-
|
|
23302
|
-
|
|
23303
|
-
|
|
23304
|
-
|
|
23305
|
-
|
|
23306
|
-
|
|
23307
|
-
|
|
23308
|
-
|
|
22529
|
+
const StoreCreditAccountsPage = () => {
|
|
22530
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
22531
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
22532
|
+
components.LayoutComposer,
|
|
22533
|
+
{
|
|
22534
|
+
widgetsZonePrefix: "store_credit_account.list",
|
|
22535
|
+
preferredLayoutId: "core:single-column",
|
|
22536
|
+
sections: {
|
|
22537
|
+
main: /* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountsTable", children: /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountsTable, {}) })
|
|
22538
|
+
}
|
|
22539
|
+
}
|
|
22540
|
+
),
|
|
22541
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Toaster, {})
|
|
23309
22542
|
] });
|
|
22543
|
+
};
|
|
22544
|
+
const config$1 = adminSdk.defineRouteConfig({
|
|
22545
|
+
label: "Store Credits",
|
|
22546
|
+
icon: StoreCreditIcon
|
|
22547
|
+
});
|
|
22548
|
+
function isObject$5(value) {
|
|
22549
|
+
var type = typeof value;
|
|
22550
|
+
return value != null && (type == "object" || type == "function");
|
|
23310
22551
|
}
|
|
23311
|
-
|
|
23312
|
-
|
|
23313
|
-
|
|
23314
|
-
|
|
23315
|
-
|
|
23316
|
-
|
|
23317
|
-
|
|
22552
|
+
var isObject_1 = isObject$5;
|
|
22553
|
+
var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
22554
|
+
var _freeGlobal = freeGlobal$1;
|
|
22555
|
+
var freeGlobal = _freeGlobal;
|
|
22556
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
22557
|
+
var root$4 = freeGlobal || freeSelf || Function("return this")();
|
|
22558
|
+
var _root = root$4;
|
|
22559
|
+
var root$3 = _root;
|
|
22560
|
+
var now$1 = function() {
|
|
22561
|
+
return root$3.Date.now();
|
|
22562
|
+
};
|
|
22563
|
+
var now_1 = now$1;
|
|
22564
|
+
var reWhitespace = /\s/;
|
|
22565
|
+
function trimmedEndIndex$1(string2) {
|
|
22566
|
+
var index = string2.length;
|
|
22567
|
+
while (index-- && reWhitespace.test(string2.charAt(index))) {
|
|
23318
22568
|
}
|
|
23319
|
-
return
|
|
23320
|
-
|
|
23321
|
-
|
|
23322
|
-
|
|
23323
|
-
|
|
23324
|
-
|
|
23325
|
-
|
|
23326
|
-
|
|
23327
|
-
|
|
23328
|
-
|
|
23329
|
-
|
|
23330
|
-
|
|
23331
|
-
|
|
23332
|
-
|
|
23333
|
-
|
|
23334
|
-
|
|
23335
|
-
|
|
23336
|
-
|
|
23337
|
-
|
|
23338
|
-
|
|
23339
|
-
|
|
23340
|
-
|
|
23341
|
-
|
|
23342
|
-
|
|
23343
|
-
|
|
23344
|
-
|
|
23345
|
-
|
|
23346
|
-
|
|
23347
|
-
|
|
23348
|
-
|
|
23349
|
-
] })
|
|
23350
|
-
}
|
|
22569
|
+
return index;
|
|
22570
|
+
}
|
|
22571
|
+
var _trimmedEndIndex = trimmedEndIndex$1;
|
|
22572
|
+
var trimmedEndIndex = _trimmedEndIndex;
|
|
22573
|
+
var reTrimStart = /^\s+/;
|
|
22574
|
+
function baseTrim$1(string2) {
|
|
22575
|
+
return string2 ? string2.slice(0, trimmedEndIndex(string2) + 1).replace(reTrimStart, "") : string2;
|
|
22576
|
+
}
|
|
22577
|
+
var _baseTrim = baseTrim$1;
|
|
22578
|
+
var root$2 = _root;
|
|
22579
|
+
var Symbol$4 = root$2.Symbol;
|
|
22580
|
+
var _Symbol = Symbol$4;
|
|
22581
|
+
var Symbol$3 = _Symbol;
|
|
22582
|
+
var objectProto$5 = Object.prototype;
|
|
22583
|
+
var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
|
|
22584
|
+
var nativeObjectToString$1 = objectProto$5.toString;
|
|
22585
|
+
var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
|
|
22586
|
+
function getRawTag$1(value) {
|
|
22587
|
+
var isOwn = hasOwnProperty$4.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
22588
|
+
try {
|
|
22589
|
+
value[symToStringTag$1] = void 0;
|
|
22590
|
+
var unmasked = true;
|
|
22591
|
+
} catch (e2) {
|
|
22592
|
+
}
|
|
22593
|
+
var result = nativeObjectToString$1.call(value);
|
|
22594
|
+
if (unmasked) {
|
|
22595
|
+
if (isOwn) {
|
|
22596
|
+
value[symToStringTag$1] = tag;
|
|
22597
|
+
} else {
|
|
22598
|
+
delete value[symToStringTag$1];
|
|
23351
22599
|
}
|
|
23352
|
-
|
|
23353
|
-
|
|
23354
|
-
|
|
23355
|
-
|
|
23356
|
-
|
|
23357
|
-
|
|
23358
|
-
|
|
23359
|
-
|
|
23360
|
-
|
|
23361
|
-
|
|
23362
|
-
|
|
22600
|
+
}
|
|
22601
|
+
return result;
|
|
22602
|
+
}
|
|
22603
|
+
var _getRawTag = getRawTag$1;
|
|
22604
|
+
var objectProto$4 = Object.prototype;
|
|
22605
|
+
var nativeObjectToString = objectProto$4.toString;
|
|
22606
|
+
function objectToString$1(value) {
|
|
22607
|
+
return nativeObjectToString.call(value);
|
|
22608
|
+
}
|
|
22609
|
+
var _objectToString = objectToString$1;
|
|
22610
|
+
var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
|
|
22611
|
+
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
|
|
22612
|
+
var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
|
|
22613
|
+
function baseGetTag$2(value) {
|
|
22614
|
+
if (value == null) {
|
|
22615
|
+
return value === void 0 ? undefinedTag : nullTag;
|
|
22616
|
+
}
|
|
22617
|
+
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
22618
|
+
}
|
|
22619
|
+
var _baseGetTag = baseGetTag$2;
|
|
22620
|
+
function isObjectLike$1(value) {
|
|
22621
|
+
return value != null && typeof value == "object";
|
|
22622
|
+
}
|
|
22623
|
+
var isObjectLike_1 = isObjectLike$1;
|
|
22624
|
+
var baseGetTag$1 = _baseGetTag, isObjectLike = isObjectLike_1;
|
|
22625
|
+
var symbolTag = "[object Symbol]";
|
|
22626
|
+
function isSymbol$4(value) {
|
|
22627
|
+
return typeof value == "symbol" || isObjectLike(value) && baseGetTag$1(value) == symbolTag;
|
|
22628
|
+
}
|
|
22629
|
+
var isSymbol_1 = isSymbol$4;
|
|
22630
|
+
var baseTrim = _baseTrim, isObject$4 = isObject_1, isSymbol$3 = isSymbol_1;
|
|
22631
|
+
var NAN = 0 / 0;
|
|
22632
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
22633
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
22634
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
22635
|
+
var freeParseInt = parseInt;
|
|
22636
|
+
function toNumber$1(value) {
|
|
22637
|
+
if (typeof value == "number") {
|
|
22638
|
+
return value;
|
|
22639
|
+
}
|
|
22640
|
+
if (isSymbol$3(value)) {
|
|
22641
|
+
return NAN;
|
|
22642
|
+
}
|
|
22643
|
+
if (isObject$4(value)) {
|
|
22644
|
+
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
22645
|
+
value = isObject$4(other) ? other + "" : other;
|
|
22646
|
+
}
|
|
22647
|
+
if (typeof value != "string") {
|
|
22648
|
+
return value === 0 ? value : +value;
|
|
22649
|
+
}
|
|
22650
|
+
value = baseTrim(value);
|
|
22651
|
+
var isBinary = reIsBinary.test(value);
|
|
22652
|
+
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
|
22653
|
+
}
|
|
22654
|
+
var toNumber_1 = toNumber$1;
|
|
22655
|
+
var isObject$3 = isObject_1, now = now_1, toNumber = toNumber_1;
|
|
22656
|
+
var FUNC_ERROR_TEXT$1 = "Expected a function";
|
|
22657
|
+
var nativeMax = Math.max, nativeMin = Math.min;
|
|
22658
|
+
function debounce$2(func, wait, options) {
|
|
22659
|
+
var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
|
|
22660
|
+
if (typeof func != "function") {
|
|
22661
|
+
throw new TypeError(FUNC_ERROR_TEXT$1);
|
|
22662
|
+
}
|
|
22663
|
+
wait = toNumber(wait) || 0;
|
|
22664
|
+
if (isObject$3(options)) {
|
|
22665
|
+
leading = !!options.leading;
|
|
22666
|
+
maxing = "maxWait" in options;
|
|
22667
|
+
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
22668
|
+
trailing = "trailing" in options ? !!options.trailing : trailing;
|
|
22669
|
+
}
|
|
22670
|
+
function invokeFunc(time2) {
|
|
22671
|
+
var args = lastArgs, thisArg = lastThis;
|
|
22672
|
+
lastArgs = lastThis = void 0;
|
|
22673
|
+
lastInvokeTime = time2;
|
|
22674
|
+
result = func.apply(thisArg, args);
|
|
22675
|
+
return result;
|
|
22676
|
+
}
|
|
22677
|
+
function leadingEdge(time2) {
|
|
22678
|
+
lastInvokeTime = time2;
|
|
22679
|
+
timerId = setTimeout(timerExpired, wait);
|
|
22680
|
+
return leading ? invokeFunc(time2) : result;
|
|
22681
|
+
}
|
|
22682
|
+
function remainingWait(time2) {
|
|
22683
|
+
var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
|
|
22684
|
+
return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
|
|
22685
|
+
}
|
|
22686
|
+
function shouldInvoke(time2) {
|
|
22687
|
+
var timeSinceLastCall = time2 - lastCallTime, timeSinceLastInvoke = time2 - lastInvokeTime;
|
|
22688
|
+
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
|
|
22689
|
+
}
|
|
22690
|
+
function timerExpired() {
|
|
22691
|
+
var time2 = now();
|
|
22692
|
+
if (shouldInvoke(time2)) {
|
|
22693
|
+
return trailingEdge(time2);
|
|
22694
|
+
}
|
|
22695
|
+
timerId = setTimeout(timerExpired, remainingWait(time2));
|
|
22696
|
+
}
|
|
22697
|
+
function trailingEdge(time2) {
|
|
22698
|
+
timerId = void 0;
|
|
22699
|
+
if (trailing && lastArgs) {
|
|
22700
|
+
return invokeFunc(time2);
|
|
22701
|
+
}
|
|
22702
|
+
lastArgs = lastThis = void 0;
|
|
22703
|
+
return result;
|
|
22704
|
+
}
|
|
22705
|
+
function cancel() {
|
|
22706
|
+
if (timerId !== void 0) {
|
|
22707
|
+
clearTimeout(timerId);
|
|
22708
|
+
}
|
|
22709
|
+
lastInvokeTime = 0;
|
|
22710
|
+
lastArgs = lastCallTime = lastThis = timerId = void 0;
|
|
22711
|
+
}
|
|
22712
|
+
function flush() {
|
|
22713
|
+
return timerId === void 0 ? result : trailingEdge(now());
|
|
22714
|
+
}
|
|
22715
|
+
function debounced() {
|
|
22716
|
+
var time2 = now(), isInvoking = shouldInvoke(time2);
|
|
22717
|
+
lastArgs = arguments;
|
|
22718
|
+
lastThis = this;
|
|
22719
|
+
lastCallTime = time2;
|
|
22720
|
+
if (isInvoking) {
|
|
22721
|
+
if (timerId === void 0) {
|
|
22722
|
+
return leadingEdge(lastCallTime);
|
|
23363
22723
|
}
|
|
23364
|
-
|
|
23365
|
-
|
|
23366
|
-
|
|
22724
|
+
if (maxing) {
|
|
22725
|
+
clearTimeout(timerId);
|
|
22726
|
+
timerId = setTimeout(timerExpired, wait);
|
|
22727
|
+
return invokeFunc(lastCallTime);
|
|
23367
22728
|
}
|
|
23368
22729
|
}
|
|
23369
|
-
|
|
23370
|
-
|
|
23371
|
-
"form",
|
|
23372
|
-
{
|
|
23373
|
-
...rest,
|
|
23374
|
-
onSubmit: handleSubmit,
|
|
23375
|
-
onKeyDown: onKeyDown ?? handleKeyDown,
|
|
23376
|
-
ref
|
|
22730
|
+
if (timerId === void 0) {
|
|
22731
|
+
timerId = setTimeout(timerExpired, wait);
|
|
23377
22732
|
}
|
|
23378
|
-
|
|
23379
|
-
});
|
|
23380
|
-
KeyboundForm.displayName = "KeyboundForm";
|
|
23381
|
-
const Note$1 = () => {
|
|
23382
|
-
const { id } = reactRouterDom.useParams();
|
|
23383
|
-
const {
|
|
23384
|
-
store_credit_account: storeCreditAccount,
|
|
23385
|
-
isPending,
|
|
23386
|
-
isError,
|
|
23387
|
-
error
|
|
23388
|
-
} = useStoreCreditAccount(id, {});
|
|
23389
|
-
if (isError) {
|
|
23390
|
-
throw error;
|
|
22733
|
+
return result;
|
|
23391
22734
|
}
|
|
23392
|
-
|
|
23393
|
-
|
|
23394
|
-
|
|
23395
|
-
|
|
23396
|
-
|
|
23397
|
-
|
|
23398
|
-
|
|
23399
|
-
]
|
|
22735
|
+
debounced.cancel = cancel;
|
|
22736
|
+
debounced.flush = flush;
|
|
22737
|
+
return debounced;
|
|
22738
|
+
}
|
|
22739
|
+
var debounce_1 = debounce$2;
|
|
22740
|
+
const debounce$1 = /* @__PURE__ */ getDefaultExportFromCjs(debounce_1);
|
|
22741
|
+
const useDebouncedSearch = () => {
|
|
22742
|
+
const [searchValue, onSearchValueChange] = React.useState("");
|
|
22743
|
+
const [debouncedQuery, setDebouncedQuery] = React.useState("");
|
|
22744
|
+
const debouncedUpdate = React.useCallback(
|
|
22745
|
+
debounce$1((query) => setDebouncedQuery(query), 300),
|
|
22746
|
+
[]
|
|
22747
|
+
);
|
|
22748
|
+
React.useEffect(() => {
|
|
22749
|
+
debouncedUpdate(searchValue);
|
|
22750
|
+
return () => debouncedUpdate.cancel();
|
|
22751
|
+
}, [searchValue, debouncedUpdate]);
|
|
22752
|
+
return {
|
|
22753
|
+
searchValue,
|
|
22754
|
+
onSearchValueChange,
|
|
22755
|
+
query: debouncedQuery || void 0
|
|
22756
|
+
};
|
|
23400
22757
|
};
|
|
23401
|
-
const
|
|
23402
|
-
|
|
22758
|
+
const useComboboxData = ({
|
|
22759
|
+
queryKey,
|
|
22760
|
+
queryFn,
|
|
22761
|
+
getOptions,
|
|
22762
|
+
defaultValue: defaultValue2,
|
|
22763
|
+
defaultValueKey,
|
|
22764
|
+
pageSize = 10
|
|
23403
22765
|
}) => {
|
|
22766
|
+
const { searchValue, onSearchValueChange, query } = useDebouncedSearch();
|
|
22767
|
+
const queryInitialDataBy = defaultValueKey || "id";
|
|
22768
|
+
const { data: initialData } = reactQuery.useQuery({
|
|
22769
|
+
queryKey,
|
|
22770
|
+
queryFn: async () => {
|
|
22771
|
+
return queryFn({
|
|
22772
|
+
[queryInitialDataBy]: defaultValue2,
|
|
22773
|
+
limit: Array.isArray(defaultValue2) ? defaultValue2.length : 1
|
|
22774
|
+
});
|
|
22775
|
+
},
|
|
22776
|
+
enabled: !!defaultValue2
|
|
22777
|
+
});
|
|
22778
|
+
const { data, ...rest } = reactQuery.useInfiniteQuery({
|
|
22779
|
+
queryKey: [...queryKey, query],
|
|
22780
|
+
queryFn: async ({ pageParam = 0 }) => {
|
|
22781
|
+
return await queryFn({
|
|
22782
|
+
q: query,
|
|
22783
|
+
limit: pageSize,
|
|
22784
|
+
offset: pageParam
|
|
22785
|
+
});
|
|
22786
|
+
},
|
|
22787
|
+
initialPageParam: 0,
|
|
22788
|
+
getNextPageParam: (lastPage) => {
|
|
22789
|
+
const moreItemsExist = lastPage.count > lastPage.offset + lastPage.limit;
|
|
22790
|
+
return moreItemsExist ? lastPage.offset + lastPage.limit : void 0;
|
|
22791
|
+
},
|
|
22792
|
+
placeholderData: reactQuery.keepPreviousData
|
|
22793
|
+
});
|
|
22794
|
+
const options = (data == null ? void 0 : data.pages.flatMap((page) => getOptions(page))) ?? [];
|
|
22795
|
+
const defaultOptions2 = initialData ? getOptions(initialData) : [];
|
|
22796
|
+
const disabled = !rest.isPending && !options.length && !searchValue;
|
|
22797
|
+
if (defaultValue2 && defaultOptions2.length && !searchValue) {
|
|
22798
|
+
defaultOptions2.forEach((option) => {
|
|
22799
|
+
if (!options.find((o2) => o2.value === option.value)) {
|
|
22800
|
+
options.unshift(option);
|
|
22801
|
+
}
|
|
22802
|
+
});
|
|
22803
|
+
}
|
|
22804
|
+
return {
|
|
22805
|
+
options,
|
|
22806
|
+
searchValue,
|
|
22807
|
+
onSearchValueChange,
|
|
22808
|
+
disabled,
|
|
22809
|
+
...rest
|
|
22810
|
+
};
|
|
22811
|
+
};
|
|
22812
|
+
const formSchema = zod.z.object({
|
|
22813
|
+
currency_code: zod.z.string().min(1, "Please select a currency"),
|
|
22814
|
+
customer_id: zod.z.string().optional()
|
|
22815
|
+
});
|
|
22816
|
+
const StoreCreditAccountCreateForm = () => {
|
|
22817
|
+
const { handleSuccess } = useRouteModal();
|
|
23404
22818
|
const form = useForm({
|
|
23405
22819
|
defaultValues: {
|
|
23406
|
-
|
|
23407
|
-
|
|
23408
|
-
value: ""
|
|
23409
|
-
},
|
|
23410
|
-
note: ""
|
|
22820
|
+
currency_code: "",
|
|
22821
|
+
customer_id: ""
|
|
23411
22822
|
},
|
|
23412
|
-
resolver: t(
|
|
22823
|
+
resolver: t(formSchema)
|
|
23413
22824
|
});
|
|
23414
|
-
const { mutateAsync, isPending } =
|
|
23415
|
-
|
|
23416
|
-
|
|
23417
|
-
|
|
23418
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
23419
|
-
if (data.amount.float <= 0) {
|
|
23420
|
-
form.setError("amount", { message: "Amount must be greater than 0" });
|
|
23421
|
-
return;
|
|
22825
|
+
const { mutateAsync: createStoreCreditAccount, isPending } = useCreateStoreCreditAccount();
|
|
22826
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
22827
|
+
if (!data.customer_id) {
|
|
22828
|
+
delete data.customer_id;
|
|
23422
22829
|
}
|
|
23423
|
-
await
|
|
23424
|
-
|
|
23425
|
-
|
|
23426
|
-
|
|
23427
|
-
|
|
22830
|
+
await createStoreCreditAccount(data, {
|
|
22831
|
+
onSuccess: (data2) => {
|
|
22832
|
+
ui.toast.success(`Store credit account was successfully created.`);
|
|
22833
|
+
handleSuccess(`../${data2.store_credit_account.id}`);
|
|
22834
|
+
},
|
|
22835
|
+
onError: (error) => {
|
|
22836
|
+
ui.toast.error(error.message);
|
|
23428
22837
|
}
|
|
22838
|
+
});
|
|
22839
|
+
});
|
|
22840
|
+
const [currencySearchValue, setCurrencySearchValue] = React.useState("");
|
|
22841
|
+
const currencyOptions = React.useMemo(() => {
|
|
22842
|
+
const options = Object.values(currencies).map((currency) => ({
|
|
22843
|
+
label: `${currency.code} - ${currency.name} (${currency.symbol_native})`,
|
|
22844
|
+
value: currency.code.toLowerCase()
|
|
22845
|
+
}));
|
|
22846
|
+
if (!currencySearchValue) {
|
|
22847
|
+
return options;
|
|
22848
|
+
}
|
|
22849
|
+
return options.filter(
|
|
22850
|
+
(option) => option.label.toLowerCase().includes(currencySearchValue.toLowerCase())
|
|
23429
22851
|
);
|
|
22852
|
+
}, [currencySearchValue]);
|
|
22853
|
+
const {
|
|
22854
|
+
options: customerOptions,
|
|
22855
|
+
fetchNextPage,
|
|
22856
|
+
isFetchingNextPage,
|
|
22857
|
+
searchValue,
|
|
22858
|
+
onSearchValueChange,
|
|
22859
|
+
isLoading
|
|
22860
|
+
} = useComboboxData({
|
|
22861
|
+
queryKey: customersQueryKeys.list(),
|
|
22862
|
+
queryFn: async (params) => {
|
|
22863
|
+
return sdk.admin.customer.list(params);
|
|
22864
|
+
},
|
|
22865
|
+
getOptions: (data) => {
|
|
22866
|
+
var _a2;
|
|
22867
|
+
return ((_a2 = data.customers) == null ? void 0 : _a2.map((customer) => {
|
|
22868
|
+
const fullName = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
22869
|
+
const label = fullName ? `${customer.email} (${fullName})` : customer.email;
|
|
22870
|
+
return {
|
|
22871
|
+
label,
|
|
22872
|
+
value: customer.id
|
|
22873
|
+
};
|
|
22874
|
+
})) || [];
|
|
22875
|
+
}
|
|
23430
22876
|
});
|
|
23431
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
23432
|
-
|
|
23433
|
-
{
|
|
23434
|
-
className: "flex flex-
|
|
23435
|
-
|
|
23436
|
-
|
|
23437
|
-
|
|
23438
|
-
|
|
23439
|
-
|
|
23440
|
-
|
|
23441
|
-
|
|
23442
|
-
|
|
23443
|
-
|
|
23444
|
-
|
|
22877
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Form, { form, children: [
|
|
22878
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "-my-2 w-full border-l" }) }),
|
|
22879
|
+
/* @__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: [
|
|
22880
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
|
|
22881
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Create Store Credit Account" }),
|
|
22882
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "text-ui-fg-subtle", size: "small", children: "Create a new store credit account for a customer" })
|
|
22883
|
+
] }),
|
|
22884
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-x-4", children: [
|
|
22885
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
22886
|
+
Form$2.Field,
|
|
22887
|
+
{
|
|
22888
|
+
control: form.control,
|
|
22889
|
+
name: "currency_code",
|
|
22890
|
+
render: ({ field }) => {
|
|
22891
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
22892
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Currency" }),
|
|
23445
22893
|
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
23446
|
-
|
|
22894
|
+
Combobox,
|
|
23447
22895
|
{
|
|
23448
|
-
|
|
23449
|
-
|
|
23450
|
-
|
|
23451
|
-
|
|
23452
|
-
|
|
23453
|
-
|
|
23454
|
-
float: (values == null ? void 0 : values.float) || null
|
|
23455
|
-
});
|
|
23456
|
-
},
|
|
23457
|
-
symbol: currencies[storeCreditAccount.currency_code.toUpperCase()].symbol_native,
|
|
23458
|
-
code: storeCreditAccount.currency_code.toUpperCase()
|
|
22896
|
+
value: field.value,
|
|
22897
|
+
onChange: field.onChange,
|
|
22898
|
+
searchValue: currencySearchValue,
|
|
22899
|
+
onSearchValueChange: setCurrencySearchValue,
|
|
22900
|
+
options: currencyOptions,
|
|
22901
|
+
placeholder: "Search for a currency..."
|
|
23459
22902
|
}
|
|
23460
22903
|
) }),
|
|
23461
22904
|
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
23462
|
-
] })
|
|
22905
|
+
] });
|
|
23463
22906
|
}
|
|
23464
|
-
|
|
23465
|
-
|
|
23466
|
-
|
|
23467
|
-
|
|
23468
|
-
|
|
23469
|
-
|
|
23470
|
-
|
|
23471
|
-
|
|
23472
|
-
|
|
22907
|
+
}
|
|
22908
|
+
),
|
|
22909
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
22910
|
+
Form$2.Field,
|
|
22911
|
+
{
|
|
22912
|
+
control: form.control,
|
|
22913
|
+
name: "customer_id",
|
|
22914
|
+
render: ({ field }) => {
|
|
22915
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
22916
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { className: "font-normal", children: "Customer" }),
|
|
22917
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
22918
|
+
Combobox,
|
|
22919
|
+
{
|
|
22920
|
+
value: field.value,
|
|
22921
|
+
onChange: field.onChange,
|
|
22922
|
+
searchValue,
|
|
22923
|
+
onSearchValueChange,
|
|
22924
|
+
options: customerOptions,
|
|
22925
|
+
placeholder: "Search for a customer...",
|
|
22926
|
+
fetchNextPage,
|
|
22927
|
+
isFetchingNextPage,
|
|
22928
|
+
noResultsPlaceholder: isLoading ? "Loading customers..." : "No customers found"
|
|
22929
|
+
}
|
|
22930
|
+
) }),
|
|
23473
22931
|
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
23474
|
-
] })
|
|
22932
|
+
] });
|
|
23475
22933
|
}
|
|
23476
|
-
|
|
23477
|
-
|
|
23478
|
-
|
|
23479
|
-
|
|
23480
|
-
|
|
23481
|
-
|
|
23482
|
-
|
|
23483
|
-
|
|
23484
|
-
|
|
22934
|
+
}
|
|
22935
|
+
)
|
|
22936
|
+
] })
|
|
22937
|
+
] }) }) }),
|
|
22938
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal.Footer, { children: [
|
|
22939
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, disabled: isPending, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", disabled: isPending, children: "Cancel" }) }),
|
|
22940
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
22941
|
+
ui.Button,
|
|
22942
|
+
{
|
|
22943
|
+
variant: "primary",
|
|
22944
|
+
size: "small",
|
|
22945
|
+
onClick: handleSubmit,
|
|
22946
|
+
disabled: isPending,
|
|
22947
|
+
children: "Create"
|
|
22948
|
+
}
|
|
22949
|
+
)
|
|
22950
|
+
] })
|
|
22951
|
+
] });
|
|
22952
|
+
};
|
|
22953
|
+
const StoreCreditAccountCreate = () => {
|
|
22954
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteFocusModal, { children: [
|
|
22955
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create Store Credit Account" }) }),
|
|
22956
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Create a new store credit account" }) }),
|
|
22957
|
+
/* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCreateForm, {})
|
|
22958
|
+
] });
|
|
23485
22959
|
};
|
|
23486
|
-
const schema$2 = zod.z.object({
|
|
23487
|
-
note: zod.z.string(),
|
|
23488
|
-
amount: zod.z.object({
|
|
23489
|
-
float: zod.z.number(),
|
|
23490
|
-
value: zod.z.string()
|
|
23491
|
-
})
|
|
23492
|
-
});
|
|
23493
22960
|
function _extends() {
|
|
23494
22961
|
return _extends = Object.assign ? Object.assign.bind() : function(n2) {
|
|
23495
22962
|
for (var e2 = 1; e2 < arguments.length; e2++) {
|
|
@@ -26170,6 +25637,243 @@ const GiftCardOrderSection = ({ giftCard }) => {
|
|
|
26170
25637
|
))
|
|
26171
25638
|
] });
|
|
26172
25639
|
};
|
|
25640
|
+
var toggleSelection = function() {
|
|
25641
|
+
var selection = document.getSelection();
|
|
25642
|
+
if (!selection.rangeCount) {
|
|
25643
|
+
return function() {
|
|
25644
|
+
};
|
|
25645
|
+
}
|
|
25646
|
+
var active = document.activeElement;
|
|
25647
|
+
var ranges = [];
|
|
25648
|
+
for (var i2 = 0; i2 < selection.rangeCount; i2++) {
|
|
25649
|
+
ranges.push(selection.getRangeAt(i2));
|
|
25650
|
+
}
|
|
25651
|
+
switch (active.tagName.toUpperCase()) {
|
|
25652
|
+
// .toUpperCase handles XHTML
|
|
25653
|
+
case "INPUT":
|
|
25654
|
+
case "TEXTAREA":
|
|
25655
|
+
active.blur();
|
|
25656
|
+
break;
|
|
25657
|
+
default:
|
|
25658
|
+
active = null;
|
|
25659
|
+
break;
|
|
25660
|
+
}
|
|
25661
|
+
selection.removeAllRanges();
|
|
25662
|
+
return function() {
|
|
25663
|
+
selection.type === "Caret" && selection.removeAllRanges();
|
|
25664
|
+
if (!selection.rangeCount) {
|
|
25665
|
+
ranges.forEach(function(range) {
|
|
25666
|
+
selection.addRange(range);
|
|
25667
|
+
});
|
|
25668
|
+
}
|
|
25669
|
+
active && active.focus();
|
|
25670
|
+
};
|
|
25671
|
+
};
|
|
25672
|
+
var deselectCurrent = toggleSelection;
|
|
25673
|
+
var clipboardToIE11Formatting = {
|
|
25674
|
+
"text/plain": "Text",
|
|
25675
|
+
"text/html": "Url",
|
|
25676
|
+
"default": "Text"
|
|
25677
|
+
};
|
|
25678
|
+
var defaultMessage = "Copy to clipboard: #{key}, Enter";
|
|
25679
|
+
function format(message2) {
|
|
25680
|
+
var copyKey = (/mac os x/i.test(navigator.userAgent) ? "⌘" : "Ctrl") + "+C";
|
|
25681
|
+
return message2.replace(/#{\s*key\s*}/g, copyKey);
|
|
25682
|
+
}
|
|
25683
|
+
function copy$2(text2, options) {
|
|
25684
|
+
var debug2, message2, reselectPrevious, range, selection, mark, success = false;
|
|
25685
|
+
if (!options) {
|
|
25686
|
+
options = {};
|
|
25687
|
+
}
|
|
25688
|
+
debug2 = options.debug || false;
|
|
25689
|
+
try {
|
|
25690
|
+
reselectPrevious = deselectCurrent();
|
|
25691
|
+
range = document.createRange();
|
|
25692
|
+
selection = document.getSelection();
|
|
25693
|
+
mark = document.createElement("span");
|
|
25694
|
+
mark.textContent = text2;
|
|
25695
|
+
mark.ariaHidden = "true";
|
|
25696
|
+
mark.style.all = "unset";
|
|
25697
|
+
mark.style.position = "fixed";
|
|
25698
|
+
mark.style.top = 0;
|
|
25699
|
+
mark.style.clip = "rect(0, 0, 0, 0)";
|
|
25700
|
+
mark.style.whiteSpace = "pre";
|
|
25701
|
+
mark.style.webkitUserSelect = "text";
|
|
25702
|
+
mark.style.MozUserSelect = "text";
|
|
25703
|
+
mark.style.msUserSelect = "text";
|
|
25704
|
+
mark.style.userSelect = "text";
|
|
25705
|
+
mark.addEventListener("copy", function(e2) {
|
|
25706
|
+
e2.stopPropagation();
|
|
25707
|
+
if (options.format) {
|
|
25708
|
+
e2.preventDefault();
|
|
25709
|
+
if (typeof e2.clipboardData === "undefined") {
|
|
25710
|
+
debug2 && console.warn("unable to use e.clipboardData");
|
|
25711
|
+
debug2 && console.warn("trying IE specific stuff");
|
|
25712
|
+
window.clipboardData.clearData();
|
|
25713
|
+
var format2 = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting["default"];
|
|
25714
|
+
window.clipboardData.setData(format2, text2);
|
|
25715
|
+
} else {
|
|
25716
|
+
e2.clipboardData.clearData();
|
|
25717
|
+
e2.clipboardData.setData(options.format, text2);
|
|
25718
|
+
}
|
|
25719
|
+
}
|
|
25720
|
+
if (options.onCopy) {
|
|
25721
|
+
e2.preventDefault();
|
|
25722
|
+
options.onCopy(e2.clipboardData);
|
|
25723
|
+
}
|
|
25724
|
+
});
|
|
25725
|
+
document.body.appendChild(mark);
|
|
25726
|
+
range.selectNodeContents(mark);
|
|
25727
|
+
selection.addRange(range);
|
|
25728
|
+
var successful = document.execCommand("copy");
|
|
25729
|
+
if (!successful) {
|
|
25730
|
+
throw new Error("copy command was unsuccessful");
|
|
25731
|
+
}
|
|
25732
|
+
success = true;
|
|
25733
|
+
} catch (err) {
|
|
25734
|
+
debug2 && console.error("unable to copy using execCommand: ", err);
|
|
25735
|
+
debug2 && console.warn("trying IE specific stuff");
|
|
25736
|
+
try {
|
|
25737
|
+
window.clipboardData.setData(options.format || "text", text2);
|
|
25738
|
+
options.onCopy && options.onCopy(window.clipboardData);
|
|
25739
|
+
success = true;
|
|
25740
|
+
} catch (err2) {
|
|
25741
|
+
debug2 && console.error("unable to copy using clipboardData: ", err2);
|
|
25742
|
+
debug2 && console.error("falling back to prompt");
|
|
25743
|
+
message2 = format("message" in options ? options.message : defaultMessage);
|
|
25744
|
+
window.prompt(message2, text2);
|
|
25745
|
+
}
|
|
25746
|
+
} finally {
|
|
25747
|
+
if (selection) {
|
|
25748
|
+
if (typeof selection.removeRange == "function") {
|
|
25749
|
+
selection.removeRange(range);
|
|
25750
|
+
} else {
|
|
25751
|
+
selection.removeAllRanges();
|
|
25752
|
+
}
|
|
25753
|
+
}
|
|
25754
|
+
if (mark) {
|
|
25755
|
+
document.body.removeChild(mark);
|
|
25756
|
+
}
|
|
25757
|
+
reselectPrevious();
|
|
25758
|
+
}
|
|
25759
|
+
return success;
|
|
25760
|
+
}
|
|
25761
|
+
var copyToClipboard = copy$2;
|
|
25762
|
+
const copy$1 = /* @__PURE__ */ getDefaultExportFromCjs(copyToClipboard);
|
|
25763
|
+
function DisplayId({ id, className }) {
|
|
25764
|
+
const [open, setOpen] = React.useState(false);
|
|
25765
|
+
const onClick = () => {
|
|
25766
|
+
copy$1(id);
|
|
25767
|
+
ui.toast.success("Copied to clipboard");
|
|
25768
|
+
};
|
|
25769
|
+
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: [
|
|
25770
|
+
"#",
|
|
25771
|
+
id.slice(-7)
|
|
25772
|
+
] }) });
|
|
25773
|
+
}
|
|
25774
|
+
const columnHelper$8 = ui.createDataTableColumnHelper();
|
|
25775
|
+
const useTransactionsTableColumns = () => {
|
|
25776
|
+
return React.useMemo(() => {
|
|
25777
|
+
return [
|
|
25778
|
+
columnHelper$8.accessor("id", {
|
|
25779
|
+
header: "ID",
|
|
25780
|
+
cell: ({ row }) => {
|
|
25781
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DisplayId, { id: row.original.id });
|
|
25782
|
+
}
|
|
25783
|
+
}),
|
|
25784
|
+
columnHelper$8.accessor("created_at", {
|
|
25785
|
+
header: "Created At",
|
|
25786
|
+
cell: ({ row }) => formatDate(row.original.created_at, false)
|
|
25787
|
+
}),
|
|
25788
|
+
columnHelper$8.accessor("note", {
|
|
25789
|
+
header: "Description",
|
|
25790
|
+
cell: ({ row }) => row.original.note
|
|
25791
|
+
}),
|
|
25792
|
+
columnHelper$8.accessor("note", {
|
|
25793
|
+
header: "Note",
|
|
25794
|
+
cell: ({ row }) => {
|
|
25795
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { title: row.original.note, className: "max-w-[300px] truncate", children: row.original.note || "-" });
|
|
25796
|
+
}
|
|
25797
|
+
}),
|
|
25798
|
+
columnHelper$8.accessor("amount", {
|
|
25799
|
+
header: "Amount",
|
|
25800
|
+
cell: ({ row }) => {
|
|
25801
|
+
const isDebit = row.original.type === "debit";
|
|
25802
|
+
return row.original.account.currency_code && formatAmount(
|
|
25803
|
+
row.original.amount * (isDebit ? -1 : 1),
|
|
25804
|
+
row.original.account.currency_code
|
|
25805
|
+
);
|
|
25806
|
+
}
|
|
25807
|
+
})
|
|
25808
|
+
];
|
|
25809
|
+
}, []);
|
|
25810
|
+
};
|
|
25811
|
+
const useTransactionsTableFilters = ({}) => {
|
|
25812
|
+
const dateFilterOptions = useDataTableDateFilters$1();
|
|
25813
|
+
return React.useMemo(() => {
|
|
25814
|
+
return [...dateFilterOptions];
|
|
25815
|
+
}, [dateFilterOptions]);
|
|
25816
|
+
};
|
|
25817
|
+
const useTransactionsTableQuery = ({
|
|
25818
|
+
prefix,
|
|
25819
|
+
pageSize = 20
|
|
25820
|
+
}) => {
|
|
25821
|
+
const queryObject = useQueryParams(
|
|
25822
|
+
["offset", "limit", "currency_code", "created_at", "updated_at"],
|
|
25823
|
+
prefix
|
|
25824
|
+
);
|
|
25825
|
+
const { offset: offset2, limit, created_at, updated_at, ...rest } = queryObject;
|
|
25826
|
+
const searchParams = {
|
|
25827
|
+
limit: limit ? Number(limit) : pageSize,
|
|
25828
|
+
offset: offset2 ? Number(offset2) : 0,
|
|
25829
|
+
created_at: created_at ? JSON.parse(created_at) : void 0,
|
|
25830
|
+
updated_at: updated_at ? JSON.parse(updated_at) : void 0,
|
|
25831
|
+
...rest
|
|
25832
|
+
};
|
|
25833
|
+
return searchParams;
|
|
25834
|
+
};
|
|
25835
|
+
const PAGE_SIZE$4 = 10;
|
|
25836
|
+
function TransactionsTable({ id }) {
|
|
25837
|
+
const queryParams = useTransactionsTableQuery({
|
|
25838
|
+
pageSize: PAGE_SIZE$4
|
|
25839
|
+
});
|
|
25840
|
+
const { transactions, isLoading, count: count2 } = useStoreCreditAccountTransactions(
|
|
25841
|
+
id,
|
|
25842
|
+
{
|
|
25843
|
+
...queryParams,
|
|
25844
|
+
order: queryParams.order ?? "-created_at",
|
|
25845
|
+
fields: "*account"
|
|
25846
|
+
}
|
|
25847
|
+
);
|
|
25848
|
+
const columns = useTransactionsTableColumns();
|
|
25849
|
+
const filters = useTransactionsTableFilters({});
|
|
25850
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
25851
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Container, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
25852
|
+
DataTable,
|
|
25853
|
+
{
|
|
25854
|
+
data: transactions ?? [],
|
|
25855
|
+
getRowId: (row) => row.id,
|
|
25856
|
+
columns,
|
|
25857
|
+
filters,
|
|
25858
|
+
isLoading,
|
|
25859
|
+
pageSize: PAGE_SIZE$4,
|
|
25860
|
+
rowCount: count2,
|
|
25861
|
+
enableSearch: false,
|
|
25862
|
+
heading: "Transactions",
|
|
25863
|
+
emptyState: {
|
|
25864
|
+
empty: {
|
|
25865
|
+
heading: "No transactions found"
|
|
25866
|
+
},
|
|
25867
|
+
filtered: {
|
|
25868
|
+
heading: "No results found",
|
|
25869
|
+
description: "No transactions match your filter criteria."
|
|
25870
|
+
}
|
|
25871
|
+
}
|
|
25872
|
+
}
|
|
25873
|
+
) }),
|
|
25874
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
|
|
25875
|
+
] });
|
|
25876
|
+
}
|
|
26173
25877
|
const GiftCardTransactionsSection = ({
|
|
26174
25878
|
storeCreditAccount
|
|
26175
25879
|
}) => {
|
|
@@ -26219,6 +25923,33 @@ const GiftCardDetailsPage = () => {
|
|
|
26219
25923
|
}
|
|
26220
25924
|
);
|
|
26221
25925
|
};
|
|
25926
|
+
const KeyboundForm = React__namespace.default.forwardRef(({ onSubmit, onKeyDown, ...rest }, ref) => {
|
|
25927
|
+
const handleSubmit = (event) => {
|
|
25928
|
+
event.preventDefault();
|
|
25929
|
+
onSubmit == null ? void 0 : onSubmit(event);
|
|
25930
|
+
};
|
|
25931
|
+
const handleKeyDown = (event) => {
|
|
25932
|
+
if (event.key === "Enter") {
|
|
25933
|
+
if (event.target instanceof HTMLTextAreaElement && !(event.metaKey || event.ctrlKey)) {
|
|
25934
|
+
return;
|
|
25935
|
+
}
|
|
25936
|
+
event.preventDefault();
|
|
25937
|
+
if (event.metaKey || event.ctrlKey) {
|
|
25938
|
+
handleSubmit(event);
|
|
25939
|
+
}
|
|
25940
|
+
}
|
|
25941
|
+
};
|
|
25942
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
25943
|
+
"form",
|
|
25944
|
+
{
|
|
25945
|
+
...rest,
|
|
25946
|
+
onSubmit: handleSubmit,
|
|
25947
|
+
onKeyDown: onKeyDown ?? handleKeyDown,
|
|
25948
|
+
ref
|
|
25949
|
+
}
|
|
25950
|
+
);
|
|
25951
|
+
});
|
|
25952
|
+
KeyboundForm.displayName = "KeyboundForm";
|
|
26222
25953
|
const GiftCardExpiration = () => {
|
|
26223
25954
|
const { id } = reactRouterDom.useParams();
|
|
26224
25955
|
const { gift_card: giftCard, isPending, isError, error } = useGiftCard(id);
|
|
@@ -26239,7 +25970,7 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
26239
25970
|
defaultValues: {
|
|
26240
25971
|
expires_at: giftCard.expires_at ? new Date(giftCard.expires_at) : null
|
|
26241
25972
|
},
|
|
26242
|
-
resolver: t(schema$
|
|
25973
|
+
resolver: t(schema$2)
|
|
26243
25974
|
});
|
|
26244
25975
|
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
26245
25976
|
const { handleSuccess } = useRouteModal();
|
|
@@ -26334,10 +26065,10 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
26334
26065
|
}
|
|
26335
26066
|
) });
|
|
26336
26067
|
};
|
|
26337
|
-
const schema$
|
|
26068
|
+
const schema$2 = zod.z.object({
|
|
26338
26069
|
expires_at: zod.z.date().nullish()
|
|
26339
26070
|
});
|
|
26340
|
-
const Note = () => {
|
|
26071
|
+
const Note$1 = () => {
|
|
26341
26072
|
const { id } = reactRouterDom.useParams();
|
|
26342
26073
|
const {
|
|
26343
26074
|
gift_card: giftCard,
|
|
@@ -26362,7 +26093,7 @@ const GiftCardNoteForm = ({ giftCard }) => {
|
|
|
26362
26093
|
defaultValues: {
|
|
26363
26094
|
note: giftCard.note ?? ""
|
|
26364
26095
|
},
|
|
26365
|
-
resolver: t(schema)
|
|
26096
|
+
resolver: t(schema$1)
|
|
26366
26097
|
});
|
|
26367
26098
|
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
26368
26099
|
const { handleSuccess } = useRouteModal();
|
|
@@ -26401,7 +26132,7 @@ const GiftCardNoteForm = ({ giftCard }) => {
|
|
|
26401
26132
|
}
|
|
26402
26133
|
) });
|
|
26403
26134
|
};
|
|
26404
|
-
const schema = zod.z.object({
|
|
26135
|
+
const schema$1 = zod.z.object({
|
|
26405
26136
|
note: zod.z.string().optional()
|
|
26406
26137
|
});
|
|
26407
26138
|
const columnHelper$7 = createColumnHelper();
|
|
@@ -39742,7 +39473,7 @@ const GiftCardProductCreate = () => {
|
|
|
39742
39473
|
isPending: isStorePending,
|
|
39743
39474
|
isError: isStoreError,
|
|
39744
39475
|
error: storeError
|
|
39745
|
-
} = useStore$
|
|
39476
|
+
} = useStore$2({
|
|
39746
39477
|
fields: "+default_sales_channel"
|
|
39747
39478
|
});
|
|
39748
39479
|
const {
|
|
@@ -39794,6 +39525,275 @@ const GiftCardProductCreate = () => {
|
|
|
39794
39525
|
)
|
|
39795
39526
|
] });
|
|
39796
39527
|
};
|
|
39528
|
+
const StoreCreditAccountBalanceSection = ({
|
|
39529
|
+
storeCreditAccount
|
|
39530
|
+
}) => {
|
|
39531
|
+
if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
|
|
39532
|
+
return;
|
|
39533
|
+
}
|
|
39534
|
+
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: [
|
|
39535
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-ui-tag-green-icon h-8 w-1 rounded-full" }),
|
|
39536
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
39537
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", size: "small", className: "text-ui-fg-subtle", children: "Current Balance" }),
|
|
39538
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
39539
|
+
ui.Text,
|
|
39540
|
+
{
|
|
39541
|
+
weight: "plus",
|
|
39542
|
+
size: "xlarge",
|
|
39543
|
+
className: "tabular-nums text-ui-fg-base",
|
|
39544
|
+
children: formatAmount(
|
|
39545
|
+
storeCreditAccount.balance,
|
|
39546
|
+
storeCreditAccount.currency_code
|
|
39547
|
+
)
|
|
39548
|
+
}
|
|
39549
|
+
)
|
|
39550
|
+
] })
|
|
39551
|
+
] }) });
|
|
39552
|
+
};
|
|
39553
|
+
const StoreCreditAccountDetailsSection = ({
|
|
39554
|
+
storeCreditAccount
|
|
39555
|
+
}) => {
|
|
39556
|
+
if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
|
|
39557
|
+
return;
|
|
39558
|
+
}
|
|
39559
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "flex justify-between gap-x-2 px-6 py-6", children: [
|
|
39560
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
39561
|
+
ui.Text,
|
|
39562
|
+
{
|
|
39563
|
+
weight: "plus",
|
|
39564
|
+
size: "xlarge",
|
|
39565
|
+
className: "text-ui-fg-base flex gap-x-4",
|
|
39566
|
+
children: [
|
|
39567
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
39568
|
+
/* @__PURE__ */ jsxRuntime.jsx(CreditCardIcon, { className: "inline" }),
|
|
39569
|
+
" "
|
|
39570
|
+
] }),
|
|
39571
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
39572
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-ui-fg-subtle", children: [
|
|
39573
|
+
storeCreditAccount.currency_code.toUpperCase(),
|
|
39574
|
+
" Account"
|
|
39575
|
+
] }),
|
|
39576
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-base", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
39577
|
+
ui.Text,
|
|
39578
|
+
{
|
|
39579
|
+
weight: "regular",
|
|
39580
|
+
size: "small",
|
|
39581
|
+
className: "text-ui-fg-base flex gap-x-4",
|
|
39582
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(DisplayId, { id: storeCreditAccount.id })
|
|
39583
|
+
}
|
|
39584
|
+
) })
|
|
39585
|
+
] })
|
|
39586
|
+
]
|
|
39587
|
+
}
|
|
39588
|
+
),
|
|
39589
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-x-4", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
39590
|
+
ActionMenu,
|
|
39591
|
+
{
|
|
39592
|
+
groups: [
|
|
39593
|
+
{
|
|
39594
|
+
actions: [
|
|
39595
|
+
{
|
|
39596
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.CreditCard, {}),
|
|
39597
|
+
label: "Credit the account",
|
|
39598
|
+
to: "credit"
|
|
39599
|
+
}
|
|
39600
|
+
]
|
|
39601
|
+
}
|
|
39602
|
+
]
|
|
39603
|
+
}
|
|
39604
|
+
) })
|
|
39605
|
+
] });
|
|
39606
|
+
};
|
|
39607
|
+
function StoreCreditAccountCustomerSection({
|
|
39608
|
+
customerId
|
|
39609
|
+
}) {
|
|
39610
|
+
const { customer, isPending } = useCustomer(customerId, void 0, {
|
|
39611
|
+
enabled: !!customerId
|
|
39612
|
+
});
|
|
39613
|
+
if (isPending || !customer) {
|
|
39614
|
+
return null;
|
|
39615
|
+
}
|
|
39616
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
39617
|
+
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Customer" }),
|
|
39618
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
39619
|
+
SidebarLink,
|
|
39620
|
+
{
|
|
39621
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(icons.User, {}),
|
|
39622
|
+
labelKey: customer.email || "N/A",
|
|
39623
|
+
descriptionKey: !customer.first_name && !customer.last_name ? "N/A" : `${customer.first_name} ${customer.last_name}`,
|
|
39624
|
+
to: `/customers/${customer.id}`
|
|
39625
|
+
},
|
|
39626
|
+
customer.id
|
|
39627
|
+
)
|
|
39628
|
+
] });
|
|
39629
|
+
}
|
|
39630
|
+
function StoreCreditAccountCodeSection({ code }) {
|
|
39631
|
+
if (!code) {
|
|
39632
|
+
return null;
|
|
39633
|
+
}
|
|
39634
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "p-0", children: [
|
|
39635
|
+
/* @__PURE__ */ jsxRuntime.jsx(Header$5, { title: "Account Code" }),
|
|
39636
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-x-4 px-6 mb-2", children: [
|
|
39637
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Share, { className: "inline" }),
|
|
39638
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle text-sm", children: code })
|
|
39639
|
+
] })
|
|
39640
|
+
] });
|
|
39641
|
+
}
|
|
39642
|
+
const StoreCreditAccountPage = () => {
|
|
39643
|
+
const { id } = reactRouterDom.useParams();
|
|
39644
|
+
const { store_credit_account: storeCreditAccount } = useStoreCreditAccount(
|
|
39645
|
+
id
|
|
39646
|
+
);
|
|
39647
|
+
if (!storeCreditAccount) {
|
|
39648
|
+
return;
|
|
39649
|
+
}
|
|
39650
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
39651
|
+
components.LayoutComposer,
|
|
39652
|
+
{
|
|
39653
|
+
widgetsZonePrefix: "store_credit_account.details",
|
|
39654
|
+
preferredLayoutId: "core:two-column",
|
|
39655
|
+
data: storeCreditAccount,
|
|
39656
|
+
sections: {
|
|
39657
|
+
main: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
39658
|
+
/* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountDetailsSection", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
39659
|
+
StoreCreditAccountDetailsSection,
|
|
39660
|
+
{
|
|
39661
|
+
storeCreditAccount
|
|
39662
|
+
}
|
|
39663
|
+
) }),
|
|
39664
|
+
/* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "TransactionsTable", children: /* @__PURE__ */ jsxRuntime.jsx(TransactionsTable, { id: storeCreditAccount.id }) })
|
|
39665
|
+
] }),
|
|
39666
|
+
side: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
39667
|
+
/* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountBalanceSection", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
39668
|
+
StoreCreditAccountBalanceSection,
|
|
39669
|
+
{
|
|
39670
|
+
storeCreditAccount
|
|
39671
|
+
}
|
|
39672
|
+
) }),
|
|
39673
|
+
/* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountCodeSection", children: /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCodeSection, { code: storeCreditAccount.code }) }),
|
|
39674
|
+
/* @__PURE__ */ jsxRuntime.jsx(components.LayoutComposer.Entry, { id: "StoreCreditAccountCustomerSection", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
39675
|
+
StoreCreditAccountCustomerSection,
|
|
39676
|
+
{
|
|
39677
|
+
customerId: storeCreditAccount.customer_id
|
|
39678
|
+
}
|
|
39679
|
+
) })
|
|
39680
|
+
] })
|
|
39681
|
+
}
|
|
39682
|
+
}
|
|
39683
|
+
);
|
|
39684
|
+
};
|
|
39685
|
+
const Note = () => {
|
|
39686
|
+
const { id } = reactRouterDom.useParams();
|
|
39687
|
+
const {
|
|
39688
|
+
store_credit_account: storeCreditAccount,
|
|
39689
|
+
isPending,
|
|
39690
|
+
isError,
|
|
39691
|
+
error
|
|
39692
|
+
} = useStoreCreditAccount(id, {});
|
|
39693
|
+
if (isError) {
|
|
39694
|
+
throw error;
|
|
39695
|
+
}
|
|
39696
|
+
const isReady = !isPending && !!storeCreditAccount;
|
|
39697
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
39698
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
39699
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Credit store credit account" }) }),
|
|
39700
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Credit the store credit account" }) })
|
|
39701
|
+
] }),
|
|
39702
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(StoreCreditAccountCreditForm, { storeCreditAccount })
|
|
39703
|
+
] });
|
|
39704
|
+
};
|
|
39705
|
+
const StoreCreditAccountCreditForm = ({
|
|
39706
|
+
storeCreditAccount
|
|
39707
|
+
}) => {
|
|
39708
|
+
const form = useForm({
|
|
39709
|
+
defaultValues: {
|
|
39710
|
+
amount: {
|
|
39711
|
+
float: 0,
|
|
39712
|
+
value: ""
|
|
39713
|
+
},
|
|
39714
|
+
note: ""
|
|
39715
|
+
},
|
|
39716
|
+
resolver: t(schema)
|
|
39717
|
+
});
|
|
39718
|
+
const { mutateAsync, isPending } = useCreditStoreCreditAccount(
|
|
39719
|
+
storeCreditAccount.id
|
|
39720
|
+
);
|
|
39721
|
+
const { handleSuccess } = useRouteModal();
|
|
39722
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
39723
|
+
if (data.amount.float <= 0) {
|
|
39724
|
+
form.setError("amount", { message: "Amount must be greater than 0" });
|
|
39725
|
+
return;
|
|
39726
|
+
}
|
|
39727
|
+
await mutateAsync(
|
|
39728
|
+
{ amount: data.amount.float, note: data.note },
|
|
39729
|
+
{
|
|
39730
|
+
onSuccess: () => handleSuccess(),
|
|
39731
|
+
onError: (error) => ui.toast.error(error.message)
|
|
39732
|
+
}
|
|
39733
|
+
);
|
|
39734
|
+
});
|
|
39735
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
39736
|
+
KeyboundForm,
|
|
39737
|
+
{
|
|
39738
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
39739
|
+
onSubmit,
|
|
39740
|
+
children: [
|
|
39741
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
39742
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
39743
|
+
Form$2.Field,
|
|
39744
|
+
{
|
|
39745
|
+
control: form.control,
|
|
39746
|
+
name: "amount",
|
|
39747
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
39748
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Amount" }),
|
|
39749
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
39750
|
+
ui.CurrencyInput,
|
|
39751
|
+
{
|
|
39752
|
+
min: 0,
|
|
39753
|
+
placeholder: "0",
|
|
39754
|
+
value: field.value.value,
|
|
39755
|
+
onValueChange: (_value, _name, values) => {
|
|
39756
|
+
field.onChange({
|
|
39757
|
+
value: values == null ? void 0 : values.value,
|
|
39758
|
+
float: (values == null ? void 0 : values.float) || null
|
|
39759
|
+
});
|
|
39760
|
+
},
|
|
39761
|
+
symbol: currencies[storeCreditAccount.currency_code.toUpperCase()].symbol_native,
|
|
39762
|
+
code: storeCreditAccount.currency_code.toUpperCase()
|
|
39763
|
+
}
|
|
39764
|
+
) }),
|
|
39765
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
39766
|
+
] })
|
|
39767
|
+
}
|
|
39768
|
+
),
|
|
39769
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
39770
|
+
Form$2.Field,
|
|
39771
|
+
{
|
|
39772
|
+
control: form.control,
|
|
39773
|
+
name: "note",
|
|
39774
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
39775
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
|
|
39776
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
|
|
39777
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
39778
|
+
] })
|
|
39779
|
+
}
|
|
39780
|
+
)
|
|
39781
|
+
] }),
|
|
39782
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
39783
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
39784
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
39785
|
+
] }) })
|
|
39786
|
+
]
|
|
39787
|
+
}
|
|
39788
|
+
) });
|
|
39789
|
+
};
|
|
39790
|
+
const schema = zod.z.object({
|
|
39791
|
+
note: zod.z.string(),
|
|
39792
|
+
amount: zod.z.object({
|
|
39793
|
+
float: zod.z.number(),
|
|
39794
|
+
value: zod.z.string()
|
|
39795
|
+
})
|
|
39796
|
+
});
|
|
39797
39797
|
const productStatusColor = (status) => {
|
|
39798
39798
|
switch (status) {
|
|
39799
39799
|
case "draft":
|
|
@@ -40591,6 +40591,270 @@ const GiftCardProductEdit = () => {
|
|
|
40591
40591
|
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditForm, { product })
|
|
40592
40592
|
] });
|
|
40593
40593
|
};
|
|
40594
|
+
const VariantPricingForm = ({ form }) => {
|
|
40595
|
+
const { store } = useStore$2();
|
|
40596
|
+
const { regions } = useRegions({ limit: 9999 });
|
|
40597
|
+
const { price_preferences: pricePreferences } = usePricePreferences({});
|
|
40598
|
+
const { setCloseOnEscape } = useRouteModal();
|
|
40599
|
+
const columns = useVariantPriceGridColumns({
|
|
40600
|
+
currencies: store == null ? void 0 : store.supported_currencies,
|
|
40601
|
+
regions,
|
|
40602
|
+
pricePreferences
|
|
40603
|
+
});
|
|
40604
|
+
const variants = useWatch({
|
|
40605
|
+
control: form.control,
|
|
40606
|
+
name: "variants"
|
|
40607
|
+
});
|
|
40608
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
40609
|
+
DataGrid,
|
|
40610
|
+
{
|
|
40611
|
+
columns,
|
|
40612
|
+
data: variants,
|
|
40613
|
+
state: form,
|
|
40614
|
+
onEditingChange: (editing) => setCloseOnEscape(!editing)
|
|
40615
|
+
}
|
|
40616
|
+
);
|
|
40617
|
+
};
|
|
40618
|
+
const columnHelper$1 = createDataGridHelper();
|
|
40619
|
+
const useVariantPriceGridColumns = ({
|
|
40620
|
+
currencies: currencies2 = [],
|
|
40621
|
+
regions = [],
|
|
40622
|
+
pricePreferences = []
|
|
40623
|
+
}) => {
|
|
40624
|
+
return React.useMemo(() => {
|
|
40625
|
+
return [
|
|
40626
|
+
columnHelper$1.column({
|
|
40627
|
+
id: "Title",
|
|
40628
|
+
header: "Title",
|
|
40629
|
+
cell: (context) => {
|
|
40630
|
+
const entity = context.row.original;
|
|
40631
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DataGrid.ReadonlyCell, { context, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full w-full items-center gap-x-2 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: entity.title }) }) });
|
|
40632
|
+
},
|
|
40633
|
+
disableHiding: true
|
|
40634
|
+
}),
|
|
40635
|
+
...createDataGridPriceColumns({
|
|
40636
|
+
currencies: currencies2.map((c2) => c2.currency_code),
|
|
40637
|
+
regions,
|
|
40638
|
+
pricePreferences,
|
|
40639
|
+
getFieldName: (context, value) => {
|
|
40640
|
+
return `variants.${context.row.index}.prices.${value}`;
|
|
40641
|
+
}
|
|
40642
|
+
})
|
|
40643
|
+
];
|
|
40644
|
+
}, [currencies2, regions, pricePreferences]);
|
|
40645
|
+
};
|
|
40646
|
+
const UpdateDenominationPricesSchema = zod__namespace.object({
|
|
40647
|
+
variants: zod__namespace.array(
|
|
40648
|
+
zod__namespace.object({
|
|
40649
|
+
prices: zod__namespace.record(zod__namespace.string(), zod__namespace.string().or(zod__namespace.number()).optional()).optional()
|
|
40650
|
+
})
|
|
40651
|
+
)
|
|
40652
|
+
});
|
|
40653
|
+
const PricingEdit = ({
|
|
40654
|
+
product,
|
|
40655
|
+
variantId
|
|
40656
|
+
}) => {
|
|
40657
|
+
var _a2;
|
|
40658
|
+
const { handleSuccess } = useRouteModal();
|
|
40659
|
+
const { mutateAsync, isPending } = useUpdateProductVariantsBatch(product.id);
|
|
40660
|
+
const { regions } = useRegions({ limit: 9999 });
|
|
40661
|
+
const regionsCurrencyMap = React.useMemo(() => {
|
|
40662
|
+
if (!(regions == null ? void 0 : regions.length)) {
|
|
40663
|
+
return {};
|
|
40664
|
+
}
|
|
40665
|
+
return regions.reduce((acc, reg) => {
|
|
40666
|
+
acc[reg.id] = reg.currency_code;
|
|
40667
|
+
return acc;
|
|
40668
|
+
}, {});
|
|
40669
|
+
}, [regions]);
|
|
40670
|
+
const variants = variantId ? (_a2 = product.variants) == null ? void 0 : _a2.filter((v) => v.id === variantId) : product.variants;
|
|
40671
|
+
const form = useForm({
|
|
40672
|
+
defaultValues: {
|
|
40673
|
+
variants: variants == null ? void 0 : variants.map((variant) => ({
|
|
40674
|
+
title: variant.title,
|
|
40675
|
+
prices: variant.prices.reduce((acc, price) => {
|
|
40676
|
+
var _a3;
|
|
40677
|
+
if ((_a3 = price.rules) == null ? void 0 : _a3.region_id) {
|
|
40678
|
+
acc[price.rules.region_id] = price.amount;
|
|
40679
|
+
} else {
|
|
40680
|
+
acc[price.currency_code] = price.amount;
|
|
40681
|
+
}
|
|
40682
|
+
return acc;
|
|
40683
|
+
}, {})
|
|
40684
|
+
}))
|
|
40685
|
+
},
|
|
40686
|
+
resolver: t(UpdateDenominationPricesSchema, {})
|
|
40687
|
+
});
|
|
40688
|
+
const handleSubmit = form.handleSubmit(async (values) => {
|
|
40689
|
+
const reqData = values.variants.map((variant, ind) => {
|
|
40690
|
+
var _a3;
|
|
40691
|
+
return {
|
|
40692
|
+
id: (_a3 = variants == null ? void 0 : variants[ind]) == null ? void 0 : _a3.id,
|
|
40693
|
+
prices: Object.entries(variant.prices || {}).filter(
|
|
40694
|
+
([_, value]) => value !== "" && typeof value !== "undefined"
|
|
40695
|
+
// deleted cells
|
|
40696
|
+
).map(([currencyCodeOrRegionId, value]) => {
|
|
40697
|
+
var _a4, _b, _c, _d, _e, _f;
|
|
40698
|
+
const regionId = currencyCodeOrRegionId.startsWith("reg_") ? currencyCodeOrRegionId : void 0;
|
|
40699
|
+
const currencyCode = currencyCodeOrRegionId.startsWith("reg_") ? regionsCurrencyMap[regionId] : currencyCodeOrRegionId;
|
|
40700
|
+
let existingId = void 0;
|
|
40701
|
+
if (regionId) {
|
|
40702
|
+
existingId = (_c = (_b = (_a4 = variants == null ? void 0 : variants[ind]) == null ? void 0 : _a4.prices) == null ? void 0 : _b.find(
|
|
40703
|
+
(p) => p.rules["region_id"] === regionId
|
|
40704
|
+
)) == null ? void 0 : _c.id;
|
|
40705
|
+
} else {
|
|
40706
|
+
existingId = (_f = (_e = (_d = variants == null ? void 0 : variants[ind]) == null ? void 0 : _d.prices) == null ? void 0 : _e.find(
|
|
40707
|
+
(p) => p.currency_code === currencyCode && Object.keys(p.rules ?? {}).length === 0
|
|
40708
|
+
)) == null ? void 0 : _f.id;
|
|
40709
|
+
}
|
|
40710
|
+
const amount = castNumber(value);
|
|
40711
|
+
return {
|
|
40712
|
+
id: existingId,
|
|
40713
|
+
currency_code: currencyCode,
|
|
40714
|
+
amount,
|
|
40715
|
+
...regionId ? { rules: { region_id: regionId } } : {}
|
|
40716
|
+
};
|
|
40717
|
+
})
|
|
40718
|
+
};
|
|
40719
|
+
});
|
|
40720
|
+
await mutateAsync(reqData, {
|
|
40721
|
+
onSuccess: () => {
|
|
40722
|
+
handleSuccess("..");
|
|
40723
|
+
}
|
|
40724
|
+
});
|
|
40725
|
+
});
|
|
40726
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { onSubmit: handleSubmit, className: "flex size-full flex-col", children: [
|
|
40727
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
40728
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(VariantPricingForm, { form }) }),
|
|
40729
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center justify-end gap-x-2", children: [
|
|
40730
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
40731
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
40732
|
+
ui.Button,
|
|
40733
|
+
{
|
|
40734
|
+
type: "submit",
|
|
40735
|
+
variant: "primary",
|
|
40736
|
+
size: "small",
|
|
40737
|
+
isLoading: isPending,
|
|
40738
|
+
children: "Save"
|
|
40739
|
+
}
|
|
40740
|
+
)
|
|
40741
|
+
] }) })
|
|
40742
|
+
] }) });
|
|
40743
|
+
};
|
|
40744
|
+
const ProductPrices = () => {
|
|
40745
|
+
const { id, variant_id } = reactRouterDom.useParams();
|
|
40746
|
+
const { product, isLoading, isError, error } = useProduct(id);
|
|
40747
|
+
if (isError) {
|
|
40748
|
+
throw error;
|
|
40749
|
+
}
|
|
40750
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(PricingEdit, { product, variantId: variant_id }) });
|
|
40751
|
+
};
|
|
40752
|
+
const EditSalesChannelsSchema = zod__namespace.object({
|
|
40753
|
+
sales_channels: zod__namespace.array(zod__namespace.string()).optional()
|
|
40754
|
+
});
|
|
40755
|
+
const PAGE_SIZE = 50;
|
|
40756
|
+
const PREFIX = "sc";
|
|
40757
|
+
const EditSalesChannelsForm = ({
|
|
40758
|
+
product
|
|
40759
|
+
}) => {
|
|
40760
|
+
var _a2, _b;
|
|
40761
|
+
const { handleSuccess } = useRouteModal();
|
|
40762
|
+
const form = useForm({
|
|
40763
|
+
defaultValues: {
|
|
40764
|
+
sales_channels: ((_a2 = product.sales_channels) == null ? void 0 : _a2.map((sc) => sc.id)) ?? []
|
|
40765
|
+
},
|
|
40766
|
+
resolver: t(EditSalesChannelsSchema)
|
|
40767
|
+
});
|
|
40768
|
+
const { setValue: setValue2 } = form;
|
|
40769
|
+
const initialState2 = ((_b = product.sales_channels) == null ? void 0 : _b.reduce((acc, curr) => {
|
|
40770
|
+
acc[curr.id] = true;
|
|
40771
|
+
return acc;
|
|
40772
|
+
}, {})) ?? {};
|
|
40773
|
+
const [rowSelection, setRowSelection] = React.useState(initialState2);
|
|
40774
|
+
React.useEffect(() => {
|
|
40775
|
+
const ids2 = Object.keys(rowSelection);
|
|
40776
|
+
setValue2("sales_channels", ids2, {
|
|
40777
|
+
shouldDirty: true,
|
|
40778
|
+
shouldTouch: true
|
|
40779
|
+
});
|
|
40780
|
+
}, [rowSelection, setValue2]);
|
|
40781
|
+
const searchParams = useSalesChannelTableQuery({
|
|
40782
|
+
pageSize: PAGE_SIZE,
|
|
40783
|
+
prefix: PREFIX
|
|
40784
|
+
});
|
|
40785
|
+
const { sales_channels, count: count2, isLoading, isError, error } = useSalesChannels(
|
|
40786
|
+
{
|
|
40787
|
+
...searchParams
|
|
40788
|
+
},
|
|
40789
|
+
{
|
|
40790
|
+
placeholderData: reactQuery.keepPreviousData
|
|
40791
|
+
}
|
|
40792
|
+
);
|
|
40793
|
+
const filters = useSalesChannelTableFilters();
|
|
40794
|
+
const emptyState = useSalesChannelTableEmptyState();
|
|
40795
|
+
const columns = useColumns();
|
|
40796
|
+
const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
|
|
40797
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
40798
|
+
const arr = data.sales_channels ?? [];
|
|
40799
|
+
const sales_channels2 = arr.map((id) => {
|
|
40800
|
+
return {
|
|
40801
|
+
id
|
|
40802
|
+
};
|
|
40803
|
+
});
|
|
40804
|
+
await mutateAsync(
|
|
40805
|
+
{
|
|
40806
|
+
sales_channels: sales_channels2
|
|
40807
|
+
},
|
|
40808
|
+
{
|
|
40809
|
+
onSuccess: () => {
|
|
40810
|
+
handleSuccess();
|
|
40811
|
+
}
|
|
40812
|
+
}
|
|
40813
|
+
);
|
|
40814
|
+
});
|
|
40815
|
+
if (isError) {
|
|
40816
|
+
throw error;
|
|
40817
|
+
}
|
|
40818
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
40819
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
40820
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
40821
|
+
DataTable,
|
|
40822
|
+
{
|
|
40823
|
+
data: sales_channels,
|
|
40824
|
+
columns,
|
|
40825
|
+
getRowId: (row) => row.id,
|
|
40826
|
+
rowCount: count2,
|
|
40827
|
+
isLoading,
|
|
40828
|
+
filters,
|
|
40829
|
+
rowSelection: {
|
|
40830
|
+
state: rowSelection,
|
|
40831
|
+
onRowSelectionChange: setRowSelection
|
|
40832
|
+
},
|
|
40833
|
+
autoFocusSearch: true,
|
|
40834
|
+
layout: "fill",
|
|
40835
|
+
emptyState,
|
|
40836
|
+
prefix: PREFIX
|
|
40837
|
+
}
|
|
40838
|
+
) }),
|
|
40839
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
40840
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
40841
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", isLoading: isMutating, onClick: handleSubmit, children: "Save" })
|
|
40842
|
+
] }) })
|
|
40843
|
+
] }) });
|
|
40844
|
+
};
|
|
40845
|
+
const columnHelper = ui.createDataTableColumnHelper();
|
|
40846
|
+
const useColumns = () => {
|
|
40847
|
+
const columns = useSalesChannelTableColumns();
|
|
40848
|
+
return React.useMemo(() => [columnHelper.select(), ...columns], [columns]);
|
|
40849
|
+
};
|
|
40850
|
+
const ProductSalesChannels = () => {
|
|
40851
|
+
const { id } = reactRouterDom.useParams();
|
|
40852
|
+
const { product, isLoading, isError, error } = useProduct(id);
|
|
40853
|
+
if (isError) {
|
|
40854
|
+
throw error;
|
|
40855
|
+
}
|
|
40856
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(EditSalesChannelsForm, { product }) });
|
|
40857
|
+
};
|
|
40594
40858
|
const EditProductMediaForm = ({ product }) => {
|
|
40595
40859
|
const [selection, setSelection] = React.useState({});
|
|
40596
40860
|
const { handleSuccess } = useRouteModal();
|
|
@@ -41204,270 +41468,6 @@ const ProductMedia = () => {
|
|
|
41204
41468
|
ready && /* @__PURE__ */ jsxRuntime.jsx(ProductMediaView, { product })
|
|
41205
41469
|
] });
|
|
41206
41470
|
};
|
|
41207
|
-
const VariantPricingForm = ({ form }) => {
|
|
41208
|
-
const { store } = useStore$1();
|
|
41209
|
-
const { regions } = useRegions({ limit: 9999 });
|
|
41210
|
-
const { price_preferences: pricePreferences } = usePricePreferences({});
|
|
41211
|
-
const { setCloseOnEscape } = useRouteModal();
|
|
41212
|
-
const columns = useVariantPriceGridColumns({
|
|
41213
|
-
currencies: store == null ? void 0 : store.supported_currencies,
|
|
41214
|
-
regions,
|
|
41215
|
-
pricePreferences
|
|
41216
|
-
});
|
|
41217
|
-
const variants = useWatch({
|
|
41218
|
-
control: form.control,
|
|
41219
|
-
name: "variants"
|
|
41220
|
-
});
|
|
41221
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
41222
|
-
DataGrid,
|
|
41223
|
-
{
|
|
41224
|
-
columns,
|
|
41225
|
-
data: variants,
|
|
41226
|
-
state: form,
|
|
41227
|
-
onEditingChange: (editing) => setCloseOnEscape(!editing)
|
|
41228
|
-
}
|
|
41229
|
-
);
|
|
41230
|
-
};
|
|
41231
|
-
const columnHelper$1 = createDataGridHelper();
|
|
41232
|
-
const useVariantPriceGridColumns = ({
|
|
41233
|
-
currencies: currencies2 = [],
|
|
41234
|
-
regions = [],
|
|
41235
|
-
pricePreferences = []
|
|
41236
|
-
}) => {
|
|
41237
|
-
return React.useMemo(() => {
|
|
41238
|
-
return [
|
|
41239
|
-
columnHelper$1.column({
|
|
41240
|
-
id: "Title",
|
|
41241
|
-
header: "Title",
|
|
41242
|
-
cell: (context) => {
|
|
41243
|
-
const entity = context.row.original;
|
|
41244
|
-
return /* @__PURE__ */ jsxRuntime.jsx(DataGrid.ReadonlyCell, { context, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full w-full items-center gap-x-2 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: entity.title }) }) });
|
|
41245
|
-
},
|
|
41246
|
-
disableHiding: true
|
|
41247
|
-
}),
|
|
41248
|
-
...createDataGridPriceColumns({
|
|
41249
|
-
currencies: currencies2.map((c2) => c2.currency_code),
|
|
41250
|
-
regions,
|
|
41251
|
-
pricePreferences,
|
|
41252
|
-
getFieldName: (context, value) => {
|
|
41253
|
-
return `variants.${context.row.index}.prices.${value}`;
|
|
41254
|
-
}
|
|
41255
|
-
})
|
|
41256
|
-
];
|
|
41257
|
-
}, [currencies2, regions, pricePreferences]);
|
|
41258
|
-
};
|
|
41259
|
-
const UpdateDenominationPricesSchema = zod__namespace.object({
|
|
41260
|
-
variants: zod__namespace.array(
|
|
41261
|
-
zod__namespace.object({
|
|
41262
|
-
prices: zod__namespace.record(zod__namespace.string(), zod__namespace.string().or(zod__namespace.number()).optional()).optional()
|
|
41263
|
-
})
|
|
41264
|
-
)
|
|
41265
|
-
});
|
|
41266
|
-
const PricingEdit = ({
|
|
41267
|
-
product,
|
|
41268
|
-
variantId
|
|
41269
|
-
}) => {
|
|
41270
|
-
var _a2;
|
|
41271
|
-
const { handleSuccess } = useRouteModal();
|
|
41272
|
-
const { mutateAsync, isPending } = useUpdateProductVariantsBatch(product.id);
|
|
41273
|
-
const { regions } = useRegions({ limit: 9999 });
|
|
41274
|
-
const regionsCurrencyMap = React.useMemo(() => {
|
|
41275
|
-
if (!(regions == null ? void 0 : regions.length)) {
|
|
41276
|
-
return {};
|
|
41277
|
-
}
|
|
41278
|
-
return regions.reduce((acc, reg) => {
|
|
41279
|
-
acc[reg.id] = reg.currency_code;
|
|
41280
|
-
return acc;
|
|
41281
|
-
}, {});
|
|
41282
|
-
}, [regions]);
|
|
41283
|
-
const variants = variantId ? (_a2 = product.variants) == null ? void 0 : _a2.filter((v) => v.id === variantId) : product.variants;
|
|
41284
|
-
const form = useForm({
|
|
41285
|
-
defaultValues: {
|
|
41286
|
-
variants: variants == null ? void 0 : variants.map((variant) => ({
|
|
41287
|
-
title: variant.title,
|
|
41288
|
-
prices: variant.prices.reduce((acc, price) => {
|
|
41289
|
-
var _a3;
|
|
41290
|
-
if ((_a3 = price.rules) == null ? void 0 : _a3.region_id) {
|
|
41291
|
-
acc[price.rules.region_id] = price.amount;
|
|
41292
|
-
} else {
|
|
41293
|
-
acc[price.currency_code] = price.amount;
|
|
41294
|
-
}
|
|
41295
|
-
return acc;
|
|
41296
|
-
}, {})
|
|
41297
|
-
}))
|
|
41298
|
-
},
|
|
41299
|
-
resolver: t(UpdateDenominationPricesSchema, {})
|
|
41300
|
-
});
|
|
41301
|
-
const handleSubmit = form.handleSubmit(async (values) => {
|
|
41302
|
-
const reqData = values.variants.map((variant, ind) => {
|
|
41303
|
-
var _a3;
|
|
41304
|
-
return {
|
|
41305
|
-
id: (_a3 = variants == null ? void 0 : variants[ind]) == null ? void 0 : _a3.id,
|
|
41306
|
-
prices: Object.entries(variant.prices || {}).filter(
|
|
41307
|
-
([_, value]) => value !== "" && typeof value !== "undefined"
|
|
41308
|
-
// deleted cells
|
|
41309
|
-
).map(([currencyCodeOrRegionId, value]) => {
|
|
41310
|
-
var _a4, _b, _c, _d, _e, _f;
|
|
41311
|
-
const regionId = currencyCodeOrRegionId.startsWith("reg_") ? currencyCodeOrRegionId : void 0;
|
|
41312
|
-
const currencyCode = currencyCodeOrRegionId.startsWith("reg_") ? regionsCurrencyMap[regionId] : currencyCodeOrRegionId;
|
|
41313
|
-
let existingId = void 0;
|
|
41314
|
-
if (regionId) {
|
|
41315
|
-
existingId = (_c = (_b = (_a4 = variants == null ? void 0 : variants[ind]) == null ? void 0 : _a4.prices) == null ? void 0 : _b.find(
|
|
41316
|
-
(p) => p.rules["region_id"] === regionId
|
|
41317
|
-
)) == null ? void 0 : _c.id;
|
|
41318
|
-
} else {
|
|
41319
|
-
existingId = (_f = (_e = (_d = variants == null ? void 0 : variants[ind]) == null ? void 0 : _d.prices) == null ? void 0 : _e.find(
|
|
41320
|
-
(p) => p.currency_code === currencyCode && Object.keys(p.rules ?? {}).length === 0
|
|
41321
|
-
)) == null ? void 0 : _f.id;
|
|
41322
|
-
}
|
|
41323
|
-
const amount = castNumber(value);
|
|
41324
|
-
return {
|
|
41325
|
-
id: existingId,
|
|
41326
|
-
currency_code: currencyCode,
|
|
41327
|
-
amount,
|
|
41328
|
-
...regionId ? { rules: { region_id: regionId } } : {}
|
|
41329
|
-
};
|
|
41330
|
-
})
|
|
41331
|
-
};
|
|
41332
|
-
});
|
|
41333
|
-
await mutateAsync(reqData, {
|
|
41334
|
-
onSuccess: () => {
|
|
41335
|
-
handleSuccess("..");
|
|
41336
|
-
}
|
|
41337
|
-
});
|
|
41338
|
-
});
|
|
41339
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { onSubmit: handleSubmit, className: "flex size-full flex-col", children: [
|
|
41340
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
41341
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex flex-col overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(VariantPricingForm, { form }) }),
|
|
41342
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex w-full items-center justify-end gap-x-2", children: [
|
|
41343
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
|
|
41344
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
41345
|
-
ui.Button,
|
|
41346
|
-
{
|
|
41347
|
-
type: "submit",
|
|
41348
|
-
variant: "primary",
|
|
41349
|
-
size: "small",
|
|
41350
|
-
isLoading: isPending,
|
|
41351
|
-
children: "Save"
|
|
41352
|
-
}
|
|
41353
|
-
)
|
|
41354
|
-
] }) })
|
|
41355
|
-
] }) });
|
|
41356
|
-
};
|
|
41357
|
-
const ProductPrices = () => {
|
|
41358
|
-
const { id, variant_id } = reactRouterDom.useParams();
|
|
41359
|
-
const { product, isLoading, isError, error } = useProduct(id);
|
|
41360
|
-
if (isError) {
|
|
41361
|
-
throw error;
|
|
41362
|
-
}
|
|
41363
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(PricingEdit, { product, variantId: variant_id }) });
|
|
41364
|
-
};
|
|
41365
|
-
const EditSalesChannelsSchema = zod__namespace.object({
|
|
41366
|
-
sales_channels: zod__namespace.array(zod__namespace.string()).optional()
|
|
41367
|
-
});
|
|
41368
|
-
const PAGE_SIZE = 50;
|
|
41369
|
-
const PREFIX = "sc";
|
|
41370
|
-
const EditSalesChannelsForm = ({
|
|
41371
|
-
product
|
|
41372
|
-
}) => {
|
|
41373
|
-
var _a2, _b;
|
|
41374
|
-
const { handleSuccess } = useRouteModal();
|
|
41375
|
-
const form = useForm({
|
|
41376
|
-
defaultValues: {
|
|
41377
|
-
sales_channels: ((_a2 = product.sales_channels) == null ? void 0 : _a2.map((sc) => sc.id)) ?? []
|
|
41378
|
-
},
|
|
41379
|
-
resolver: t(EditSalesChannelsSchema)
|
|
41380
|
-
});
|
|
41381
|
-
const { setValue: setValue2 } = form;
|
|
41382
|
-
const initialState2 = ((_b = product.sales_channels) == null ? void 0 : _b.reduce((acc, curr) => {
|
|
41383
|
-
acc[curr.id] = true;
|
|
41384
|
-
return acc;
|
|
41385
|
-
}, {})) ?? {};
|
|
41386
|
-
const [rowSelection, setRowSelection] = React.useState(initialState2);
|
|
41387
|
-
React.useEffect(() => {
|
|
41388
|
-
const ids2 = Object.keys(rowSelection);
|
|
41389
|
-
setValue2("sales_channels", ids2, {
|
|
41390
|
-
shouldDirty: true,
|
|
41391
|
-
shouldTouch: true
|
|
41392
|
-
});
|
|
41393
|
-
}, [rowSelection, setValue2]);
|
|
41394
|
-
const searchParams = useSalesChannelTableQuery({
|
|
41395
|
-
pageSize: PAGE_SIZE,
|
|
41396
|
-
prefix: PREFIX
|
|
41397
|
-
});
|
|
41398
|
-
const { sales_channels, count: count2, isLoading, isError, error } = useSalesChannels(
|
|
41399
|
-
{
|
|
41400
|
-
...searchParams
|
|
41401
|
-
},
|
|
41402
|
-
{
|
|
41403
|
-
placeholderData: reactQuery.keepPreviousData
|
|
41404
|
-
}
|
|
41405
|
-
);
|
|
41406
|
-
const filters = useSalesChannelTableFilters();
|
|
41407
|
-
const emptyState = useSalesChannelTableEmptyState();
|
|
41408
|
-
const columns = useColumns();
|
|
41409
|
-
const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
|
|
41410
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
41411
|
-
const arr = data.sales_channels ?? [];
|
|
41412
|
-
const sales_channels2 = arr.map((id) => {
|
|
41413
|
-
return {
|
|
41414
|
-
id
|
|
41415
|
-
};
|
|
41416
|
-
});
|
|
41417
|
-
await mutateAsync(
|
|
41418
|
-
{
|
|
41419
|
-
sales_channels: sales_channels2
|
|
41420
|
-
},
|
|
41421
|
-
{
|
|
41422
|
-
onSuccess: () => {
|
|
41423
|
-
handleSuccess();
|
|
41424
|
-
}
|
|
41425
|
-
}
|
|
41426
|
-
);
|
|
41427
|
-
});
|
|
41428
|
-
if (isError) {
|
|
41429
|
-
throw error;
|
|
41430
|
-
}
|
|
41431
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
41432
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
41433
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
41434
|
-
DataTable,
|
|
41435
|
-
{
|
|
41436
|
-
data: sales_channels,
|
|
41437
|
-
columns,
|
|
41438
|
-
getRowId: (row) => row.id,
|
|
41439
|
-
rowCount: count2,
|
|
41440
|
-
isLoading,
|
|
41441
|
-
filters,
|
|
41442
|
-
rowSelection: {
|
|
41443
|
-
state: rowSelection,
|
|
41444
|
-
onRowSelectionChange: setRowSelection
|
|
41445
|
-
},
|
|
41446
|
-
autoFocusSearch: true,
|
|
41447
|
-
layout: "fill",
|
|
41448
|
-
emptyState,
|
|
41449
|
-
prefix: PREFIX
|
|
41450
|
-
}
|
|
41451
|
-
) }),
|
|
41452
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
41453
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
41454
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", isLoading: isMutating, onClick: handleSubmit, children: "Save" })
|
|
41455
|
-
] }) })
|
|
41456
|
-
] }) });
|
|
41457
|
-
};
|
|
41458
|
-
const columnHelper = ui.createDataTableColumnHelper();
|
|
41459
|
-
const useColumns = () => {
|
|
41460
|
-
const columns = useSalesChannelTableColumns();
|
|
41461
|
-
return React.useMemo(() => [columnHelper.select(), ...columns], [columns]);
|
|
41462
|
-
};
|
|
41463
|
-
const ProductSalesChannels = () => {
|
|
41464
|
-
const { id } = reactRouterDom.useParams();
|
|
41465
|
-
const { product, isLoading, isError, error } = useProduct(id);
|
|
41466
|
-
if (isError) {
|
|
41467
|
-
throw error;
|
|
41468
|
-
}
|
|
41469
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(EditSalesChannelsForm, { product }) });
|
|
41470
|
-
};
|
|
41471
41471
|
const widgetModule = { widgets: [
|
|
41472
41472
|
{
|
|
41473
41473
|
Component: CustomerStoreCreditWidget,
|
|
@@ -41487,16 +41487,6 @@ const widgetModule = { widgets: [
|
|
|
41487
41487
|
] };
|
|
41488
41488
|
const routeModule = {
|
|
41489
41489
|
routes: [
|
|
41490
|
-
{
|
|
41491
|
-
Component: StoreCreditAccountsPage,
|
|
41492
|
-
path: "/store-credit-accounts",
|
|
41493
|
-
children: [
|
|
41494
|
-
{
|
|
41495
|
-
Component: StoreCreditAccountCreate,
|
|
41496
|
-
path: "/store-credit-accounts/create"
|
|
41497
|
-
}
|
|
41498
|
-
]
|
|
41499
|
-
},
|
|
41500
41490
|
{
|
|
41501
41491
|
Component: GiftCardsPage,
|
|
41502
41492
|
path: "/gift-cards",
|
|
@@ -41508,12 +41498,12 @@ const routeModule = {
|
|
|
41508
41498
|
]
|
|
41509
41499
|
},
|
|
41510
41500
|
{
|
|
41511
|
-
Component:
|
|
41512
|
-
path: "/store-credit-accounts
|
|
41501
|
+
Component: StoreCreditAccountsPage,
|
|
41502
|
+
path: "/store-credit-accounts",
|
|
41513
41503
|
children: [
|
|
41514
41504
|
{
|
|
41515
|
-
Component:
|
|
41516
|
-
path: "/store-credit-accounts
|
|
41505
|
+
Component: StoreCreditAccountCreate,
|
|
41506
|
+
path: "/store-credit-accounts/create"
|
|
41517
41507
|
}
|
|
41518
41508
|
]
|
|
41519
41509
|
},
|
|
@@ -41526,7 +41516,7 @@ const routeModule = {
|
|
|
41526
41516
|
path: "/gift-cards/:id/expiration"
|
|
41527
41517
|
},
|
|
41528
41518
|
{
|
|
41529
|
-
Component: Note,
|
|
41519
|
+
Component: Note$1,
|
|
41530
41520
|
path: "/gift-cards/:id/note"
|
|
41531
41521
|
}
|
|
41532
41522
|
]
|
|
@@ -41541,6 +41531,16 @@ const routeModule = {
|
|
|
41541
41531
|
}
|
|
41542
41532
|
]
|
|
41543
41533
|
},
|
|
41534
|
+
{
|
|
41535
|
+
Component: StoreCreditAccountPage,
|
|
41536
|
+
path: "/store-credit-accounts/:id",
|
|
41537
|
+
children: [
|
|
41538
|
+
{
|
|
41539
|
+
Component: Note,
|
|
41540
|
+
path: "/store-credit-accounts/:id/credit"
|
|
41541
|
+
}
|
|
41542
|
+
]
|
|
41543
|
+
},
|
|
41544
41544
|
{
|
|
41545
41545
|
Component: ProductDetail,
|
|
41546
41546
|
path: "/gift-cards/gift-card-products/:id",
|
|
@@ -41555,10 +41555,6 @@ const routeModule = {
|
|
|
41555
41555
|
}
|
|
41556
41556
|
]
|
|
41557
41557
|
},
|
|
41558
|
-
{
|
|
41559
|
-
Component: ProductMedia,
|
|
41560
|
-
path: "/gift-cards/gift-card-products/:id/media"
|
|
41561
|
-
},
|
|
41562
41558
|
{
|
|
41563
41559
|
Component: ProductPrices,
|
|
41564
41560
|
path: "/gift-cards/gift-card-products/:id/prices"
|
|
@@ -41566,22 +41562,26 @@ const routeModule = {
|
|
|
41566
41562
|
{
|
|
41567
41563
|
Component: ProductSalesChannels,
|
|
41568
41564
|
path: "/gift-cards/gift-card-products/:id/sales-channels"
|
|
41565
|
+
},
|
|
41566
|
+
{
|
|
41567
|
+
Component: ProductMedia,
|
|
41568
|
+
path: "/gift-cards/gift-card-products/:id/media"
|
|
41569
41569
|
}
|
|
41570
41570
|
]
|
|
41571
41571
|
};
|
|
41572
41572
|
const menuItemModule = {
|
|
41573
41573
|
menuItems: [
|
|
41574
41574
|
{
|
|
41575
|
-
label: config$
|
|
41576
|
-
icon: config$
|
|
41575
|
+
label: config$3.label,
|
|
41576
|
+
icon: config$3.icon,
|
|
41577
41577
|
path: "/gift-cards",
|
|
41578
41578
|
nested: void 0,
|
|
41579
41579
|
rank: void 0,
|
|
41580
41580
|
translationNs: void 0
|
|
41581
41581
|
},
|
|
41582
41582
|
{
|
|
41583
|
-
label: config$
|
|
41584
|
-
icon: config$
|
|
41583
|
+
label: config$1.label,
|
|
41584
|
+
icon: config$1.icon,
|
|
41585
41585
|
path: "/store-credit-accounts",
|
|
41586
41586
|
nested: void 0,
|
|
41587
41587
|
rank: void 0,
|