Add task label colors to the calendar view for better task identification

Fetches and displays task label colors as border colors on task badges within the CalendarView component. Imports Label schema and uses react-query to fetch labels from the API.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: ceced2fc-aa46-458d-ba87-ddd4b7bb1518
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/659922a9-0087-461c-90dd-6d9a58b81d4d/ceced2fc-aa46-458d-ba87-ddd4b7bb1518/dckFKzQ
This commit is contained in:
paul-nothaft
2025-09-11 13:53:14 +00:00
parent 0e97f4d87f
commit 36453140f3
2 changed files with 37 additions and 23 deletions
-4
View File
@@ -18,10 +18,6 @@ externalPort = 80
localPort = 35345 localPort = 35345
externalPort = 3002 externalPort = 3002
[[ports]]
localPort = 37425
externalPort = 3001
[[ports]] [[ports]]
localPort = 41353 localPort = 41353
externalPort = 3000 externalPort = 3000
+21 -3
View File
@@ -3,7 +3,8 @@ import { Card } from '@/components/ui/card';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge'; import { Badge } from '@/components/ui/badge';
import { ChevronLeft, ChevronRight, Calendar } from 'lucide-react'; import { ChevronLeft, ChevronRight, Calendar } from 'lucide-react';
import { Task } from './TaskCard'; import { Task, Label } from '@shared/schema';
import { useQuery } from '@tanstack/react-query';
import { addDays, format, isSameDay, startOfWeek } from 'date-fns'; import { addDays, format, isSameDay, startOfWeek } from 'date-fns';
interface CalendarViewProps { interface CalendarViewProps {
@@ -16,6 +17,13 @@ export default function CalendarView({ tasks, onTaskDrop, onDateSelect }: Calend
const [currentDate, setCurrentDate] = useState(new Date()); const [currentDate, setCurrentDate] = useState(new Date());
const [draggedTask, setDraggedTask] = useState<string | null>(null); const [draggedTask, setDraggedTask] = useState<string | null>(null);
// Fetch labels to get label colors
const { data: labels = [] } = useQuery<Label[]>({
queryKey: ['/api/labels'],
staleTime: 5 * 60 * 1000, // 5 minutes cache
refetchOnWindowFocus: false,
});
// Get two weeks starting from current week // Get two weeks starting from current week
const startDate = startOfWeek(currentDate); const startDate = startOfWeek(currentDate);
const dates = Array.from({ length: 14 }, (_, i) => addDays(startDate, i)); const dates = Array.from({ length: 14 }, (_, i) => addDays(startDate, i));
@@ -122,7 +130,11 @@ export default function CalendarView({ tasks, onTaskDrop, onDateSelect }: Calend
</div> </div>
<div className="space-y-1"> <div className="space-y-1">
{dayTasks.slice(0, 3).map((task, taskIndex) => ( {dayTasks.slice(0, 3).map((task, taskIndex) => {
// Find the label for this task
const taskLabel = task.labelId && labels.length > 0 ? labels.find(label => label.id === task.labelId) : null;
return (
<div <div
key={task.id} key={task.id}
draggable draggable
@@ -134,13 +146,19 @@ export default function CalendarView({ tasks, onTaskDrop, onDateSelect }: Calend
<Badge <Badge
variant="outline" variant="outline"
className="w-full justify-start text-xs p-1 h-auto" className="w-full justify-start text-xs p-1 h-auto"
style={taskLabel ? {
borderColor: taskLabel.color,
borderWidth: '2px',
borderStyle: 'solid'
} : {}}
> >
<div className="truncate flex-1 text-left"> <div className="truncate flex-1 text-left">
{task.title} {task.title}
</div> </div>
</Badge> </Badge>
</div> </div>
))} );
})}
{dayTasks.length > 3 && ( {dayTasks.length > 3 && (
<Badge variant="secondary" className="w-full justify-center text-xs"> <Badge variant="secondary" className="w-full justify-center text-xs">