mirror of
https://github.com/EdiFarcas/Giveaway-app.git
synced 2026-06-28 21:00:48 +03:00
Commenting users scraper and coin updater
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import handleUpdateCoins from "./AdminServer";
|
||||
|
||||
interface AdminClientProps {
|
||||
email: string;
|
||||
@@ -8,7 +9,8 @@ interface AdminClientProps {
|
||||
|
||||
export default function AdminClient({ email }: AdminClientProps) {
|
||||
const [giveaway, setGiveaway] = useState({ title: "", description: "", value: 0, prize: "", duration: 0, endsAt: 0 });
|
||||
const [userCoins, setUserCoins] = useState({ userId: "", coins: 0 });
|
||||
const [youtube_url, setYoutubeUrl] = useState("https://www.youtube.com/watch?v=48oDy9Ni1TA&ab_channel=TCGLove");
|
||||
const [coin_value, setCoinValue] = useState(0);
|
||||
|
||||
const handleCreateGiveaway = async () => {
|
||||
const response = await fetch("/api/admin/create-giveaway", {
|
||||
@@ -25,21 +27,6 @@ export default function AdminClient({ email }: AdminClientProps) {
|
||||
}
|
||||
};
|
||||
|
||||
const handleUpdateCoins = async () => {
|
||||
const response = await fetch("/api/admin/update-coins", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(userCoins),
|
||||
});
|
||||
if (response.ok) {
|
||||
alert("User coins updated successfully!");
|
||||
setUserCoins({ userId: "", coins: 0 }); // Reset form
|
||||
} else {
|
||||
const error = await response.json();
|
||||
alert(`Failed to update user coins: ${error.error}`);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-white text-black py-12 px-4 sm:px-6 lg:px-8">
|
||||
<div className="max-w-3xl mx-auto space-y-8">
|
||||
@@ -97,19 +84,19 @@ export default function AdminClient({ email }: AdminClientProps) {
|
||||
<input
|
||||
type="text"
|
||||
placeholder="YouTube Video URL"
|
||||
value={userCoins.userId}
|
||||
onChange={(e) => setUserCoins({ ...userCoins, userId: e.target.value })}
|
||||
value={youtube_url}
|
||||
onChange={(e) => setYoutubeUrl(e.target.value)}
|
||||
className="block w-full mt-2 p-2 border rounded bg-gray-700 text-gray-200"
|
||||
/>
|
||||
<input
|
||||
type="number"
|
||||
placeholder="Coins"
|
||||
value={userCoins.coins}
|
||||
onChange={(e) => setUserCoins({ ...userCoins, coins: Number(e.target.value) })}
|
||||
value={coin_value}
|
||||
onChange={(e) => setCoinValue(Number(e.target.value))}
|
||||
className="block w-full mt-2 p-2 border rounded bg-gray-700 text-gray-200"
|
||||
/>
|
||||
<button
|
||||
onClick={handleUpdateCoins}
|
||||
onClick={() => handleUpdateCoins(youtube_url, coin_value)}
|
||||
className="mt-4 bg-green-600 text-white px-4 py-2 rounded"
|
||||
>
|
||||
Update Coins
|
||||
|
||||
Reference in New Issue
Block a user