This commit is contained in:
Alexandru Eduard Farcas
2025-04-28 01:39:33 +03:00
parent d8da8c839f
commit 4f6455ffbe
4 changed files with 33 additions and 18 deletions
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Giveaway" ADD COLUMN "entryCost" INTEGER NOT NULL DEFAULT 7000000;
+1
View File
@@ -64,6 +64,7 @@ model Giveaway {
prize String prize String
active Boolean @default(true) active Boolean @default(true)
createdAt DateTime @default(now()) createdAt DateTime @default(now())
entryCost Int @default(7000000)
entries Entry[] entries Entry[]
} }
+24 -14
View File
@@ -1,23 +1,33 @@
import { getServerSession } from "next-auth"; import { getServerSession } from "next-auth";
import { authOptions } from "../api/auth/[...nextauth]/route"; import { authOptions } from "../api/auth/[...nextauth]/route";
import { db } from "@/lib/db"; 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 ( return (
<div className="min-h-screen bg-gray-50 py-12 px-4 sm:px-6 lg:px-8"> <div className="min-h-screen bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
<div className="max-w-3xl mx-auto"> <div className="max-w-7xl mx-auto">
<div className="bg-black rounded-2xl shadow-xl overflow-hidden"> <h1 className="text-3xl font-bold text-gray-800 mb-8">Active Giveaways</h1>
{/* Profile Header */} <div className="text-black grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
<div className="bg-gradient-to-r from-purple-600 to-blue-500 p-6"> {giveaways.map((giveaway) => (
<div className="flex items-center space-x-4"> <GiveawayCard
<div className="h-16 w-16 bg-white rounded-full flex items-center justify-center"> key={giveaway.id}
</div> title={giveaway.title}
<div> description={giveaway.description}
<h1 className="text-2xl font-bold text-white">{"Giveaway page"}</h1> imageUrl={giveaway.prize} // Assuming prize is a URL to an image
</div> />
</div> ))}
</div>
</div> </div>
</div> </div>
</div> </div>
+6 -4
View File
@@ -8,10 +8,12 @@ interface GiveawayCardProps {
const GiveawayCard: React.FC<GiveawayCardProps> = ({ title, description, imageUrl }) => { const GiveawayCard: React.FC<GiveawayCardProps> = ({ title, description, imageUrl }) => {
return ( return (
<div className="card"> <div className="bg-white shadow-md rounded-lg overflow-hidden">
<img src={imageUrl} alt={title} className="card-image" /> <img src={imageUrl} alt={title} className="w-full h-48 object-cover" />
<h3>{title}</h3> <div className="p-4">
<p>{description}</p> <h3 className="text-lg font-bold mb-2">{title}</h3>
<p className="text-gray-600 text-sm">{description}</p>
</div>
</div> </div>
); );
}; };