From b19d1c2efedba30e6834d2b1e5079be5c0d05da5 Mon Sep 17 00:00:00 2001 From: Eric Date: Sat, 10 Dec 2022 09:30:07 +0100 Subject: [PATCH] suppression fichier d'exemple --- .vscode/settings.json | 5 + pages/_fichier_exemple_/api/post/[id].ts | 26 --- pages/_fichier_exemple_/api/post/index.ts | 25 --- pages/_fichier_exemple_/api/profile/index.ts | 34 ---- pages/_fichier_exemple_/api/publish/[id].ts | 19 --- pages/_fichier_exemple_/create.tsx | 81 --------- pages/_fichier_exemple_/drafts.tsx | 78 --------- pages/_fichier_exemple_/p/[id].tsx | 91 ---------- pages/_fichier_exemple_/profile.tsx | 171 ------------------- pages/admin.tsx | 2 +- 10 files changed, 6 insertions(+), 526 deletions(-) delete mode 100644 pages/_fichier_exemple_/api/post/[id].ts delete mode 100644 pages/_fichier_exemple_/api/post/index.ts delete mode 100644 pages/_fichier_exemple_/api/profile/index.ts delete mode 100644 pages/_fichier_exemple_/api/publish/[id].ts delete mode 100644 pages/_fichier_exemple_/create.tsx delete mode 100644 pages/_fichier_exemple_/drafts.tsx delete mode 100644 pages/_fichier_exemple_/p/[id].tsx delete mode 100644 pages/_fichier_exemple_/profile.tsx diff --git a/.vscode/settings.json b/.vscode/settings.json index 7a73a41..297b8d0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,2 +1,7 @@ { + "workbench.colorCustomizations": { + "activityBar.background": "#4C1F25", + "titleBar.activeBackground": "#6A2C34", + "titleBar.activeForeground": "#FEFCFC" + } } \ No newline at end of file diff --git a/pages/_fichier_exemple_/api/post/[id].ts b/pages/_fichier_exemple_/api/post/[id].ts deleted file mode 100644 index c25f56c..0000000 --- a/pages/_fichier_exemple_/api/post/[id].ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { NextApiRequest, NextApiResponse } from 'next' -import { getSession } from 'next-auth/react'; -import prisma from '../../../../lib/prisma' - - -// DELETE /api/post/:id -export default async function handle(req: NextApiRequest, res: NextApiResponse) { - const postId = req.query.id; - - const session = await getSession({ req }) - - if (req.method === "DELETE") { - if (session) { - const post = await prisma.post.delete({ - where: { id: Number(postId) }, - }); - res.json(post); - } else { - res.status(401).send({ message: 'Unauthorized' }) - } - } else { - throw new Error( - `The HTTP ${req.method} method is not supported at this route.` - ); - } -} diff --git a/pages/_fichier_exemple_/api/post/index.ts b/pages/_fichier_exemple_/api/post/index.ts deleted file mode 100644 index 3f8b12e..0000000 --- a/pages/_fichier_exemple_/api/post/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { NextApiRequest, NextApiResponse } from 'next' -import prisma from '../../../../lib/prisma' -import { getSession } from 'next-auth/react' - - -// POST /api/post -// Required fields in body: title -// Optional fields in body: content -export default async function handle(req: NextApiRequest, res: NextApiResponse) { - const { title, content } = req.body; - - const session = await getSession({ req }); - if (session) { - const result = await prisma.post.create({ - data: { - title: title, - content: content, - author: { connect: { email: session?.user?.email } }, - }, - }); - res.json(result); - } else { - res.status(401).send({ message: 'Unauthorized' }) - } -} diff --git a/pages/_fichier_exemple_/api/profile/index.ts b/pages/_fichier_exemple_/api/profile/index.ts deleted file mode 100644 index 2d03ede..0000000 --- a/pages/_fichier_exemple_/api/profile/index.ts +++ /dev/null @@ -1,34 +0,0 @@ -import type { NextApiRequest, NextApiResponse } from 'next' -import prisma from '../../../../lib/prisma' -import { getSession } from 'next-auth/react' - - -// UPDATE /api/profile -// Required fields in body: title -export default async function handle(req: NextApiRequest, res: NextApiResponse) { - const { bioValue } = req.body; - console.log('server biovalue:', bioValue) - const session = await getSession({ req }); - - if (req.method === "PUT") { - if (session) { - const updateUserProfil = await prisma.user.update({ - where: { email: session.user.email }, - data: { - profile: { - update: { - bio: bioValue, - }, - }, - } - }) - res.status(200).send({ result: updateUserProfil, message: 'Profiled updated !' }); - } else { - res.status(401).send({ message: 'Unauthorized' }) - } - } else { - throw new Error( - `The HTTP ${req.method} method is not supported at this route.` - ); - } -} \ No newline at end of file diff --git a/pages/_fichier_exemple_/api/publish/[id].ts b/pages/_fichier_exemple_/api/publish/[id].ts deleted file mode 100644 index 3d1f064..0000000 --- a/pages/_fichier_exemple_/api/publish/[id].ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { NextApiRequest, NextApiResponse } from 'next' -import { getSession } from 'next-auth/react'; -import prisma from '../../../../lib/prisma' - -// PUT /api/publish/:id -export default async function handle(req: NextApiRequest, res: NextApiResponse) { - const postId = req.query.id; - const session = await getSession({ req }) - - if (session) { - const post = await prisma.post.update({ - where: { id: Number(postId) }, - data: { published: true }, - }); - res.json(post); - } else { - res.status(401).send({ message: 'Unauthorized' }) - } -} diff --git a/pages/_fichier_exemple_/create.tsx b/pages/_fichier_exemple_/create.tsx deleted file mode 100644 index d9f8b1a..0000000 --- a/pages/_fichier_exemple_/create.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import React, { useState } from "react"; -import Layout from "../../components/Layout"; -import Router from "next/router"; - -const Draft = () => { - const [title, setTitle] = useState(""); - const [content, setContent] = useState(""); - - const submitData = async (e: React.SyntheticEvent) => { - e.preventDefault(); - try { - const body = { title, content }; - await fetch(`/api/post`, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify(body), - }); - await Router.push("/drafts"); - } catch (error) { - console.error(error); - } - }; - - return ( - -
-
-

New Draft

- setTitle(e.target.value)} - placeholder="Title" - type="text" - value={title} - /> -