From dedcbe97fc0215feb4906bf92dcea1b15a47cefc Mon Sep 17 00:00:00 2001 From: Eddie Jaoude Date: Tue, 25 Jun 2024 06:54:25 +0100 Subject: [PATCH] feat: platform to have custom title --- .../20240625055033_platform_title/migration.sql | 2 ++ prisma/schema.prisma | 1 + src/app/[username]/page.js | 6 +----- src/app/account/platforms/action.js | 13 ++++++++++++- src/app/account/platforms/form.js | 7 +++++++ src/app/account/platforms/page.js | 6 +----- src/models/Platform.js | 2 ++ 7 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 prisma/migrations/20240625055033_platform_title/migration.sql diff --git a/prisma/migrations/20240625055033_platform_title/migration.sql b/prisma/migrations/20240625055033_platform_title/migration.sql new file mode 100644 index 0000000..7463730 --- /dev/null +++ b/prisma/migrations/20240625055033_platform_title/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Platform" ADD COLUMN "title" TEXT; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 55bb79a..1efac02 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -100,6 +100,7 @@ model Platform { price Int url String example String? + title String? description String? user User @relation(fields: [userId], references: [id], onDelete: Cascade) diff --git a/src/app/[username]/page.js b/src/app/[username]/page.js index 44d5e74..2731504 100644 --- a/src/app/[username]/page.js +++ b/src/app/[username]/page.js @@ -100,11 +100,7 @@ export default async function Page({ params }) { id: platform.id, icon: platform.name, url: platform.example, - urlText: `${REACH().data[platform.reach].name} on ${ - PLATFORMS().data[platform.name].display - } with ${REACH().data[platform.reach].group} ($${ - platform.price - })`, + urlText: platform.title ? platform.title : platform.name, description: platform.description, meta: [ { diff --git a/src/app/account/platforms/action.js b/src/app/account/platforms/action.js index 2619083..9c6187d 100644 --- a/src/app/account/platforms/action.js +++ b/src/app/account/platforms/action.js @@ -15,6 +15,7 @@ export async function platformUpdate(prevState, formData) { const price = Number(formData.get("price")); const url = formData.get("url"); const example = formData.get("example"); + const title = formData.get("title"); const description = formData.get("description"); // check authentication @@ -23,7 +24,15 @@ export async function platformUpdate(prevState, formData) { throw new Error("Not authenticated"); } - const validate = Platform({ name, reach, price, url, description, example }); + const validate = Platform({ + name, + reach, + price, + url, + description, + example, + title, + }); if (!validate.success) { return validate; @@ -43,6 +52,7 @@ export async function platformUpdate(prevState, formData) { url, description, example, + title, }, }); } else { @@ -59,6 +69,7 @@ export async function platformUpdate(prevState, formData) { url, description, example, + title, }, }); } diff --git a/src/app/account/platforms/form.js b/src/app/account/platforms/form.js index 9ea6f77..cdd39d0 100644 --- a/src/app/account/platforms/form.js +++ b/src/app/account/platforms/form.js @@ -89,6 +89,13 @@ export default function Form({ data }) { value={edit.example} /> + +