Spaces:
Build error

rbachina commited on
Commit
f72f0ec
·
verified ·
1 Parent(s): 8a43dbf

Upload pages/index.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. pages/index.js +86 -0
pages/index.js ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState, useEffect } from 'react';
2
+ import Head from 'next/head';
3
+ import { Dumbbell, Calendar, Heart, Settings, Menu, X } from 'lucide-react';
4
+ import WorkoutGenerator from '../components/WorkoutGenerator';
5
+ import WeeklyCalendar from '../components/WeeklyCalendar';
6
+ import FavoritesManager from '../components/FavoritesManager';
7
+ import AlertSettings from '../components/AlertSettings';
8
+
9
+ export default function Home() {
10
+ const [activeTab, setActiveTab] = useState('generator');
11
+ const [favorites, setFavorites] = useState([]);
12
+ const [workouts, setWorkouts] = useState([]);
13
+ const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
14
+
15
+ useEffect(() => {
16
+ const savedFavorites = localStorage.getItem('microfit_favorites');
17
+ if (savedFavorites) {
18
+ setFavorites(JSON.parse(savedFavorites));
19
+ }
20
+
21
+ fetch('/api/workouts')
22
+ .then(res => res.json())
23
+ .then(data => setWorkouts(data))
24
+ .catch(err => console.error('Failed to load workouts:', err));
25
+ }, []);
26
+
27
+ useEffect(() => {
28
+ localStorage.setItem('microfit_favorites', JSON.stringify(favorites));
29
+ }, [favorites]);
30
+
31
+ const toggleFavorite = (workoutId) => {
32
+ setFavorites(prev => {
33
+ if (prev.includes(workoutId)) {
34
+ return prev.filter(id => id !== workoutId);
35
+ }
36
+ return [...prev, workoutId];
37
+ });
38
+ };
39
+
40
+ const tabs = [
41
+ { id: 'generator', label: 'Generator', icon: Dumbbell },
42
+ { id: 'calendar', label: 'Schedule', icon: Calendar },
43
+ { id: 'favorites', label: 'Favorites', icon: Heart },
44
+ { id: 'settings', label: 'Alerts', icon: Settings },
45
+ ];
46
+
47
+ return (
48
+ <div className="min-h-screen bg-gray-50">
49
+ <Head>
50
+ <title>Microfit - Desk Workout Snacks</title>
51
+ <meta name="description" content="Quick workout snacks for desk workers" />
52
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
53
+ </Head>
54
+
55
+ <nav className="bg-white shadow-sm border-b border-gray-200 sticky top-0 z-40">
56
+ <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
57
+ <div className="flex justify-between h-16">
58
+ <div className="flex items-center gap-3">
59
+ <div className="w-10 h-10 bg-gradient-to-br from-primary-500 to-accent-500 rounded-xl flex items-center justify-center shadow-lg">
60
+ <Dumbbell className="w-6 h-6 text-white" />
61
+ </div>
62
+ <div>
63
+ <h1 className="text-xl font-bold text-gray-900 tracking-tight">Microfit</h1>
64
+ <p className="text-xs text-gray-500">Desk Workout Snacks</p>
65
+ </div>
66
+ </div>
67
+
68
+ <div className="hidden md:flex items-center space-x-1">
69
+ {tabs.map(tab => (
70
+ <button
71
+ key={tab.id}
72
+ onClick={() => setActiveTab(tab.id)}
73
+ className={`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all duration-200 ${activeTab === tab.id ? 'bg-primary-50 text-primary-700' : 'text-gray-600 hover:text-gray-900 hover:bg-gray-50'}`}
74
+ >
75
+ <tab.icon className="w-4 h-4" />
76
+ {tab.label}
77
+ {tab.id === 'favorites' && favorites.length > 0 && (
78
+ <span className="bg-red-500 text-white text-xs rounded-full w-5 h-5 flex items-center justify-center">
79
+ {favorites.length}
80
+ </span>
81
+ )}
82
+ </button>
83
+ ))}
84
+ <a
85
+ href="https://huggingface.co/spaces/akhaliq/anycoder"
86
+ target