gomtm 0.0.189 → 0.0.191
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/esm/components/blog/BlogPostActions.js +6 -1
- package/dist/esm/curd/CommonListViewV2.backup.d.ts +7 -0
- package/dist/esm/curd/CommonListViewV2.backup.js +81 -0
- package/dist/esm/curd/CommonListViewV2.d.ts +2 -0
- package/dist/esm/curd/CommonListViewV2.js +14 -11
- package/dist/esm/curd/curd-detail.d.ts +2 -1
- package/dist/esm/curd/curd-detail.js +17 -17
- package/dist/esm/curd/curd.atoms.d.ts +1 -0
- package/dist/esm/curd/curd.atoms.js +14 -1
- package/dist/esm/curd/list-item/ListItem.js +1 -1
- package/dist/esm/gomtm-clients-ss.js +6 -1
- package/dist/esm/gomtmcurd/gomtmcurd-detailview.d.ts +2 -0
- package/dist/esm/gomtmcurd/gomtmcurd-detailview.js +19 -0
- package/dist/esm/gomtmcurd/gomtmcurd-listview.d.ts +2 -0
- package/dist/esm/gomtmcurd/gomtmcurd-listview.js +24 -0
- package/dist/esm/gomtmcurd/hooks.d.ts +1 -0
- package/dist/esm/gomtmcurd/hooks.js +16 -0
- package/dist/esm/providers/GomtmProvider.js +2 -1
- package/dist/tsconfig.type.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useAtom } from "jotai";
|
|
3
4
|
import { Icons } from "mtxuilib/icons/icons";
|
|
4
5
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger } from "mtxuilib/ui/dropdown-menu";
|
|
5
6
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
6
7
|
import { DropdownMenuItemLink } from "mtxuilib/ui/ui-mt/DropdownMenuItemLink";
|
|
8
|
+
import { curdSlugPathAtom } from "../../curd/CommonListViewV2";
|
|
7
9
|
const BlogPostItemActions = (props) => {
|
|
8
10
|
const { postId } = props;
|
|
11
|
+
const [curdSlugPath] = useAtom(curdSlugPathAtom);
|
|
9
12
|
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
10
13
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
11
14
|
MtButton,
|
|
@@ -19,8 +22,10 @@ const BlogPostItemActions = (props) => {
|
|
|
19
22
|
}
|
|
20
23
|
) }),
|
|
21
24
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { align: "end", className: "w-[160px]", children: [
|
|
22
|
-
/* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `/post/${postId}/edit`, children: "Edit" }),
|
|
23
25
|
/* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `/post/${postId}/create`, children: "create" }),
|
|
26
|
+
/* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `/post/show`, children: "show" }),
|
|
27
|
+
/* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/edit`, children: "edit" }),
|
|
28
|
+
/* @__PURE__ */ jsx(DropdownMenuItemLink, { href: `${curdSlugPath}/listdebug`, children: "list debug" }),
|
|
24
29
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
25
30
|
/* @__PURE__ */ jsxs(DropdownMenuItem, { children: [
|
|
26
31
|
"Delete",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Message } from "@bufbuild/protobuf";
|
|
2
|
+
import { PropsWithChildren } from "react";
|
|
3
|
+
import { MethodUnaryDescriptor } from "../connectquery";
|
|
4
|
+
export declare function CommonListViewProvider<I extends Message<I>, O extends Message<O>>(props: {
|
|
5
|
+
methodList: MethodUnaryDescriptor<I, any>;
|
|
6
|
+
} & PropsWithChildren): import("react").JSX.Element;
|
|
7
|
+
export declare function CommonListView<I extends Message<I>, O extends Message<O>>(): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { atom, useAtom } from "jotai";
|
|
4
|
+
import { ScopeAtomsHydrator } from "mtxlib/jotai/jotai-helper";
|
|
5
|
+
import { cn } from "mtxuilib/lib/utils";
|
|
6
|
+
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "mtxuilib/ui/pagination";
|
|
7
|
+
import { MtUnaryCallErrorView } from "../components/MtUnaryCallErrorView";
|
|
8
|
+
import { useSuspenseInfiniteQuery } from "../connectquery";
|
|
9
|
+
import { ListViewLayout } from "../gomtmpb/mtm/sppb/mtm_pb";
|
|
10
|
+
import { ListItemView } from "./list-item/ListItem";
|
|
11
|
+
const listQueryAtom = atom(null);
|
|
12
|
+
function CommonListViewProvider(props) {
|
|
13
|
+
const { children, methodList } = props;
|
|
14
|
+
const listquery = useSuspenseInfiniteQuery(methodList, {
|
|
15
|
+
//@ts-expect-error
|
|
16
|
+
page: 1
|
|
17
|
+
}, {
|
|
18
|
+
pageParamKey: "pagination",
|
|
19
|
+
getNextPageParam: (res, b, c) => {
|
|
20
|
+
return {
|
|
21
|
+
//@ts-expect-error
|
|
22
|
+
page: ((c == null ? void 0 : c.page) || 0) + 1
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return /* @__PURE__ */ jsx(ScopeAtomsHydrator, { atomValues: [
|
|
27
|
+
[listQueryAtom, listquery]
|
|
28
|
+
], children });
|
|
29
|
+
}
|
|
30
|
+
function CommonListView() {
|
|
31
|
+
const [listQuery, setListQuery] = useAtom(listQueryAtom);
|
|
32
|
+
if (!(listQuery == null ? void 0 : listQuery.data)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
36
|
+
/* @__PURE__ */ jsx(
|
|
37
|
+
"div",
|
|
38
|
+
{
|
|
39
|
+
className: cn(
|
|
40
|
+
"w-full"
|
|
41
|
+
// 滚动设置
|
|
42
|
+
// " max-h-[700px] overflow-y-auto"
|
|
43
|
+
),
|
|
44
|
+
children: listQuery.data.pages.map((page, i) => {
|
|
45
|
+
var _a;
|
|
46
|
+
if (page.error_code) {
|
|
47
|
+
return /* @__PURE__ */ jsx(MtUnaryCallErrorView, { unaryError: page }, i);
|
|
48
|
+
} else {
|
|
49
|
+
return /* @__PURE__ */ jsx(ListLayout, { layout: page.listLayout, children: (_a = page == null ? void 0 : page.items) == null ? void 0 : _a.map((item, j) => /* @__PURE__ */ jsx(ListItemView, { item }, `${i}-${j}`)) }, i);
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
/* @__PURE__ */ jsx(Pagination, { children: /* @__PURE__ */ jsxs(PaginationContent, { children: [
|
|
55
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationPrevious, { href: "#" }) }),
|
|
56
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationLink, { href: "#", children: "1" }) }),
|
|
57
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationLink, { href: "#", isActive: true, children: "2" }) }),
|
|
58
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationLink, { href: "#", children: "3" }) }),
|
|
59
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationEllipsis, {}) }),
|
|
60
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationNext, { href: "#" }) })
|
|
61
|
+
] }) }),
|
|
62
|
+
/* @__PURE__ */ jsx("div", { className: "absolute right-1 top-1" })
|
|
63
|
+
] });
|
|
64
|
+
}
|
|
65
|
+
const ListLayout = (props) => {
|
|
66
|
+
const { children } = props;
|
|
67
|
+
switch (props.layout) {
|
|
68
|
+
case ListViewLayout.simple:
|
|
69
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1 rounded-md p-2 shadow-sm", children });
|
|
70
|
+
case ListViewLayout.grid:
|
|
71
|
+
return /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 grid-rows-3 gap-4 px-4 lg:grid-cols-3", children });
|
|
72
|
+
case ListViewLayout.card:
|
|
73
|
+
return /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 grid-rows-3 gap-4 px-4 lg:grid-cols-3", children });
|
|
74
|
+
default:
|
|
75
|
+
return children;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
CommonListView,
|
|
80
|
+
CommonListViewProvider
|
|
81
|
+
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Message } from "@bufbuild/protobuf";
|
|
2
2
|
import { PropsWithChildren } from "react";
|
|
3
3
|
import { MethodUnaryDescriptor } from "../connectquery";
|
|
4
|
+
export declare const curdSlugPathAtom: import("jotai").Atom<string>;
|
|
4
5
|
export declare function CommonListViewProvider<I extends Message<I>, O extends Message<O>>(props: {
|
|
5
6
|
methodList: MethodUnaryDescriptor<I, any>;
|
|
7
|
+
slugPath?: string;
|
|
6
8
|
} & PropsWithChildren): import("react").JSX.Element;
|
|
7
9
|
export declare function CommonListView<I extends Message<I>, O extends Message<O>>(): import("react").JSX.Element | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { atom, useAtom } from "jotai";
|
|
4
|
-
import {
|
|
4
|
+
import { ScopeAtomsHydrator } from "mtxlib/jotai/jotai-helper";
|
|
5
5
|
import { cn } from "mtxuilib/lib/utils";
|
|
6
6
|
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "mtxuilib/ui/pagination";
|
|
7
7
|
import { MtUnaryCallErrorView } from "../components/MtUnaryCallErrorView";
|
|
@@ -9,8 +9,13 @@ import { useSuspenseInfiniteQuery } from "../connectquery";
|
|
|
9
9
|
import { ListViewLayout } from "../gomtmpb/mtm/sppb/mtm_pb";
|
|
10
10
|
import { ListItemView } from "./list-item/ListItem";
|
|
11
11
|
const listQueryAtom = atom(null);
|
|
12
|
+
const curdSlugPathValueAtom = atom("");
|
|
13
|
+
const curdSlugPathAtom = atom((get) => {
|
|
14
|
+
const value = get(curdSlugPathValueAtom);
|
|
15
|
+
return value || "/";
|
|
16
|
+
});
|
|
12
17
|
function CommonListViewProvider(props) {
|
|
13
|
-
const { children, methodList } = props;
|
|
18
|
+
const { children, methodList, slugPath } = props;
|
|
14
19
|
const listquery = useSuspenseInfiniteQuery(methodList, {
|
|
15
20
|
//@ts-expect-error
|
|
16
21
|
page: 1
|
|
@@ -23,13 +28,10 @@ function CommonListViewProvider(props) {
|
|
|
23
28
|
};
|
|
24
29
|
}
|
|
25
30
|
});
|
|
26
|
-
|
|
27
|
-
[
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
]
|
|
31
|
-
]);
|
|
32
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
31
|
+
return /* @__PURE__ */ jsx(ScopeAtomsHydrator, { atomValues: [
|
|
32
|
+
[listQueryAtom, listquery],
|
|
33
|
+
[curdSlugPathValueAtom, slugPath]
|
|
34
|
+
], children });
|
|
33
35
|
}
|
|
34
36
|
function CommonListView() {
|
|
35
37
|
const [listQuery, setListQuery] = useAtom(listQueryAtom);
|
|
@@ -81,5 +83,6 @@ const ListLayout = (props) => {
|
|
|
81
83
|
};
|
|
82
84
|
export {
|
|
83
85
|
CommonListView,
|
|
84
|
-
CommonListViewProvider
|
|
86
|
+
CommonListViewProvider,
|
|
87
|
+
curdSlugPathAtom
|
|
85
88
|
};
|
|
@@ -2,5 +2,6 @@ import { PropsWithChildren } from "react";
|
|
|
2
2
|
export declare const curdDetailSlugAtom: import("jotai").PrimitiveAtom<string> & {
|
|
3
3
|
init: string;
|
|
4
4
|
};
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function CurdViewDetailProvider<T = any>(props: PropsWithChildren): import("react").JSX.Element;
|
|
6
|
+
export declare const CurdViewDetailDefault: () => import("react").JSX.Element;
|
|
6
7
|
export declare const DetailViewActions: () => import("react").JSX.Element;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useMemo } from "react";
|
|
4
3
|
import { atom, useAtom } from "jotai";
|
|
5
4
|
import { ScopeAtomsHydrator } from "mtxlib/jotai/jotai-helper";
|
|
6
5
|
import { Icons } from "mtxuilib/icons/icons";
|
|
@@ -10,28 +9,25 @@ import { usePathname } from "next/navigation";
|
|
|
10
9
|
import { useSuspenseQuery } from "../connectquery";
|
|
11
10
|
import { SchemaFormView } from "../form/SchemaFormView";
|
|
12
11
|
import { curdDetail } from "../gomtmpb/mtm/sppb/curd-CurdService_connectquery";
|
|
12
|
+
import { curdViewGet } from "../gomtmpb/mtm/sppb/mtm-MtmService_connectquery";
|
|
13
|
+
import { useCurdSlugName } from "./curd.atoms";
|
|
13
14
|
const curdDetailSlugAtom = atom("");
|
|
14
|
-
function
|
|
15
|
+
function CurdViewDetailProvider(props) {
|
|
15
16
|
const { children } = props;
|
|
16
17
|
const pathName = usePathname();
|
|
17
|
-
return /* @__PURE__ */
|
|
18
|
+
return /* @__PURE__ */ jsx(ScopeAtomsHydrator, { atomValues: [
|
|
18
19
|
[curdDetailSlugAtom, pathName]
|
|
19
|
-
], children
|
|
20
|
-
/* @__PURE__ */ jsx(CurdViewDetailInner, {}),
|
|
21
|
-
children
|
|
22
|
-
] });
|
|
20
|
+
], children });
|
|
23
21
|
}
|
|
24
|
-
const
|
|
22
|
+
const CurdViewDetailDefault = () => {
|
|
25
23
|
var _a, _b, _c, _d;
|
|
26
24
|
const [slugPath] = useAtom(curdDetailSlugAtom);
|
|
27
|
-
const
|
|
28
|
-
const path2 = slugPath.split("/");
|
|
29
|
-
if (path2.length >= 2) {
|
|
30
|
-
return path2[2];
|
|
31
|
-
}
|
|
32
|
-
}, [slugPath]);
|
|
25
|
+
const nameSlug = useCurdSlugName();
|
|
33
26
|
const detailQuery = useSuspenseQuery(curdDetail, {
|
|
34
|
-
slug
|
|
27
|
+
slug: nameSlug
|
|
28
|
+
});
|
|
29
|
+
const curdGetQuery = useSuspenseQuery(curdViewGet, {
|
|
30
|
+
name: nameSlug
|
|
35
31
|
});
|
|
36
32
|
if ((_b = (_a = detailQuery.data) == null ? void 0 : _a.detailView) == null ? void 0 : _b.form) {
|
|
37
33
|
return /* @__PURE__ */ jsx(
|
|
@@ -44,7 +40,10 @@ const CurdViewDetailInner = () => {
|
|
|
44
40
|
}
|
|
45
41
|
);
|
|
46
42
|
}
|
|
47
|
-
return /* @__PURE__ */
|
|
43
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
44
|
+
/* @__PURE__ */ jsx("pre", { children: JSON.stringify(detailQuery.data, null, 2) }),
|
|
45
|
+
/* @__PURE__ */ jsx("pre", { children: JSON.stringify(curdGetQuery.data, null, 2) })
|
|
46
|
+
] });
|
|
48
47
|
};
|
|
49
48
|
const DetailViewActions = () => {
|
|
50
49
|
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
@@ -58,7 +57,8 @@ const DetailViewActions = () => {
|
|
|
58
57
|
] });
|
|
59
58
|
};
|
|
60
59
|
export {
|
|
61
|
-
|
|
60
|
+
CurdViewDetailDefault,
|
|
61
|
+
CurdViewDetailProvider,
|
|
62
62
|
DetailViewActions,
|
|
63
63
|
curdDetailSlugAtom
|
|
64
64
|
};
|
|
@@ -22,6 +22,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
22
22
|
import { atom } from "jotai";
|
|
23
23
|
import { CommontListRes } from "../gomtmpb/mtm/sppb/mtm_pb";
|
|
24
24
|
import { gomtmBaseUrlAtom } from "../providers/GomtmProvider";
|
|
25
|
+
import { usePathname } from "next/navigation";
|
|
26
|
+
import { useMemo } from "react";
|
|
25
27
|
const curdDashPathPrefixAtom = atom("/gomtmadmin");
|
|
26
28
|
const curdActivateIdAtom = atom("");
|
|
27
29
|
const curd3ListParamsAtom = atom({});
|
|
@@ -36,10 +38,21 @@ const curd3ItemsV2Atom = atom((get) => __async(void 0, null, function* () {
|
|
|
36
38
|
const data2 = CommontListRes.fromJson(data);
|
|
37
39
|
return data2;
|
|
38
40
|
}));
|
|
41
|
+
const useCurdSlugName = () => {
|
|
42
|
+
const pathname = usePathname();
|
|
43
|
+
const nameSlug = useMemo(() => {
|
|
44
|
+
const a = pathname.split("/");
|
|
45
|
+
if (a.length >= 2) {
|
|
46
|
+
return a[2];
|
|
47
|
+
}
|
|
48
|
+
}, [pathname]);
|
|
49
|
+
return nameSlug;
|
|
50
|
+
};
|
|
39
51
|
export {
|
|
40
52
|
curd3ItemsV2Atom,
|
|
41
53
|
curd3ListParamsAtom,
|
|
42
54
|
curdActivateIdAtom,
|
|
43
55
|
curdDashPathPrefixAtom,
|
|
44
|
-
curdPathAtom
|
|
56
|
+
curdPathAtom,
|
|
57
|
+
useCurdSlugName
|
|
45
58
|
};
|
|
@@ -44,7 +44,7 @@ const CommonListItemView = (props) => {
|
|
|
44
44
|
// item.id == curd.activateId && " font-bold"
|
|
45
45
|
),
|
|
46
46
|
"aria-label": item.id,
|
|
47
|
-
children: /* @__PURE__ */ jsxs(MtLink, { href: `/
|
|
47
|
+
children: /* @__PURE__ */ jsxs(MtLink, { href: `/admin/${slug}/${item.id}`, children: [
|
|
48
48
|
item.title || item.id,
|
|
49
49
|
item.description && /* @__PURE__ */ jsx("div", { children: item.description })
|
|
50
50
|
] })
|
|
@@ -103,6 +103,7 @@ const gomtmFetcher = (initGlobal) => {
|
|
|
103
103
|
}), headerCookie && { "Cookie": headerCookie })
|
|
104
104
|
});
|
|
105
105
|
let fetcher = fetch;
|
|
106
|
+
req.enableCache = false;
|
|
106
107
|
if (req.enableCache) {
|
|
107
108
|
fetcher = fetchMiddleWithCache(fetch);
|
|
108
109
|
}
|
|
@@ -110,7 +111,11 @@ const gomtmFetcher = (initGlobal) => {
|
|
|
110
111
|
const responseData = yield fetcher(input, init);
|
|
111
112
|
return responseData;
|
|
112
113
|
} catch (e) {
|
|
113
|
-
console.error("mtmfetch error",
|
|
114
|
+
console.error("[mtmfetch error]", {
|
|
115
|
+
input,
|
|
116
|
+
error: e,
|
|
117
|
+
init
|
|
118
|
+
});
|
|
114
119
|
const errorRsp = {
|
|
115
120
|
errCode: "-1",
|
|
116
121
|
errMessage: (e == null ? void 0 : e.toString()) || "unknow error"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useSuspenseQuery } from "../connectquery";
|
|
4
|
+
import { curdViewGet } from "../gomtmpb/mtm/sppb/mtm-MtmService_connectquery";
|
|
5
|
+
import { useCurdSlugName } from "./hooks";
|
|
6
|
+
const GomtmCurdDetailView = () => {
|
|
7
|
+
const nameSlug = useCurdSlugName();
|
|
8
|
+
const curdGetQuery = useSuspenseQuery(curdViewGet, {
|
|
9
|
+
name: nameSlug
|
|
10
|
+
});
|
|
11
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "bg-blue-200 p-2", children: [
|
|
12
|
+
"nameSlug:",
|
|
13
|
+
nameSlug,
|
|
14
|
+
/* @__PURE__ */ jsx("pre", { children: JSON.stringify(curdGetQuery.data, null, 2) })
|
|
15
|
+
] }) });
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
GomtmCurdDetailView
|
|
19
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useSuspenseQuery } from "../connectquery";
|
|
4
|
+
import { ListItemView } from "../curd/list-item/ListItem";
|
|
5
|
+
import { curdList } from "../gomtmpb/mtm/sppb/curd-CurdService_connectquery";
|
|
6
|
+
import { useCurdSlugName } from "./hooks";
|
|
7
|
+
const GomtmCurdListView = () => {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
const slugName = useCurdSlugName();
|
|
10
|
+
const listQuery = useSuspenseQuery(curdList, {
|
|
11
|
+
params: {
|
|
12
|
+
slugs: slugName
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
return /* @__PURE__ */ jsx("div", { className: " bg-cyan-500", children: ((_a = listQuery.data.error) == null ? void 0 : _a.code) ? /* @__PURE__ */ jsxs("div", { children: [
|
|
16
|
+
"error: ",
|
|
17
|
+
listQuery.data.error.code
|
|
18
|
+
] }) : /* @__PURE__ */ jsx(Fragment, { children: (_b = listQuery.data.items) == null ? void 0 : _b.map((item, i) => {
|
|
19
|
+
return /* @__PURE__ */ jsx(ListItemView, { item }, i);
|
|
20
|
+
}) }) });
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
GomtmCurdListView
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useCurdSlugName: () => string | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { usePathname } from "next/navigation";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
const useCurdSlugName = () => {
|
|
5
|
+
const pathname = usePathname();
|
|
6
|
+
const nameSlug = useMemo(() => {
|
|
7
|
+
const a = pathname.split("/");
|
|
8
|
+
if (a.length >= 2) {
|
|
9
|
+
return a[2];
|
|
10
|
+
}
|
|
11
|
+
}, [pathname]);
|
|
12
|
+
return nameSlug;
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
useCurdSlugName
|
|
16
|
+
};
|
|
@@ -24,8 +24,9 @@ const curd3BackendUrlAtom = atom((get) => {
|
|
|
24
24
|
});
|
|
25
25
|
const transportAtom = atom((get) => {
|
|
26
26
|
const baseUrl = get(curd3BackendUrlAtom);
|
|
27
|
+
const baseUrl2 = new URL("/api", baseUrl).toString();
|
|
27
28
|
return createConnectTransport({
|
|
28
|
-
baseUrl,
|
|
29
|
+
baseUrl: baseUrl2,
|
|
29
30
|
fetch: gomtmFetcher()
|
|
30
31
|
});
|
|
31
32
|
});
|