diff --git a/AGENTS.md b/AGENTS.md index 78c7e92e..b143d5dd 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -155,6 +155,10 @@ The frontend is built with: - **Framework**: React - **Styling**: Tailwind CSS + Shadcn UI (Components) +### UI Rules + +- **Prefer System Colors**: Always prefer using semantic system color design tokens (e.g., `bg-background`, `text-foreground`, `text-sidebar-primary`, `text-muted-foreground`, etc.) over hardcoded color utilities (e.g., `bg-blue-50`, `text-emerald-600`, `bg-emerald-500`). This ensures seamless compatibility with light and dark themes. + ### Development - **Run Dev**: `bun --hot src/index.ts` (Runs on port 3000) diff --git a/src/services/upload/upload.test.ts b/src/services/upload/upload.test.ts index aebf2cff..9010623a 100644 --- a/src/services/upload/upload.test.ts +++ b/src/services/upload/upload.test.ts @@ -310,4 +310,21 @@ describe('UploadService', () => { const parentFolder = await prisma.asset.findUnique({ where: { id: parentId } }) expect(parentFolder?.sizeByte).toBe(3000) }) + + it('should list upload tasks', async () => { + const task = await prisma.task.create({ + data: { + creatorId: userId, + total: 3, + uploaded: 1, + type: 'upload', + name: 'test-upload-task', + }, + }) + + const result = await uploadService.listUploadTasks(userId, { first: 10 }) + expect(result.data).toHaveLength(1) + expect(result.data[0].id).toBe(task.id) + expect(result.data[0].name).toBe('test-upload-task') + }) }) diff --git a/src/ui/components/upload-tasks.tsx b/src/ui/components/upload-tasks.tsx index 12e02d7c..b961c257 100644 --- a/src/ui/components/upload-tasks.tsx +++ b/src/ui/components/upload-tasks.tsx @@ -2,28 +2,92 @@ import { client } from '@/ui/api/client' import type { TaskInfo } from '@/dtos/upload' import { useTeamId } from '@/ui/hooks/use-team-id' import { useInfiniteQuery } from '@tanstack/react-query' -import { Loader2 } from 'lucide-react' +import { Loader2, CheckCircle2, Clock, UploadCloud } from 'lucide-react' import { useEffect } from 'react' import { useInView } from 'react-intersection-observer' +import { format, parseISO, isToday, isYesterday } from 'date-fns' +import { Progress } from '@/ui/components/ui/progress' +import { formatTimeAgo } from '@/ui/lib/time' + +function formatDayHeader(dateString: string): string { + const date = parseISO(dateString) + if (isNaN(date.getTime())) { + return 'Unknown Date' + } + if (isToday(date)) { + return 'Today' + } + if (isYesterday(date)) { + return 'Yesterday' + } + return format(date, 'MMMM d, yyyy') +} function UploadTaskItem({ task }: { task: TaskInfo }) { - const progress = - task.total && task.total > 0 ? `${((task.uploaded ?? 0) / task.total) * 100}%` : '0%' + const isCompleted = task.uploaded === task.total + const percent = task.total > 0 ? (task.uploaded / task.total) * 100 : 0 + + let formattedTime = '' + try { + formattedTime = formatTimeAgo(task.createdAt) + } catch { + formattedTime = 'unknown' + } + return ( -
No uploads yet
++ Upload files in the project view to track progress here. +
+