Compare commits
3 Commits
30e62b397d
...
da165ddf5e
| Author | SHA1 | Date | |
|---|---|---|---|
| da165ddf5e | |||
| 24b16aa6df | |||
| 772395ae1a |
@ -2,8 +2,8 @@
|
|||||||
cache: "no-store";
|
cache: "no-store";
|
||||||
import AuthHandler from "@/components/server/admin/authHandler";
|
import AuthHandler from "@/components/server/admin/authHandler";
|
||||||
import Sidebar, { SidebarEntry } from "@/components/server/admin/views/sidebar";
|
import Sidebar, { SidebarEntry } from "@/components/server/admin/views/sidebar";
|
||||||
import ProjectView from "@/views/admin/ProjectView";
|
import { ProjectView } from "@/views/admin/project";
|
||||||
import PostView from "@/views/admin/PostView";
|
import { PostView } from "@/views/admin/post";
|
||||||
import { redirect } from 'next/navigation'
|
import { redirect } from 'next/navigation'
|
||||||
|
|
||||||
function Home() {
|
function Home() {
|
||||||
|
|||||||
@ -1,16 +0,0 @@
|
|||||||
import { AuthContext } from "@/providers/providers";
|
|
||||||
import { ReactNode, useContext } from "react"
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
children:ReactNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default function AdminOnlyComponent(p:Props){
|
|
||||||
const context = useContext(AuthContext)
|
|
||||||
return
|
|
||||||
(<div>
|
|
||||||
|
|
||||||
</div>);
|
|
||||||
}
|
|
||||||
@ -18,7 +18,8 @@ import {
|
|||||||
GetPostsAttributes,
|
GetPostsAttributes,
|
||||||
PostServerActions,
|
PostServerActions,
|
||||||
} from "@/app/lib/actions/entityManagement/post/postActions";
|
} from "@/app/lib/actions/entityManagement/post/postActions";
|
||||||
import { PostViewProps } from "@/views/admin/ClientPostView";
|
|
||||||
|
import { PostViewProps } from "@/views/admin/post";
|
||||||
import { aifa, StateHook } from "@/util/";
|
import { aifa, StateHook } from "@/util/";
|
||||||
|
|
||||||
export type PostTableStateProps = {
|
export type PostTableStateProps = {
|
||||||
|
|||||||
@ -1,61 +0,0 @@
|
|||||||
'use server'
|
|
||||||
cache: "no-store";
|
|
||||||
|
|
||||||
import { ReactNode, useEffect } from "react";
|
|
||||||
import PostTable from "@/components/client/admin/PostTable";
|
|
||||||
import {
|
|
||||||
deletePost,
|
|
||||||
getPostsWithBucketsAndProject,
|
|
||||||
updatePost,
|
|
||||||
GetPostsAttributes,
|
|
||||||
PostServerActions,
|
|
||||||
} from "@/app/lib/actions/entityManagement/post/postActions";
|
|
||||||
import { getProjects } from "@/app/lib/actions/entityManagement/post/projectActions";
|
|
||||||
import { Bucket, Project, Post, dbSync, Attachment } from "@/models";
|
|
||||||
import { handleActionResult } from "../../app/lib/actions/clientActionHandler";
|
|
||||||
import { ClientPostView } from "./ClientPostView";
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
children?: ReactNode;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default async function PostView(props: Props) {
|
|
||||||
const sync = await dbSync;
|
|
||||||
|
|
||||||
const headings:string[] = [
|
|
||||||
"#",
|
|
||||||
"Title",
|
|
||||||
"Content",
|
|
||||||
"Project",
|
|
||||||
"CreatedAt",
|
|
||||||
"UpdatedAt",
|
|
||||||
];
|
|
||||||
|
|
||||||
const actions: PostServerActions = {
|
|
||||||
deletePost: deletePost,
|
|
||||||
getPosts: getPostsWithBucketsAndProject,
|
|
||||||
getProjects: getProjects,
|
|
||||||
savePost: updatePost,
|
|
||||||
// uploadAttachment:tryCreateAttachment
|
|
||||||
};
|
|
||||||
|
|
||||||
const posts: GetPostsAttributes[]| undefined = handleActionResult(
|
|
||||||
await getPostsWithBucketsAndProject()
|
|
||||||
);
|
|
||||||
const projects = await Project.findAll().then((projects) =>
|
|
||||||
projects.map((project) => JSON.parse(JSON.stringify(project)))
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="w-[100%] min-h-fit bg-gray-100 overflow-scroll">
|
|
||||||
<div className="w-[100%] m-auto">
|
|
||||||
<ClientPostView
|
|
||||||
posts={posts ? posts : []}
|
|
||||||
projects={projects}
|
|
||||||
headings={headings}
|
|
||||||
actions={actions}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
61
src/views/admin/post/PostView.tsx
Normal file
61
src/views/admin/post/PostView.tsx
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
"use server";
|
||||||
|
cache: "no-store";
|
||||||
|
|
||||||
|
import { ReactNode, useEffect } from "react";
|
||||||
|
import PostTable from "@/components/client/admin/PostTable";
|
||||||
|
import {
|
||||||
|
deletePost,
|
||||||
|
getPostsWithBucketsAndProject,
|
||||||
|
updatePost,
|
||||||
|
GetPostsAttributes,
|
||||||
|
PostServerActions,
|
||||||
|
} from "@/app/lib/actions/entityManagement/post/postActions";
|
||||||
|
import { getProjects } from "@/app/lib/actions/entityManagement/post/projectActions";
|
||||||
|
import { Bucket, Project, Post, dbSync, Attachment } from "@/models";
|
||||||
|
import { handleActionResult } from "@/app/lib/actions/clientActionHandler";
|
||||||
|
import { ClientPostView } from "@/views/admin/post";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
children?: ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function PostView(props: Props) {
|
||||||
|
const sync = await dbSync;
|
||||||
|
|
||||||
|
const headings: string[] = [
|
||||||
|
"#",
|
||||||
|
"Title",
|
||||||
|
"Content",
|
||||||
|
"Project",
|
||||||
|
"CreatedAt",
|
||||||
|
"UpdatedAt",
|
||||||
|
];
|
||||||
|
|
||||||
|
const actions: PostServerActions = {
|
||||||
|
deletePost: deletePost,
|
||||||
|
getPosts: getPostsWithBucketsAndProject,
|
||||||
|
getProjects: getProjects,
|
||||||
|
savePost: updatePost,
|
||||||
|
// uploadAttachment:tryCreateAttachment
|
||||||
|
};
|
||||||
|
|
||||||
|
const posts: GetPostsAttributes[] | undefined = handleActionResult(
|
||||||
|
await getPostsWithBucketsAndProject()
|
||||||
|
);
|
||||||
|
const projects = await Project.findAll().then((projects) =>
|
||||||
|
projects.map((project) => JSON.parse(JSON.stringify(project)))
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="w-[100%] min-h-fit bg-gray-100 overflow-scroll">
|
||||||
|
<div className="w-[100%] m-auto">
|
||||||
|
<ClientPostView
|
||||||
|
posts={posts ? posts : []}
|
||||||
|
projects={projects}
|
||||||
|
headings={headings}
|
||||||
|
actions={actions}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
2
src/views/admin/post/index.ts
Normal file
2
src/views/admin/post/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from './CPostView';
|
||||||
|
export * from './PostView';
|
||||||
0
src/views/admin/project/CProjectView.tsx
Normal file
0
src/views/admin/project/CProjectView.tsx
Normal file
@ -1,9 +1,7 @@
|
|||||||
cache: "no-store";
|
cache: "no-store";
|
||||||
|
|
||||||
import { tryFetchPosts } from "@/app/api/post/route";
|
|
||||||
import { constructAPIUrl } from "@/util/utils";
|
|
||||||
import { ReactNode, useEffect } from "react";
|
import { ReactNode, useEffect } from "react";
|
||||||
import EntityManagementTable from "../../components/client/EntityManagementTable";
|
import EntityManagementTable from "../../../components/client/EntityManagementTable";
|
||||||
import PostTable from "@/components/client/admin/PostTable";
|
import PostTable from "@/components/client/admin/PostTable";
|
||||||
import {
|
import {
|
||||||
deletePost,
|
deletePost,
|
||||||
@ -28,7 +26,7 @@ async function getHeadings() {
|
|||||||
return headings;
|
return headings;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function ProjectView(props: Props) {
|
export async function ProjectView(props: Props) {
|
||||||
const sync = await dbSync;
|
const sync = await dbSync;
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
2
src/views/admin/project/index.ts
Normal file
2
src/views/admin/project/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export * from './CProjectView';
|
||||||
|
export * from './ProjectView';
|
||||||
0
src/views/admin/template/CTemplateView.tsx
Normal file
0
src/views/admin/template/CTemplateView.tsx
Normal file
0
src/views/admin/template/TemplateView.tsx
Normal file
0
src/views/admin/template/TemplateView.tsx
Normal file
Loading…
x
Reference in New Issue
Block a user