@lunejs/admin-ui 0.1.3 → 0.1.5
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/api/fetchers/gql-fetcher.js +6 -6
- 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/shared/components/asset-selector/list/asset-selector-list.js +12 -9
- package/package.json +1 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { ClientError as
|
|
1
|
+
import { ClientError as a } from "../../../node_modules/graphql-request/build/legacy/classes/ClientError.js";
|
|
2
2
|
import { gqlClient as o } from "../../../app/app.js";
|
|
3
|
-
import { getCookie as t, setCookie as
|
|
3
|
+
import { getCookie as t, setCookie as m } from "../../../shared/cookies/cookies.js";
|
|
4
4
|
import { CookiesKeys as r } from "../../../shared/cookies/keys.js";
|
|
5
|
-
async function
|
|
5
|
+
async function d(i, n) {
|
|
6
6
|
try {
|
|
7
7
|
const e = t(r.UserToken), s = t(r.ActiveShop);
|
|
8
|
-
return o.setHeader("Authorization", e ? `Bearer ${e}` : ""), o.setHeader("x_lune_shop_id", s ?? ""), await o.request({
|
|
8
|
+
return o.setHeader("Authorization", e ? `Bearer ${e}` : ""), o.setHeader("x_lune_shop_id", s ?? ""), o.setHeader("x_lune_timezone", Intl.DateTimeFormat().resolvedOptions().timeZone), await o.request({
|
|
9
9
|
document: i,
|
|
10
10
|
variables: n
|
|
11
11
|
});
|
|
12
12
|
} catch (e) {
|
|
13
|
-
throw e instanceof
|
|
13
|
+
throw e instanceof a && e.response.errors?.[0].extensions.code === "UNAUTHORIZED" && (m(r.UserToken, ""), window.location.href = "/login"), e;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
export {
|
|
17
|
-
|
|
17
|
+
d as gqlFetcher
|
|
18
18
|
};
|
|
@@ -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
|
};
|
|
@@ -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
|
]
|