@medusajs/loyalty-plugin 0.0.7-preview.5 → 0.0.7-preview.6
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 +1018 -1018
- package/.medusa/server/src/admin/index.mjs +430 -430
- package/package.json +5 -3
|
@@ -7,7 +7,7 @@ import { DropdownMenu, IconButton, clx, Heading, Text, Tooltip, Button, Containe
|
|
|
7
7
|
import { Link, useParams, useSearchParams, useNavigate, Outlet, useBlocker, useLocation } from "react-router-dom";
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import React__default, { createElement as createElement$1, useState, useCallback, useMemo, Fragment as Fragment$1, createContext, forwardRef, useId as useId$1, useContext, useEffect, isValidElement as isValidElement$1, useLayoutEffect, useRef, useReducer, useTransition, useImperativeHandle, useDeferredValue, Suspense, memo as memo$2, cloneElement } from "react";
|
|
10
|
-
import { EllipsisHorizontal, InformationCircleSolid, ExclamationCircle, PlusMini, TriangleRightMini, Gift, Photo, PencilSquare, Trash, Tag, XMarkMini, TrianglesMini, CheckMini, EllipseMiniSolid, ArrowUpRightOnBox, TriangleDownMini, Check, SquareTwoStack, Calendar, ShoppingCart,
|
|
10
|
+
import { EllipsisHorizontal, InformationCircleSolid, ExclamationCircle, PlusMini, TriangleRightMini, Gift, Photo, PencilSquare, Trash, Tag, XMarkMini, TrianglesMini, CheckMini, EllipseMiniSolid, ArrowUpRightOnBox, TriangleDownMini, Check, SquareTwoStack, Calendar, ShoppingCart, AdjustmentsDone, Adjustments, TaxInclusive, TaxExclusive, XMark, ArrowDownTray, DotsSix, ThumbnailBadge, StackPerspective, CreditCard, User, Share, XCircleSolid, TriangleLeftMini } from "@medusajs/icons";
|
|
11
11
|
import { useQuery, useQueryClient, useMutation, useInfiniteQuery, keepPreviousData } from "@tanstack/react-query";
|
|
12
12
|
import Medusa, { FetchError } from "@medusajs/js-sdk";
|
|
13
13
|
import { format as format$1, subDays, subMonths, formatDistance, sub } from "date-fns";
|
|
@@ -23851,270 +23851,6 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
23851
23851
|
const schema$1 = objectType({
|
|
23852
23852
|
expires_at: dateType().nullish()
|
|
23853
23853
|
});
|
|
23854
|
-
const StoreCreditAccountBalanceSection = ({
|
|
23855
|
-
storeCreditAccount
|
|
23856
|
-
}) => {
|
|
23857
|
-
if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
|
|
23858
|
-
return;
|
|
23859
|
-
}
|
|
23860
|
-
return /* @__PURE__ */ jsx(Container$1, { className: "grid grid-cols-2 gap-x-2 px-6 py-4", children: /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-x-3", children: [
|
|
23861
|
-
/* @__PURE__ */ jsx("div", { className: "bg-ui-tag-green-icon h-8 w-1 rounded-full" }),
|
|
23862
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
23863
|
-
/* @__PURE__ */ jsx(Text, { weight: "plus", size: "small", className: "text-ui-fg-subtle", children: "Current Balance" }),
|
|
23864
|
-
/* @__PURE__ */ jsx(
|
|
23865
|
-
Text,
|
|
23866
|
-
{
|
|
23867
|
-
weight: "plus",
|
|
23868
|
-
size: "xlarge",
|
|
23869
|
-
className: "tabular-nums text-ui-fg-base",
|
|
23870
|
-
children: formatAmount(
|
|
23871
|
-
storeCreditAccount.balance,
|
|
23872
|
-
storeCreditAccount.currency_code
|
|
23873
|
-
)
|
|
23874
|
-
}
|
|
23875
|
-
)
|
|
23876
|
-
] })
|
|
23877
|
-
] }) });
|
|
23878
|
-
};
|
|
23879
|
-
const StoreCreditAccountDetailsSection = ({
|
|
23880
|
-
storeCreditAccount
|
|
23881
|
-
}) => {
|
|
23882
|
-
if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
|
|
23883
|
-
return;
|
|
23884
|
-
}
|
|
23885
|
-
return /* @__PURE__ */ jsxs(Container$1, { className: "flex justify-between gap-x-2 px-6 py-6", children: [
|
|
23886
|
-
/* @__PURE__ */ jsxs(
|
|
23887
|
-
Text,
|
|
23888
|
-
{
|
|
23889
|
-
weight: "plus",
|
|
23890
|
-
size: "xlarge",
|
|
23891
|
-
className: "text-ui-fg-base flex gap-x-4",
|
|
23892
|
-
children: [
|
|
23893
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
23894
|
-
/* @__PURE__ */ jsx(CreditCardIcon, { className: "inline" }),
|
|
23895
|
-
" "
|
|
23896
|
-
] }),
|
|
23897
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
23898
|
-
/* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle", children: [
|
|
23899
|
-
storeCreditAccount.currency_code.toUpperCase(),
|
|
23900
|
-
" Account"
|
|
23901
|
-
] }),
|
|
23902
|
-
/* @__PURE__ */ jsx("div", { className: "text-ui-fg-base", children: /* @__PURE__ */ jsx(
|
|
23903
|
-
Text,
|
|
23904
|
-
{
|
|
23905
|
-
weight: "regular",
|
|
23906
|
-
size: "small",
|
|
23907
|
-
className: "text-ui-fg-base flex gap-x-4",
|
|
23908
|
-
children: /* @__PURE__ */ jsx(DisplayId, { id: storeCreditAccount.id })
|
|
23909
|
-
}
|
|
23910
|
-
) })
|
|
23911
|
-
] })
|
|
23912
|
-
]
|
|
23913
|
-
}
|
|
23914
|
-
),
|
|
23915
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-x-4", children: /* @__PURE__ */ jsx(
|
|
23916
|
-
ActionMenu,
|
|
23917
|
-
{
|
|
23918
|
-
groups: [
|
|
23919
|
-
{
|
|
23920
|
-
actions: [
|
|
23921
|
-
{
|
|
23922
|
-
icon: /* @__PURE__ */ jsx(CreditCard, {}),
|
|
23923
|
-
label: "Credit the account",
|
|
23924
|
-
to: "credit"
|
|
23925
|
-
}
|
|
23926
|
-
]
|
|
23927
|
-
}
|
|
23928
|
-
]
|
|
23929
|
-
}
|
|
23930
|
-
) })
|
|
23931
|
-
] });
|
|
23932
|
-
};
|
|
23933
|
-
function StoreCreditAccountCustomerSection({
|
|
23934
|
-
customerId
|
|
23935
|
-
}) {
|
|
23936
|
-
const { customer, isPending } = useCustomer(customerId, void 0, {
|
|
23937
|
-
enabled: !!customerId
|
|
23938
|
-
});
|
|
23939
|
-
if (isPending || !customer) {
|
|
23940
|
-
return null;
|
|
23941
|
-
}
|
|
23942
|
-
return /* @__PURE__ */ jsxs(Container$1, { className: "p-0", children: [
|
|
23943
|
-
/* @__PURE__ */ jsx(Header$5, { title: "Customer" }),
|
|
23944
|
-
/* @__PURE__ */ jsx(
|
|
23945
|
-
SidebarLink,
|
|
23946
|
-
{
|
|
23947
|
-
icon: /* @__PURE__ */ jsx(User, {}),
|
|
23948
|
-
labelKey: customer.email || "N/A",
|
|
23949
|
-
descriptionKey: !customer.first_name && !customer.last_name ? "N/A" : `${customer.first_name} ${customer.last_name}`,
|
|
23950
|
-
to: `/customers/${customer.id}`
|
|
23951
|
-
},
|
|
23952
|
-
customer.id
|
|
23953
|
-
)
|
|
23954
|
-
] });
|
|
23955
|
-
}
|
|
23956
|
-
function StoreCreditAccountCodeSection({ code }) {
|
|
23957
|
-
if (!code) {
|
|
23958
|
-
return null;
|
|
23959
|
-
}
|
|
23960
|
-
return /* @__PURE__ */ jsxs(Container$1, { className: "p-0", children: [
|
|
23961
|
-
/* @__PURE__ */ jsx(Header$5, { title: "Account Code" }),
|
|
23962
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-4 px-6 mb-2", children: [
|
|
23963
|
-
/* @__PURE__ */ jsx(Share, { className: "inline" }),
|
|
23964
|
-
/* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle text-sm", children: code })
|
|
23965
|
-
] })
|
|
23966
|
-
] });
|
|
23967
|
-
}
|
|
23968
|
-
const StoreCreditAccountPage = () => {
|
|
23969
|
-
const { id } = useParams();
|
|
23970
|
-
const { store_credit_account: storeCreditAccount } = useStoreCreditAccount(
|
|
23971
|
-
id
|
|
23972
|
-
);
|
|
23973
|
-
if (!storeCreditAccount) {
|
|
23974
|
-
return;
|
|
23975
|
-
}
|
|
23976
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
23977
|
-
TwoColumnLayout,
|
|
23978
|
-
{
|
|
23979
|
-
firstCol: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
23980
|
-
/* @__PURE__ */ jsx(
|
|
23981
|
-
StoreCreditAccountDetailsSection,
|
|
23982
|
-
{
|
|
23983
|
-
storeCreditAccount
|
|
23984
|
-
}
|
|
23985
|
-
),
|
|
23986
|
-
/* @__PURE__ */ jsx(TransactionsTable, { id: storeCreditAccount.id })
|
|
23987
|
-
] }),
|
|
23988
|
-
secondCol: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
23989
|
-
/* @__PURE__ */ jsx(
|
|
23990
|
-
StoreCreditAccountBalanceSection,
|
|
23991
|
-
{
|
|
23992
|
-
storeCreditAccount
|
|
23993
|
-
}
|
|
23994
|
-
),
|
|
23995
|
-
/* @__PURE__ */ jsx(StoreCreditAccountCodeSection, { code: storeCreditAccount.code }),
|
|
23996
|
-
/* @__PURE__ */ jsx(
|
|
23997
|
-
StoreCreditAccountCustomerSection,
|
|
23998
|
-
{
|
|
23999
|
-
customerId: storeCreditAccount.customer_id
|
|
24000
|
-
}
|
|
24001
|
-
)
|
|
24002
|
-
] })
|
|
24003
|
-
}
|
|
24004
|
-
) });
|
|
24005
|
-
};
|
|
24006
|
-
const Note = () => {
|
|
24007
|
-
const { id } = useParams();
|
|
24008
|
-
const {
|
|
24009
|
-
store_credit_account: storeCreditAccount,
|
|
24010
|
-
isPending,
|
|
24011
|
-
isError,
|
|
24012
|
-
error
|
|
24013
|
-
} = useStoreCreditAccount(id, {});
|
|
24014
|
-
if (isError) {
|
|
24015
|
-
throw error;
|
|
24016
|
-
}
|
|
24017
|
-
const isReady = !isPending && !!storeCreditAccount;
|
|
24018
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
24019
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
24020
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Credit store credit account" }) }),
|
|
24021
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Credit the store credit account" }) })
|
|
24022
|
-
] }),
|
|
24023
|
-
isReady && /* @__PURE__ */ jsx(StoreCreditAccountCreditForm, { storeCreditAccount })
|
|
24024
|
-
] });
|
|
24025
|
-
};
|
|
24026
|
-
const StoreCreditAccountCreditForm = ({
|
|
24027
|
-
storeCreditAccount
|
|
24028
|
-
}) => {
|
|
24029
|
-
const form = useForm({
|
|
24030
|
-
defaultValues: {
|
|
24031
|
-
amount: {
|
|
24032
|
-
float: 0,
|
|
24033
|
-
value: ""
|
|
24034
|
-
},
|
|
24035
|
-
note: ""
|
|
24036
|
-
},
|
|
24037
|
-
resolver: t(schema)
|
|
24038
|
-
});
|
|
24039
|
-
const { mutateAsync, isPending } = useCreditStoreCreditAccount(
|
|
24040
|
-
storeCreditAccount.id
|
|
24041
|
-
);
|
|
24042
|
-
const { handleSuccess } = useRouteModal();
|
|
24043
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
24044
|
-
if (data.amount.float <= 0) {
|
|
24045
|
-
form.setError("amount", { message: "Amount must be greater than 0" });
|
|
24046
|
-
return;
|
|
24047
|
-
}
|
|
24048
|
-
await mutateAsync(
|
|
24049
|
-
{ amount: data.amount.float, note: data.note },
|
|
24050
|
-
{
|
|
24051
|
-
onSuccess: () => handleSuccess(),
|
|
24052
|
-
onError: (error) => toast.error(error.message)
|
|
24053
|
-
}
|
|
24054
|
-
);
|
|
24055
|
-
});
|
|
24056
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
24057
|
-
KeyboundForm,
|
|
24058
|
-
{
|
|
24059
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
24060
|
-
onSubmit,
|
|
24061
|
-
children: [
|
|
24062
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
24063
|
-
/* @__PURE__ */ jsx(
|
|
24064
|
-
Form$2.Field,
|
|
24065
|
-
{
|
|
24066
|
-
control: form.control,
|
|
24067
|
-
name: "amount",
|
|
24068
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
24069
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Amount" }),
|
|
24070
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
24071
|
-
CurrencyInput$1,
|
|
24072
|
-
{
|
|
24073
|
-
min: 0,
|
|
24074
|
-
placeholder: "0",
|
|
24075
|
-
value: field.value.value,
|
|
24076
|
-
onValueChange: (_value, _name, values) => {
|
|
24077
|
-
field.onChange({
|
|
24078
|
-
value: values == null ? void 0 : values.value,
|
|
24079
|
-
float: (values == null ? void 0 : values.float) || null
|
|
24080
|
-
});
|
|
24081
|
-
},
|
|
24082
|
-
symbol: currencies[storeCreditAccount.currency_code.toUpperCase()].symbol_native,
|
|
24083
|
-
code: storeCreditAccount.currency_code.toUpperCase()
|
|
24084
|
-
}
|
|
24085
|
-
) }),
|
|
24086
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
24087
|
-
] })
|
|
24088
|
-
}
|
|
24089
|
-
),
|
|
24090
|
-
/* @__PURE__ */ jsx(
|
|
24091
|
-
Form$2.Field,
|
|
24092
|
-
{
|
|
24093
|
-
control: form.control,
|
|
24094
|
-
name: "note",
|
|
24095
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
24096
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Note" }),
|
|
24097
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
|
|
24098
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
24099
|
-
] })
|
|
24100
|
-
}
|
|
24101
|
-
)
|
|
24102
|
-
] }),
|
|
24103
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
24104
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
24105
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
24106
|
-
] }) })
|
|
24107
|
-
]
|
|
24108
|
-
}
|
|
24109
|
-
) });
|
|
24110
|
-
};
|
|
24111
|
-
const schema = objectType({
|
|
24112
|
-
note: stringType(),
|
|
24113
|
-
amount: objectType({
|
|
24114
|
-
float: numberType(),
|
|
24115
|
-
value: stringType()
|
|
24116
|
-
})
|
|
24117
|
-
});
|
|
24118
23854
|
const columnHelper$7 = createColumnHelper();
|
|
24119
23855
|
const useGiftCardProductsTableColumns = () => {
|
|
24120
23856
|
return useMemo(
|
|
@@ -36922,6 +36658,270 @@ const GiftCardProductCreate = () => {
|
|
|
36922
36658
|
)
|
|
36923
36659
|
] });
|
|
36924
36660
|
};
|
|
36661
|
+
const StoreCreditAccountBalanceSection = ({
|
|
36662
|
+
storeCreditAccount
|
|
36663
|
+
}) => {
|
|
36664
|
+
if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
|
|
36665
|
+
return;
|
|
36666
|
+
}
|
|
36667
|
+
return /* @__PURE__ */ jsx(Container$1, { className: "grid grid-cols-2 gap-x-2 px-6 py-4", children: /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex items-center gap-x-3", children: [
|
|
36668
|
+
/* @__PURE__ */ jsx("div", { className: "bg-ui-tag-green-icon h-8 w-1 rounded-full" }),
|
|
36669
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
36670
|
+
/* @__PURE__ */ jsx(Text, { weight: "plus", size: "small", className: "text-ui-fg-subtle", children: "Current Balance" }),
|
|
36671
|
+
/* @__PURE__ */ jsx(
|
|
36672
|
+
Text,
|
|
36673
|
+
{
|
|
36674
|
+
weight: "plus",
|
|
36675
|
+
size: "xlarge",
|
|
36676
|
+
className: "tabular-nums text-ui-fg-base",
|
|
36677
|
+
children: formatAmount(
|
|
36678
|
+
storeCreditAccount.balance,
|
|
36679
|
+
storeCreditAccount.currency_code
|
|
36680
|
+
)
|
|
36681
|
+
}
|
|
36682
|
+
)
|
|
36683
|
+
] })
|
|
36684
|
+
] }) });
|
|
36685
|
+
};
|
|
36686
|
+
const StoreCreditAccountDetailsSection = ({
|
|
36687
|
+
storeCreditAccount
|
|
36688
|
+
}) => {
|
|
36689
|
+
if (!storeCreditAccount || typeof storeCreditAccount.balance === "undefined") {
|
|
36690
|
+
return;
|
|
36691
|
+
}
|
|
36692
|
+
return /* @__PURE__ */ jsxs(Container$1, { className: "flex justify-between gap-x-2 px-6 py-6", children: [
|
|
36693
|
+
/* @__PURE__ */ jsxs(
|
|
36694
|
+
Text,
|
|
36695
|
+
{
|
|
36696
|
+
weight: "plus",
|
|
36697
|
+
size: "xlarge",
|
|
36698
|
+
className: "text-ui-fg-base flex gap-x-4",
|
|
36699
|
+
children: [
|
|
36700
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
36701
|
+
/* @__PURE__ */ jsx(CreditCardIcon, { className: "inline" }),
|
|
36702
|
+
" "
|
|
36703
|
+
] }),
|
|
36704
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
36705
|
+
/* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle", children: [
|
|
36706
|
+
storeCreditAccount.currency_code.toUpperCase(),
|
|
36707
|
+
" Account"
|
|
36708
|
+
] }),
|
|
36709
|
+
/* @__PURE__ */ jsx("div", { className: "text-ui-fg-base", children: /* @__PURE__ */ jsx(
|
|
36710
|
+
Text,
|
|
36711
|
+
{
|
|
36712
|
+
weight: "regular",
|
|
36713
|
+
size: "small",
|
|
36714
|
+
className: "text-ui-fg-base flex gap-x-4",
|
|
36715
|
+
children: /* @__PURE__ */ jsx(DisplayId, { id: storeCreditAccount.id })
|
|
36716
|
+
}
|
|
36717
|
+
) })
|
|
36718
|
+
] })
|
|
36719
|
+
]
|
|
36720
|
+
}
|
|
36721
|
+
),
|
|
36722
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-x-4", children: /* @__PURE__ */ jsx(
|
|
36723
|
+
ActionMenu,
|
|
36724
|
+
{
|
|
36725
|
+
groups: [
|
|
36726
|
+
{
|
|
36727
|
+
actions: [
|
|
36728
|
+
{
|
|
36729
|
+
icon: /* @__PURE__ */ jsx(CreditCard, {}),
|
|
36730
|
+
label: "Credit the account",
|
|
36731
|
+
to: "credit"
|
|
36732
|
+
}
|
|
36733
|
+
]
|
|
36734
|
+
}
|
|
36735
|
+
]
|
|
36736
|
+
}
|
|
36737
|
+
) })
|
|
36738
|
+
] });
|
|
36739
|
+
};
|
|
36740
|
+
function StoreCreditAccountCustomerSection({
|
|
36741
|
+
customerId
|
|
36742
|
+
}) {
|
|
36743
|
+
const { customer, isPending } = useCustomer(customerId, void 0, {
|
|
36744
|
+
enabled: !!customerId
|
|
36745
|
+
});
|
|
36746
|
+
if (isPending || !customer) {
|
|
36747
|
+
return null;
|
|
36748
|
+
}
|
|
36749
|
+
return /* @__PURE__ */ jsxs(Container$1, { className: "p-0", children: [
|
|
36750
|
+
/* @__PURE__ */ jsx(Header$5, { title: "Customer" }),
|
|
36751
|
+
/* @__PURE__ */ jsx(
|
|
36752
|
+
SidebarLink,
|
|
36753
|
+
{
|
|
36754
|
+
icon: /* @__PURE__ */ jsx(User, {}),
|
|
36755
|
+
labelKey: customer.email || "N/A",
|
|
36756
|
+
descriptionKey: !customer.first_name && !customer.last_name ? "N/A" : `${customer.first_name} ${customer.last_name}`,
|
|
36757
|
+
to: `/customers/${customer.id}`
|
|
36758
|
+
},
|
|
36759
|
+
customer.id
|
|
36760
|
+
)
|
|
36761
|
+
] });
|
|
36762
|
+
}
|
|
36763
|
+
function StoreCreditAccountCodeSection({ code }) {
|
|
36764
|
+
if (!code) {
|
|
36765
|
+
return null;
|
|
36766
|
+
}
|
|
36767
|
+
return /* @__PURE__ */ jsxs(Container$1, { className: "p-0", children: [
|
|
36768
|
+
/* @__PURE__ */ jsx(Header$5, { title: "Account Code" }),
|
|
36769
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-4 px-6 mb-2", children: [
|
|
36770
|
+
/* @__PURE__ */ jsx(Share, { className: "inline" }),
|
|
36771
|
+
/* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle text-sm", children: code })
|
|
36772
|
+
] })
|
|
36773
|
+
] });
|
|
36774
|
+
}
|
|
36775
|
+
const StoreCreditAccountPage = () => {
|
|
36776
|
+
const { id } = useParams();
|
|
36777
|
+
const { store_credit_account: storeCreditAccount } = useStoreCreditAccount(
|
|
36778
|
+
id
|
|
36779
|
+
);
|
|
36780
|
+
if (!storeCreditAccount) {
|
|
36781
|
+
return;
|
|
36782
|
+
}
|
|
36783
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
36784
|
+
TwoColumnLayout,
|
|
36785
|
+
{
|
|
36786
|
+
firstCol: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
36787
|
+
/* @__PURE__ */ jsx(
|
|
36788
|
+
StoreCreditAccountDetailsSection,
|
|
36789
|
+
{
|
|
36790
|
+
storeCreditAccount
|
|
36791
|
+
}
|
|
36792
|
+
),
|
|
36793
|
+
/* @__PURE__ */ jsx(TransactionsTable, { id: storeCreditAccount.id })
|
|
36794
|
+
] }),
|
|
36795
|
+
secondCol: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
36796
|
+
/* @__PURE__ */ jsx(
|
|
36797
|
+
StoreCreditAccountBalanceSection,
|
|
36798
|
+
{
|
|
36799
|
+
storeCreditAccount
|
|
36800
|
+
}
|
|
36801
|
+
),
|
|
36802
|
+
/* @__PURE__ */ jsx(StoreCreditAccountCodeSection, { code: storeCreditAccount.code }),
|
|
36803
|
+
/* @__PURE__ */ jsx(
|
|
36804
|
+
StoreCreditAccountCustomerSection,
|
|
36805
|
+
{
|
|
36806
|
+
customerId: storeCreditAccount.customer_id
|
|
36807
|
+
}
|
|
36808
|
+
)
|
|
36809
|
+
] })
|
|
36810
|
+
}
|
|
36811
|
+
) });
|
|
36812
|
+
};
|
|
36813
|
+
const Note = () => {
|
|
36814
|
+
const { id } = useParams();
|
|
36815
|
+
const {
|
|
36816
|
+
store_credit_account: storeCreditAccount,
|
|
36817
|
+
isPending,
|
|
36818
|
+
isError,
|
|
36819
|
+
error
|
|
36820
|
+
} = useStoreCreditAccount(id, {});
|
|
36821
|
+
if (isError) {
|
|
36822
|
+
throw error;
|
|
36823
|
+
}
|
|
36824
|
+
const isReady = !isPending && !!storeCreditAccount;
|
|
36825
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
36826
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
36827
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Credit store credit account" }) }),
|
|
36828
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Credit the store credit account" }) })
|
|
36829
|
+
] }),
|
|
36830
|
+
isReady && /* @__PURE__ */ jsx(StoreCreditAccountCreditForm, { storeCreditAccount })
|
|
36831
|
+
] });
|
|
36832
|
+
};
|
|
36833
|
+
const StoreCreditAccountCreditForm = ({
|
|
36834
|
+
storeCreditAccount
|
|
36835
|
+
}) => {
|
|
36836
|
+
const form = useForm({
|
|
36837
|
+
defaultValues: {
|
|
36838
|
+
amount: {
|
|
36839
|
+
float: 0,
|
|
36840
|
+
value: ""
|
|
36841
|
+
},
|
|
36842
|
+
note: ""
|
|
36843
|
+
},
|
|
36844
|
+
resolver: t(schema)
|
|
36845
|
+
});
|
|
36846
|
+
const { mutateAsync, isPending } = useCreditStoreCreditAccount(
|
|
36847
|
+
storeCreditAccount.id
|
|
36848
|
+
);
|
|
36849
|
+
const { handleSuccess } = useRouteModal();
|
|
36850
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
36851
|
+
if (data.amount.float <= 0) {
|
|
36852
|
+
form.setError("amount", { message: "Amount must be greater than 0" });
|
|
36853
|
+
return;
|
|
36854
|
+
}
|
|
36855
|
+
await mutateAsync(
|
|
36856
|
+
{ amount: data.amount.float, note: data.note },
|
|
36857
|
+
{
|
|
36858
|
+
onSuccess: () => handleSuccess(),
|
|
36859
|
+
onError: (error) => toast.error(error.message)
|
|
36860
|
+
}
|
|
36861
|
+
);
|
|
36862
|
+
});
|
|
36863
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
36864
|
+
KeyboundForm,
|
|
36865
|
+
{
|
|
36866
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
36867
|
+
onSubmit,
|
|
36868
|
+
children: [
|
|
36869
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
|
|
36870
|
+
/* @__PURE__ */ jsx(
|
|
36871
|
+
Form$2.Field,
|
|
36872
|
+
{
|
|
36873
|
+
control: form.control,
|
|
36874
|
+
name: "amount",
|
|
36875
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
36876
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Amount" }),
|
|
36877
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
|
|
36878
|
+
CurrencyInput$1,
|
|
36879
|
+
{
|
|
36880
|
+
min: 0,
|
|
36881
|
+
placeholder: "0",
|
|
36882
|
+
value: field.value.value,
|
|
36883
|
+
onValueChange: (_value, _name, values) => {
|
|
36884
|
+
field.onChange({
|
|
36885
|
+
value: values == null ? void 0 : values.value,
|
|
36886
|
+
float: (values == null ? void 0 : values.float) || null
|
|
36887
|
+
});
|
|
36888
|
+
},
|
|
36889
|
+
symbol: currencies[storeCreditAccount.currency_code.toUpperCase()].symbol_native,
|
|
36890
|
+
code: storeCreditAccount.currency_code.toUpperCase()
|
|
36891
|
+
}
|
|
36892
|
+
) }),
|
|
36893
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
36894
|
+
] })
|
|
36895
|
+
}
|
|
36896
|
+
),
|
|
36897
|
+
/* @__PURE__ */ jsx(
|
|
36898
|
+
Form$2.Field,
|
|
36899
|
+
{
|
|
36900
|
+
control: form.control,
|
|
36901
|
+
name: "note",
|
|
36902
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
36903
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Note" }),
|
|
36904
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
|
|
36905
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
36906
|
+
] })
|
|
36907
|
+
}
|
|
36908
|
+
)
|
|
36909
|
+
] }),
|
|
36910
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
36911
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
36912
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
36913
|
+
] }) })
|
|
36914
|
+
]
|
|
36915
|
+
}
|
|
36916
|
+
) });
|
|
36917
|
+
};
|
|
36918
|
+
const schema = objectType({
|
|
36919
|
+
note: stringType(),
|
|
36920
|
+
amount: objectType({
|
|
36921
|
+
float: numberType(),
|
|
36922
|
+
value: stringType()
|
|
36923
|
+
})
|
|
36924
|
+
});
|
|
36925
36925
|
const productStatusColor = (status) => {
|
|
36926
36926
|
switch (status) {
|
|
36927
36927
|
case "draft":
|
|
@@ -37397,6 +37397,153 @@ const ProductDetail = () => {
|
|
|
37397
37397
|
] });
|
|
37398
37398
|
};
|
|
37399
37399
|
const EditProductSchema$1 = objectType({
|
|
37400
|
+
denominations: arrayType(
|
|
37401
|
+
objectType({
|
|
37402
|
+
id: stringType().optional(),
|
|
37403
|
+
value: stringType().min(1),
|
|
37404
|
+
prices: recordType(stringType(), optionalFloat).optional()
|
|
37405
|
+
})
|
|
37406
|
+
).min(1)
|
|
37407
|
+
});
|
|
37408
|
+
const GiftCardProductEditDenominationsForm = ({
|
|
37409
|
+
product
|
|
37410
|
+
}) => {
|
|
37411
|
+
var _a;
|
|
37412
|
+
const { handleSuccess } = useRouteModal();
|
|
37413
|
+
const form = useForm({
|
|
37414
|
+
defaultValues: {
|
|
37415
|
+
denominations: (_a = product.variants) == null ? void 0 : _a.map((variant) => ({
|
|
37416
|
+
id: variant.id,
|
|
37417
|
+
value: variant.title
|
|
37418
|
+
}))
|
|
37419
|
+
},
|
|
37420
|
+
resolver: t(EditProductSchema$1)
|
|
37421
|
+
});
|
|
37422
|
+
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
37423
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
37424
|
+
const optionValues = data.denominations.map(
|
|
37425
|
+
(denomination) => denomination.value
|
|
37426
|
+
);
|
|
37427
|
+
const options = [
|
|
37428
|
+
{
|
|
37429
|
+
title: "denomination",
|
|
37430
|
+
values: optionValues
|
|
37431
|
+
}
|
|
37432
|
+
];
|
|
37433
|
+
await mutateAsync(
|
|
37434
|
+
{
|
|
37435
|
+
options,
|
|
37436
|
+
variants: data.denominations.map((denomination) => ({
|
|
37437
|
+
id: denomination.id,
|
|
37438
|
+
title: denomination.value,
|
|
37439
|
+
manage_inventory: false,
|
|
37440
|
+
options: {
|
|
37441
|
+
denomination: denomination.value
|
|
37442
|
+
}
|
|
37443
|
+
}))
|
|
37444
|
+
},
|
|
37445
|
+
{
|
|
37446
|
+
onSuccess: () => {
|
|
37447
|
+
toast.success(`Denominations updated successfully`);
|
|
37448
|
+
handleSuccess();
|
|
37449
|
+
},
|
|
37450
|
+
onError: (e2) => {
|
|
37451
|
+
toast.error(e2.message);
|
|
37452
|
+
}
|
|
37453
|
+
}
|
|
37454
|
+
);
|
|
37455
|
+
});
|
|
37456
|
+
const {
|
|
37457
|
+
fields: denominationsFields,
|
|
37458
|
+
append: addDenomination,
|
|
37459
|
+
remove: removeDenomination
|
|
37460
|
+
} = useFieldArray({
|
|
37461
|
+
name: "denominations",
|
|
37462
|
+
control: form.control
|
|
37463
|
+
});
|
|
37464
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
37465
|
+
KeyboundForm,
|
|
37466
|
+
{
|
|
37467
|
+
onSubmit: handleSubmit,
|
|
37468
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
37469
|
+
children: [
|
|
37470
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
37471
|
+
denominationsFields.map((denominationField, index) => {
|
|
37472
|
+
return /* @__PURE__ */ jsxs(
|
|
37473
|
+
"div",
|
|
37474
|
+
{
|
|
37475
|
+
className: "flex items-center justify-between shadow-elevation-card-rest bg-ui-bg-component transition-fg rounded-md px-4 py-2",
|
|
37476
|
+
children: [
|
|
37477
|
+
/* @__PURE__ */ jsx(
|
|
37478
|
+
Form$2.Field,
|
|
37479
|
+
{
|
|
37480
|
+
control: form.control,
|
|
37481
|
+
name: `denominations.${index}.value`,
|
|
37482
|
+
render: ({ field }) => {
|
|
37483
|
+
return /* @__PURE__ */ jsxs(Form$2.Item, { className: "w-full", children: [
|
|
37484
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field, placeholder: "100" }) }),
|
|
37485
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
37486
|
+
] });
|
|
37487
|
+
}
|
|
37488
|
+
},
|
|
37489
|
+
denominationField.id
|
|
37490
|
+
),
|
|
37491
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsx(
|
|
37492
|
+
Button,
|
|
37493
|
+
{
|
|
37494
|
+
size: "small",
|
|
37495
|
+
variant: "secondary",
|
|
37496
|
+
type: "button",
|
|
37497
|
+
className: "rounded-full p-0 ml-4",
|
|
37498
|
+
onClick: () => {
|
|
37499
|
+
removeDenomination(index);
|
|
37500
|
+
},
|
|
37501
|
+
children: /* @__PURE__ */ jsx(XCircleSolid, { className: "rounded-full" })
|
|
37502
|
+
}
|
|
37503
|
+
) })
|
|
37504
|
+
]
|
|
37505
|
+
},
|
|
37506
|
+
denominationField.id
|
|
37507
|
+
);
|
|
37508
|
+
}),
|
|
37509
|
+
/* @__PURE__ */ jsx(
|
|
37510
|
+
Button,
|
|
37511
|
+
{
|
|
37512
|
+
size: "small",
|
|
37513
|
+
variant: "secondary",
|
|
37514
|
+
type: "button",
|
|
37515
|
+
className: "w-full",
|
|
37516
|
+
onClick: () => {
|
|
37517
|
+
addDenomination({ value: "", prices: {} });
|
|
37518
|
+
},
|
|
37519
|
+
children: "Add denomination"
|
|
37520
|
+
}
|
|
37521
|
+
),
|
|
37522
|
+
form.formState.errors.denominations && /* @__PURE__ */ jsx(Alert, { variant: "error", children: "Please add at least one denomination." })
|
|
37523
|
+
] }) }) }) }),
|
|
37524
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
37525
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
37526
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
37527
|
+
] }) })
|
|
37528
|
+
]
|
|
37529
|
+
}
|
|
37530
|
+
) });
|
|
37531
|
+
};
|
|
37532
|
+
const GiftCardProductEdit$1 = () => {
|
|
37533
|
+
const { id } = useParams();
|
|
37534
|
+
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
37535
|
+
if (isError) {
|
|
37536
|
+
throw error;
|
|
37537
|
+
}
|
|
37538
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
37539
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
37540
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift cards denominations" }) }),
|
|
37541
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
|
|
37542
|
+
] }),
|
|
37543
|
+
!isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditDenominationsForm, { product })
|
|
37544
|
+
] });
|
|
37545
|
+
};
|
|
37546
|
+
const EditProductSchema = objectType({
|
|
37400
37547
|
status: enumType(["draft", "published", "proposed", "rejected"]),
|
|
37401
37548
|
title: stringType().min(1),
|
|
37402
37549
|
subtitle: stringType().optional(),
|
|
@@ -37415,7 +37562,7 @@ const GiftCardProductEditForm = ({
|
|
|
37415
37562
|
handle: product.handle || "",
|
|
37416
37563
|
description: product.description || ""
|
|
37417
37564
|
},
|
|
37418
|
-
resolver: t(EditProductSchema
|
|
37565
|
+
resolver: t(EditProductSchema)
|
|
37419
37566
|
});
|
|
37420
37567
|
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
37421
37568
|
const handleSubmit = form.handleSubmit(async (data) => {
|
|
@@ -37556,7 +37703,7 @@ const GiftCardProductEditForm = ({
|
|
|
37556
37703
|
}
|
|
37557
37704
|
) });
|
|
37558
37705
|
};
|
|
37559
|
-
const GiftCardProductEdit
|
|
37706
|
+
const GiftCardProductEdit = () => {
|
|
37560
37707
|
const { id } = useParams();
|
|
37561
37708
|
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
37562
37709
|
if (isError) {
|
|
@@ -37570,153 +37717,6 @@ const GiftCardProductEdit$1 = () => {
|
|
|
37570
37717
|
!isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditForm, { product })
|
|
37571
37718
|
] });
|
|
37572
37719
|
};
|
|
37573
|
-
const EditProductSchema = objectType({
|
|
37574
|
-
denominations: arrayType(
|
|
37575
|
-
objectType({
|
|
37576
|
-
id: stringType().optional(),
|
|
37577
|
-
value: stringType().min(1),
|
|
37578
|
-
prices: recordType(stringType(), optionalFloat).optional()
|
|
37579
|
-
})
|
|
37580
|
-
).min(1)
|
|
37581
|
-
});
|
|
37582
|
-
const GiftCardProductEditDenominationsForm = ({
|
|
37583
|
-
product
|
|
37584
|
-
}) => {
|
|
37585
|
-
var _a;
|
|
37586
|
-
const { handleSuccess } = useRouteModal();
|
|
37587
|
-
const form = useForm({
|
|
37588
|
-
defaultValues: {
|
|
37589
|
-
denominations: (_a = product.variants) == null ? void 0 : _a.map((variant) => ({
|
|
37590
|
-
id: variant.id,
|
|
37591
|
-
value: variant.title
|
|
37592
|
-
}))
|
|
37593
|
-
},
|
|
37594
|
-
resolver: t(EditProductSchema)
|
|
37595
|
-
});
|
|
37596
|
-
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
37597
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
37598
|
-
const optionValues = data.denominations.map(
|
|
37599
|
-
(denomination) => denomination.value
|
|
37600
|
-
);
|
|
37601
|
-
const options = [
|
|
37602
|
-
{
|
|
37603
|
-
title: "denomination",
|
|
37604
|
-
values: optionValues
|
|
37605
|
-
}
|
|
37606
|
-
];
|
|
37607
|
-
await mutateAsync(
|
|
37608
|
-
{
|
|
37609
|
-
options,
|
|
37610
|
-
variants: data.denominations.map((denomination) => ({
|
|
37611
|
-
id: denomination.id,
|
|
37612
|
-
title: denomination.value,
|
|
37613
|
-
manage_inventory: false,
|
|
37614
|
-
options: {
|
|
37615
|
-
denomination: denomination.value
|
|
37616
|
-
}
|
|
37617
|
-
}))
|
|
37618
|
-
},
|
|
37619
|
-
{
|
|
37620
|
-
onSuccess: () => {
|
|
37621
|
-
toast.success(`Denominations updated successfully`);
|
|
37622
|
-
handleSuccess();
|
|
37623
|
-
},
|
|
37624
|
-
onError: (e2) => {
|
|
37625
|
-
toast.error(e2.message);
|
|
37626
|
-
}
|
|
37627
|
-
}
|
|
37628
|
-
);
|
|
37629
|
-
});
|
|
37630
|
-
const {
|
|
37631
|
-
fields: denominationsFields,
|
|
37632
|
-
append: addDenomination,
|
|
37633
|
-
remove: removeDenomination
|
|
37634
|
-
} = useFieldArray({
|
|
37635
|
-
name: "denominations",
|
|
37636
|
-
control: form.control
|
|
37637
|
-
});
|
|
37638
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
37639
|
-
KeyboundForm,
|
|
37640
|
-
{
|
|
37641
|
-
onSubmit: handleSubmit,
|
|
37642
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
37643
|
-
children: [
|
|
37644
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-1 flex-col gap-y-8 overflow-y-auto", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
37645
|
-
denominationsFields.map((denominationField, index) => {
|
|
37646
|
-
return /* @__PURE__ */ jsxs(
|
|
37647
|
-
"div",
|
|
37648
|
-
{
|
|
37649
|
-
className: "flex items-center justify-between shadow-elevation-card-rest bg-ui-bg-component transition-fg rounded-md px-4 py-2",
|
|
37650
|
-
children: [
|
|
37651
|
-
/* @__PURE__ */ jsx(
|
|
37652
|
-
Form$2.Field,
|
|
37653
|
-
{
|
|
37654
|
-
control: form.control,
|
|
37655
|
-
name: `denominations.${index}.value`,
|
|
37656
|
-
render: ({ field }) => {
|
|
37657
|
-
return /* @__PURE__ */ jsxs(Form$2.Item, { className: "w-full", children: [
|
|
37658
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field, placeholder: "100" }) }),
|
|
37659
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
37660
|
-
] });
|
|
37661
|
-
}
|
|
37662
|
-
},
|
|
37663
|
-
denominationField.id
|
|
37664
|
-
),
|
|
37665
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsx(
|
|
37666
|
-
Button,
|
|
37667
|
-
{
|
|
37668
|
-
size: "small",
|
|
37669
|
-
variant: "secondary",
|
|
37670
|
-
type: "button",
|
|
37671
|
-
className: "rounded-full p-0 ml-4",
|
|
37672
|
-
onClick: () => {
|
|
37673
|
-
removeDenomination(index);
|
|
37674
|
-
},
|
|
37675
|
-
children: /* @__PURE__ */ jsx(XCircleSolid, { className: "rounded-full" })
|
|
37676
|
-
}
|
|
37677
|
-
) })
|
|
37678
|
-
]
|
|
37679
|
-
},
|
|
37680
|
-
denominationField.id
|
|
37681
|
-
);
|
|
37682
|
-
}),
|
|
37683
|
-
/* @__PURE__ */ jsx(
|
|
37684
|
-
Button,
|
|
37685
|
-
{
|
|
37686
|
-
size: "small",
|
|
37687
|
-
variant: "secondary",
|
|
37688
|
-
type: "button",
|
|
37689
|
-
className: "w-full",
|
|
37690
|
-
onClick: () => {
|
|
37691
|
-
addDenomination({ value: "", prices: {} });
|
|
37692
|
-
},
|
|
37693
|
-
children: "Add denomination"
|
|
37694
|
-
}
|
|
37695
|
-
),
|
|
37696
|
-
form.formState.errors.denominations && /* @__PURE__ */ jsx(Alert, { variant: "error", children: "Please add at least one denomination." })
|
|
37697
|
-
] }) }) }) }),
|
|
37698
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
37699
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
37700
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
37701
|
-
] }) })
|
|
37702
|
-
]
|
|
37703
|
-
}
|
|
37704
|
-
) });
|
|
37705
|
-
};
|
|
37706
|
-
const GiftCardProductEdit = () => {
|
|
37707
|
-
const { id } = useParams();
|
|
37708
|
-
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
37709
|
-
if (isError) {
|
|
37710
|
-
throw error;
|
|
37711
|
-
}
|
|
37712
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
37713
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
37714
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit gift cards denominations" }) }),
|
|
37715
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
|
|
37716
|
-
] }),
|
|
37717
|
-
!isLoading && product && /* @__PURE__ */ jsx(GiftCardProductEditDenominationsForm, { product })
|
|
37718
|
-
] });
|
|
37719
|
-
};
|
|
37720
37720
|
const EditProductMediaForm = ({ product }) => {
|
|
37721
37721
|
const [selection, setSelection] = useState({});
|
|
37722
37722
|
const { handleSuccess } = useRouteModal();
|
|
@@ -38645,22 +38645,22 @@ const routeModule = {
|
|
|
38645
38645
|
]
|
|
38646
38646
|
},
|
|
38647
38647
|
{
|
|
38648
|
-
Component:
|
|
38649
|
-
path: "/
|
|
38648
|
+
Component: GiftCardProductsPage,
|
|
38649
|
+
path: "/gift-cards/gift-card-products",
|
|
38650
38650
|
children: [
|
|
38651
38651
|
{
|
|
38652
|
-
Component:
|
|
38653
|
-
path: "/
|
|
38652
|
+
Component: GiftCardProductCreate,
|
|
38653
|
+
path: "/gift-cards/gift-card-products/create"
|
|
38654
38654
|
}
|
|
38655
38655
|
]
|
|
38656
38656
|
},
|
|
38657
38657
|
{
|
|
38658
|
-
Component:
|
|
38659
|
-
path: "/
|
|
38658
|
+
Component: StoreCreditAccountPage,
|
|
38659
|
+
path: "/store-credit-accounts/:id",
|
|
38660
38660
|
children: [
|
|
38661
38661
|
{
|
|
38662
|
-
Component:
|
|
38663
|
-
path: "/
|
|
38662
|
+
Component: Note,
|
|
38663
|
+
path: "/store-credit-accounts/:id/credit"
|
|
38664
38664
|
}
|
|
38665
38665
|
]
|
|
38666
38666
|
},
|
|
@@ -38670,11 +38670,11 @@ const routeModule = {
|
|
|
38670
38670
|
children: [
|
|
38671
38671
|
{
|
|
38672
38672
|
Component: GiftCardProductEdit$1,
|
|
38673
|
-
path: "/gift-cards/gift-card-products/:id/
|
|
38673
|
+
path: "/gift-cards/gift-card-products/:id/denominations"
|
|
38674
38674
|
},
|
|
38675
38675
|
{
|
|
38676
38676
|
Component: GiftCardProductEdit,
|
|
38677
|
-
path: "/gift-cards/gift-card-products/:id/
|
|
38677
|
+
path: "/gift-cards/gift-card-products/:id/edit"
|
|
38678
38678
|
}
|
|
38679
38679
|
]
|
|
38680
38680
|
},
|
|
@@ -38694,18 +38694,18 @@ const routeModule = {
|
|
|
38694
38694
|
};
|
|
38695
38695
|
const menuItemModule = {
|
|
38696
38696
|
menuItems: [
|
|
38697
|
-
{
|
|
38698
|
-
label: config$1.label,
|
|
38699
|
-
icon: config$1.icon,
|
|
38700
|
-
path: "/store-credit-accounts",
|
|
38701
|
-
nested: void 0
|
|
38702
|
-
},
|
|
38703
38697
|
{
|
|
38704
38698
|
label: config$2.label,
|
|
38705
38699
|
icon: config$2.icon,
|
|
38706
38700
|
path: "/gift-cards",
|
|
38707
38701
|
nested: void 0
|
|
38708
38702
|
},
|
|
38703
|
+
{
|
|
38704
|
+
label: config$1.label,
|
|
38705
|
+
icon: config$1.icon,
|
|
38706
|
+
path: "/store-credit-accounts",
|
|
38707
|
+
nested: void 0
|
|
38708
|
+
},
|
|
38709
38709
|
{
|
|
38710
38710
|
label: config.label,
|
|
38711
38711
|
icon: void 0,
|