Spaces:
Running
Running
File size: 6,115 Bytes
382ef23 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | 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>
)
} |