Skip to content

Commit

Permalink
done Issue #45 #46
Browse files Browse the repository at this point in the history
  • Loading branch information
minhphuc010194 committed Aug 28, 2023
1 parent 5134cce commit 6a949ee
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion prisma/migrations/20230715184123_init/migration.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/components/TextEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Editor as TinyMCEEditor } from 'tinymce';
type PropTypes = {
value?: string;
onChange?: (value: string) => void;

};

export const TextEditor: FC<PropTypes> = ({ value, onChange }) => {
Expand All @@ -14,7 +15,7 @@ export const TextEditor: FC<PropTypes> = ({ value, onChange }) => {
<Editor
onInit={(evt, editor) => (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,
Expand Down
5 changes: 3 additions & 2 deletions src/pages/api/pages/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ export default async function handler(
req: NextApiRequest,
res: NextApiResponse<Post[] | Post>
) {

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),
});
Expand Down

0 comments on commit 6a949ee

Please sign in to comment.