diff --git a/prisma/migrations/20250427204315_giveaway_update/migration.sql b/prisma/migrations/20250427204315_giveaway_update/migration.sql new file mode 100644 index 0000000..cfe081c --- /dev/null +++ b/prisma/migrations/20250427204315_giveaway_update/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Giveaway" ADD COLUMN "entryCost" INTEGER NOT NULL DEFAULT 7000000; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 5a0571d..b727e97 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -64,6 +64,7 @@ model Giveaway { prize String active Boolean @default(true) createdAt DateTime @default(now()) + entryCost Int @default(7000000) entries Entry[] } diff --git a/src/app/giveaways/page.tsx b/src/app/giveaways/page.tsx index 384f0e7..4cbb7d1 100644 --- a/src/app/giveaways/page.tsx +++ b/src/app/giveaways/page.tsx @@ -1,23 +1,33 @@ import { getServerSession } from "next-auth"; import { authOptions } from "../api/auth/[...nextauth]/route"; import { db } from "@/lib/db"; -import { redirect } from "next/navigation"; +import GiveawayCard from "@/components/GiveawayCard"; + +export default async function GiveawaysPage() { + // Fetch giveaways from the database + const giveaways = await db.giveaway.findMany({ + where: { active: true }, + select: { + id: true, + title: true, + description: true, + prize: true, + }, + }); -export default async function ProfilePage() { return (
-
-
- {/* Profile Header */} -
-
-
-
-
-

{"Giveaway page"}

-
-
-
+
+

Active Giveaways

+
+ {giveaways.map((giveaway) => ( + + ))}
diff --git a/src/components/GiveawayCard.tsx b/src/components/GiveawayCard.tsx index 141eb43..9f5e26d 100644 --- a/src/components/GiveawayCard.tsx +++ b/src/components/GiveawayCard.tsx @@ -8,10 +8,12 @@ interface GiveawayCardProps { const GiveawayCard: React.FC = ({ title, description, imageUrl }) => { return ( -
- {title} -

{title}

-

{description}

+
+ {title} +
+

{title}

+

{description}

+
); };