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