mirror of
https://github.com/EdiFarcas/Giveaway-app.git
synced 2026-06-28 15:00:43 +03:00
Update Giveaway, app-functional
This commit is contained in:
@@ -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) {
|
||||
<div className="p-4 text-white bg-gray-800 shadow rounded">
|
||||
<h2 className="text-xl font-semibold">Create Giveaway</h2>
|
||||
<input
|
||||
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"
|
||||
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"
|
||||
/>
|
||||
<textarea
|
||||
placeholder="Description"
|
||||
value={giveaway.description}
|
||||
onChange={(e) => setGiveaway({ ...giveaway, description: e.target.value })}
|
||||
className="block w-full mt-2 p-2 border rounded bg-gray-700 text-gray-200"
|
||||
placeholder="Description"
|
||||
value={giveaway.description}
|
||||
onChange={(e) => setGiveaway({ ...giveaway, description: e.target.value })}
|
||||
className="block w-full mt-2 p-2 border rounded bg-gray-700 text-gray-200"
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Prize"
|
||||
value={giveaway.prize}
|
||||
onChange={(e) => setGiveaway({ ...giveaway, prize: e.target.value })}
|
||||
className="block w-full mt-2 p-2 border rounded bg-gray-700 text-gray-200"
|
||||
type="text"
|
||||
placeholder="Prize"
|
||||
value={giveaway.prize}
|
||||
onChange={(e) => setGiveaway({ ...giveaway, prize: e.target.value })}
|
||||
className="block w-full mt-2 p-2 border rounded bg-gray-700 text-gray-200"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
placeholder="Value"
|
||||
value={giveaway.value}
|
||||
onChange={(e) => setGiveaway({ ...giveaway, value: Number(e.target.value) })}
|
||||
className="block w-full mt-2 p-2 border rounded bg-gray-700 text-gray-200"
|
||||
type="number"
|
||||
placeholder="Value"
|
||||
value={giveaway.value || ""}
|
||||
onChange={(e) => setGiveaway({ ...giveaway, value: Number(e.target.value) })}
|
||||
className="block w-full mt-2 p-2 border rounded bg-gray-700 text-gray-200"
|
||||
/>
|
||||
<input
|
||||
type="datetime-local"
|
||||
placeholder="Ends At"
|
||||
value={giveaway.endsAt ? new Date(giveaway.endsAt).toISOString().slice(0, 16) : ""}
|
||||
onChange={(e) => setGiveaway({ ...giveaway, endsAt: Date.parse(e.target.value) })}
|
||||
className="block w-full mt-2 p-2 border rounded bg-gray-700 text-gray-200"
|
||||
/>
|
||||
<button
|
||||
onClick={handleCreateGiveaway}
|
||||
className="mt-4 bg-blue-600 text-white px-4 py-2 rounded"
|
||||
>
|
||||
Create Giveaway
|
||||
onClick={handleCreateGiveaway}
|
||||
className="mt-4 bg-blue-600 text-white px-4 py-2 rounded"
|
||||
>
|
||||
Create Giveaway
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user