diff --git a/prisma/migrations/20250428111616_giveaway_update3/migration.sql b/prisma/migrations/20250428111616_giveaway_update3/migration.sql new file mode 100644 index 0000000..b78cd53 --- /dev/null +++ b/prisma/migrations/20250428111616_giveaway_update3/migration.sql @@ -0,0 +1,3 @@ +-- AlterTable +ALTER TABLE "Giveaway" ADD COLUMN "duration" INTEGER, +ADD COLUMN "endsAt" TIMESTAMP(3); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index b727e97..6523268 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -64,6 +64,8 @@ model Giveaway { prize String active Boolean @default(true) createdAt DateTime @default(now()) + duration Int? + endsAt DateTime? entryCost Int @default(7000000) entries Entry[] } diff --git a/src/app/admin/AdminClient.tsx b/src/app/admin/AdminClient.tsx index 5f5e164..c909774 100644 --- a/src/app/admin/AdminClient.tsx +++ b/src/app/admin/AdminClient.tsx @@ -7,7 +7,7 @@ interface AdminClientProps { } export default function AdminClient({ email }: AdminClientProps) { - const [giveaway, setGiveaway] = useState({ title: "", description: "", value: 0, prize: "" }); + const [giveaway, setGiveaway] = useState({ title: "", description: "", value: 0, prize: "", duration: 0, endsAt: 0 }); const [userCoins, setUserCoins] = useState({ userId: "", coins: 0 }); const handleCreateGiveaway = async () => { @@ -18,7 +18,7 @@ export default function AdminClient({ email }: AdminClientProps) { }); if (response.ok) { alert("Giveaway created successfully!"); - setGiveaway({ title: "", description: "", value:0, prize: "" }); // Reset form + setGiveaway({ title: "", description: "", value: 0, prize: "", duration: 0, endsAt: 0 }); // Reset form } else { const error = await response.json(); alert(`Failed to create giveaway: ${error.error}`); @@ -50,37 +50,44 @@ export default function AdminClient({ email }: AdminClientProps) {

Create Giveaway

setGiveaway({ ...giveaway, title: e.target.value })} - className="block w-full mt-2 p-2 border rounded bg-gray-700 text-gray-200" + type="text" + placeholder="Title" + value={giveaway.title} + onChange={(e) => setGiveaway({ ...giveaway, title: e.target.value })} + className="block w-full mt-2 p-2 border rounded bg-gray-700 text-gray-200" />