diff --git a/admin-web/app/layout.tsx b/admin-web/app/layout.tsx index 1e42dc9..16f07f3 100644 --- a/admin-web/app/layout.tsx +++ b/admin-web/app/layout.tsx @@ -19,7 +19,7 @@ export default function RootLayout({ children: React.ReactNode; }>) { return ( - +
diff --git a/admin-web/app/trainers/page.tsx b/admin-web/app/trainers/page.tsx index f81e488..defff19 100644 --- a/admin-web/app/trainers/page.tsx +++ b/admin-web/app/trainers/page.tsx @@ -4,7 +4,8 @@ import { useEffect, useState } from "react"; import { supabase } from "@/lib/supabase"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; -import { Plus, Trash2, Edit, Loader2 } from "lucide-react"; +import { Plus, Trash2, Edit, Loader2, Users, AlertCircle } from "lucide-react"; +import Link from "next/link"; import type { Database } from "@/lib/supabase"; type Trainer = Database["public"]["Tables"]["trainers"]["Row"]; @@ -12,6 +13,7 @@ type Trainer = Database["public"]["Tables"]["trainers"]["Row"]; export default function TrainersPage() { const [trainers, setTrainers] = useState([]); const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); const [deletingId, setDeletingId] = useState(null); useEffect(() => { @@ -20,11 +22,13 @@ export default function TrainersPage() { const fetchTrainers = async () => { try { - const { data, error } = await supabase.from("trainers").select("*"); + setError(null); + const { data, error } = await supabase.from("trainers").select("*").order("name"); if (error) throw error; setTrainers(data || []); - } catch (error) { - console.error("Failed to fetch trainers:", error); + } catch (err) { + console.error("Failed to fetch trainers:", err); + setError(err instanceof Error ? err.message : "Failed to connect to database"); } finally { setLoading(false); } @@ -53,16 +57,52 @@ export default function TrainersPage() {

Trainers

Manage your fitness trainers

- + + + {loading ? (
+ ) : error ? ( +
+
+ +
+

Failed to Load Trainers

+

{error}

+

+ Make sure your Supabase database is running and the trainers table exists. +

+ +
+ ) : trainers.length === 0 ? ( +
+
+ +
+

No Trainers Yet

+

+ Get started by adding your first trainer. Trainers lead workouts and help users achieve their fitness goals. +

+ + + +
) : (
{trainers.map((trainer) => ( diff --git a/supabase/seed.sql b/supabase/seed.sql new file mode 100644 index 0000000..4ff2a21 --- /dev/null +++ b/supabase/seed.sql @@ -0,0 +1,52 @@ +-- ============================================================ +-- TabataFit Seed Data +-- ============================================================ +-- Run this SQL in Supabase SQL Editor to populate your database with sample data + +-- Sample Trainers +INSERT INTO public.trainers (name, specialty, color, workout_count) VALUES + ('Sarah Chen', 'HIIT & Cardio', '#FF6B35', 12), + ('Marcus Johnson', 'Strength Training', '#5AC8FA', 8), + ('Elena Rodriguez', 'Yoga & Mobility', '#30D158', 15), + ('David Kim', 'Full Body Conditioning', '#FF9500', 10); + +-- Sample Collections +INSERT INTO public.collections (title, description, icon, gradient) VALUES + ('Quick Burns', 'High-intensity workouts under 10 minutes', 'flame', ARRAY['#FF6B35', '#FF9500']), + ('Core Strength', 'Build a solid foundation', 'shield', ARRAY['#5AC8FA', '#30D158']), + ('Cardio Blast', 'Get your heart pumping', 'heart', ARRAY['#FF6B35', '#FF3B30']), + ('Total Body', 'Full body workouts for maximum results', 'body', ARRAY['#30D158', '#5856D6']); + +-- Note: Workouts will be added after trainers are created (they reference trainer_ids) +-- To add workouts, first note the UUIDs generated for trainers above, then: + +-- Sample Workout (uncomment and update trainer_id after running above) +-- INSERT INTO public.workouts ( +-- title, trainer_id, category, level, duration, calories, rounds, +-- prep_time, work_time, rest_time, equipment, music_vibe, exercises, is_featured +-- ) VALUES ( +-- 'Morning Ignite', +-- 'PASTE_TRAINER_UUID_HERE', +-- 'full-body', +-- 'Beginner', +-- 4, +-- 45, +-- 8, +-- 10, +-- 20, +-- 10, +-- ARRAY['yoga-mat'], +-- 'electronic', +-- '[{"name": "Jumping Jacks", "duration": 20}, {"name": "Push-ups", "duration": 20}, {"name": "Squats", "duration": 20}, {"name": "Plank", "duration": 20}]'::jsonb, +-- true +-- ); + +-- Update trainer workout counts +UPDATE public.trainers SET workout_count = 12 WHERE name = 'Sarah Chen'; +UPDATE public.trainers SET workout_count = 8 WHERE name = 'Marcus Johnson'; +UPDATE public.trainers SET workout_count = 15 WHERE name = 'Elena Rodriguez'; +UPDATE public.trainers SET workout_count = 10 WHERE name = 'David Kim'; + +-- Verify data +SELECT * FROM public.trainers ORDER BY name; +SELECT * FROM public.collections ORDER BY title; \ No newline at end of file