Spaces:
Running
Running
Download components/HomeView.js from Leogron777/anycoder-fa44b9d5: direct link, hf CLI and curl.
- Browser
- Download file 6.12 kB
-
https://huggingface.co/spaces/Leogron777/anycoder-fa44b9d5/resolve/main/components/HomeView.js
- Command line
-
hf download hf://spaces/Leogron777/anycoder-fa44b9d5/components/HomeView.js
-
curl -L -o HomeView.js https://huggingface.co/spaces/Leogron777/anycoder-fa44b9d5/resolve/main/components/HomeView.js
6.12 kB
| import { useState, useEffect } from 'react' | |
| import { Filter, Plus, Search, Clock, CheckCircle, XCircle, Archive } from 'lucide-react' | |
| import { useFirebase } from './FirebaseProvider' | |
| const filters = [ | |
| { id: 'all', label: 'All', icon: null }, | |
| { id: 'pending', label: 'Pending', icon: Clock }, | |
| { id: 'completed', label: 'Completed', icon: CheckCircle }, | |
| { id: 'declined', label: 'Declined', icon: XCircle }, | |
| { id: 'archive', label: 'Archive', icon: Archive } | |
| ] | |
| const mockTasks = [ | |
| { id: 1, title: 'Complete project proposal', status: 'pending', priority: 'high', dueDate: '2024-01-15', assignedTo: 'John Doe' }, | |
| { id: 2, title: 'Review code changes', status: 'completed', priority: 'medium', dueDate: '2024-01-10', assignedTo: 'Jane Smith' }, | |
| { id: 3, title: 'Team meeting preparation', status: 'pending', priority: 'high', dueDate: '2024-01-12', assignedTo: 'Mike Johnson' }, | |
| { id: 4, title: 'Update documentation', status: 'declined', priority: 'low', dueDate: '2024-01-20', assignedTo: 'Sarah Williams' }, | |
| { id: 5, title: 'Client presentation', status: 'completed', priority: 'high', dueDate: '2024-01-08', assignedTo: 'Tom Brown' } | |
| ] | |
| export default function HomeView() { | |
| const [selectedFilter, setSelectedFilter] = useState('all') | |
| const [searchQuery, setSearchQuery] = useState('') | |
| const [tasks, setTasks] = useState(mockTasks) | |
| const { user } = useFirebase() | |
| const filteredTasks = tasks.filter(task => { | |
| const matchesFilter = selectedFilter === 'all' || task.status === selectedFilter | |
| const matchesSearch = task.title.toLowerCase().includes(searchQuery.toLowerCase()) || | |
| task.assignedTo.toLowerCase().includes(searchQuery.toLowerCase()) | |
| return matchesFilter && matchesSearch | |
| }) | |
| const getStatusColor = (status) => { | |
| switch(status) { | |
| case 'pending': return 'bg-yellow-100 text-yellow-800' | |
| case 'completed': return 'bg-green-100 text-green-800' | |
| case 'declined': return 'bg-red-100 text-red-800' | |
| case 'archive': return 'bg-gray-100 text-gray-800' | |
| default: return 'bg-gray-100 text-gray-800' | |
| } | |
| } | |
| const getPriorityColor = (priority) => { | |
| switch(priority) { | |
| case 'high': return 'border-red-400' | |
| case 'medium': return 'border-yellow-400' | |
| case 'low': return 'border-green-400' | |
| default: return 'border-gray-300' | |
| } | |
| } | |
| return ( | |
| <div className="min-h-screen bg-gray-50"> | |
| <header className="bg-white shadow-sm sticky top-0 z-40"> | |
| <div className="px-4 py-4"> | |
| <div className="flex items-center justify-between mb-4"> | |
| <h1 className="text-2xl font-bold text-gray-800">Tasks</h1> | |
| <button className="bg-primary-600 text-white p-2 rounded-full hover:bg-primary-700 transition-colors"> | |
| <Plus className="w-5 h-5" /> | |
| </button> | |
| </div> | |
| <div className="relative"> | |
| <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-5 h-5" /> | |
| <input | |
| type="text" | |
| value={searchQuery} | |
| onChange={(e) => setSearchQuery(e.target.value)} | |
| placeholder="Search tasks..." | |
| className="w-full pl-10 pr-4 py-2 bg-gray-100 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500" | |
| /> | |
| </div> | |
| </div> | |
| <div className="px-4 pb-3"> | |
| <div className="flex gap-2 overflow-x-auto scrollbar-hide"> | |
| {filters.map((filter) => { | |
| const Icon = filter.icon | |
| const isActive = selectedFilter === filter.id | |
| return ( | |
| <button | |
| key={filter.id} | |
| onClick={() => setSelectedFilter(filter.id)} | |
| className={`flex items-center gap-2 px-4 py-2 rounded-full whitespace-nowrap transition-colors ${ | |
| isActive | |
| ? 'bg-primary-600 text-white' | |
| : 'bg-gray-100 text-gray-600 hover:bg-gray-200' | |
| }`} | |
| > | |
| {Icon && <Icon className="w-4 h-4" />} | |
| <span className="text-sm font-medium">{filter.label}</span> | |
| </button> | |
| ) | |
| })} | |
| </div> | |
| </div> | |
| </header> | |
| <main className="px-4 py-4"> | |
| <div className="space-y-3"> | |
| {filteredTasks.map((task) => ( | |
| <div | |
| key={task.id} | |
| className={`task-card border-l-4 ${getPriorityColor(task.priority)} animate-slide-up`} | |
| > | |
| <div className="flex items-start justify-between"> | |
| <div className="flex-1"> | |
| <h3 className="font-semibold text-gray-800 mb-1">{task.title}</h3> | |
| <div className="flex items-center gap-3 text-sm text-gray-600"> | |
| <span className="flex items-center gap-1"> | |
| <Clock className="w-4 h-4" /> | |
| {task.dueDate} | |
| </span> | |
| <span className="flex items-center gap-1"> | |
| <div className="w-6 h-6 bg-primary-200 rounded-full flex items-center justify-center text-xs font-medium text-primary-700"> | |
| {task.assignedTo.split(' ').map(n => n[0]).join('')} | |
| </div> | |
| {task.assignedTo} | |
| </span> | |
| </div> | |
| </div> | |
| <span className={`px-3 py-1 rounded-full text-xs font-medium ${getStatusColor(task.status)}`}> | |
| {task.status} | |
| </span> | |
| </div> | |
| </div> | |
| ))} | |
| </div> | |
| {filteredTasks.length === 0 && ( | |
| <div className="text-center py-12"> | |
| <div className="w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4"> | |
| <Filter className="w-8 h-8 text-gray-400" /> | |
| </div> | |
| <p className="text-gray-500">No tasks found</p> | |
| </div> | |
| )} | |
| </main> | |
| </div> | |
| ) | |
| } |