push work
This commit is contained in:
parent
7312ab632c
commit
d8d0aaa90e
@ -1,11 +1,14 @@
|
||||
'use server';
|
||||
"use server";
|
||||
import { Project } from "@/models";
|
||||
import { ActionResult } from "../../ActionResult";
|
||||
import { Attributes } from "@sequelize/core";
|
||||
import { userIsAdmin } from "../../actions";
|
||||
|
||||
export async function getProjects(): Promise<ActionResult<Attributes<Project>[]>> {
|
||||
if (! await userIsAdmin()) return { error: 'Unauthorized, not fetching Projects' }
|
||||
export async function getProjects(): Promise<
|
||||
ActionResult<Attributes<Project>[]>
|
||||
> {
|
||||
if (!(await userIsAdmin()))
|
||||
return { error: "Unauthorized, not fetching Projects" };
|
||||
const posts = await Project.findAll();
|
||||
return { result: JSON.parse(JSON.stringify(posts)) };
|
||||
}
|
||||
|
||||
@ -12,12 +12,10 @@ import {
|
||||
PostAttributesWithBuckets,
|
||||
} from "@/models";
|
||||
import { handleActionResult } from "@/app/lib/actions/clientActionHandler";
|
||||
|
||||
import {
|
||||
getPostsWithBucketsAndProject,
|
||||
GetPostsAttributes,
|
||||
} from "@/app/lib/actions/entitymanagement/post/postActions";
|
||||
|
||||
import { PostViewProps } from "@/components/views/admin/post";
|
||||
import { StateHook } from "@/util/";
|
||||
|
||||
@ -67,9 +65,7 @@ export default function PostTable({
|
||||
.getPosts() // Get Posts From Server
|
||||
.then((getPostsServerActionResult) => {
|
||||
// Handle Result and toast error on failure
|
||||
const result = handleActionResult(
|
||||
getPostsServerActionResult
|
||||
);
|
||||
const result = handleActionResult(getPostsServerActionResult);
|
||||
// Set Posts state
|
||||
if (result) state.posts.setState(result);
|
||||
});
|
||||
@ -123,9 +119,7 @@ export default function PostTable({
|
||||
key="editbutton"
|
||||
type="button"
|
||||
className="btn btn-primary"
|
||||
onClick={() =>
|
||||
editorControls.showEditor(post)
|
||||
}
|
||||
onClick={() => editorControls.showEditor(post)}
|
||||
>
|
||||
Edit
|
||||
</button>
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
"use client";
|
||||
|
||||
import PostTable, {
|
||||
PostTableStateProps,
|
||||
} from "@/components/client/admin/PostTable";
|
||||
|
||||
@ -48,7 +48,7 @@ export async function PostView(props: Props) {
|
||||
deletePost: deletePost,
|
||||
getPosts: getPostsWithBucketsAndProject,
|
||||
getProjects: getProjects,
|
||||
savePost: updatePost
|
||||
savePost: updatePost,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user