187 lines
6.5 KiB
JavaScript
187 lines
6.5 KiB
JavaScript
import React, { useState } from "react";
|
|
import { motion } from "framer-motion";
|
|
import { Swiper, SwiperSlide } from "swiper/react";
|
|
import "swiper/css";
|
|
import "swiper/css/navigation";
|
|
import { Navigation } from "swiper/modules";
|
|
|
|
const AdminDashboard = () => {
|
|
const [activeTab, setActiveTab] = useState("hero");
|
|
const [images, setImages] = useState([
|
|
"https://vibra.qodeinteractive.com/wp-content/uploads/2019/02/h1-slider-3-background.jpg",
|
|
"https://vibra.qodeinteractive.com/wp-content/uploads/2019/02/h1-slider-2-background.jpg",
|
|
"https://vibra.qodeinteractive.com/wp-content/uploads/2019/02/h1-slider-1-background.jpg",
|
|
]);
|
|
|
|
const [coaches, setCoaches] = useState([
|
|
{ name: "John Doe", title: "Head Coach" },
|
|
{ name: "Jane Smith", title: "Assistant Coach" },
|
|
]);
|
|
const [newCoach, setNewCoach] = useState({ name: "", title: "" });
|
|
|
|
const addCoach = () => {
|
|
if (newCoach.name && newCoach.title) {
|
|
setCoaches([...coaches, newCoach]);
|
|
setNewCoach({ name: "", title: "" });
|
|
}
|
|
};
|
|
|
|
const removeCoach = (index) => {
|
|
setCoaches(coaches.filter((_, i) => i !== index));
|
|
};
|
|
|
|
return (
|
|
<div className="min-h-screen w-full bg-black text-white">
|
|
<motion.div
|
|
className="w-full"
|
|
initial={{ opacity: 0, y: -20 }}
|
|
animate={{ opacity: 1, y: 0 }}
|
|
transition={{ duration: 0.5 }}
|
|
>
|
|
{/* Header */}
|
|
<div className="bg-gray-900 p-6 shadow-lg">
|
|
<h1 className="text-3xl font-bold tracking-wide">Admin Dashboard</h1>
|
|
</div>
|
|
|
|
{/* Tab Navigation */}
|
|
<div className="flex justify-center mt-6 space-x-4">
|
|
{[
|
|
{ label: "Hero", value: "hero" },
|
|
{ label: "Coach", value: "coach" },
|
|
{ label: "Events", value: "calendar" },
|
|
].map((tab) => (
|
|
<button
|
|
key={tab.value}
|
|
onClick={() => setActiveTab(tab.value)}
|
|
className={`px-6 py-3 rounded-full text-sm cursor-pointer font-medium transition-all shadow-md focus:outline-none ${
|
|
activeTab === tab.value
|
|
? "bg-white text-black"
|
|
: "bg-gray-700 text-gray-300 hover:bg-gray-600"
|
|
}`}
|
|
>
|
|
{tab.label}
|
|
</button>
|
|
))}
|
|
</div>
|
|
|
|
{/* Tab Content */}
|
|
<motion.div
|
|
key={activeTab}
|
|
initial={{ opacity: 0, x: -50 }}
|
|
animate={{ opacity: 1, x: 0 }}
|
|
transition={{ duration: 0.4 }}
|
|
className="p-8"
|
|
>
|
|
{activeTab === "hero" && (
|
|
<div>
|
|
<Swiper
|
|
modules={[Navigation]}
|
|
navigation
|
|
loop={true}
|
|
className="rounded-xl overflow-hidden shadow-lg mb-6"
|
|
spaceBetween={10}
|
|
slidesPerView={1}
|
|
>
|
|
{images.map((image, index) => (
|
|
<SwiperSlide key={index} className="relative">
|
|
<img
|
|
src={image}
|
|
alt={`Slide ${index + 1}`}
|
|
className="w-full h-72 object-cover"
|
|
/>
|
|
<button
|
|
className="absolute top-4 right-4 bg-red-500 text-white px-4 py-2 rounded-full hover:bg-red-600"
|
|
onClick={() =>
|
|
setImages(images.filter((_, i) => i !== index))
|
|
}
|
|
>
|
|
Remove
|
|
</button>
|
|
</SwiperSlide>
|
|
))}
|
|
</Swiper>
|
|
|
|
<button className="bg-white text-black px-6 py-3 rounded-lg hover:bg-gray-300">
|
|
Add Image
|
|
</button>
|
|
|
|
<p className="text-gray-400 mt-4">Manage hero section images.</p>
|
|
</div>
|
|
)}
|
|
|
|
{activeTab === "coach" && (
|
|
<div>
|
|
<h2 className="text-2xl font-semibold mb-4">Manage Coaches</h2>
|
|
<div className="mb-6 grid grid-cols-1 gap-4 md:grid-cols-2">
|
|
<input
|
|
type="text"
|
|
placeholder="Coach Name"
|
|
value={newCoach.name}
|
|
onChange={(e) =>
|
|
setNewCoach({ ...newCoach, name: e.target.value })
|
|
}
|
|
className="px-4 py-3 border rounded-lg bg-gray-800 text-white focus:ring focus:ring-gray-500"
|
|
/>
|
|
<input
|
|
type="text"
|
|
placeholder="Coach Title"
|
|
value={newCoach.title}
|
|
onChange={(e) =>
|
|
setNewCoach({ ...newCoach, title: e.target.value })
|
|
}
|
|
className="px-4 py-3 border rounded-lg bg-gray-800 text-white focus:ring focus:ring-gray-500"
|
|
/>
|
|
|
|
<button
|
|
onClick={addCoach}
|
|
className="bg-white text-black px-6 py-3 rounded-lg hover:bg-gray-300"
|
|
>
|
|
Add Coach
|
|
</button>
|
|
</div>
|
|
|
|
<ul className="space-y-4">
|
|
{coaches.map((coach, index) => (
|
|
<li
|
|
key={index}
|
|
className="flex items-center justify-between bg-gray-800 p-4 rounded-lg shadow-md"
|
|
>
|
|
<div>
|
|
<h3 className="text-lg font-medium text-white">
|
|
{coach.name}
|
|
</h3>
|
|
<p className="text-gray-400">{coach.title}</p>
|
|
</div>
|
|
<button
|
|
onClick={() => removeCoach(index)}
|
|
className="bg-red-500 text-white px-4 py-2 rounded-lg hover:bg-red-600"
|
|
>
|
|
Remove
|
|
</button>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
|
|
<p className="text-gray-400 mt-4">Manage the coaching team.</p>
|
|
</div>
|
|
)}
|
|
|
|
{activeTab === "calendar" && (
|
|
<div>
|
|
<h2 className="text-2xl font-semibold mb-4">Events Calendar</h2>
|
|
<button className="bg-gray-700 text-white px-6 py-3 rounded-lg hover:bg-gray-600">
|
|
Add New Event
|
|
</button>
|
|
<p className="text-gray-400 mt-4">
|
|
Schedule, edit, or remove events from the calendar.
|
|
</p>
|
|
</div>
|
|
)}
|
|
</motion.div>
|
|
</motion.div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default AdminDashboard;
|