@lunejs/admin-ui 0.1.2 → 0.1.4
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/dist/lib/asset/components/table/use-assets-table.js +19 -16
- package/dist/lib/asset/hooks/use-get-assets.d.ts +1 -1
- package/dist/lib/asset/hooks/use-get-assets.js +14 -14
- package/dist/lib/custom-fields/hooks/use-get-custom-field-definitions.js +2 -2
- package/dist/lib/order/components/table/use-orders-table.js +16 -16
- package/dist/lib/product/components/product-details/header/submit-button/product-submit-button.js +1 -1
- package/dist/lib/product/components/product-details/use-form/use-update.js +38 -31
- package/dist/lib/product/components/product-details/variants/variant-item/variant-item.js +16 -15
- package/dist/lib/product/hooks/use-update-product.js +34 -29
- package/dist/lib/product/pages/variatns-page.js +11 -10
- package/dist/node_modules/es-toolkit/dist/compat/object/cloneDeep.js +1 -1
- package/dist/node_modules/es-toolkit/dist/object/cloneDeep.js +1 -1
- package/dist/shared/components/asset-selector/list/asset-selector-list.js +12 -9
- package/package.json +1 -1
|
@@ -1,37 +1,40 @@
|
|
|
1
|
-
import { useEffect as
|
|
2
|
-
import { useDataTable as
|
|
1
|
+
import { useEffect as d, useMemo as c } from "react";
|
|
2
|
+
import { useDataTable as g } from "../../../../shared/components/data-table/use-data-table.js";
|
|
3
3
|
import { getSkip as h } from "../../../../shared/utils/pagination.utils.js";
|
|
4
4
|
import { useAssetsCount as A } from "../../hooks/use-assets-count.js";
|
|
5
5
|
import { useGetAssets as b } from "../../hooks/use-get-assets.js";
|
|
6
6
|
const z = () => {
|
|
7
|
-
const
|
|
7
|
+
const a = g({
|
|
8
8
|
search: ""
|
|
9
|
-
}), { filters: e, pagination: t } =
|
|
9
|
+
}), { filters: e, pagination: t } = a, { isLoading: o, count: n } = A(), {
|
|
10
10
|
isLoading: s,
|
|
11
11
|
isRefetching: m,
|
|
12
12
|
assets: i,
|
|
13
13
|
pagination: { pageInfo: p },
|
|
14
14
|
refetch: f
|
|
15
|
-
} = b(
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
} = b(
|
|
16
|
+
{
|
|
17
|
+
filters: {
|
|
18
|
+
...e.search && { filename: { contains: e.search } }
|
|
19
|
+
},
|
|
20
|
+
skip: h(t.page, t.size),
|
|
21
|
+
take: t.size
|
|
18
22
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
g(() => {
|
|
23
|
+
"data-table"
|
|
24
|
+
);
|
|
25
|
+
d(() => {
|
|
23
26
|
f();
|
|
24
27
|
}, [e, t]);
|
|
25
|
-
const
|
|
28
|
+
const l = c(
|
|
26
29
|
() => i?.map((r) => ({ ...r, createdAt: new Date(r.createdAt) })) ?? [],
|
|
27
30
|
[i]
|
|
28
|
-
),
|
|
31
|
+
), u = c(() => !s && !o && !n, [s, o, n]);
|
|
29
32
|
return {
|
|
30
|
-
dataTable:
|
|
33
|
+
dataTable: a,
|
|
31
34
|
isLoading: s,
|
|
32
35
|
isRefetching: m,
|
|
33
|
-
shouldRenderEmptyState:
|
|
34
|
-
assets:
|
|
36
|
+
shouldRenderEmptyState: u,
|
|
37
|
+
assets: l,
|
|
35
38
|
totalRows: p?.total ?? 0
|
|
36
39
|
};
|
|
37
40
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AssetListInput, CommonAssetFragment, GetAllAssetsQueryQuery } from '../../api/types';
|
|
2
2
|
import { GraphQLError } from 'graphql';
|
|
3
3
|
import { RefetchOptions, QueryObserverResult, FetchStatus } from '@tanstack/query-core';
|
|
4
|
-
export declare const useGetAssets: (input?: AssetListInput) => {
|
|
4
|
+
export declare const useGetAssets: (input?: AssetListInput, key?: string) => {
|
|
5
5
|
assets: CommonAssetFragment[];
|
|
6
6
|
pagination: {
|
|
7
7
|
count: number | undefined;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { useMemo as
|
|
2
|
-
import { useGqlQuery as
|
|
3
|
-
import { GET_ALL_ASSETS_QUERY as
|
|
4
|
-
import { getFragmentData as
|
|
5
|
-
import { AssetCacheKeys as
|
|
6
|
-
const
|
|
7
|
-
const t =
|
|
1
|
+
import { useMemo as n } from "react";
|
|
2
|
+
import { useGqlQuery as i } from "../../api/fetchers/use-gql-query.js";
|
|
3
|
+
import { GET_ALL_ASSETS_QUERY as p, COMMON_ASSET_FRAGMENT as u } from "../../api/operations/asset.operations.js";
|
|
4
|
+
import { getFragmentData as A } from "../../api/codegen/fragment-masking.js";
|
|
5
|
+
import { AssetCacheKeys as c } from "../constants/cache-keys.js";
|
|
6
|
+
const g = (s, e = "") => {
|
|
7
|
+
const t = i(p, {
|
|
8
8
|
variables: { input: s },
|
|
9
|
-
key: [
|
|
10
|
-
}),
|
|
11
|
-
() => t.data?.assets.items.map((
|
|
9
|
+
key: [c.All, e]
|
|
10
|
+
}), a = n(
|
|
11
|
+
() => t.data?.assets.items.map((m) => A(u, m)) ?? [],
|
|
12
12
|
[t.data]
|
|
13
|
-
), { count:
|
|
13
|
+
), { count: o, pageInfo: r } = t.data?.assets ?? {};
|
|
14
14
|
return {
|
|
15
15
|
...t,
|
|
16
|
-
assets:
|
|
17
|
-
pagination: { count:
|
|
16
|
+
assets: a,
|
|
17
|
+
pagination: { count: o, pageInfo: r }
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
export {
|
|
21
|
-
|
|
21
|
+
g as useGetAssets
|
|
22
22
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getFragmentData as m } from "../../api/codegen/fragment-masking.js";
|
|
2
2
|
import { useGqlQuery as r } from "../../api/fetchers/use-gql-query.js";
|
|
3
3
|
import { GET_CUSTOM_FIELD_DEFINITIONS_QUERY as a, COMMON_CUSTOM_FIELD_DEFINITION_FRAGMENT as f } from "../../api/operations/custom-field-definition.operations.js";
|
|
4
|
-
import { CustomFieldDefinitionsCacheKeys as
|
|
4
|
+
import { CustomFieldDefinitionsCacheKeys as F } from "../constants/cache-keys.js";
|
|
5
5
|
const I = (t) => {
|
|
6
6
|
const { data: i, ...o } = r(a, {
|
|
7
7
|
variables: { input: t },
|
|
8
|
-
key: [
|
|
8
|
+
key: [F.All, JSON.stringify(t)]
|
|
9
9
|
}), e = i?.customFieldDefinitions?.items.map(
|
|
10
10
|
(s) => m(f, s)
|
|
11
11
|
) ?? [], n = {
|
|
@@ -5,18 +5,18 @@ import { useDataTable as F } from "../../../../shared/components/data-table/use-
|
|
|
5
5
|
import { getSkip as k } from "../../../../shared/utils/pagination.utils.js";
|
|
6
6
|
import { OrderParamFiltersKeys as u } from "../../constants/param-filters-keys.js";
|
|
7
7
|
import { useCountOrders as E } from "../../hooks/use-count-orders.js";
|
|
8
|
-
import { useGetOrders as
|
|
8
|
+
import { useGetOrders as L } from "../../hooks/use-get-orders.js";
|
|
9
9
|
const N = () => {
|
|
10
|
-
const [
|
|
11
|
-
() =>
|
|
10
|
+
const [l] = P(), c = a(
|
|
11
|
+
() => l.get(u.OrderState),
|
|
12
12
|
[]
|
|
13
13
|
), p = a(
|
|
14
|
-
() =>
|
|
14
|
+
() => l.get(u.CustomerEmail),
|
|
15
15
|
[]
|
|
16
|
-
),
|
|
16
|
+
), m = F({
|
|
17
17
|
search: p ?? "",
|
|
18
|
-
states:
|
|
19
|
-
}), { filters: t, pagination: s } =
|
|
18
|
+
states: c ? [c] : []
|
|
19
|
+
}), { filters: t, pagination: s } = m, { isLoading: o, count: n } = E({
|
|
20
20
|
filters: {
|
|
21
21
|
states: [
|
|
22
22
|
r.Canceled,
|
|
@@ -28,12 +28,12 @@ const N = () => {
|
|
|
28
28
|
]
|
|
29
29
|
}
|
|
30
30
|
}), {
|
|
31
|
-
isLoading:
|
|
31
|
+
isLoading: i,
|
|
32
32
|
isRefetching: f,
|
|
33
33
|
orders: d,
|
|
34
|
-
pagination: { pageInfo:
|
|
35
|
-
refetch:
|
|
36
|
-
} =
|
|
34
|
+
pagination: { pageInfo: g },
|
|
35
|
+
refetch: h
|
|
36
|
+
} = L({
|
|
37
37
|
filters: {
|
|
38
38
|
...t.search && { code: { contains: t.search } },
|
|
39
39
|
...t.search && { customer: { contains: t.search } },
|
|
@@ -43,7 +43,7 @@ const N = () => {
|
|
|
43
43
|
take: s.size
|
|
44
44
|
});
|
|
45
45
|
O(() => {
|
|
46
|
-
|
|
46
|
+
h();
|
|
47
47
|
}, [t, s]);
|
|
48
48
|
const y = a(
|
|
49
49
|
() => d?.map((e) => ({
|
|
@@ -57,14 +57,14 @@ const N = () => {
|
|
|
57
57
|
placedAt: e.placedAt ?? null
|
|
58
58
|
})) ?? [],
|
|
59
59
|
[d]
|
|
60
|
-
), S = a(() => !
|
|
60
|
+
), S = a(() => !i && !o && !n, [i, o, n]);
|
|
61
61
|
return {
|
|
62
|
-
dataTable:
|
|
63
|
-
isLoading: o,
|
|
62
|
+
dataTable: m,
|
|
63
|
+
isLoading: i || o,
|
|
64
64
|
isRefetching: f,
|
|
65
65
|
shouldRenderEmptyState: S,
|
|
66
66
|
orders: y,
|
|
67
|
-
totalRows:
|
|
67
|
+
totalRows: g?.total ?? 0
|
|
68
68
|
};
|
|
69
69
|
};
|
|
70
70
|
export {
|
|
@@ -1,44 +1,51 @@
|
|
|
1
|
-
import { LunePrice as
|
|
1
|
+
import { LunePrice as t } from "../../../../../packages/lune-common/dist/index.js";
|
|
2
2
|
import { useUpdateProduct as l } from "../../../hooks/use-update-product.js";
|
|
3
|
-
const
|
|
4
|
-
const { updateProduct:
|
|
3
|
+
const p = () => {
|
|
4
|
+
const { updateProduct: c } = l();
|
|
5
5
|
return {
|
|
6
|
-
updateProduct: (
|
|
7
|
-
const { variants:
|
|
8
|
-
return
|
|
9
|
-
name:
|
|
10
|
-
description:
|
|
11
|
-
enabled:
|
|
12
|
-
defaultVariant: d ?
|
|
13
|
-
customFields:
|
|
14
|
-
variants:
|
|
15
|
-
id:
|
|
16
|
-
action:
|
|
17
|
-
salePrice:
|
|
18
|
-
stock:
|
|
19
|
-
|
|
6
|
+
updateProduct: (s, i) => {
|
|
7
|
+
const { variants: a, options: o } = i, d = s.variants.items[0].optionValues.length === 0, n = s?.variants.items[0];
|
|
8
|
+
return c(s.id, {
|
|
9
|
+
name: i.name,
|
|
10
|
+
description: i.description,
|
|
11
|
+
enabled: i.enabled,
|
|
12
|
+
defaultVariant: d ? s.variants.items[0].id : null,
|
|
13
|
+
customFields: i.customFields,
|
|
14
|
+
variants: a.length ? a.map((e) => ({
|
|
15
|
+
id: e?.id,
|
|
16
|
+
action: e.action,
|
|
17
|
+
salePrice: e.salePrice ? t.parse(e.salePrice) : 0,
|
|
18
|
+
stock: e.stock || 0,
|
|
19
|
+
comparisonPrice: e.comparisonPrice ? t.parse(e.comparisonPrice) : 0,
|
|
20
|
+
sku: e.sku,
|
|
21
|
+
requiresShipping: e.requiresShipping,
|
|
22
|
+
weight: e.weight,
|
|
23
|
+
height: e.height,
|
|
24
|
+
width: e.width,
|
|
25
|
+
length: e.length,
|
|
26
|
+
optionValues: e.optionValues
|
|
20
27
|
})) : [
|
|
21
28
|
{
|
|
22
|
-
id:
|
|
23
|
-
salePrice:
|
|
24
|
-
comparisonPrice:
|
|
25
|
-
stock:
|
|
26
|
-
sku:
|
|
27
|
-
weight:
|
|
28
|
-
length:
|
|
29
|
-
width:
|
|
30
|
-
height:
|
|
31
|
-
requiresShipping:
|
|
29
|
+
id: n?.id,
|
|
30
|
+
salePrice: i.salePrice ? t.parse(i.salePrice) : 0,
|
|
31
|
+
comparisonPrice: i.comparisonPrice ? t.parse(i.comparisonPrice) : 0,
|
|
32
|
+
stock: i.stock || 0,
|
|
33
|
+
sku: i.sku,
|
|
34
|
+
weight: i.weight,
|
|
35
|
+
length: i.length,
|
|
36
|
+
width: i.width,
|
|
37
|
+
height: i.height,
|
|
38
|
+
requiresShipping: i.requiresShipping,
|
|
32
39
|
action: "none"
|
|
33
40
|
}
|
|
34
41
|
],
|
|
35
|
-
variantsToRemove:
|
|
36
|
-
optionsToRemove:
|
|
37
|
-
options:
|
|
42
|
+
variantsToRemove: s?.variants.items.filter((e) => !a.some((r) => r.id === e.id)).filter((e) => a.length ? !0 : e.id !== n?.id).map((e) => e.id) ?? [],
|
|
43
|
+
optionsToRemove: s?.options.filter((e) => !o.some((r) => r.id === e.id)).map((e) => e.id) ?? [],
|
|
44
|
+
options: o
|
|
38
45
|
});
|
|
39
46
|
}
|
|
40
47
|
};
|
|
41
48
|
};
|
|
42
49
|
export {
|
|
43
|
-
|
|
50
|
+
p as useProductDetailsUpdate
|
|
44
51
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as l, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
+
import { isUUID as f } from "../../../../../../packages/lune-common/dist/index.js";
|
|
3
4
|
import "../../../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-accordion/dist/index.js";
|
|
4
|
-
import { cn as
|
|
5
|
+
import { cn as n } from "../../../../../../packages/lune-ui/dist/lib/utils.js";
|
|
5
6
|
import "../../../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-alert-dialog/dist/index.js";
|
|
6
7
|
import "../../../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-avatar/dist/index.js";
|
|
7
8
|
import "../../../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-separator/dist/index.js";
|
|
@@ -32,32 +33,32 @@ import "../../../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-tog
|
|
|
32
33
|
import "../../../../../../packages/lune-ui/dist/components/toggle-group.js";
|
|
33
34
|
import "../../../../../../packages/lune-ui/dist/node_modules/@radix-ui/react-tooltip/dist/index.js";
|
|
34
35
|
import "../../../../../../packages/lune-ui/dist/form/form.js";
|
|
35
|
-
import { Link as
|
|
36
|
-
import { useVariantContext as
|
|
37
|
-
const
|
|
38
|
-
const { product: u, variants: i, updateVariants: m } =
|
|
39
|
-
return /* @__PURE__ */
|
|
40
|
-
/* @__PURE__ */
|
|
36
|
+
import { Link as x } from "../../../../../../node_modules/react-router/dist/development/chunk-JMJ3UQ3L.js";
|
|
37
|
+
import { useVariantContext as g } from "../variants.context.js";
|
|
38
|
+
const oe = ({ variant: r, groupName: a, className: d }) => {
|
|
39
|
+
const { product: u, variants: i, updateVariants: m } = g(), s = !!a, p = s ? r.values.filter((e) => e.name !== a).map((e) => e.name).join("/") : r.values.map((e) => e.name).join(" / ");
|
|
40
|
+
return /* @__PURE__ */ l("div", { className: n("flex items-center px-6 py-4 hover:bg-muted/50", d), children: [
|
|
41
|
+
/* @__PURE__ */ l("div", { className: n("flex items-center gap-4 w-full", s && "pl-8"), children: [
|
|
41
42
|
/* @__PURE__ */ t(
|
|
42
43
|
h,
|
|
43
44
|
{
|
|
44
|
-
"aria-label": `Select variant "${
|
|
45
|
+
"aria-label": `Select variant "${p}"`,
|
|
45
46
|
checked: r.selected,
|
|
46
47
|
onCheckedChange: (e) => m(
|
|
47
48
|
i.map((o) => o.id === r.id ? { ...o, selected: !!e } : o)
|
|
48
49
|
)
|
|
49
50
|
}
|
|
50
51
|
),
|
|
51
|
-
/* @__PURE__ */ t(
|
|
52
|
-
|
|
52
|
+
f(r.id) ? /* @__PURE__ */ t(
|
|
53
|
+
x,
|
|
53
54
|
{
|
|
54
55
|
to: `/products/${u?.id}/variants/${r.id}`,
|
|
55
56
|
className: "hover:underline w-full cursor-pointer",
|
|
56
|
-
children:
|
|
57
|
+
children: p
|
|
57
58
|
}
|
|
58
|
-
)
|
|
59
|
+
) : /* @__PURE__ */ t("span", { className: "w-full", children: p })
|
|
59
60
|
] }),
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
+
/* @__PURE__ */ l("div", { className: "flex items-center gap-2 w-full", children: [
|
|
61
62
|
/* @__PURE__ */ t(
|
|
62
63
|
c,
|
|
63
64
|
{
|
|
@@ -83,5 +84,5 @@ const _ = ({ variant: r, groupName: a, className: d }) => {
|
|
|
83
84
|
] });
|
|
84
85
|
};
|
|
85
86
|
export {
|
|
86
|
-
|
|
87
|
+
oe as VariantItem
|
|
87
88
|
};
|
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
import { isUUID as r } from "../../../packages/lune-common/dist/index.js";
|
|
2
|
-
import { queryClient as
|
|
2
|
+
import { queryClient as I } from "../../../app/app.js";
|
|
3
3
|
import { useGqlMutationDEPRECATED as s } from "../../api/fetchers/use-gql-mutation.js";
|
|
4
|
-
import { UPDATE_OPTION_MUTATION as
|
|
4
|
+
import { UPDATE_OPTION_MUTATION as U, CREATE_OPTION_MUTATION as V, REMOVE_OPTION_MUTATION as _ } from "../../api/operations/option.operations.js";
|
|
5
5
|
import { UPDATE_PRODUCT_MUTATION as N } from "../../api/operations/product.operations.js";
|
|
6
6
|
import { UPDATE_VARIANT_MUTATION as M, REMOVE_VARIANT_MUTATION as R, CREATE_VARIANT_MUTATION as b } from "../../api/operations/variant.operations.js";
|
|
7
7
|
import { ProductCacheKeys as C } from "../constants/cache-keys.js";
|
|
8
8
|
const G = () => {
|
|
9
|
-
const { mutateAsync:
|
|
9
|
+
const { mutateAsync: h } = s(N), { mutateAsync: T } = s(M), { mutateAsync: d } = s(R), { mutateAsync: O } = s(b), { mutateAsync: A } = s(U), { mutateAsync: P } = s(V), { mutateAsync: g } = s(_);
|
|
10
10
|
return {
|
|
11
|
-
updateProduct: async (
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const
|
|
11
|
+
updateProduct: async (n, o) => {
|
|
12
|
+
const a = o.options?.filter((e) => !r(e.id)), c = o.options?.filter((e) => r(e.id));
|
|
13
|
+
a?.length && o.defaultVariant && await d({ id: o.defaultVariant });
|
|
14
|
+
const E = c.length ? await Promise.all(
|
|
15
15
|
c.map(
|
|
16
|
-
(e, t) =>
|
|
16
|
+
(e, t) => A({
|
|
17
17
|
id: e.id,
|
|
18
18
|
input: {
|
|
19
19
|
order: t,
|
|
20
20
|
name: e.name,
|
|
21
|
-
values: e.values.map((
|
|
22
|
-
id: r(
|
|
23
|
-
name:
|
|
24
|
-
customObjectEntryId:
|
|
21
|
+
values: e.values.map((i, m) => ({
|
|
22
|
+
id: r(i.id) ? i.id : "",
|
|
23
|
+
name: i.customObjectEntryId ? null : i.name,
|
|
24
|
+
customObjectEntryId: i.customObjectEntryId,
|
|
25
25
|
order: m
|
|
26
26
|
}))
|
|
27
27
|
}
|
|
28
28
|
})
|
|
29
29
|
)
|
|
30
|
-
) : [],
|
|
31
|
-
productId:
|
|
32
|
-
input:
|
|
30
|
+
) : [], w = a.length ? await P({
|
|
31
|
+
productId: n,
|
|
32
|
+
input: a.map((e, t) => ({
|
|
33
33
|
order: c.length + t,
|
|
34
34
|
name: e.name,
|
|
35
|
-
values: e.values.map((
|
|
36
|
-
name:
|
|
37
|
-
customObjectEntryId:
|
|
35
|
+
values: e.values.map((i, m) => ({
|
|
36
|
+
name: i.customObjectEntryId ? null : i.name,
|
|
37
|
+
customObjectEntryId: i.customObjectEntryId,
|
|
38
38
|
order: m
|
|
39
39
|
}))
|
|
40
40
|
}))
|
|
41
41
|
}) : [];
|
|
42
|
-
await Promise.all(o.optionsToRemove.map((e) =>
|
|
43
|
-
const
|
|
44
|
-
|
|
42
|
+
await Promise.all(o.optionsToRemove.map((e) => g({ id: e })));
|
|
43
|
+
const y = [...E, ...w], p = /* @__PURE__ */ new Map();
|
|
44
|
+
y.forEach((e) => {
|
|
45
45
|
e.values.forEach((t) => {
|
|
46
46
|
p.set(t.name, t.id);
|
|
47
47
|
});
|
|
@@ -50,8 +50,8 @@ const G = () => {
|
|
|
50
50
|
...e,
|
|
51
51
|
optionValues: e.optionValues?.map((t) => ({ id: p.get(t.name) ?? t.id, name: t.name })).filter((t) => t.id) ?? []
|
|
52
52
|
}));
|
|
53
|
-
await
|
|
54
|
-
id:
|
|
53
|
+
await h({
|
|
54
|
+
id: n,
|
|
55
55
|
input: {
|
|
56
56
|
name: o.name,
|
|
57
57
|
description: o.description,
|
|
@@ -59,20 +59,25 @@ const G = () => {
|
|
|
59
59
|
customFields: Object.entries(o.customFields).map(([e, t]) => ({ id: e, value: t }))
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
|
-
const
|
|
62
|
+
const f = l.filter((e) => e.action === "none"), u = l.filter((e) => e.action === "create");
|
|
63
63
|
await Promise.all(
|
|
64
|
-
|
|
65
|
-
async (e) => await
|
|
64
|
+
f.map(
|
|
65
|
+
async (e) => await T({
|
|
66
66
|
id: e.id,
|
|
67
67
|
input: {
|
|
68
68
|
salePrice: e.salePrice,
|
|
69
69
|
stock: e.stock,
|
|
70
|
+
comparisonPrice: e.comparisonPrice,
|
|
71
|
+
sku: e.sku,
|
|
72
|
+
requiresShipping: e.requiresShipping,
|
|
73
|
+
weight: e.weight,
|
|
74
|
+
dimensions: { height: e.height, width: e.width, length: e.length },
|
|
70
75
|
optionValues: e.optionValues?.map((t) => t.id)
|
|
71
76
|
}
|
|
72
77
|
})
|
|
73
78
|
)
|
|
74
|
-
), u.length && await
|
|
75
|
-
productId:
|
|
79
|
+
), u.length && await O({
|
|
80
|
+
productId: n,
|
|
76
81
|
input: u.map((e) => ({
|
|
77
82
|
salePrice: e.salePrice,
|
|
78
83
|
stock: e.stock,
|
|
@@ -85,7 +90,7 @@ const G = () => {
|
|
|
85
90
|
}))
|
|
86
91
|
}), await Promise.all(
|
|
87
92
|
o.variantsToRemove.map(async (e) => await d({ id: e }))
|
|
88
|
-
),
|
|
93
|
+
), I.refetchQueries({ queryKey: [C.Unique(n)] });
|
|
89
94
|
}
|
|
90
95
|
};
|
|
91
96
|
};
|
|
@@ -33,20 +33,21 @@ import "../../../packages/lune-ui/dist/node_modules/@radix-ui/react-tooltip/dist
|
|
|
33
33
|
import "../../../packages/lune-ui/dist/form/form.js";
|
|
34
34
|
import { useParams as f } from "../../../node_modules/react-router/dist/development/chunk-JMJ3UQ3L.js";
|
|
35
35
|
import { PageLayout as x } from "../../../shared/components/layout/page-layout.js";
|
|
36
|
+
import { PageLoader as u } from "../../../shared/components/loader/page-loader.js";
|
|
36
37
|
import { NotFound as h } from "../../../shared/components/not-found/not-found.js";
|
|
37
|
-
import { VariantDetails as
|
|
38
|
+
import { VariantDetails as v } from "../components/variant-details/variant-details.js";
|
|
38
39
|
import { VariantsList as o } from "../components/variant-details/variants-list/variants-list.js";
|
|
39
|
-
import { useGetProductForVariants as
|
|
40
|
-
const
|
|
41
|
-
const { id:
|
|
40
|
+
import { useGetProductForVariants as g } from "../hooks/use-get-product-for-variants.js";
|
|
41
|
+
const mr = () => {
|
|
42
|
+
const { id: s, variantId: a } = f(), { isLoading: m, product: i } = g(s), p = n(
|
|
42
43
|
() => i?.variants.items.find((e) => e.id === a) ?? null,
|
|
43
44
|
[i, a]
|
|
44
45
|
);
|
|
45
|
-
return i.id ? /* @__PURE__ */ t(
|
|
46
|
+
return m ? /* @__PURE__ */ r(u, {}) : i.id ? /* @__PURE__ */ t(
|
|
46
47
|
x,
|
|
47
48
|
{
|
|
48
49
|
className: "max-w-5xl mx-auto w-full fade-in grid grid-cols-6 gap-6",
|
|
49
|
-
isLoading:
|
|
50
|
+
isLoading: m,
|
|
50
51
|
children: [
|
|
51
52
|
/* @__PURE__ */ r("section", { className: "col-span-2 hidden lg:block", children: /* @__PURE__ */ r(l, { className: "pt-4 pb-0 overflow-hidden", children: /* @__PURE__ */ t(c, { className: "px-0 flex flex-col gap-4", children: [
|
|
52
53
|
/* @__PURE__ */ r(d, { className: "px-4", children: "Variants" }),
|
|
@@ -55,11 +56,11 @@ const or = () => {
|
|
|
55
56
|
/* @__PURE__ */ r("div", { className: "border-t max-h-[calc(100vh-48px*2-16px-16px-16px-36px-34px)] overflow-y-auto", children: /* @__PURE__ */ r(o.List, {}) })
|
|
56
57
|
] })
|
|
57
58
|
] }) }) }),
|
|
58
|
-
/* @__PURE__ */ r("section", { className: "col-span-6 lg:col-span-4", children:
|
|
59
|
-
|
|
59
|
+
/* @__PURE__ */ r("section", { className: "col-span-6 lg:col-span-4", children: p && /* @__PURE__ */ r(
|
|
60
|
+
v,
|
|
60
61
|
{
|
|
61
62
|
productId: i.id,
|
|
62
|
-
variant:
|
|
63
|
+
variant: p,
|
|
63
64
|
variants: i.variants.items
|
|
64
65
|
}
|
|
65
66
|
) })
|
|
@@ -68,5 +69,5 @@ const or = () => {
|
|
|
68
69
|
) : /* @__PURE__ */ r(h, {});
|
|
69
70
|
};
|
|
70
71
|
export {
|
|
71
|
-
|
|
72
|
+
mr as VariantsPage
|
|
72
73
|
};
|
|
@@ -46,11 +46,14 @@ import { AssetSelectorEmptyState as Y } from "../empty-state/asset-selector-empt
|
|
|
46
46
|
import { AssetSelectorNoMatchingFiltersState as _ } from "../empty-state/asset-selector-no-matching-filters-state.js";
|
|
47
47
|
import O from "../../../../node_modules/lucide-react/dist/esm/icons/cloud-upload.js";
|
|
48
48
|
const Mr = ({ selected: h, setSelected: s }) => {
|
|
49
|
-
const { theme: n } = U(), [g,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
const { theme: n } = U(), [g, c] = P(), [i, x] = C(""), { isUploading: p, uploadAsset: b } = M(), { isLoading: l, isRefetching: N, refetch: y, assets: m } = B(
|
|
50
|
+
{
|
|
51
|
+
filters: {
|
|
52
|
+
...i && { filename: { contains: i } }
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"asset-selector"
|
|
56
|
+
), d = !!i, k = !l && !m.length && !d;
|
|
54
57
|
I(() => {
|
|
55
58
|
y();
|
|
56
59
|
}, [i]);
|
|
@@ -69,8 +72,8 @@ const Mr = ({ selected: h, setSelected: s }) => {
|
|
|
69
72
|
{
|
|
70
73
|
className: f(
|
|
71
74
|
"flex items-center justify-between gap-3 pb-6 px-6 z-10 h-fit border border-transparent",
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
c && n === "light" && "shadow-sm",
|
|
76
|
+
c && n === "dark" && "border-b-border"
|
|
74
77
|
),
|
|
75
78
|
children: [
|
|
76
79
|
/* @__PURE__ */ o(E, { className: "max-w-80 w-full", children: [
|
|
@@ -90,8 +93,8 @@ const Mr = ({ selected: h, setSelected: s }) => {
|
|
|
90
93
|
}
|
|
91
94
|
)
|
|
92
95
|
] }),
|
|
93
|
-
/* @__PURE__ */ e(T, { onDrop: (r) => b(r), children: /* @__PURE__ */ o(D, { isLoading:
|
|
94
|
-
!
|
|
96
|
+
/* @__PURE__ */ e(T, { onDrop: (r) => b(r), children: /* @__PURE__ */ o(D, { isLoading: p, variant: "outline", className: "shrink-0", children: [
|
|
97
|
+
!p && /* @__PURE__ */ e(O, {}),
|
|
95
98
|
" Upload"
|
|
96
99
|
] }) })
|
|
97
100
|
]
|