Skip to content

Commit

Permalink
fix: missing params promise on edit post-page
Browse files Browse the repository at this point in the history
  • Loading branch information
iRevolutionDev committed Dec 9, 2024
1 parent 852756e commit 68eaa6b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
11 changes: 4 additions & 7 deletions src/app/[locale]/dashboard/(main)/posts/[id]/edit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use client";
import { use } from "react";
import type { FC } from "react";

import { PostForm, type PostFormData } from "@/components/post-form";
import {
Expand All @@ -10,17 +10,14 @@ import { CircularProgress } from "@mui/material";
import { useTranslations } from "next-intl";
import { useRouter } from "next/navigation";
import { enqueueSnackbar } from "notistack";
import type { FC } from "react";
import type { SubmitHandler } from "react-hook-form";

type EditPostPageProps = {
params: {
id: string;
};
params: Promise<{ id: string }>;
};

const EditPostPage: FC<EditPostPageProps> = (props) => {
const params = use(props.params);
const EditPostPage: FC<EditPostPageProps> = async (props) => {
const params = await props.params;

const { id } = params;

Expand Down
2 changes: 0 additions & 2 deletions src/app/[locale]/dashboard/(main)/posts/new/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ export default function NewPostPage() {
title,
content,
published,
created_at: new Date().toISOString(),
updated_at: new Date().toISOString(),
})
.unwrap()
.then(() => {
Expand Down
5 changes: 4 additions & 1 deletion src/redux/services/post-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export const postApi = createApi({
listPost: builder.query<Posts, void>({
query: () => ({ url: "/list" }),
}),
createPost: builder.mutation<PostModel, Omit<PostModel, "id" | "author">>({
createPost: builder.mutation<
PostModel,
Omit<PostModel, "id" | "author" | "created_at" | "updated_at">
>({
query: (post) => ({
url: "/create",
options: {
Expand Down

0 comments on commit 68eaa6b

Please sign in to comment.