Compare commits

..

3 Commits

Author SHA1 Message Date
da165ddf5e Merge branch 'master' of https://git.subsonics.nl/andreas/portfolio2023 2024-07-02 19:57:49 +02:00
24b16aa6df More refactoring 2024-07-02 19:56:17 +02:00
772395ae1a More refactoring 2024-07-02 19:56:03 +02:00
12 changed files with 71 additions and 84 deletions

View File

@ -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() {

View File

@ -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>);
}

View File

@ -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 = {

View File

@ -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>
);
}

View 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>
);
}

View File

@ -0,0 +1,2 @@
export * from './CPostView';
export * from './PostView';

View File

View 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 = {

View File

@ -0,0 +1,2 @@
export * from './CProjectView';
export * from './ProjectView';