@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.
@@ -1,18 +1,18 @@
1
- import { ClientError as c } from "../../../node_modules/graphql-request/build/legacy/classes/ClientError.js";
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 a } from "../../../shared/cookies/cookies.js";
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 l(i, n) {
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 c && e.response.errors?.[0].extensions.code === "UNAUTHORIZED" && (a(r.UserToken, ""), window.location.href = "/login"), e;
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
- l as gqlFetcher
17
+ d as gqlFetcher
18
18
  };
@@ -1,37 +1,40 @@
1
- import { useEffect as g, useMemo as c } from "react";
2
- import { useDataTable as d } from "../../../../shared/components/data-table/use-data-table.js";
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 o = d({
7
+ const a = g({
8
8
  search: ""
9
- }), { filters: e, pagination: t } = o, { isLoading: a, count: n } = A(), {
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
- filters: {
17
- ...e.search && { filename: { contains: e.search } }
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
- skip: h(t.page, t.size),
20
- take: t.size
21
- });
22
- g(() => {
23
+ "data-table"
24
+ );
25
+ d(() => {
23
26
  f();
24
27
  }, [e, t]);
25
- const u = c(
28
+ const l = c(
26
29
  () => i?.map((r) => ({ ...r, createdAt: new Date(r.createdAt) })) ?? [],
27
30
  [i]
28
- ), l = c(() => !s && !a && !n, [s, a, n]);
31
+ ), u = c(() => !s && !o && !n, [s, o, n]);
29
32
  return {
30
- dataTable: o,
33
+ dataTable: a,
31
34
  isLoading: s,
32
35
  isRefetching: m,
33
- shouldRenderEmptyState: l,
34
- assets: u,
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 m } from "react";
2
- import { useGqlQuery as n } from "../../api/fetchers/use-gql-query.js";
3
- import { GET_ALL_ASSETS_QUERY as i, COMMON_ASSET_FRAGMENT as p } from "../../api/operations/asset.operations.js";
4
- import { getFragmentData as u } from "../../api/codegen/fragment-masking.js";
5
- import { AssetCacheKeys as A } from "../constants/cache-keys.js";
6
- const _ = (s) => {
7
- const t = n(i, {
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: [A.All]
10
- }), e = m(
11
- () => t.data?.assets.items.map((r) => u(p, r)) ?? [],
9
+ key: [c.All, e]
10
+ }), a = n(
11
+ () => t.data?.assets.items.map((m) => A(u, m)) ?? [],
12
12
  [t.data]
13
- ), { count: a, pageInfo: o } = t.data?.assets ?? {};
13
+ ), { count: o, pageInfo: r } = t.data?.assets ?? {};
14
14
  return {
15
15
  ...t,
16
- assets: e,
17
- pagination: { count: a, pageInfo: o }
16
+ assets: a,
17
+ pagination: { count: o, pageInfo: r }
18
18
  };
19
19
  };
20
20
  export {
21
- _ as useGetAssets
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, p] = P(), [i, x] = C(""), { isUploading: c, uploadAsset: b } = M(), { isLoading: l, isRefetching: N, refetch: y, assets: m } = B({
50
- filters: {
51
- ...i && { filename: { contains: i } }
52
- }
53
- }), d = !!i, k = !l && !m.length && !d;
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
- p && n === "light" && "shadow-sm",
73
- p && n === "dark" && "border-b-border"
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: c, variant: "outline", className: "shrink-0", children: [
94
- !c && /* @__PURE__ */ e(O, {}),
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
  ]
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@lunejs/admin-ui",
3
3
  "description": "Admin UI for Lune",
4
4
  "license": "AGPL-3.0",
5
- "version": "0.1.3",
5
+ "version": "0.1.5",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist"