Compare commits
No commits in common. "da165ddf5e48cf8077931d072cc95d61089cab6b" and "30e62b397d0e8d6ee1462a315a490f7939805452" have entirely different histories.
da165ddf5e
...
30e62b397d
@ -2,8 +2,8 @@
|
||||
cache: "no-store";
|
||||
import AuthHandler from "@/components/server/admin/authHandler";
|
||||
import Sidebar, { SidebarEntry } from "@/components/server/admin/views/sidebar";
|
||||
import { ProjectView } from "@/views/admin/project";
|
||||
import { PostView } from "@/views/admin/post";
|
||||
import ProjectView from "@/views/admin/ProjectView";
|
||||
import PostView from "@/views/admin/PostView";
|
||||
import { redirect } from 'next/navigation'
|
||||
|
||||
function Home() {
|
||||
|
||||
16
src/components/auth/authComponents.tsx
Normal file
16
src/components/auth/authComponents.tsx
Normal file
@ -0,0 +1,16 @@
|
||||
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,8 +18,7 @@ import {
|
||||
GetPostsAttributes,
|
||||
PostServerActions,
|
||||
} from "@/app/lib/actions/entityManagement/post/postActions";
|
||||
|
||||
import { PostViewProps } from "@/views/admin/post";
|
||||
import { PostViewProps } from "@/views/admin/ClientPostView";
|
||||
import { aifa, StateHook } from "@/util/";
|
||||
|
||||
export type PostTableStateProps = {
|
||||
|
||||
61
src/views/admin/PostView.tsx
Normal file
61
src/views/admin/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 "./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>
|
||||
);
|
||||
}
|
||||
@ -1,7 +1,9 @@
|
||||
cache: "no-store";
|
||||
|
||||
import { tryFetchPosts } from "@/app/api/post/route";
|
||||
import { constructAPIUrl } from "@/util/utils";
|
||||
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 {
|
||||
deletePost,
|
||||
@ -26,7 +28,7 @@ async function getHeadings() {
|
||||
return headings;
|
||||
}
|
||||
|
||||
export async function ProjectView(props: Props) {
|
||||
export default async function ProjectView(props: Props) {
|
||||
const sync = await dbSync;
|
||||
|
||||
const actions = {
|
||||
@ -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 "@/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>
|
||||
);
|
||||
}
|
||||
@ -1,2 +0,0 @@
|
||||
export * from './CPostView';
|
||||
export * from './PostView';
|
||||
@ -1,2 +0,0 @@
|
||||
export * from './CProjectView';
|
||||
export * from './ProjectView';
|
||||
Loading…
x
Reference in New Issue
Block a user