@medusajs/loyalty-plugin 2.14.2 → 2.14.3-preview-20260504041544
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 +191 -191
- package/.medusa/server/src/admin/index.mjs +191 -191
- package/package.json +15 -15
|
@@ -25934,73 +25934,6 @@ const KeyboundForm = React__namespace.default.forwardRef(({ onSubmit, onKeyDown,
|
|
|
25934
25934
|
);
|
|
25935
25935
|
});
|
|
25936
25936
|
KeyboundForm.displayName = "KeyboundForm";
|
|
25937
|
-
const Note$1 = () => {
|
|
25938
|
-
const { id } = reactRouterDom.useParams();
|
|
25939
|
-
const {
|
|
25940
|
-
gift_card: giftCard,
|
|
25941
|
-
isPending,
|
|
25942
|
-
isError,
|
|
25943
|
-
error
|
|
25944
|
-
} = useGiftCard(id, {});
|
|
25945
|
-
if (isError) {
|
|
25946
|
-
throw error;
|
|
25947
|
-
}
|
|
25948
|
-
const isReady = !isPending && !!giftCard;
|
|
25949
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
25950
|
-
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
25951
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit note" }) }),
|
|
25952
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
|
|
25953
|
-
] }),
|
|
25954
|
-
isReady && /* @__PURE__ */ jsxRuntime.jsx(GiftCardNoteForm, { giftCard })
|
|
25955
|
-
] });
|
|
25956
|
-
};
|
|
25957
|
-
const GiftCardNoteForm = ({ giftCard }) => {
|
|
25958
|
-
const form = useForm({
|
|
25959
|
-
defaultValues: {
|
|
25960
|
-
note: giftCard.note ?? ""
|
|
25961
|
-
},
|
|
25962
|
-
resolver: t(schema$2)
|
|
25963
|
-
});
|
|
25964
|
-
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
25965
|
-
const { handleSuccess } = useRouteModal();
|
|
25966
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
25967
|
-
await mutateAsync(
|
|
25968
|
-
{ note: data.note },
|
|
25969
|
-
{
|
|
25970
|
-
onSuccess: () => handleSuccess(),
|
|
25971
|
-
onError: (error) => ui.toast.error(error.message)
|
|
25972
|
-
}
|
|
25973
|
-
);
|
|
25974
|
-
});
|
|
25975
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
25976
|
-
KeyboundForm,
|
|
25977
|
-
{
|
|
25978
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
25979
|
-
onSubmit,
|
|
25980
|
-
children: [
|
|
25981
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
25982
|
-
Form$2.Field,
|
|
25983
|
-
{
|
|
25984
|
-
control: form.control,
|
|
25985
|
-
name: "note",
|
|
25986
|
-
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
25987
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
|
|
25988
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
|
|
25989
|
-
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
25990
|
-
] })
|
|
25991
|
-
}
|
|
25992
|
-
) }),
|
|
25993
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
25994
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
25995
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
25996
|
-
] }) })
|
|
25997
|
-
]
|
|
25998
|
-
}
|
|
25999
|
-
) });
|
|
26000
|
-
};
|
|
26001
|
-
const schema$2 = zod.z.object({
|
|
26002
|
-
note: zod.z.string().optional()
|
|
26003
|
-
});
|
|
26004
25937
|
const GiftCardExpiration = () => {
|
|
26005
25938
|
const { id } = reactRouterDom.useParams();
|
|
26006
25939
|
const { gift_card: giftCard, isPending, isError, error } = useGiftCard(id);
|
|
@@ -26021,7 +25954,7 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
26021
25954
|
defaultValues: {
|
|
26022
25955
|
expires_at: giftCard.expires_at ? new Date(giftCard.expires_at) : null
|
|
26023
25956
|
},
|
|
26024
|
-
resolver: t(schema$
|
|
25957
|
+
resolver: t(schema$2)
|
|
26025
25958
|
});
|
|
26026
25959
|
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
26027
25960
|
const { handleSuccess } = useRouteModal();
|
|
@@ -26116,9 +26049,76 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
26116
26049
|
}
|
|
26117
26050
|
) });
|
|
26118
26051
|
};
|
|
26119
|
-
const schema$
|
|
26052
|
+
const schema$2 = zod.z.object({
|
|
26120
26053
|
expires_at: zod.z.date().nullish()
|
|
26121
26054
|
});
|
|
26055
|
+
const Note$1 = () => {
|
|
26056
|
+
const { id } = reactRouterDom.useParams();
|
|
26057
|
+
const {
|
|
26058
|
+
gift_card: giftCard,
|
|
26059
|
+
isPending,
|
|
26060
|
+
isError,
|
|
26061
|
+
error
|
|
26062
|
+
} = useGiftCard(id, {});
|
|
26063
|
+
if (isError) {
|
|
26064
|
+
throw error;
|
|
26065
|
+
}
|
|
26066
|
+
const isReady = !isPending && !!giftCard;
|
|
26067
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
|
|
26068
|
+
/* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
|
|
26069
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit note" }) }),
|
|
26070
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
|
|
26071
|
+
] }),
|
|
26072
|
+
isReady && /* @__PURE__ */ jsxRuntime.jsx(GiftCardNoteForm, { giftCard })
|
|
26073
|
+
] });
|
|
26074
|
+
};
|
|
26075
|
+
const GiftCardNoteForm = ({ giftCard }) => {
|
|
26076
|
+
const form = useForm({
|
|
26077
|
+
defaultValues: {
|
|
26078
|
+
note: giftCard.note ?? ""
|
|
26079
|
+
},
|
|
26080
|
+
resolver: t(schema$1)
|
|
26081
|
+
});
|
|
26082
|
+
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
26083
|
+
const { handleSuccess } = useRouteModal();
|
|
26084
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
26085
|
+
await mutateAsync(
|
|
26086
|
+
{ note: data.note },
|
|
26087
|
+
{
|
|
26088
|
+
onSuccess: () => handleSuccess(),
|
|
26089
|
+
onError: (error) => ui.toast.error(error.message)
|
|
26090
|
+
}
|
|
26091
|
+
);
|
|
26092
|
+
});
|
|
26093
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
26094
|
+
KeyboundForm,
|
|
26095
|
+
{
|
|
26096
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
26097
|
+
onSubmit,
|
|
26098
|
+
children: [
|
|
26099
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
26100
|
+
Form$2.Field,
|
|
26101
|
+
{
|
|
26102
|
+
control: form.control,
|
|
26103
|
+
name: "note",
|
|
26104
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
|
|
26105
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Note" }),
|
|
26106
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Textarea, { ...field }) }),
|
|
26107
|
+
/* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
|
|
26108
|
+
] })
|
|
26109
|
+
}
|
|
26110
|
+
) }),
|
|
26111
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
26112
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
26113
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
26114
|
+
] }) })
|
|
26115
|
+
]
|
|
26116
|
+
}
|
|
26117
|
+
) });
|
|
26118
|
+
};
|
|
26119
|
+
const schema$1 = zod.z.object({
|
|
26120
|
+
note: zod.z.string().optional()
|
|
26121
|
+
});
|
|
26122
26122
|
const columnHelper$7 = createColumnHelper();
|
|
26123
26123
|
const useGiftCardProductsTableColumns = () => {
|
|
26124
26124
|
return React.useMemo(
|
|
@@ -41172,6 +41172,112 @@ const ProductMedia = () => {
|
|
|
41172
41172
|
ready && /* @__PURE__ */ jsxRuntime.jsx(ProductMediaView, { product })
|
|
41173
41173
|
] });
|
|
41174
41174
|
};
|
|
41175
|
+
const EditSalesChannelsSchema = zod__namespace.object({
|
|
41176
|
+
sales_channels: zod__namespace.array(zod__namespace.string()).optional()
|
|
41177
|
+
});
|
|
41178
|
+
const PAGE_SIZE = 50;
|
|
41179
|
+
const PREFIX = "sc";
|
|
41180
|
+
const EditSalesChannelsForm = ({
|
|
41181
|
+
product
|
|
41182
|
+
}) => {
|
|
41183
|
+
var _a2, _b;
|
|
41184
|
+
const { handleSuccess } = useRouteModal();
|
|
41185
|
+
const form = useForm({
|
|
41186
|
+
defaultValues: {
|
|
41187
|
+
sales_channels: ((_a2 = product.sales_channels) == null ? void 0 : _a2.map((sc) => sc.id)) ?? []
|
|
41188
|
+
},
|
|
41189
|
+
resolver: t(EditSalesChannelsSchema)
|
|
41190
|
+
});
|
|
41191
|
+
const { setValue: setValue2 } = form;
|
|
41192
|
+
const initialState2 = ((_b = product.sales_channels) == null ? void 0 : _b.reduce((acc, curr) => {
|
|
41193
|
+
acc[curr.id] = true;
|
|
41194
|
+
return acc;
|
|
41195
|
+
}, {})) ?? {};
|
|
41196
|
+
const [rowSelection, setRowSelection] = React.useState(initialState2);
|
|
41197
|
+
React.useEffect(() => {
|
|
41198
|
+
const ids2 = Object.keys(rowSelection);
|
|
41199
|
+
setValue2("sales_channels", ids2, {
|
|
41200
|
+
shouldDirty: true,
|
|
41201
|
+
shouldTouch: true
|
|
41202
|
+
});
|
|
41203
|
+
}, [rowSelection, setValue2]);
|
|
41204
|
+
const searchParams = useSalesChannelTableQuery({
|
|
41205
|
+
pageSize: PAGE_SIZE,
|
|
41206
|
+
prefix: PREFIX
|
|
41207
|
+
});
|
|
41208
|
+
const { sales_channels, count: count2, isLoading, isError, error } = useSalesChannels(
|
|
41209
|
+
{
|
|
41210
|
+
...searchParams
|
|
41211
|
+
},
|
|
41212
|
+
{
|
|
41213
|
+
placeholderData: reactQuery.keepPreviousData
|
|
41214
|
+
}
|
|
41215
|
+
);
|
|
41216
|
+
const filters = useSalesChannelTableFilters();
|
|
41217
|
+
const emptyState = useSalesChannelTableEmptyState();
|
|
41218
|
+
const columns = useColumns();
|
|
41219
|
+
const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
|
|
41220
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
41221
|
+
const arr = data.sales_channels ?? [];
|
|
41222
|
+
const sales_channels2 = arr.map((id) => {
|
|
41223
|
+
return {
|
|
41224
|
+
id
|
|
41225
|
+
};
|
|
41226
|
+
});
|
|
41227
|
+
await mutateAsync(
|
|
41228
|
+
{
|
|
41229
|
+
sales_channels: sales_channels2
|
|
41230
|
+
},
|
|
41231
|
+
{
|
|
41232
|
+
onSuccess: () => {
|
|
41233
|
+
handleSuccess();
|
|
41234
|
+
}
|
|
41235
|
+
}
|
|
41236
|
+
);
|
|
41237
|
+
});
|
|
41238
|
+
if (isError) {
|
|
41239
|
+
throw error;
|
|
41240
|
+
}
|
|
41241
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
41242
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
41243
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
41244
|
+
DataTable,
|
|
41245
|
+
{
|
|
41246
|
+
data: sales_channels,
|
|
41247
|
+
columns,
|
|
41248
|
+
getRowId: (row) => row.id,
|
|
41249
|
+
rowCount: count2,
|
|
41250
|
+
isLoading,
|
|
41251
|
+
filters,
|
|
41252
|
+
rowSelection: {
|
|
41253
|
+
state: rowSelection,
|
|
41254
|
+
onRowSelectionChange: setRowSelection
|
|
41255
|
+
},
|
|
41256
|
+
autoFocusSearch: true,
|
|
41257
|
+
layout: "fill",
|
|
41258
|
+
emptyState,
|
|
41259
|
+
prefix: PREFIX
|
|
41260
|
+
}
|
|
41261
|
+
) }),
|
|
41262
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
41263
|
+
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
41264
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", isLoading: isMutating, onClick: handleSubmit, children: "Save" })
|
|
41265
|
+
] }) })
|
|
41266
|
+
] }) });
|
|
41267
|
+
};
|
|
41268
|
+
const columnHelper$1 = ui.createDataTableColumnHelper();
|
|
41269
|
+
const useColumns = () => {
|
|
41270
|
+
const columns = useSalesChannelTableColumns();
|
|
41271
|
+
return React.useMemo(() => [columnHelper$1.select(), ...columns], [columns]);
|
|
41272
|
+
};
|
|
41273
|
+
const ProductSalesChannels = () => {
|
|
41274
|
+
const { id } = reactRouterDom.useParams();
|
|
41275
|
+
const { product, isLoading, isError, error } = useProduct(id);
|
|
41276
|
+
if (isError) {
|
|
41277
|
+
throw error;
|
|
41278
|
+
}
|
|
41279
|
+
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(EditSalesChannelsForm, { product }) });
|
|
41280
|
+
};
|
|
41175
41281
|
const VariantPricingForm = ({ form }) => {
|
|
41176
41282
|
const { store } = useStore$2();
|
|
41177
41283
|
const { regions } = useRegions({ limit: 9999 });
|
|
@@ -41196,7 +41302,7 @@ const VariantPricingForm = ({ form }) => {
|
|
|
41196
41302
|
}
|
|
41197
41303
|
);
|
|
41198
41304
|
};
|
|
41199
|
-
const columnHelper
|
|
41305
|
+
const columnHelper = createDataGridHelper();
|
|
41200
41306
|
const useVariantPriceGridColumns = ({
|
|
41201
41307
|
currencies: currencies2 = [],
|
|
41202
41308
|
regions = [],
|
|
@@ -41204,7 +41310,7 @@ const useVariantPriceGridColumns = ({
|
|
|
41204
41310
|
}) => {
|
|
41205
41311
|
return React.useMemo(() => {
|
|
41206
41312
|
return [
|
|
41207
|
-
columnHelper
|
|
41313
|
+
columnHelper.column({
|
|
41208
41314
|
id: "Title",
|
|
41209
41315
|
header: "Title",
|
|
41210
41316
|
cell: (context) => {
|
|
@@ -41330,112 +41436,6 @@ const ProductPrices = () => {
|
|
|
41330
41436
|
}
|
|
41331
41437
|
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(PricingEdit, { product, variantId: variant_id }) });
|
|
41332
41438
|
};
|
|
41333
|
-
const EditSalesChannelsSchema = zod__namespace.object({
|
|
41334
|
-
sales_channels: zod__namespace.array(zod__namespace.string()).optional()
|
|
41335
|
-
});
|
|
41336
|
-
const PAGE_SIZE = 50;
|
|
41337
|
-
const PREFIX = "sc";
|
|
41338
|
-
const EditSalesChannelsForm = ({
|
|
41339
|
-
product
|
|
41340
|
-
}) => {
|
|
41341
|
-
var _a2, _b;
|
|
41342
|
-
const { handleSuccess } = useRouteModal();
|
|
41343
|
-
const form = useForm({
|
|
41344
|
-
defaultValues: {
|
|
41345
|
-
sales_channels: ((_a2 = product.sales_channels) == null ? void 0 : _a2.map((sc) => sc.id)) ?? []
|
|
41346
|
-
},
|
|
41347
|
-
resolver: t(EditSalesChannelsSchema)
|
|
41348
|
-
});
|
|
41349
|
-
const { setValue: setValue2 } = form;
|
|
41350
|
-
const initialState2 = ((_b = product.sales_channels) == null ? void 0 : _b.reduce((acc, curr) => {
|
|
41351
|
-
acc[curr.id] = true;
|
|
41352
|
-
return acc;
|
|
41353
|
-
}, {})) ?? {};
|
|
41354
|
-
const [rowSelection, setRowSelection] = React.useState(initialState2);
|
|
41355
|
-
React.useEffect(() => {
|
|
41356
|
-
const ids2 = Object.keys(rowSelection);
|
|
41357
|
-
setValue2("sales_channels", ids2, {
|
|
41358
|
-
shouldDirty: true,
|
|
41359
|
-
shouldTouch: true
|
|
41360
|
-
});
|
|
41361
|
-
}, [rowSelection, setValue2]);
|
|
41362
|
-
const searchParams = useSalesChannelTableQuery({
|
|
41363
|
-
pageSize: PAGE_SIZE,
|
|
41364
|
-
prefix: PREFIX
|
|
41365
|
-
});
|
|
41366
|
-
const { sales_channels, count: count2, isLoading, isError, error } = useSalesChannels(
|
|
41367
|
-
{
|
|
41368
|
-
...searchParams
|
|
41369
|
-
},
|
|
41370
|
-
{
|
|
41371
|
-
placeholderData: reactQuery.keepPreviousData
|
|
41372
|
-
}
|
|
41373
|
-
);
|
|
41374
|
-
const filters = useSalesChannelTableFilters();
|
|
41375
|
-
const emptyState = useSalesChannelTableEmptyState();
|
|
41376
|
-
const columns = useColumns();
|
|
41377
|
-
const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
|
|
41378
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
41379
|
-
const arr = data.sales_channels ?? [];
|
|
41380
|
-
const sales_channels2 = arr.map((id) => {
|
|
41381
|
-
return {
|
|
41382
|
-
id
|
|
41383
|
-
};
|
|
41384
|
-
});
|
|
41385
|
-
await mutateAsync(
|
|
41386
|
-
{
|
|
41387
|
-
sales_channels: sales_channels2
|
|
41388
|
-
},
|
|
41389
|
-
{
|
|
41390
|
-
onSuccess: () => {
|
|
41391
|
-
handleSuccess();
|
|
41392
|
-
}
|
|
41393
|
-
}
|
|
41394
|
-
);
|
|
41395
|
-
});
|
|
41396
|
-
if (isError) {
|
|
41397
|
-
throw error;
|
|
41398
|
-
}
|
|
41399
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
41400
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Header, {}),
|
|
41401
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
41402
|
-
DataTable,
|
|
41403
|
-
{
|
|
41404
|
-
data: sales_channels,
|
|
41405
|
-
columns,
|
|
41406
|
-
getRowId: (row) => row.id,
|
|
41407
|
-
rowCount: count2,
|
|
41408
|
-
isLoading,
|
|
41409
|
-
filters,
|
|
41410
|
-
rowSelection: {
|
|
41411
|
-
state: rowSelection,
|
|
41412
|
-
onRowSelectionChange: setRowSelection
|
|
41413
|
-
},
|
|
41414
|
-
autoFocusSearch: true,
|
|
41415
|
-
layout: "fill",
|
|
41416
|
-
emptyState,
|
|
41417
|
-
prefix: PREFIX
|
|
41418
|
-
}
|
|
41419
|
-
) }),
|
|
41420
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
41421
|
-
/* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
41422
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", isLoading: isMutating, onClick: handleSubmit, children: "Save" })
|
|
41423
|
-
] }) })
|
|
41424
|
-
] }) });
|
|
41425
|
-
};
|
|
41426
|
-
const columnHelper = ui.createDataTableColumnHelper();
|
|
41427
|
-
const useColumns = () => {
|
|
41428
|
-
const columns = useSalesChannelTableColumns();
|
|
41429
|
-
return React.useMemo(() => [columnHelper.select(), ...columns], [columns]);
|
|
41430
|
-
};
|
|
41431
|
-
const ProductSalesChannels = () => {
|
|
41432
|
-
const { id } = reactRouterDom.useParams();
|
|
41433
|
-
const { product, isLoading, isError, error } = useProduct(id);
|
|
41434
|
-
if (isError) {
|
|
41435
|
-
throw error;
|
|
41436
|
-
}
|
|
41437
|
-
return /* @__PURE__ */ jsxRuntime.jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsxRuntime.jsx(EditSalesChannelsForm, { product }) });
|
|
41438
|
-
};
|
|
41439
41439
|
const widgetModule = { widgets: [
|
|
41440
41440
|
{
|
|
41441
41441
|
Component: CustomerStoreCreditWidget,
|
|
@@ -41476,13 +41476,13 @@ const routeModule = {
|
|
|
41476
41476
|
Component: GiftCardDetailsPage,
|
|
41477
41477
|
path: "/gift-cards/:id",
|
|
41478
41478
|
children: [
|
|
41479
|
-
{
|
|
41480
|
-
Component: Note$1,
|
|
41481
|
-
path: "/gift-cards/:id/note"
|
|
41482
|
-
},
|
|
41483
41479
|
{
|
|
41484
41480
|
Component: GiftCardExpiration,
|
|
41485
41481
|
path: "/gift-cards/:id/expiration"
|
|
41482
|
+
},
|
|
41483
|
+
{
|
|
41484
|
+
Component: Note$1,
|
|
41485
|
+
path: "/gift-cards/:id/note"
|
|
41486
41486
|
}
|
|
41487
41487
|
]
|
|
41488
41488
|
},
|
|
@@ -41524,30 +41524,30 @@ const routeModule = {
|
|
|
41524
41524
|
Component: ProductMedia,
|
|
41525
41525
|
path: "/gift-cards/gift-card-products/:id/media"
|
|
41526
41526
|
},
|
|
41527
|
-
{
|
|
41528
|
-
Component: ProductPrices,
|
|
41529
|
-
path: "/gift-cards/gift-card-products/:id/prices"
|
|
41530
|
-
},
|
|
41531
41527
|
{
|
|
41532
41528
|
Component: ProductSalesChannels,
|
|
41533
41529
|
path: "/gift-cards/gift-card-products/:id/sales-channels"
|
|
41530
|
+
},
|
|
41531
|
+
{
|
|
41532
|
+
Component: ProductPrices,
|
|
41533
|
+
path: "/gift-cards/gift-card-products/:id/prices"
|
|
41534
41534
|
}
|
|
41535
41535
|
]
|
|
41536
41536
|
};
|
|
41537
41537
|
const menuItemModule = {
|
|
41538
41538
|
menuItems: [
|
|
41539
41539
|
{
|
|
41540
|
-
label: config$
|
|
41541
|
-
icon: config$
|
|
41542
|
-
path: "/
|
|
41540
|
+
label: config$3.label,
|
|
41541
|
+
icon: config$3.icon,
|
|
41542
|
+
path: "/gift-cards",
|
|
41543
41543
|
nested: void 0,
|
|
41544
41544
|
rank: void 0,
|
|
41545
41545
|
translationNs: void 0
|
|
41546
41546
|
},
|
|
41547
41547
|
{
|
|
41548
|
-
label: config$
|
|
41549
|
-
icon: config$
|
|
41550
|
-
path: "/
|
|
41548
|
+
label: config$1.label,
|
|
41549
|
+
icon: config$1.icon,
|
|
41550
|
+
path: "/store-credit-accounts",
|
|
41551
41551
|
nested: void 0,
|
|
41552
41552
|
rank: void 0,
|
|
41553
41553
|
translationNs: void 0
|
|
@@ -25914,73 +25914,6 @@ const KeyboundForm = React__default.forwardRef(({ onSubmit, onKeyDown, ...rest }
|
|
|
25914
25914
|
);
|
|
25915
25915
|
});
|
|
25916
25916
|
KeyboundForm.displayName = "KeyboundForm";
|
|
25917
|
-
const Note$1 = () => {
|
|
25918
|
-
const { id } = useParams();
|
|
25919
|
-
const {
|
|
25920
|
-
gift_card: giftCard,
|
|
25921
|
-
isPending,
|
|
25922
|
-
isError,
|
|
25923
|
-
error
|
|
25924
|
-
} = useGiftCard(id, {});
|
|
25925
|
-
if (isError) {
|
|
25926
|
-
throw error;
|
|
25927
|
-
}
|
|
25928
|
-
const isReady = !isPending && !!giftCard;
|
|
25929
|
-
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
25930
|
-
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
25931
|
-
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit note" }) }),
|
|
25932
|
-
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
|
|
25933
|
-
] }),
|
|
25934
|
-
isReady && /* @__PURE__ */ jsx(GiftCardNoteForm, { giftCard })
|
|
25935
|
-
] });
|
|
25936
|
-
};
|
|
25937
|
-
const GiftCardNoteForm = ({ giftCard }) => {
|
|
25938
|
-
const form = useForm({
|
|
25939
|
-
defaultValues: {
|
|
25940
|
-
note: giftCard.note ?? ""
|
|
25941
|
-
},
|
|
25942
|
-
resolver: t(schema$2)
|
|
25943
|
-
});
|
|
25944
|
-
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
25945
|
-
const { handleSuccess } = useRouteModal();
|
|
25946
|
-
const onSubmit = form.handleSubmit(async (data) => {
|
|
25947
|
-
await mutateAsync(
|
|
25948
|
-
{ note: data.note },
|
|
25949
|
-
{
|
|
25950
|
-
onSuccess: () => handleSuccess(),
|
|
25951
|
-
onError: (error) => toast.error(error.message)
|
|
25952
|
-
}
|
|
25953
|
-
);
|
|
25954
|
-
});
|
|
25955
|
-
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
25956
|
-
KeyboundForm,
|
|
25957
|
-
{
|
|
25958
|
-
className: "flex flex-1 flex-col overflow-hidden",
|
|
25959
|
-
onSubmit,
|
|
25960
|
-
children: [
|
|
25961
|
-
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
25962
|
-
Form$2.Field,
|
|
25963
|
-
{
|
|
25964
|
-
control: form.control,
|
|
25965
|
-
name: "note",
|
|
25966
|
-
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
25967
|
-
/* @__PURE__ */ jsx(Form$2.Label, { children: "Note" }),
|
|
25968
|
-
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
|
|
25969
|
-
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
25970
|
-
] })
|
|
25971
|
-
}
|
|
25972
|
-
) }),
|
|
25973
|
-
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
25974
|
-
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
25975
|
-
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
25976
|
-
] }) })
|
|
25977
|
-
]
|
|
25978
|
-
}
|
|
25979
|
-
) });
|
|
25980
|
-
};
|
|
25981
|
-
const schema$2 = z.object({
|
|
25982
|
-
note: z.string().optional()
|
|
25983
|
-
});
|
|
25984
25917
|
const GiftCardExpiration = () => {
|
|
25985
25918
|
const { id } = useParams();
|
|
25986
25919
|
const { gift_card: giftCard, isPending, isError, error } = useGiftCard(id);
|
|
@@ -26001,7 +25934,7 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
26001
25934
|
defaultValues: {
|
|
26002
25935
|
expires_at: giftCard.expires_at ? new Date(giftCard.expires_at) : null
|
|
26003
25936
|
},
|
|
26004
|
-
resolver: t(schema$
|
|
25937
|
+
resolver: t(schema$2)
|
|
26005
25938
|
});
|
|
26006
25939
|
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
26007
25940
|
const { handleSuccess } = useRouteModal();
|
|
@@ -26096,9 +26029,76 @@ const GiftCardExpirationForm = ({ giftCard }) => {
|
|
|
26096
26029
|
}
|
|
26097
26030
|
) });
|
|
26098
26031
|
};
|
|
26099
|
-
const schema$
|
|
26032
|
+
const schema$2 = z.object({
|
|
26100
26033
|
expires_at: z.date().nullish()
|
|
26101
26034
|
});
|
|
26035
|
+
const Note$1 = () => {
|
|
26036
|
+
const { id } = useParams();
|
|
26037
|
+
const {
|
|
26038
|
+
gift_card: giftCard,
|
|
26039
|
+
isPending,
|
|
26040
|
+
isError,
|
|
26041
|
+
error
|
|
26042
|
+
} = useGiftCard(id, {});
|
|
26043
|
+
if (isError) {
|
|
26044
|
+
throw error;
|
|
26045
|
+
}
|
|
26046
|
+
const isReady = !isPending && !!giftCard;
|
|
26047
|
+
return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
|
|
26048
|
+
/* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
|
|
26049
|
+
/* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit note" }) }),
|
|
26050
|
+
/* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the note for the gift card" }) })
|
|
26051
|
+
] }),
|
|
26052
|
+
isReady && /* @__PURE__ */ jsx(GiftCardNoteForm, { giftCard })
|
|
26053
|
+
] });
|
|
26054
|
+
};
|
|
26055
|
+
const GiftCardNoteForm = ({ giftCard }) => {
|
|
26056
|
+
const form = useForm({
|
|
26057
|
+
defaultValues: {
|
|
26058
|
+
note: giftCard.note ?? ""
|
|
26059
|
+
},
|
|
26060
|
+
resolver: t(schema$1)
|
|
26061
|
+
});
|
|
26062
|
+
const { mutateAsync, isPending } = useUpdateGiftCard(giftCard.id);
|
|
26063
|
+
const { handleSuccess } = useRouteModal();
|
|
26064
|
+
const onSubmit = form.handleSubmit(async (data) => {
|
|
26065
|
+
await mutateAsync(
|
|
26066
|
+
{ note: data.note },
|
|
26067
|
+
{
|
|
26068
|
+
onSuccess: () => handleSuccess(),
|
|
26069
|
+
onError: (error) => toast.error(error.message)
|
|
26070
|
+
}
|
|
26071
|
+
);
|
|
26072
|
+
});
|
|
26073
|
+
return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
|
|
26074
|
+
KeyboundForm,
|
|
26075
|
+
{
|
|
26076
|
+
className: "flex flex-1 flex-col overflow-hidden",
|
|
26077
|
+
onSubmit,
|
|
26078
|
+
children: [
|
|
26079
|
+
/* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(
|
|
26080
|
+
Form$2.Field,
|
|
26081
|
+
{
|
|
26082
|
+
control: form.control,
|
|
26083
|
+
name: "note",
|
|
26084
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
|
|
26085
|
+
/* @__PURE__ */ jsx(Form$2.Label, { children: "Note" }),
|
|
26086
|
+
/* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Textarea, { ...field }) }),
|
|
26087
|
+
/* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
|
|
26088
|
+
] })
|
|
26089
|
+
}
|
|
26090
|
+
) }),
|
|
26091
|
+
/* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
26092
|
+
/* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
26093
|
+
/* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
|
|
26094
|
+
] }) })
|
|
26095
|
+
]
|
|
26096
|
+
}
|
|
26097
|
+
) });
|
|
26098
|
+
};
|
|
26099
|
+
const schema$1 = z.object({
|
|
26100
|
+
note: z.string().optional()
|
|
26101
|
+
});
|
|
26102
26102
|
const columnHelper$7 = createColumnHelper();
|
|
26103
26103
|
const useGiftCardProductsTableColumns = () => {
|
|
26104
26104
|
return useMemo(
|
|
@@ -41152,6 +41152,112 @@ const ProductMedia = () => {
|
|
|
41152
41152
|
ready && /* @__PURE__ */ jsx(ProductMediaView, { product })
|
|
41153
41153
|
] });
|
|
41154
41154
|
};
|
|
41155
|
+
const EditSalesChannelsSchema = zod.object({
|
|
41156
|
+
sales_channels: zod.array(zod.string()).optional()
|
|
41157
|
+
});
|
|
41158
|
+
const PAGE_SIZE = 50;
|
|
41159
|
+
const PREFIX = "sc";
|
|
41160
|
+
const EditSalesChannelsForm = ({
|
|
41161
|
+
product
|
|
41162
|
+
}) => {
|
|
41163
|
+
var _a2, _b;
|
|
41164
|
+
const { handleSuccess } = useRouteModal();
|
|
41165
|
+
const form = useForm({
|
|
41166
|
+
defaultValues: {
|
|
41167
|
+
sales_channels: ((_a2 = product.sales_channels) == null ? void 0 : _a2.map((sc) => sc.id)) ?? []
|
|
41168
|
+
},
|
|
41169
|
+
resolver: t(EditSalesChannelsSchema)
|
|
41170
|
+
});
|
|
41171
|
+
const { setValue: setValue2 } = form;
|
|
41172
|
+
const initialState2 = ((_b = product.sales_channels) == null ? void 0 : _b.reduce((acc, curr) => {
|
|
41173
|
+
acc[curr.id] = true;
|
|
41174
|
+
return acc;
|
|
41175
|
+
}, {})) ?? {};
|
|
41176
|
+
const [rowSelection, setRowSelection] = useState(initialState2);
|
|
41177
|
+
useEffect(() => {
|
|
41178
|
+
const ids2 = Object.keys(rowSelection);
|
|
41179
|
+
setValue2("sales_channels", ids2, {
|
|
41180
|
+
shouldDirty: true,
|
|
41181
|
+
shouldTouch: true
|
|
41182
|
+
});
|
|
41183
|
+
}, [rowSelection, setValue2]);
|
|
41184
|
+
const searchParams = useSalesChannelTableQuery({
|
|
41185
|
+
pageSize: PAGE_SIZE,
|
|
41186
|
+
prefix: PREFIX
|
|
41187
|
+
});
|
|
41188
|
+
const { sales_channels, count: count2, isLoading, isError, error } = useSalesChannels(
|
|
41189
|
+
{
|
|
41190
|
+
...searchParams
|
|
41191
|
+
},
|
|
41192
|
+
{
|
|
41193
|
+
placeholderData: keepPreviousData
|
|
41194
|
+
}
|
|
41195
|
+
);
|
|
41196
|
+
const filters = useSalesChannelTableFilters();
|
|
41197
|
+
const emptyState = useSalesChannelTableEmptyState();
|
|
41198
|
+
const columns = useColumns();
|
|
41199
|
+
const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
|
|
41200
|
+
const handleSubmit = form.handleSubmit(async (data) => {
|
|
41201
|
+
const arr = data.sales_channels ?? [];
|
|
41202
|
+
const sales_channels2 = arr.map((id) => {
|
|
41203
|
+
return {
|
|
41204
|
+
id
|
|
41205
|
+
};
|
|
41206
|
+
});
|
|
41207
|
+
await mutateAsync(
|
|
41208
|
+
{
|
|
41209
|
+
sales_channels: sales_channels2
|
|
41210
|
+
},
|
|
41211
|
+
{
|
|
41212
|
+
onSuccess: () => {
|
|
41213
|
+
handleSuccess();
|
|
41214
|
+
}
|
|
41215
|
+
}
|
|
41216
|
+
);
|
|
41217
|
+
});
|
|
41218
|
+
if (isError) {
|
|
41219
|
+
throw error;
|
|
41220
|
+
}
|
|
41221
|
+
return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
41222
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
41223
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
41224
|
+
DataTable,
|
|
41225
|
+
{
|
|
41226
|
+
data: sales_channels,
|
|
41227
|
+
columns,
|
|
41228
|
+
getRowId: (row) => row.id,
|
|
41229
|
+
rowCount: count2,
|
|
41230
|
+
isLoading,
|
|
41231
|
+
filters,
|
|
41232
|
+
rowSelection: {
|
|
41233
|
+
state: rowSelection,
|
|
41234
|
+
onRowSelectionChange: setRowSelection
|
|
41235
|
+
},
|
|
41236
|
+
autoFocusSearch: true,
|
|
41237
|
+
layout: "fill",
|
|
41238
|
+
emptyState,
|
|
41239
|
+
prefix: PREFIX
|
|
41240
|
+
}
|
|
41241
|
+
) }),
|
|
41242
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
41243
|
+
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
41244
|
+
/* @__PURE__ */ jsx(Button, { size: "small", isLoading: isMutating, onClick: handleSubmit, children: "Save" })
|
|
41245
|
+
] }) })
|
|
41246
|
+
] }) });
|
|
41247
|
+
};
|
|
41248
|
+
const columnHelper$1 = createDataTableColumnHelper();
|
|
41249
|
+
const useColumns = () => {
|
|
41250
|
+
const columns = useSalesChannelTableColumns();
|
|
41251
|
+
return useMemo(() => [columnHelper$1.select(), ...columns], [columns]);
|
|
41252
|
+
};
|
|
41253
|
+
const ProductSalesChannels = () => {
|
|
41254
|
+
const { id } = useParams();
|
|
41255
|
+
const { product, isLoading, isError, error } = useProduct(id);
|
|
41256
|
+
if (isError) {
|
|
41257
|
+
throw error;
|
|
41258
|
+
}
|
|
41259
|
+
return /* @__PURE__ */ jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsx(EditSalesChannelsForm, { product }) });
|
|
41260
|
+
};
|
|
41155
41261
|
const VariantPricingForm = ({ form }) => {
|
|
41156
41262
|
const { store } = useStore$2();
|
|
41157
41263
|
const { regions } = useRegions({ limit: 9999 });
|
|
@@ -41176,7 +41282,7 @@ const VariantPricingForm = ({ form }) => {
|
|
|
41176
41282
|
}
|
|
41177
41283
|
);
|
|
41178
41284
|
};
|
|
41179
|
-
const columnHelper
|
|
41285
|
+
const columnHelper = createDataGridHelper();
|
|
41180
41286
|
const useVariantPriceGridColumns = ({
|
|
41181
41287
|
currencies: currencies2 = [],
|
|
41182
41288
|
regions = [],
|
|
@@ -41184,7 +41290,7 @@ const useVariantPriceGridColumns = ({
|
|
|
41184
41290
|
}) => {
|
|
41185
41291
|
return useMemo(() => {
|
|
41186
41292
|
return [
|
|
41187
|
-
columnHelper
|
|
41293
|
+
columnHelper.column({
|
|
41188
41294
|
id: "Title",
|
|
41189
41295
|
header: "Title",
|
|
41190
41296
|
cell: (context) => {
|
|
@@ -41310,112 +41416,6 @@ const ProductPrices = () => {
|
|
|
41310
41416
|
}
|
|
41311
41417
|
return /* @__PURE__ */ jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsx(PricingEdit, { product, variantId: variant_id }) });
|
|
41312
41418
|
};
|
|
41313
|
-
const EditSalesChannelsSchema = zod.object({
|
|
41314
|
-
sales_channels: zod.array(zod.string()).optional()
|
|
41315
|
-
});
|
|
41316
|
-
const PAGE_SIZE = 50;
|
|
41317
|
-
const PREFIX = "sc";
|
|
41318
|
-
const EditSalesChannelsForm = ({
|
|
41319
|
-
product
|
|
41320
|
-
}) => {
|
|
41321
|
-
var _a2, _b;
|
|
41322
|
-
const { handleSuccess } = useRouteModal();
|
|
41323
|
-
const form = useForm({
|
|
41324
|
-
defaultValues: {
|
|
41325
|
-
sales_channels: ((_a2 = product.sales_channels) == null ? void 0 : _a2.map((sc) => sc.id)) ?? []
|
|
41326
|
-
},
|
|
41327
|
-
resolver: t(EditSalesChannelsSchema)
|
|
41328
|
-
});
|
|
41329
|
-
const { setValue: setValue2 } = form;
|
|
41330
|
-
const initialState2 = ((_b = product.sales_channels) == null ? void 0 : _b.reduce((acc, curr) => {
|
|
41331
|
-
acc[curr.id] = true;
|
|
41332
|
-
return acc;
|
|
41333
|
-
}, {})) ?? {};
|
|
41334
|
-
const [rowSelection, setRowSelection] = useState(initialState2);
|
|
41335
|
-
useEffect(() => {
|
|
41336
|
-
const ids2 = Object.keys(rowSelection);
|
|
41337
|
-
setValue2("sales_channels", ids2, {
|
|
41338
|
-
shouldDirty: true,
|
|
41339
|
-
shouldTouch: true
|
|
41340
|
-
});
|
|
41341
|
-
}, [rowSelection, setValue2]);
|
|
41342
|
-
const searchParams = useSalesChannelTableQuery({
|
|
41343
|
-
pageSize: PAGE_SIZE,
|
|
41344
|
-
prefix: PREFIX
|
|
41345
|
-
});
|
|
41346
|
-
const { sales_channels, count: count2, isLoading, isError, error } = useSalesChannels(
|
|
41347
|
-
{
|
|
41348
|
-
...searchParams
|
|
41349
|
-
},
|
|
41350
|
-
{
|
|
41351
|
-
placeholderData: keepPreviousData
|
|
41352
|
-
}
|
|
41353
|
-
);
|
|
41354
|
-
const filters = useSalesChannelTableFilters();
|
|
41355
|
-
const emptyState = useSalesChannelTableEmptyState();
|
|
41356
|
-
const columns = useColumns();
|
|
41357
|
-
const { mutateAsync, isPending: isMutating } = useUpdateProduct(product.id);
|
|
41358
|
-
const handleSubmit = form.handleSubmit(async (data) => {
|
|
41359
|
-
const arr = data.sales_channels ?? [];
|
|
41360
|
-
const sales_channels2 = arr.map((id) => {
|
|
41361
|
-
return {
|
|
41362
|
-
id
|
|
41363
|
-
};
|
|
41364
|
-
});
|
|
41365
|
-
await mutateAsync(
|
|
41366
|
-
{
|
|
41367
|
-
sales_channels: sales_channels2
|
|
41368
|
-
},
|
|
41369
|
-
{
|
|
41370
|
-
onSuccess: () => {
|
|
41371
|
-
handleSuccess();
|
|
41372
|
-
}
|
|
41373
|
-
}
|
|
41374
|
-
);
|
|
41375
|
-
});
|
|
41376
|
-
if (isError) {
|
|
41377
|
-
throw error;
|
|
41378
|
-
}
|
|
41379
|
-
return /* @__PURE__ */ jsx(RouteFocusModal.Form, { form, children: /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
41380
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Header, {}),
|
|
41381
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Body, { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
41382
|
-
DataTable,
|
|
41383
|
-
{
|
|
41384
|
-
data: sales_channels,
|
|
41385
|
-
columns,
|
|
41386
|
-
getRowId: (row) => row.id,
|
|
41387
|
-
rowCount: count2,
|
|
41388
|
-
isLoading,
|
|
41389
|
-
filters,
|
|
41390
|
-
rowSelection: {
|
|
41391
|
-
state: rowSelection,
|
|
41392
|
-
onRowSelectionChange: setRowSelection
|
|
41393
|
-
},
|
|
41394
|
-
autoFocusSearch: true,
|
|
41395
|
-
layout: "fill",
|
|
41396
|
-
emptyState,
|
|
41397
|
-
prefix: PREFIX
|
|
41398
|
-
}
|
|
41399
|
-
) }),
|
|
41400
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
41401
|
-
/* @__PURE__ */ jsx(RouteFocusModal.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
|
|
41402
|
-
/* @__PURE__ */ jsx(Button, { size: "small", isLoading: isMutating, onClick: handleSubmit, children: "Save" })
|
|
41403
|
-
] }) })
|
|
41404
|
-
] }) });
|
|
41405
|
-
};
|
|
41406
|
-
const columnHelper = createDataTableColumnHelper();
|
|
41407
|
-
const useColumns = () => {
|
|
41408
|
-
const columns = useSalesChannelTableColumns();
|
|
41409
|
-
return useMemo(() => [columnHelper.select(), ...columns], [columns]);
|
|
41410
|
-
};
|
|
41411
|
-
const ProductSalesChannels = () => {
|
|
41412
|
-
const { id } = useParams();
|
|
41413
|
-
const { product, isLoading, isError, error } = useProduct(id);
|
|
41414
|
-
if (isError) {
|
|
41415
|
-
throw error;
|
|
41416
|
-
}
|
|
41417
|
-
return /* @__PURE__ */ jsx(RouteFocusModal, { children: !isLoading && product && /* @__PURE__ */ jsx(EditSalesChannelsForm, { product }) });
|
|
41418
|
-
};
|
|
41419
41419
|
const widgetModule = { widgets: [
|
|
41420
41420
|
{
|
|
41421
41421
|
Component: CustomerStoreCreditWidget,
|
|
@@ -41456,13 +41456,13 @@ const routeModule = {
|
|
|
41456
41456
|
Component: GiftCardDetailsPage,
|
|
41457
41457
|
path: "/gift-cards/:id",
|
|
41458
41458
|
children: [
|
|
41459
|
-
{
|
|
41460
|
-
Component: Note$1,
|
|
41461
|
-
path: "/gift-cards/:id/note"
|
|
41462
|
-
},
|
|
41463
41459
|
{
|
|
41464
41460
|
Component: GiftCardExpiration,
|
|
41465
41461
|
path: "/gift-cards/:id/expiration"
|
|
41462
|
+
},
|
|
41463
|
+
{
|
|
41464
|
+
Component: Note$1,
|
|
41465
|
+
path: "/gift-cards/:id/note"
|
|
41466
41466
|
}
|
|
41467
41467
|
]
|
|
41468
41468
|
},
|
|
@@ -41504,30 +41504,30 @@ const routeModule = {
|
|
|
41504
41504
|
Component: ProductMedia,
|
|
41505
41505
|
path: "/gift-cards/gift-card-products/:id/media"
|
|
41506
41506
|
},
|
|
41507
|
-
{
|
|
41508
|
-
Component: ProductPrices,
|
|
41509
|
-
path: "/gift-cards/gift-card-products/:id/prices"
|
|
41510
|
-
},
|
|
41511
41507
|
{
|
|
41512
41508
|
Component: ProductSalesChannels,
|
|
41513
41509
|
path: "/gift-cards/gift-card-products/:id/sales-channels"
|
|
41510
|
+
},
|
|
41511
|
+
{
|
|
41512
|
+
Component: ProductPrices,
|
|
41513
|
+
path: "/gift-cards/gift-card-products/:id/prices"
|
|
41514
41514
|
}
|
|
41515
41515
|
]
|
|
41516
41516
|
};
|
|
41517
41517
|
const menuItemModule = {
|
|
41518
41518
|
menuItems: [
|
|
41519
41519
|
{
|
|
41520
|
-
label: config$
|
|
41521
|
-
icon: config$
|
|
41522
|
-
path: "/
|
|
41520
|
+
label: config$3.label,
|
|
41521
|
+
icon: config$3.icon,
|
|
41522
|
+
path: "/gift-cards",
|
|
41523
41523
|
nested: void 0,
|
|
41524
41524
|
rank: void 0,
|
|
41525
41525
|
translationNs: void 0
|
|
41526
41526
|
},
|
|
41527
41527
|
{
|
|
41528
|
-
label: config$
|
|
41529
|
-
icon: config$
|
|
41530
|
-
path: "/
|
|
41528
|
+
label: config$1.label,
|
|
41529
|
+
icon: config$1.icon,
|
|
41530
|
+
path: "/store-credit-accounts",
|
|
41531
41531
|
nested: void 0,
|
|
41532
41532
|
rank: void 0,
|
|
41533
41533
|
translationNs: void 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/loyalty-plugin",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.3-preview-20260504041544",
|
|
4
4
|
"description": "Medusa Plugin: Loyalty - Gift Cards",
|
|
5
5
|
"author": "Medusa (https://medusajs.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,14 +49,14 @@
|
|
|
49
49
|
"prepare": "cross-env NODE_ENV=production yarn run build"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@medusajs/admin-sdk": "2.14.
|
|
53
|
-
"@medusajs/cli": "2.14.
|
|
54
|
-
"@medusajs/framework": "2.14.
|
|
55
|
-
"@medusajs/icons": "2.14.
|
|
56
|
-
"@medusajs/test-utils": "2.14.
|
|
57
|
-
"@medusajs/types": "2.14.
|
|
58
|
-
"@medusajs/ui": "4.1.
|
|
59
|
-
"@medusajs/ui-preset": "2.14.
|
|
52
|
+
"@medusajs/admin-sdk": "2.14.3-preview-20260504041544",
|
|
53
|
+
"@medusajs/cli": "2.14.3-preview-20260504041544",
|
|
54
|
+
"@medusajs/framework": "2.14.3-preview-20260504041544",
|
|
55
|
+
"@medusajs/icons": "2.14.3-preview-20260504041544",
|
|
56
|
+
"@medusajs/test-utils": "2.14.3-preview-20260504041544",
|
|
57
|
+
"@medusajs/types": "2.14.3-preview-20260504041544",
|
|
58
|
+
"@medusajs/ui": "4.1.10-preview-20260504041544",
|
|
59
|
+
"@medusajs/ui-preset": "2.14.3-preview-20260504041544",
|
|
60
60
|
"@swc/core": "1.5.7",
|
|
61
61
|
"@types/node": "^20.0.0",
|
|
62
62
|
"cross-env": "^7.0.3",
|
|
@@ -64,12 +64,12 @@
|
|
|
64
64
|
"typescript": "^5.7.3"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@medusajs/admin-sdk": "2.14.
|
|
68
|
-
"@medusajs/cli": "2.14.
|
|
69
|
-
"@medusajs/framework": "2.14.
|
|
70
|
-
"@medusajs/icons": "2.14.
|
|
71
|
-
"@medusajs/test-utils": "2.14.
|
|
72
|
-
"@medusajs/ui": "4.1.
|
|
67
|
+
"@medusajs/admin-sdk": "2.14.3-preview-20260504041544",
|
|
68
|
+
"@medusajs/cli": "2.14.3-preview-20260504041544",
|
|
69
|
+
"@medusajs/framework": "2.14.3-preview-20260504041544",
|
|
70
|
+
"@medusajs/icons": "2.14.3-preview-20260504041544",
|
|
71
|
+
"@medusajs/test-utils": "2.14.3-preview-20260504041544",
|
|
72
|
+
"@medusajs/ui": "4.1.10-preview-20260504041544",
|
|
73
73
|
"react": "^18.3.1",
|
|
74
74
|
"react-dom": "^18.3.1",
|
|
75
75
|
"react-router-dom": "6.30.3"
|