diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..55bca7e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,32 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Next.js: debug server-side", + "type": "node-terminal", + "request": "launch", + "command": "npm run dev" + }, + { + "name": "Next.js: debug client-side", + "type": "chrome", + "request": "launch", + "url": "http://localhost:3000" + }, + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "skipFiles": [ + "/**" + ], + "program": "${workspaceFolder}\\pages\\moncompte.tsx", + "outFiles": [ + "${workspaceFolder}/**/*.js" + ] + } + ] +} \ No newline at end of file diff --git a/components/Header.tsx b/components/Header.tsx index 5832e00..142795d 100644 --- a/components/Header.tsx +++ b/components/Header.tsx @@ -8,7 +8,7 @@ const Header = () => { const isActive: (pathname: string) => boolean = (pathname) => router.pathname === pathname; - const {data: session, status} = useSession(); + const { data: session, status } = useSession(); let left = (
@@ -124,6 +124,11 @@ const Header = () => { My drafts + + + Mon Compte + + + + ); +}; + +export default Profil; diff --git a/prisma/dev.db b/prisma/dev.db index b8b0f71..4324548 100644 Binary files a/prisma/dev.db and b/prisma/dev.db differ diff --git a/prisma/migrations/20221110093840_/migration.sql b/prisma/migrations/20221110093840_/migration.sql new file mode 100644 index 0000000..276bf9b --- /dev/null +++ b/prisma/migrations/20221110093840_/migration.sql @@ -0,0 +1,10 @@ +-- CreateTable +CREATE TABLE "Profile" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "bio" TEXT, + "userId" INTEGER NOT NULL, + CONSTRAINT "Profile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); + +-- CreateIndex +CREATE UNIQUE INDEX "Profile_userId_key" ON "Profile"("userId"); diff --git a/prisma/migrations/20221110112827_/migration.sql b/prisma/migrations/20221110112827_/migration.sql new file mode 100644 index 0000000..ed4acf4 --- /dev/null +++ b/prisma/migrations/20221110112827_/migration.sql @@ -0,0 +1,21 @@ +/* + Warnings: + + - You are about to drop the `Profile` table. If the table is not empty, all the data it contains will be lost. + +*/ +-- DropTable +PRAGMA foreign_keys=off; +DROP TABLE "Profile"; +PRAGMA foreign_keys=on; + +-- CreateTable +CREATE TABLE "Profil" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "bio" TEXT, + "userId" INTEGER NOT NULL, + CONSTRAINT "Profil_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); + +-- CreateIndex +CREATE UNIQUE INDEX "Profil_userId_key" ON "Profil"("userId"); diff --git a/prisma/migrations/20221110113201_/migration.sql b/prisma/migrations/20221110113201_/migration.sql new file mode 100644 index 0000000..25b5ab9 --- /dev/null +++ b/prisma/migrations/20221110113201_/migration.sql @@ -0,0 +1,21 @@ +/* + Warnings: + + - You are about to drop the `Profil` table. If the table is not empty, all the data it contains will be lost. + +*/ +-- DropTable +PRAGMA foreign_keys=off; +DROP TABLE "Profil"; +PRAGMA foreign_keys=on; + +-- CreateTable +CREATE TABLE "Profile" ( + "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, + "bio" TEXT, + "userId" INTEGER NOT NULL, + CONSTRAINT "Profile_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE +); + +-- CreateIndex +CREATE UNIQUE INDEX "Profile_userId_key" ON "Profile"("userId"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index abc25bb..cbbd836 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -7,15 +7,6 @@ datasource db { url = "file:./dev.db" } -model Post { - id Int @id @default(autoincrement()) - title String - content String? - published Boolean @default(false) - author User? @relation(fields: [authorId], references: [id]) - authorId Int? -} - model Account { id Int @id @default(autoincrement()) userId Int @map("user_id") @@ -59,10 +50,27 @@ model User { posts Post[] accounts Account[] sessions Session[] + profile Profile? @@map(name: "users") } +model Post { + id Int @id @default(autoincrement()) + title String + content String? + published Boolean @default(false) + author User? @relation(fields: [authorId], references: [id]) + authorId Int? +} + +model Profile { + id Int @id @default(autoincrement()) + bio String? + user User? @relation(fields: [userId], references: [id]) + userId Int @unique +} + model VerificationToken { identifier String token String @unique diff --git a/types/post.ts b/types/post.ts new file mode 100644 index 0000000..ff36e2d --- /dev/null +++ b/types/post.ts @@ -0,0 +1,10 @@ +export type PostProps = { + id: number; + title: string; + author: { + name: string; + email: string; + } | null; + content: string; + published: boolean; + }; \ No newline at end of file diff --git a/types/profile.ts b/types/profile.ts new file mode 100644 index 0000000..e42f395 --- /dev/null +++ b/types/profile.ts @@ -0,0 +1,8 @@ +export type ProfileProps = { + id: number; + bio: string; + user: { + name: string; + email: string; + } +}; \ No newline at end of file