@medusajs/loyalty-plugin 0.0.7-snapshot.0 → 0.0.7-snapshot.1
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/medusa-config.d.ts +2 -0
- package/.medusa/server/src/admin/index.js +224 -224
- package/.medusa/server/src/admin/index.mjs +224 -224
- package/.medusa/server/src/api/admin/gift-cards/[id]/orders/route.d.ts +2 -0
- package/.medusa/server/src/api/admin/gift-cards/[id]/route.d.ts +4 -0
- package/.medusa/server/src/api/admin/gift-cards/middlewares.d.ts +2 -0
- package/.medusa/server/src/api/admin/gift-cards/query-config.d.ts +14 -0
- package/.medusa/server/src/api/admin/gift-cards/route.d.ts +4 -0
- package/.medusa/server/src/api/admin/gift-cards/validators.d.ts +381 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/credit/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/[id]/transactions/route.d.ts +3 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/middlewares.d.ts +2 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/query-config.d.ts +18 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/route.d.ts +4 -0
- package/.medusa/server/src/api/admin/store-credit-accounts/validators.d.ts +412 -0
- package/.medusa/server/src/api/middlewares.d.ts +2 -0
- package/.medusa/server/src/api/store/carts/[id]/gift-cards/route.d.ts +5 -0
- package/.medusa/server/src/api/store/carts/[id]/store-credits/route.d.ts +4 -0
- package/.medusa/server/src/api/store/carts/middlewares.d.ts +2 -0
- package/.medusa/server/src/api/store/carts/query-config.d.ts +4 -0
- package/.medusa/server/src/api/store/carts/validators.d.ts +25 -0
- package/.medusa/server/src/api/store/gift-cards/[idOrCode]/route.d.ts +3 -0
- package/.medusa/server/src/api/store/gift-cards/middlewares.d.ts +2 -0
- package/.medusa/server/src/api/store/gift-cards/query-config.d.ts +9 -0
- package/.medusa/server/src/api/store/gift-cards/validators.d.ts +11 -0
- package/.medusa/server/src/api/store/store-credit-accounts/[id]/route.d.ts +3 -0
- package/.medusa/server/src/api/store/store-credit-accounts/claim/route.d.ts +3 -0
- package/.medusa/server/src/api/store/store-credit-accounts/middlewares.d.ts +2 -0
- package/.medusa/server/src/api/store/store-credit-accounts/query-config.d.ts +9 -0
- package/.medusa/server/src/api/store/store-credit-accounts/route.d.ts +3 -0
- package/.medusa/server/src/api/store/store-credit-accounts/validators.d.ts +120 -0
- package/.medusa/server/src/links/cart-gift-cards-link.d.ts +2 -0
- package/.medusa/server/src/links/customer-store-credit-account-link.d.ts +1 -0
- package/.medusa/server/src/links/gift-card-store-credit.d.ts +2 -0
- package/.medusa/server/src/links/order-gift-cards-link.d.ts +2 -0
- package/.medusa/server/src/links/order-line-item-gift-card-link.d.ts +1 -0
- package/.medusa/server/src/modules/loyalty/index.d.ts +21 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250123130553.d.ts +5 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250127174331.d.ts +5 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141026.d.ts +5 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206141429.d.ts +5 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250206144714.d.ts +5 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250326095923.d.ts +5 -0
- package/.medusa/server/src/modules/loyalty/migrations/Migration20250617080328.d.ts +5 -0
- package/.medusa/server/src/modules/loyalty/models/gift-card.d.ts +18 -0
- package/.medusa/server/src/modules/loyalty/service.d.ts +21 -0
- package/.medusa/server/src/modules/store-credit/index.d.ts +5 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250129115518.d.ts +5 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250130213237.d.ts +5 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250130220640.d.ts +5 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250131205753.d.ts +5 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250520081315.d.ts +5 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250626081315.d.ts +5 -0
- package/.medusa/server/src/modules/store-credit/migrations/Migration20250722080351.d.ts +5 -0
- package/.medusa/server/src/modules/store-credit/models/account-transaction.d.ts +28 -0
- package/.medusa/server/src/modules/store-credit/models/store-credit-account.d.ts +27 -0
- package/.medusa/server/src/modules/store-credit/service.d.ts +29 -0
- package/.medusa/server/src/subscribers/create-gift-card.d.ts +5 -0
- package/.medusa/server/src/types/cart/index.d.ts +6 -0
- package/.medusa/server/src/types/http/gift-card.d.ts +42 -0
- package/.medusa/server/src/types/http/index.d.ts +3 -0
- package/.medusa/server/src/types/http/store-credit-account.d.ts +60 -0
- package/.medusa/server/src/types/http/transaction.d.ts +19 -0
- package/.medusa/server/src/types/index.d.ts +4 -0
- package/.medusa/server/src/types/loyalty/index.d.ts +3 -0
- package/.medusa/server/src/types/loyalty/module.d.ts +42 -0
- package/.medusa/server/src/types/loyalty/service.d.ts +24 -0
- package/.medusa/server/src/types/loyalty/workflows.d.ts +3 -0
- package/.medusa/server/src/types/modules.d.ts +6 -0
- package/.medusa/server/src/types/store-credit/index.d.ts +2 -0
- package/.medusa/server/src/types/store-credit/module.d.ts +82 -0
- package/.medusa/server/src/types/store-credit/service.d.ts +34 -0
- package/.medusa/server/src/utils/code-generator.d.ts +1 -0
- package/.medusa/server/src/workflows/carts/index.d.ts +5 -0
- package/.medusa/server/src/workflows/carts/steps/validate-gift-card-balances.d.ts +5 -0
- package/.medusa/server/src/workflows/carts/workflows/add-gift-card-to-cart.d.ts +15 -0
- package/.medusa/server/src/workflows/carts/workflows/add-store-credits-to-cart.d.ts +15 -0
- package/.medusa/server/src/workflows/carts/workflows/confirm-cart-credit-lines.d.ts +9 -0
- package/.medusa/server/src/workflows/carts/workflows/refresh-cart-gift-cards.d.ts +3 -0
- package/.medusa/server/src/workflows/carts/workflows/remove-gift-cart-from-cart.d.ts +13 -0
- package/.medusa/server/src/workflows/common/steps/validate-presence-of.d.ts +5 -0
- package/.medusa/server/src/workflows/gift-cards/index.d.ts +9 -0
- package/.medusa/server/src/workflows/gift-cards/steps/create-gift-cards.d.ts +2 -0
- package/.medusa/server/src/workflows/gift-cards/steps/delete-gift-cards.d.ts +3 -0
- package/.medusa/server/src/workflows/gift-cards/steps/retrieve-gift-card-balance.d.ts +6 -0
- package/.medusa/server/src/workflows/gift-cards/steps/update-gift-cards.d.ts +2 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/claim-gift-card.d.ts +23 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/create-gift-cards.d.ts +2 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/delete-gift-card.d.ts +3 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/redeem-gift-card.d.ts +13 -0
- package/.medusa/server/src/workflows/gift-cards/workflows/update-gift-cards.d.ts +2 -0
- package/.medusa/server/src/workflows/hooks/after-order-created.d.ts +1 -0
- package/.medusa/server/src/workflows/hooks/after-order-credit-lines-created.d.ts +1 -0
- package/.medusa/server/src/workflows/hooks/before-payment-collection-refresh.d.ts +1 -0
- package/.medusa/server/src/workflows/hooks/complete-cart-before-payment-authorization.d.ts +1 -0
- package/.medusa/server/src/workflows/index.d.ts +3 -0
- package/.medusa/server/src/workflows/orders/index.d.ts +2 -0
- package/.medusa/server/src/workflows/orders/workflows/link-gift-cards-to-order.d.ts +4 -0
- package/.medusa/server/src/workflows/orders/workflows/refund-credit-lines.d.ts +17 -0
- package/.medusa/server/src/workflows/store-credit/index.d.ts +8 -0
- package/.medusa/server/src/workflows/store-credit/steps/create-store-credit-accounts.d.ts +2 -0
- package/.medusa/server/src/workflows/store-credit/steps/credit-account.d.ts +2 -0
- package/.medusa/server/src/workflows/store-credit/steps/debit-account.d.ts +2 -0
- package/.medusa/server/src/workflows/store-credit/workflows/claim-store-credit-account.d.ts +11 -0
- package/.medusa/server/src/workflows/store-credit/workflows/create-store-credit-accounts.d.ts +9 -0
- package/.medusa/server/src/workflows/store-credit/workflows/credit-accounts.d.ts +2 -0
- package/.medusa/server/src/workflows/store-credit/workflows/credit-store-credit-account.d.ts +2 -0
- package/.medusa/server/src/workflows/store-credit/workflows/debit-accounts.d.ts +2 -0
- package/package.json +5 -2
|
@@ -23690,6 +23690,73 @@ const KeyboundForm = React__namespace.default.forwardRef(({ onSubmit, onKeyDown,
|
|
|
23690
23690
|
);
|
|
23691
23691
|
});
|
|
23692
23692
|
KeyboundForm.displayName = "KeyboundForm";
|
|
23693
|
+
const Note$1 = () => {
|
|
23694
|
+
const { id } = reactRouterDom.useParams();
|
|
23695
|
+
const {
|
|
23696
|
+
gift_card: giftCard,
|
|
23697
|
+
isPending,
|
|
23698
|
+
isError,
|
|
23699
|
+
error
|
|
23700
|
+
} = useGiftCard(id, {});
|
|
23701
|
+
if (isError) {
|
|
23702
|
+
throw error;
|
|
23703
|
+
}
|
|
23704
|
+
const isReady = !isPending && !!giftCard;
|
|
23705
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
23706
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
23707
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit note" }) }),
|
|
23708
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
|
|
23709
|
+
] }),
|
|
23710
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(GiftCardNoteForm, { giftCard })
|
|
23711
|
+
] });
|
|
23712
|
+
};
|
|
23713
|
+
const GiftCardNoteForm = ({ giftCard }) => {
|
|
23714
|
+
const form = useForm({
|
|
23715
|
+
defaultValues: {
|
|
23716
|
+
note: giftCard.note ?? ""
|
|
23717
|
+
},
|
|
23718
|
+
resolver: t(schema$2)
|
|
23719
|
+
});
|
|
23720
|
+
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
23721
|
+
const { handleSuccess } = useRouteModal();
|
|
23722
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
23723
|
+
await mutateAsync(
|
|
23724
|
+
{ note: data.note },
|
|
23725
|
+
{
|
|
23726
|
+
onSuccess: () => handleSuccess(),
|
|
23727
|
+
onError: (error) => ui.toast.error(error.message)
|
|
23728
|
+
}
|
|
23729
|
+
);
|
|
23730
|
+
});
|
|
23731
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
23732
|
+
KeyboundForm,
|
|
23733
|
+
{
|
|
23734
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
23735
|
+
onSubmit,
|
|
23736
|
+
children: [
|
|
23737
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
23738
|
+
Form$2.Field,
|
|
23739
|
+
{
|
|
23740
|
+
control: form.control,
|
|
23741
|
+
name: "note",
|
|
23742
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
23743
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
|
|
23744
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
|
|
23745
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
23746
|
+
] })
|
|
23747
|
+
}
|
|
23748
|
+
) }),
|
|
23749
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
23750
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
23751
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
23752
|
+
] }) })
|
|
23753
|
+
]
|
|
23754
|
+
}
|
|
23755
|
+
) });
|
|
23756
|
+
};
|
|
23757
|
+
const schema$2 = objectType({
|
|
23758
|
+
note: stringType().optional()
|
|
23759
|
+
});
|
|
23693
23760
|
const GiftCardExpiration = () => {
|
|
23694
23761
|
const { id } = reactRouterDom.useParams();
|
|
23695
23762
|
const {
|
|
@@ -23715,7 +23782,7 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
23715
23782
|
defaultValues: {
|
|
23716
23783
|
expires_at: giftCard.expires_at ? new Date(giftCard.expires_at) : null
|
|
23717
23784
|
},
|
|
23718
|
-
resolver: t(schema$
|
|
23785
|
+
resolver: t(schema$1)
|
|
23719
23786
|
});
|
|
23720
23787
|
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
23721
23788
|
const { handleSuccess } = useRouteModal();
|
|
@@ -23804,75 +23871,8 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
23804
23871
|
}
|
|
23805
23872
|
) });
|
|
23806
23873
|
};
|
|
23807
|
-
const schema$2 = objectType({
|
|
23808
|
-
expires_at: dateType().nullish()
|
|
23809
|
-
});
|
|
23810
|
-
const Note$1 = () => {
|
|
23811
|
-
const { id } = reactRouterDom.useParams();
|
|
23812
|
-
const {
|
|
23813
|
-
gift_card: giftCard,
|
|
23814
|
-
isPending,
|
|
23815
|
-
isError,
|
|
23816
|
-
error
|
|
23817
|
-
} = useGiftCard(id, {});
|
|
23818
|
-
if (isError) {
|
|
23819
|
-
throw error;
|
|
23820
|
-
}
|
|
23821
|
-
const isReady = !isPending && !!giftCard;
|
|
23822
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
23823
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
23824
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit note" }) }),
|
|
23825
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
|
|
23826
|
-
] }),
|
|
23827
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(GiftCardNoteForm, { giftCard })
|
|
23828
|
-
] });
|
|
23829
|
-
};
|
|
23830
|
-
const GiftCardNoteForm = ({ giftCard }) => {
|
|
23831
|
-
const form = useForm({
|
|
23832
|
-
defaultValues: {
|
|
23833
|
-
note: giftCard.note ?? ""
|
|
23834
|
-
},
|
|
23835
|
-
resolver: t(schema$1)
|
|
23836
|
-
});
|
|
23837
|
-
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
23838
|
-
const { handleSuccess } = useRouteModal();
|
|
23839
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
23840
|
-
await mutateAsync(
|
|
23841
|
-
{ note: data.note },
|
|
23842
|
-
{
|
|
23843
|
-
onSuccess: () => handleSuccess(),
|
|
23844
|
-
onError: (error) => ui.toast.error(error.message)
|
|
23845
|
-
}
|
|
23846
|
-
);
|
|
23847
|
-
});
|
|
23848
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
23849
|
-
KeyboundForm,
|
|
23850
|
-
{
|
|
23851
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
23852
|
-
onSubmit,
|
|
23853
|
-
children: [
|
|
23854
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
23855
|
-
Form$2.Field,
|
|
23856
|
-
{
|
|
23857
|
-
control: form.control,
|
|
23858
|
-
name: "note",
|
|
23859
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
23860
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
|
|
23861
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
|
|
23862
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
23863
|
-
] })
|
|
23864
|
-
}
|
|
23865
|
-
) }),
|
|
23866
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
23867
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
23868
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
23869
|
-
] }) })
|
|
23870
|
-
]
|
|
23871
|
-
}
|
|
23872
|
-
) });
|
|
23873
|
-
};
|
|
23874
23874
|
const schema$1 = objectType({
|
|
23875
|
-
|
|
23875
|
+
expires_at: dateType().nullish()
|
|
23876
23876
|
});
|
|
23877
23877
|
const columnHelper$7 = createColumnHelper();
|
|
23878
23878
|
const useGiftCardProductsTableColumns = () => {
|
|
@@ -37420,153 +37420,6 @@ const ProductDetail = () => {
|
|
|
37420
37420
|
] });
|
|
37421
37421
|
};
|
|
37422
37422
|
const EditProductSchema$1 = objectType({
|
|
37423
|
-
denominations: arrayType(
|
|
37424
|
-
objectType({
|
|
37425
|
-
id: stringType().optional(),
|
|
37426
|
-
value: stringType().min(1),
|
|
37427
|
-
prices: recordType(stringType(), optionalFloat).optional()
|
|
37428
|
-
})
|
|
37429
|
-
).min(1)
|
|
37430
|
-
});
|
|
37431
|
-
const GiftCardProductEditDenominationsForm = ({
|
|
37432
|
-
product
|
|
37433
|
-
}) => {
|
|
37434
|
-
var _a;
|
|
37435
|
-
const { handleSuccess } = useRouteModal();
|
|
37436
|
-
const form = useForm({
|
|
37437
|
-
defaultValues: {
|
|
37438
|
-
denominations: (_a = product.variants) == null ? void 0 : _a.map((variant) => ({
|
|
37439
|
-
id: variant.id,
|
|
37440
|
-
value: variant.title
|
|
37441
|
-
}))
|
|
37442
|
-
},
|
|
37443
|
-
resolver: t(EditProductSchema$1)
|
|
37444
|
-
});
|
|
37445
|
-
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
37446
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
37447
|
-
const optionValues = data.denominations.map(
|
|
37448
|
-
(denomination) => denomination.value
|
|
37449
|
-
);
|
|
37450
|
-
const options = [
|
|
37451
|
-
{
|
|
37452
|
-
title: "denomination",
|
|
37453
|
-
values: optionValues
|
|
37454
|
-
}
|
|
37455
|
-
];
|
|
37456
|
-
await mutateAsync(
|
|
37457
|
-
{
|
|
37458
|
-
options,
|
|
37459
|
-
variants: data.denominations.map((denomination) => ({
|
|
37460
|
-
id: denomination.id,
|
|
37461
|
-
title: denomination.value,
|
|
37462
|
-
manage_inventory: false,
|
|
37463
|
-
options: {
|
|
37464
|
-
denomination: denomination.value
|
|
37465
|
-
}
|
|
37466
|
-
}))
|
|
37467
|
-
},
|
|
37468
|
-
{
|
|
37469
|
-
onSuccess: () => {
|
|
37470
|
-
ui.toast.success(`Denominations updated successfully`);
|
|
37471
|
-
handleSuccess();
|
|
37472
|
-
},
|
|
37473
|
-
onError: (e2) => {
|
|
37474
|
-
ui.toast.error(e2.message);
|
|
37475
|
-
}
|
|
37476
|
-
}
|
|
37477
|
-
);
|
|
37478
|
-
});
|
|
37479
|
-
const {
|
|
37480
|
-
fields: denominationsFields,
|
|
37481
|
-
append: addDenomination,
|
|
37482
|
-
remove: removeDenomination
|
|
37483
|
-
} = useFieldArray({
|
|
37484
|
-
name: "denominations",
|
|
37485
|
-
control: form.control
|
|
37486
|
-
});
|
|
37487
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
37488
|
-
KeyboundForm,
|
|
37489
|
-
{
|
|
37490
|
-
onSubmit: handleSubmit,
|
|
37491
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
37492
|
-
children: [
|
|
37493
|
-
/* @__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: [
|
|
37494
|
-
denominationsFields.map((denominationField, index) => {
|
|
37495
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
37496
|
-
"div",
|
|
37497
|
-
{
|
|
37498
|
-
className: "flex items-center justify-between shadow-elevation-card-rest bg-ui-bg-component transition-fg rounded-md px-4 py-2",
|
|
37499
|
-
children: [
|
|
37500
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
37501
|
-
Form$2.Field,
|
|
37502
|
-
{
|
|
37503
|
-
control: form.control,
|
|
37504
|
-
name: `denominations.${index}.value`,
|
|
37505
|
-
render: ({ field }) => {
|
|
37506
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
37507
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field, placeholder: "100" }) }),
|
|
37508
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
37509
|
-
] });
|
|
37510
|
-
}
|
|
37511
|
-
},
|
|
37512
|
-
denominationField.id
|
|
37513
|
-
),
|
|
37514
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
37515
|
-
ui.Button,
|
|
37516
|
-
{
|
|
37517
|
-
size: "small",
|
|
37518
|
-
variant: "secondary",
|
|
37519
|
-
type: "button",
|
|
37520
|
-
className: "rounded-full p-0 ml-4",
|
|
37521
|
-
onClick: () => {
|
|
37522
|
-
removeDenomination(index);
|
|
37523
|
-
},
|
|
37524
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XCircleSolid, { className: "rounded-full" })
|
|
37525
|
-
}
|
|
37526
|
-
) })
|
|
37527
|
-
]
|
|
37528
|
-
},
|
|
37529
|
-
denominationField.id
|
|
37530
|
-
);
|
|
37531
|
-
}),
|
|
37532
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
37533
|
-
ui.Button,
|
|
37534
|
-
{
|
|
37535
|
-
size: "small",
|
|
37536
|
-
variant: "secondary",
|
|
37537
|
-
type: "button",
|
|
37538
|
-
className: "w-full",
|
|
37539
|
-
onClick: () => {
|
|
37540
|
-
addDenomination({ value: "", prices: {} });
|
|
37541
|
-
},
|
|
37542
|
-
children: "Add denomination"
|
|
37543
|
-
}
|
|
37544
|
-
),
|
|
37545
|
-
form.formState.errors.denominations && /* @__PURE__ */ jsxRuntime.jsx(ui.Alert, { variant: "error", children: "Please add at least one denomination." })
|
|
37546
|
-
] }) }) }) }),
|
|
37547
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
37548
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
37549
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
37550
|
-
] }) })
|
|
37551
|
-
]
|
|
37552
|
-
}
|
|
37553
|
-
) });
|
|
37554
|
-
};
|
|
37555
|
-
const GiftCardProductEdit$1 = () => {
|
|
37556
|
-
const { id } = reactRouterDom.useParams();
|
|
37557
|
-
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
37558
|
-
if (isError) {
|
|
37559
|
-
throw error;
|
|
37560
|
-
}
|
|
37561
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
37562
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
37563
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift cards denominations" }) }),
|
|
37564
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
|
|
37565
|
-
] }),
|
|
37566
|
-
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditDenominationsForm, { product })
|
|
37567
|
-
] });
|
|
37568
|
-
};
|
|
37569
|
-
const EditProductSchema = objectType({
|
|
37570
37423
|
status: enumType(["draft", "published", "proposed", "rejected"]),
|
|
37571
37424
|
title: stringType().min(1),
|
|
37572
37425
|
subtitle: stringType().optional(),
|
|
@@ -37585,7 +37438,7 @@ const GiftCardProductEditForm = ({
|
|
|
37585
37438
|
handle: product.handle || "",
|
|
37586
37439
|
description: product.description || ""
|
|
37587
37440
|
},
|
|
37588
|
-
resolver: t(EditProductSchema)
|
|
37441
|
+
resolver: t(EditProductSchema$1)
|
|
37589
37442
|
});
|
|
37590
37443
|
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
37591
37444
|
const handleSubmit = form.handleSubmit(async (data) => {
|
|
@@ -37726,7 +37579,7 @@ const GiftCardProductEditForm = ({
|
|
|
37726
37579
|
}
|
|
37727
37580
|
) });
|
|
37728
37581
|
};
|
|
37729
|
-
const GiftCardProductEdit = () => {
|
|
37582
|
+
const GiftCardProductEdit$1 = () => {
|
|
37730
37583
|
const { id } = reactRouterDom.useParams();
|
|
37731
37584
|
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
37732
37585
|
if (isError) {
|
|
@@ -37740,6 +37593,153 @@ const GiftCardProductEdit = () => {
|
|
|
37740
37593
|
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditForm, { product })
|
|
37741
37594
|
] });
|
|
37742
37595
|
};
|
|
37596
|
+
const EditProductSchema = objectType({
|
|
37597
|
+
denominations: arrayType(
|
|
37598
|
+
objectType({
|
|
37599
|
+
id: stringType().optional(),
|
|
37600
|
+
value: stringType().min(1),
|
|
37601
|
+
prices: recordType(stringType(), optionalFloat).optional()
|
|
37602
|
+
})
|
|
37603
|
+
).min(1)
|
|
37604
|
+
});
|
|
37605
|
+
const GiftCardProductEditDenominationsForm = ({
|
|
37606
|
+
product
|
|
37607
|
+
}) => {
|
|
37608
|
+
var _a;
|
|
37609
|
+
const { handleSuccess } = useRouteModal();
|
|
37610
|
+
const form = useForm({
|
|
37611
|
+
defaultValues: {
|
|
37612
|
+
denominations: (_a = product.variants) == null ? void 0 : _a.map((variant) => ({
|
|
37613
|
+
id: variant.id,
|
|
37614
|
+
value: variant.title
|
|
37615
|
+
}))
|
|
37616
|
+
},
|
|
37617
|
+
resolver: t(EditProductSchema)
|
|
37618
|
+
});
|
|
37619
|
+
const { mutateAsync, isPending } = useUpdateProduct(product.id);
|
|
37620
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
37621
|
+
const optionValues = data.denominations.map(
|
|
37622
|
+
(denomination) => denomination.value
|
|
37623
|
+
);
|
|
37624
|
+
const options = [
|
|
37625
|
+
{
|
|
37626
|
+
title: "denomination",
|
|
37627
|
+
values: optionValues
|
|
37628
|
+
}
|
|
37629
|
+
];
|
|
37630
|
+
await mutateAsync(
|
|
37631
|
+
{
|
|
37632
|
+
options,
|
|
37633
|
+
variants: data.denominations.map((denomination) => ({
|
|
37634
|
+
id: denomination.id,
|
|
37635
|
+
title: denomination.value,
|
|
37636
|
+
manage_inventory: false,
|
|
37637
|
+
options: {
|
|
37638
|
+
denomination: denomination.value
|
|
37639
|
+
}
|
|
37640
|
+
}))
|
|
37641
|
+
},
|
|
37642
|
+
{
|
|
37643
|
+
onSuccess: () => {
|
|
37644
|
+
ui.toast.success(`Denominations updated successfully`);
|
|
37645
|
+
handleSuccess();
|
|
37646
|
+
},
|
|
37647
|
+
onError: (e2) => {
|
|
37648
|
+
ui.toast.error(e2.message);
|
|
37649
|
+
}
|
|
37650
|
+
}
|
|
37651
|
+
);
|
|
37652
|
+
});
|
|
37653
|
+
const {
|
|
37654
|
+
fields: denominationsFields,
|
|
37655
|
+
append: addDenomination,
|
|
37656
|
+
remove: removeDenomination
|
|
37657
|
+
} = useFieldArray({
|
|
37658
|
+
name: "denominations",
|
|
37659
|
+
control: form.control
|
|
37660
|
+
});
|
|
37661
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
37662
|
+
KeyboundForm,
|
|
37663
|
+
{
|
|
37664
|
+
onSubmit: handleSubmit,
|
|
37665
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
37666
|
+
children: [
|
|
37667
|
+
/* @__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: [
|
|
37668
|
+
denominationsFields.map((denominationField, index) => {
|
|
37669
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
37670
|
+
"div",
|
|
37671
|
+
{
|
|
37672
|
+
className: "flex items-center justify-between shadow-elevation-card-rest bg-ui-bg-component transition-fg rounded-md px-4 py-2",
|
|
37673
|
+
children: [
|
|
37674
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
37675
|
+
Form$2.Field,
|
|
37676
|
+
{
|
|
37677
|
+
control: form.control,
|
|
37678
|
+
name: `denominations.${index}.value`,
|
|
37679
|
+
render: ({ field }) => {
|
|
37680
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "w-full", children: [
|
|
37681
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field, placeholder: "100" }) }),
|
|
37682
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
37683
|
+
] });
|
|
37684
|
+
}
|
|
37685
|
+
},
|
|
37686
|
+
denominationField.id
|
|
37687
|
+
),
|
|
37688
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center rounded-xl", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
37689
|
+
ui.Button,
|
|
37690
|
+
{
|
|
37691
|
+
size: "small",
|
|
37692
|
+
variant: "secondary",
|
|
37693
|
+
type: "button",
|
|
37694
|
+
className: "rounded-full p-0 ml-4",
|
|
37695
|
+
onClick: () => {
|
|
37696
|
+
removeDenomination(index);
|
|
37697
|
+
},
|
|
37698
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.XCircleSolid, { className: "rounded-full" })
|
|
37699
|
+
}
|
|
37700
|
+
) })
|
|
37701
|
+
]
|
|
37702
|
+
},
|
|
37703
|
+
denominationField.id
|
|
37704
|
+
);
|
|
37705
|
+
}),
|
|
37706
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
37707
|
+
ui.Button,
|
|
37708
|
+
{
|
|
37709
|
+
size: "small",
|
|
37710
|
+
variant: "secondary",
|
|
37711
|
+
type: "button",
|
|
37712
|
+
className: "w-full",
|
|
37713
|
+
onClick: () => {
|
|
37714
|
+
addDenomination({ value: "", prices: {} });
|
|
37715
|
+
},
|
|
37716
|
+
children: "Add denomination"
|
|
37717
|
+
}
|
|
37718
|
+
),
|
|
37719
|
+
form.formState.errors.denominations && /* @__PURE__ */ jsxRuntime.jsx(ui.Alert, { variant: "error", children: "Please add at least one denomination." })
|
|
37720
|
+
] }) }) }) }),
|
|
37721
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
37722
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
37723
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
37724
|
+
] }) })
|
|
37725
|
+
]
|
|
37726
|
+
}
|
|
37727
|
+
) });
|
|
37728
|
+
};
|
|
37729
|
+
const GiftCardProductEdit = () => {
|
|
37730
|
+
const { id } = reactRouterDom.useParams();
|
|
37731
|
+
const { product, isLoading, isError, error } = useProduct(id, {});
|
|
37732
|
+
if (isError) {
|
|
37733
|
+
throw error;
|
|
37734
|
+
}
|
|
37735
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
37736
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
37737
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit gift cards denominations" }) }),
|
|
37738
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { className: "sr-only", children: "Edit the gift card denominations" })
|
|
37739
|
+
] }),
|
|
37740
|
+
!isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(GiftCardProductEditDenominationsForm, { product })
|
|
37741
|
+
] });
|
|
37742
|
+
};
|
|
37743
37743
|
const EditProductMediaForm = ({ product }) => {
|
|
37744
37744
|
const [selection, setSelection] = React.useState({});
|
|
37745
37745
|
const { handleSuccess } = useRouteModal();
|
|
@@ -38657,13 +38657,13 @@ const routeModule = {
|
|
|
38657
38657
|
Component: GiftCardDetailsPage,
|
|
38658
38658
|
path: "/gift-cards/:id",
|
|
38659
38659
|
children: [
|
|
38660
|
-
{
|
|
38661
|
-
Component: GiftCardExpiration,
|
|
38662
|
-
path: "/gift-cards/:id/expiration"
|
|
38663
|
-
},
|
|
38664
38660
|
{
|
|
38665
38661
|
Component: Note$1,
|
|
38666
38662
|
path: "/gift-cards/:id/note"
|
|
38663
|
+
},
|
|
38664
|
+
{
|
|
38665
|
+
Component: GiftCardExpiration,
|
|
38666
|
+
path: "/gift-cards/:id/expiration"
|
|
38667
38667
|
}
|
|
38668
38668
|
]
|
|
38669
38669
|
},
|
|
@@ -38693,11 +38693,11 @@ const routeModule = {
|
|
|
38693
38693
|
children: [
|
|
38694
38694
|
{
|
|
38695
38695
|
Component: GiftCardProductEdit$1,
|
|
38696
|
-
path: "/gift-cards/gift-card-products/:id/
|
|
38696
|
+
path: "/gift-cards/gift-card-products/:id/edit"
|
|
38697
38697
|
},
|
|
38698
38698
|
{
|
|
38699
38699
|
Component: GiftCardProductEdit,
|
|
38700
|
-
path: "/gift-cards/gift-card-products/:id/
|
|
38700
|
+
path: "/gift-cards/gift-card-products/:id/denominations"
|
|
38701
38701
|
}
|
|
38702
38702
|
]
|
|
38703
38703
|
},
|