diff --git a/package.json b/package.json index 9808f46..9862756 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "react-dom": "18.2.0", "react-icons": "4.10.1", "react-virtuoso": "4.5.0", - "swr": "2.2.1" + "swr": "2.2.1", + "tinymce": "^6.6.2" }, "devDependencies": { "@tanstack/react-table": "8.9.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 284b90b..8535be9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -71,6 +71,9 @@ dependencies: swr: specifier: 2.2.1 version: 2.2.1(react@18.2.0) + tinymce: + specifier: ^6.6.2 + version: 6.6.2 devDependencies: '@tanstack/react-table': diff --git a/prisma/migrations/20230715184123_init/migration.sql b/prisma/migrations/20230715184123_init/migration.sql index 1b7176d..ab41cc8 100644 --- a/prisma/migrations/20230715184123_init/migration.sql +++ b/prisma/migrations/20230715184123_init/migration.sql @@ -39,7 +39,7 @@ CREATE TABLE "User" ( -- CreateTable CREATE TABLE "Post" ( "id" TEXT NOT NULL, - "title": TEXT, + "title" TEXT, "createdAt" TIMESTAMP(3) NOT NULL, "updatedAt" TIMESTAMP(3) NOT NULL, "published" BOOLEAN, diff --git a/src/components/TextEditor/index.tsx b/src/components/TextEditor/index.tsx index 792c56b..b07377c 100644 --- a/src/components/TextEditor/index.tsx +++ b/src/components/TextEditor/index.tsx @@ -5,6 +5,7 @@ import { Editor as TinyMCEEditor } from 'tinymce'; type PropTypes = { value?: string; onChange?: (value: string) => void; + }; export const TextEditor: FC = ({ value, onChange }) => { @@ -14,7 +15,7 @@ export const TextEditor: FC = ({ value, onChange }) => { (editorRef.current = editor)} apiKey={process.env.NEXT_PUBLIC_API_KEY_TINYMCE} - onEditorChange={(text) => onChange && onChange(text)} + onEditorChange={(text) => onChange&&onChange(text)} initialValue={value} init={{ height: 500, diff --git a/src/pages/api/pages/posts.ts b/src/pages/api/pages/posts.ts index 16e34f6..52f5764 100644 --- a/src/pages/api/pages/posts.ts +++ b/src/pages/api/pages/posts.ts @@ -6,13 +6,14 @@ export default async function handler( req: NextApiRequest, res: NextApiResponse ) { + + console.log("===>",req.method) if (req.method === 'GET') { const posts = await prisma.post.findMany(); - res.status(200).json(posts); } if (req.method === 'POST') { - console.log(req.body); + // console.log(req.body); const newPost = await prisma.post.create({ data: JSON.parse(req.body), });