Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
feat: platform to have custom title
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiejaoude committed Jun 25, 2024
1 parent 8b84bb4 commit dedcbe9
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 11 deletions.
2 changes: 2 additions & 0 deletions prisma/migrations/20240625055033_platform_title/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Platform" ADD COLUMN "title" TEXT;
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 1 addition & 5 deletions src/app/[username]/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down
13 changes: 12 additions & 1 deletion src/app/account/platforms/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -43,6 +52,7 @@ export async function platformUpdate(prevState, formData) {
url,
description,
example,
title,
},
});
} else {
Expand All @@ -59,6 +69,7 @@ export async function platformUpdate(prevState, formData) {
url,
description,
example,
title,
},
});
}
Expand Down
7 changes: 7 additions & 0 deletions src/app/account/platforms/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ export default function Form({ data }) {
value={edit.example}
/>

<Input
id="title"
name="Title of content"
error={state?.errors?.title}
value={edit.title}
/>

<Textarea
id="description"
name="Description of service"
Expand Down
6 changes: 1 addition & 5 deletions src/app/account/platforms/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ export default async function Page() {
id: platform.id,
icon: platform.name,
url: `?id=${platform.id}`,
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: [
{
Expand Down
2 changes: 2 additions & 0 deletions src/models/Platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default function Platform(platform) {
price: z.number().min(10),
url: z.string().url(),
example: z.string().url(),
title: z.string().max(256),
description: z.string().max(1024),
});

Expand All @@ -19,6 +20,7 @@ export default function Platform(platform) {
price: platform.price,
url: platform.url,
example: platform.example,
title: platform.title,
description: platform.description,
});

Expand Down

0 comments on commit dedcbe9

Please sign in to comment.