@knotpad/app 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/(app)/calendar/page.tsx +57 -0
- package/app/(app)/error.tsx +35 -0
- package/app/(app)/graph/page.tsx +32 -0
- package/app/(app)/guide/page.tsx +21 -0
- package/app/(app)/kanban/loading.tsx +24 -0
- package/app/(app)/kanban/page.tsx +59 -0
- package/app/(app)/layout.tsx +122 -0
- package/app/(app)/list/loading.tsx +21 -0
- package/app/(app)/list/page.tsx +137 -0
- package/app/(app)/loading.tsx +18 -0
- package/app/(app)/notes/[noteId]/page.tsx +84 -0
- package/app/(app)/notes/layout.tsx +30 -0
- package/app/(app)/notes/page.tsx +39 -0
- package/app/(app)/page.tsx +5 -0
- package/app/(app)/settings/agent-token/page.tsx +59 -0
- package/app/(app)/settings/backup/page.tsx +49 -0
- package/app/(app)/settings/billing/page.tsx +53 -0
- package/app/(app)/settings/calendar/page.tsx +41 -0
- package/app/(app)/settings/layout.test.tsx +39 -0
- package/app/(app)/settings/layout.tsx +71 -0
- package/app/(app)/settings/page.tsx +4 -0
- package/app/(app)/settings/security/page.tsx +43 -0
- package/app/(app)/settings/team/page.tsx +74 -0
- package/app/(app)/settings/workspace/page.tsx +27 -0
- package/app/(app)/tasks/[taskId]/page.tsx +79 -0
- package/app/(auth)/forgot-password/page.tsx +106 -0
- package/app/(auth)/guest/page.tsx +56 -0
- package/app/(auth)/layout.tsx +13 -0
- package/app/(auth)/login/page.tsx +14 -0
- package/app/(auth)/register/page.tsx +193 -0
- package/app/(auth)/reset-password/page.tsx +138 -0
- package/app/api/account/claim/route.tsx +135 -0
- package/app/api/admin/backfill-encryption/route.tsx +43 -0
- package/app/api/admin/license/route.tsx +42 -0
- package/app/api/auth/2fa/route.tsx +148 -0
- package/app/api/auth/[...nextauth]/route.tsx +3 -0
- package/app/api/auth/change-password/route.tsx +61 -0
- package/app/api/auth/check-2fa/route.tsx +19 -0
- package/app/api/auth/forgot-password/route.tsx +65 -0
- package/app/api/auth/reset-password/route.tsx +52 -0
- package/app/api/auth/verify-2fa/route.tsx +88 -0
- package/app/api/backup/download/db/route.ts +29 -0
- package/app/api/backup/download/notes/route.ts +25 -0
- package/app/api/backup/settings/route.ts +92 -0
- package/app/api/billing/checkout/route.tsx +81 -0
- package/app/api/billing/migrate/route.tsx +163 -0
- package/app/api/billing/portal/route.tsx +24 -0
- package/app/api/billing/setup-intent/route.tsx +55 -0
- package/app/api/billing/status/route.tsx +36 -0
- package/app/api/billing/subscribe/route.tsx +85 -0
- package/app/api/billing/webhook/route.tsx +199 -0
- package/app/api/calendar-feeds/[feedId]/route.tsx +67 -0
- package/app/api/calendar-feeds/[feedId]/sync/route.tsx +37 -0
- package/app/api/calendar-feeds/events/route.tsx +82 -0
- package/app/api/calendar-feeds/route.tsx +52 -0
- package/app/api/calendar-feeds/sync-all/route.tsx +34 -0
- package/app/api/cron/calendar-feeds/route.tsx +31 -0
- package/app/api/cron/stale-tasks/route.tsx +51 -0
- package/app/api/cron/sync/route.tsx +34 -0
- package/app/api/devices/[deviceId]/route.tsx +25 -0
- package/app/api/devices/route.tsx +41 -0
- package/app/api/export/route.tsx +40 -0
- package/app/api/feedback/route.tsx +54 -0
- package/app/api/folders/[folderId]/route.tsx +51 -0
- package/app/api/folders/route.tsx +37 -0
- package/app/api/graph/route.tsx +242 -0
- package/app/api/guest/route.tsx +58 -0
- package/app/api/health/route.tsx +10 -0
- package/app/api/holidays/countries/route.tsx +14 -0
- package/app/api/holidays/route.tsx +49 -0
- package/app/api/holidays/states/route.tsx +21 -0
- package/app/api/invites/[token]/route.tsx +131 -0
- package/app/api/invites/route.tsx +74 -0
- package/app/api/mcp/generate-token/route.tsx +55 -0
- package/app/api/mcp/revoke-token/[tokenId]/route.tsx +30 -0
- package/app/api/mcp/update-alias/[tokenId]/route.tsx +22 -0
- package/app/api/notes/[noteId]/export/route.tsx +45 -0
- package/app/api/notes/[noteId]/route.tsx +360 -0
- package/app/api/notes/route.tsx +112 -0
- package/app/api/notifications/route.tsx +44 -0
- package/app/api/register/route.tsx +67 -0
- package/app/api/restore/route.tsx +148 -0
- package/app/api/sync/conflicts/[conflictId]/route.tsx +134 -0
- package/app/api/sync/conflicts/route.tsx +48 -0
- package/app/api/sync/status/route.tsx +49 -0
- package/app/api/sync/trigger/route.tsx +15 -0
- package/app/api/tasks/[taskId]/detail/route.tsx +68 -0
- package/app/api/tasks/[taskId]/route.tsx +259 -0
- package/app/api/tasks/bulk/route.tsx +133 -0
- package/app/api/tasks/route.tsx +36 -0
- package/app/api/workspace/active/route.tsx +39 -0
- package/app/api/workspace/create-team/route.tsx +42 -0
- package/app/api/workspace/kanban-statuses/route.tsx +71 -0
- package/app/api/workspace/members/[memberId]/route.tsx +69 -0
- package/app/api/workspace/route.tsx +24 -0
- package/app/download/page.tsx +170 -0
- package/app/favicon.ico +0 -0
- package/app/generated/prisma/client.d.ts +1 -0
- package/app/generated/prisma/client.js +5 -0
- package/app/generated/prisma/default.d.ts +1 -0
- package/app/generated/prisma/default.js +5 -0
- package/app/generated/prisma/edge.d.ts +1 -0
- package/app/generated/prisma/edge.js +497 -0
- package/app/generated/prisma/index-browser.js +523 -0
- package/app/generated/prisma/index.d.ts +46376 -0
- package/app/generated/prisma/index.js +497 -0
- package/app/generated/prisma/package.json +144 -0
- package/app/generated/prisma/query_compiler_fast_bg.js +2 -0
- package/app/generated/prisma/query_compiler_fast_bg.wasm +0 -0
- package/app/generated/prisma/query_compiler_fast_bg.wasm-base64.js +2 -0
- package/app/generated/prisma/runtime/client.d.ts +3386 -0
- package/app/generated/prisma/runtime/client.js +86 -0
- package/app/generated/prisma/runtime/index-browser.d.ts +90 -0
- package/app/generated/prisma/runtime/index-browser.js +6 -0
- package/app/generated/prisma/runtime/wasm-compiler-edge.js +76 -0
- package/app/generated/prisma/schema.prisma +456 -0
- package/app/generated/prisma/wasm-edge-light-loader.mjs +5 -0
- package/app/generated/prisma/wasm-worker-loader.mjs +5 -0
- package/app/globals.css +54 -0
- package/app/invite/[token]/page.tsx +52 -0
- package/app/layout.tsx +90 -0
- package/app/mcp/route.tsx +430 -0
- package/app/opengraph-image.tsx +120 -0
- package/app/page.tsx +398 -0
- package/app/privacy/page.tsx +69 -0
- package/app/robots.tsx +25 -0
- package/app/sitemap.tsx +36 -0
- package/app/terms/page.tsx +69 -0
- package/app/upgrade/page.tsx +75 -0
- package/auth.config.ts +33 -0
- package/auth.ts +79 -0
- package/bin/brief.js +229 -0
- package/components/auth/login-form.tsx +302 -0
- package/components/auth/password-checklist.tsx +31 -0
- package/components/auth/password-input.tsx +36 -0
- package/components/auth/switch-account-button.test.tsx +22 -0
- package/components/auth/switch-account-button.tsx +19 -0
- package/components/auth/two-factor-input.tsx +116 -0
- package/components/billing/billing-dashboard.tsx +265 -0
- package/components/billing/card-form.tsx +210 -0
- package/components/billing/claim-account-form.tsx +99 -0
- package/components/branding/app-logo.test.tsx +20 -0
- package/components/branding/app-logo.tsx +25 -0
- package/components/calendar/calendar-agenda.tsx +150 -0
- package/components/calendar/calendar-drag.test.tsx +177 -0
- package/components/calendar/calendar-grid.tsx +357 -0
- package/components/calendar/calendar-hooks.test.tsx +27 -0
- package/components/calendar/calendar-hooks.ts +351 -0
- package/components/calendar/calendar-toolbar.test.tsx +68 -0
- package/components/calendar/calendar-toolbar.tsx +291 -0
- package/components/calendar/calendar-types.ts +148 -0
- package/components/calendar/calendar-view.test.tsx +295 -0
- package/components/calendar/calendar-view.tsx +307 -0
- package/components/calendar/day-detail-popover.tsx +174 -0
- package/components/calendar/task-chip.tsx +86 -0
- package/components/command/command-palette.test.tsx +33 -0
- package/components/command/command-palette.tsx +310 -0
- package/components/download-cta.tsx +87 -0
- package/components/feedback/feedback-popup.tsx +207 -0
- package/components/graph/graph-draw.ts +337 -0
- package/components/graph/graph-overlays.tsx +160 -0
- package/components/graph/graph-page.test.tsx +131 -0
- package/components/graph/graph-page.tsx +263 -0
- package/components/graph/graph-types.ts +47 -0
- package/components/graph/graph-view.tsx +322 -0
- package/components/guide/guide-view.tsx +522 -0
- package/components/kanban/kanban-board.test.tsx +128 -0
- package/components/kanban/kanban-board.tsx +361 -0
- package/components/kanban/kanban-card-menu.tsx +102 -0
- package/components/kanban/kanban-card.tsx +227 -0
- package/components/kanban/kanban-column.tsx +49 -0
- package/components/kanban/kanban-status-context.tsx +28 -0
- package/components/landing/calendar-sandbox.test.tsx +15 -0
- package/components/landing/calendar-sandbox.tsx +107 -0
- package/components/landing/graph-sandbox.test.tsx +27 -0
- package/components/landing/graph-sandbox.tsx +80 -0
- package/components/landing/kanban-sandbox.test.tsx +24 -0
- package/components/landing/kanban-sandbox.tsx +101 -0
- package/components/landing/landing-showcase.test.tsx +21 -0
- package/components/landing/landing-showcase.tsx +54 -0
- package/components/landing/list-sandbox.tsx +86 -0
- package/components/landing/mock-workspace.ts +168 -0
- package/components/landing/notes-sandbox.test.tsx +14 -0
- package/components/landing/notes-sandbox.tsx +88 -0
- package/components/layout/app-shell.tsx +83 -0
- package/components/layout/backup-scheduler.tsx +122 -0
- package/components/layout/bottom-nav.tsx +43 -0
- package/components/layout/icon-bar.test.tsx +29 -0
- package/components/layout/icon-bar.tsx +118 -0
- package/components/layout/mobile-top-bar.tsx +68 -0
- package/components/layout/notes-panel-folder.tsx +127 -0
- package/components/layout/notes-panel-note-item.tsx +140 -0
- package/components/layout/notes-panel-task-tab.tsx +63 -0
- package/components/layout/notes-panel-types.ts +44 -0
- package/components/layout/notes-panel.tsx +476 -0
- package/components/layout/notification-bell.tsx +251 -0
- package/components/layout/paywall-screen.tsx +41 -0
- package/components/layout/pro-banner.tsx +76 -0
- package/components/layout/sw-register.tsx +27 -0
- package/components/layout/workspace-switcher.tsx +90 -0
- package/components/notes/mobile-bottom-sheet.tsx +99 -0
- package/components/notes/note-editor-context-menu.tsx +47 -0
- package/components/notes/note-editor-dom.ts +33 -0
- package/components/notes/note-editor-dropdowns.tsx +484 -0
- package/components/notes/note-editor-hooks.ts +692 -0
- package/components/notes/note-editor-keyboard.ts +305 -0
- package/components/notes/note-editor-overlay.tsx +90 -0
- package/components/notes/note-editor.test.tsx +372 -0
- package/components/notes/note-editor.tsx +662 -0
- package/components/notes/note-preview-pane.tsx +156 -0
- package/components/notes/note-tabs.tsx +120 -0
- package/components/notes/note-types.tsx +157 -0
- package/components/settings/accept-invite.tsx +108 -0
- package/components/settings/agent-token-settings.tsx +369 -0
- package/components/settings/backup-restore-settings.test.tsx +25 -0
- package/components/settings/backup-restore-settings.tsx +327 -0
- package/components/settings/calendar-feeds-settings.tsx +489 -0
- package/components/settings/calendar-general-settings.tsx +174 -0
- package/components/settings/confirm-danger-action.test.tsx +215 -0
- package/components/settings/confirm-danger-action.tsx +65 -0
- package/components/settings/security-settings.tsx +252 -0
- package/components/settings/settings-guidance.test.tsx +98 -0
- package/components/settings/team-settings.tsx +319 -0
- package/components/settings/two-factor-auth.tsx +296 -0
- package/components/settings/workspace-settings-client.tsx +363 -0
- package/components/settings/workspace-settings-form.tsx +73 -0
- package/components/sync/conflict-viewer.tsx +247 -0
- package/components/sync/sync-indicator.tsx +171 -0
- package/components/tasks/snippet-thread.tsx +119 -0
- package/components/tasks/status-dot.tsx +47 -0
- package/components/tasks/task-badge.tsx +43 -0
- package/components/tasks/task-detail.test.tsx +187 -0
- package/components/tasks/task-detail.tsx +458 -0
- package/components/tasks/task-list-filters.test.tsx +75 -0
- package/components/tasks/task-list-filters.tsx +163 -0
- package/components/tasks/task-list-types.ts +20 -0
- package/components/tasks/task-list.test.tsx +175 -0
- package/components/tasks/task-list.tsx +481 -0
- package/components/tasks/task-row.tsx +85 -0
- package/components/tasks/task-table-row.tsx +259 -0
- package/components/ui/skeleton.tsx +3 -0
- package/components/ui/toast.test.tsx +42 -0
- package/components/ui/toast.tsx +70 -0
- package/instrumentation.tsx +23 -0
- package/lib/api-error.ts +50 -0
- package/lib/backup/backup-runner.test.ts +32 -0
- package/lib/backup/backup-runner.ts +19 -0
- package/lib/backup/backup-schedule.test.ts +23 -0
- package/lib/backup/backup-schedule.ts +55 -0
- package/lib/backup/backup-settings.test.ts +30 -0
- package/lib/backup/backup-settings.ts +27 -0
- package/lib/backup/export-notes-zip.test.ts +26 -0
- package/lib/backup/export-notes-zip.ts +82 -0
- package/lib/backup/export-workspace-backup.test.ts +17 -0
- package/lib/backup/export-workspace-backup.ts +77 -0
- package/lib/backup/restore-workspace-from-export.test.ts +18 -0
- package/lib/backup/restore-workspace-from-export.ts +183 -0
- package/lib/backup/types.ts +14 -0
- package/lib/brand-icons.ts +1 -0
- package/lib/calendar-feed-crypto.ts +38 -0
- package/lib/calendar-feed.ts +239 -0
- package/lib/client/online-status.ts +47 -0
- package/lib/conflict-resolver.test.ts +57 -0
- package/lib/conflict-resolver.ts +240 -0
- package/lib/db-init.ts +79 -0
- package/lib/email.ts +159 -0
- package/lib/encryption.test.ts +41 -0
- package/lib/encryption.ts +98 -0
- package/lib/extract-snippet.test.ts +123 -0
- package/lib/extract-snippet.ts +69 -0
- package/lib/kanban-status.ts +55 -0
- package/lib/license.ts +21 -0
- package/lib/limits.ts +31 -0
- package/lib/mcp-auth.test.ts +58 -0
- package/lib/mcp-auth.ts +65 -0
- package/lib/mcp-contract.test.ts +25 -0
- package/lib/mcp-contract.ts +210 -0
- package/lib/mcp-handler.ts +31 -0
- package/lib/mcp-url.test.ts +12 -0
- package/lib/mcp-url.ts +7 -0
- package/lib/mentions.test.ts +45 -0
- package/lib/mentions.ts +73 -0
- package/lib/note-crypto.ts +108 -0
- package/lib/note-sync.ts +201 -0
- package/lib/note-title.ts +93 -0
- package/lib/prisma.ts +193 -0
- package/lib/pro-flush.ts +292 -0
- package/lib/rate-limit.ts +57 -0
- package/lib/stripe.ts +38 -0
- package/lib/sync-worker.ts +388 -0
- package/lib/task-parser.test.ts +91 -0
- package/lib/task-parser.ts +81 -0
- package/lib/task-utils.ts +52 -0
- package/lib/use-is-electron.ts +19 -0
- package/lib/use-is-mobile.ts +22 -0
- package/lib/validation/calendar-feed.ts +31 -0
- package/lib/validation/note.ts +27 -0
- package/lib/validation/task.ts +26 -0
- package/lib/view-preferences.test.ts +54 -0
- package/lib/view-preferences.ts +28 -0
- package/lib/workspace.ts +66 -0
- package/next.config.ts +21 -0
- package/package.json +54 -3
- package/postcss.config.mjs +7 -0
- package/prisma/migrations/20260519021916_init/migration.sql +388 -0
- package/prisma/migrations/20260519061113_drop_sync_password/migration.sql +8 -0
- package/prisma/migrations/20260520065016_add_task_start_date/migration.sql +2 -0
- package/prisma/migrations/20260529010600_remove_encryption_fields/migration.sql +12 -0
- package/prisma/migrations/20260529020000_restore_encryption_salt/migration.sql +3 -0
- package/prisma/migrations/20260529030000_add_folders/migration.sql +17 -0
- package/prisma/migrations/20260605000000_deferred_fixes/migration.sql +31 -0
- package/prisma/migrations/20260605020806_add_pending_sync_to_note_and_task/migration.sql +5 -0
- package/prisma/migrations/20260605063634_add_stripe_webhook_event_sync_lock/migration.sql +14 -0
- package/prisma/migrations/20260605100000_add_prod_indexes/migration.sql +26 -0
- package/prisma/migrations/20260608081404_add_kanban_statuses/migration.sql +23 -0
- package/prisma/migrations/20260611032723_add_calendar_feeds/migration.sql +43 -0
- package/prisma/migrations/20260611040000_add_calendar_feed_color/migration.sql +2 -0
- package/prisma/migrations/20260611050000_add_task_priority/migration.sql +14 -0
- package/prisma/migrations/20260612060000_add_critical_priority/migration.sql +2 -0
- package/prisma/migrations/20260613090000_add_backup_settings/migration.sql +25 -0
- package/prisma/migrations/20260614160000_add_feedback/migration.sql +20 -0
- package/prisma/migrations/20260614210000_add_2fa/migration.sql +4 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +457 -0
- package/public/Logo_icon.svg +1 -0
- package/public/file.svg +1 -0
- package/public/globe.svg +1 -0
- package/public/icon_dark.svg +1 -0
- package/public/knotpad_icon.svg +1 -0
- package/public/knotpad_logo_full.svg +1 -0
- package/public/manifest.json +14 -0
- package/public/next.svg +1 -0
- package/public/sw.js +137 -0
- package/public/vercel.svg +1 -0
- package/public/window.svg +1 -0
- package/tsconfig.json +35 -0
- package/brief.js +0 -311
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type Task = {
|
|
2
|
+
id: string;
|
|
3
|
+
title: string;
|
|
4
|
+
status: string;
|
|
5
|
+
priority?: string | null;
|
|
6
|
+
startDate: string | Date | null;
|
|
7
|
+
dueDate: string | Date | null;
|
|
8
|
+
assigneeType: "HUMAN" | "AGENT";
|
|
9
|
+
claimedBy: string | null;
|
|
10
|
+
claimedByAlias: string | null;
|
|
11
|
+
assignee: { id: string; name: string | null; email: string | null; image: string | null } | null;
|
|
12
|
+
note: { id: string; title: string; folder?: { id: string; name: string } | null };
|
|
13
|
+
createdAt?: string | Date;
|
|
14
|
+
updatedAt?: string | Date;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type SortField = "title" | "status" | "dueDate" | "priority" | "assignee" | "note" | "updatedAt";
|
|
18
|
+
export type SortDirection = "asc" | "desc";
|
|
19
|
+
|
|
20
|
+
export type Props = { tasks: Task[]; groupBy?: "status" | "note" };
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { cleanup, render, screen } from "@testing-library/react";
|
|
3
|
+
import userEvent from "@testing-library/user-event";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { TaskList } from "@/components/tasks/task-list";
|
|
6
|
+
import type { Task } from "@/components/tasks/task-list-types";
|
|
7
|
+
|
|
8
|
+
const pushMock = vi.fn();
|
|
9
|
+
const refreshMock = vi.fn();
|
|
10
|
+
let pathname = "/list";
|
|
11
|
+
let searchParams = new URLSearchParams();
|
|
12
|
+
|
|
13
|
+
vi.mock("next/navigation", () => ({
|
|
14
|
+
useRouter: () => ({ push: pushMock, refresh: refreshMock }),
|
|
15
|
+
usePathname: () => pathname,
|
|
16
|
+
useSearchParams: () => searchParams,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
vi.mock("@/components/kanban/kanban-status-context", () => ({
|
|
20
|
+
useKanbanStatuses: () => [
|
|
21
|
+
{ key: "TODO", label: "To Do", isVisible: true },
|
|
22
|
+
{ key: "DONE", label: "Done", isVisible: true },
|
|
23
|
+
],
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
vi.mock("@/components/tasks/task-table-row", () => ({
|
|
27
|
+
TaskTableRow: ({
|
|
28
|
+
task,
|
|
29
|
+
detailHref,
|
|
30
|
+
isSelected,
|
|
31
|
+
onSelect,
|
|
32
|
+
}: {
|
|
33
|
+
task: Task;
|
|
34
|
+
detailHref?: string;
|
|
35
|
+
isSelected: boolean;
|
|
36
|
+
onSelect: () => void;
|
|
37
|
+
}) => (
|
|
38
|
+
<tr data-testid="task-row" data-selected={isSelected ? "true" : "false"}>
|
|
39
|
+
<td>
|
|
40
|
+
<input
|
|
41
|
+
aria-label={`Select ${task.title}`}
|
|
42
|
+
type="checkbox"
|
|
43
|
+
checked={isSelected}
|
|
44
|
+
onChange={onSelect}
|
|
45
|
+
/>
|
|
46
|
+
</td>
|
|
47
|
+
<td>
|
|
48
|
+
{detailHref ? <a href={detailHref}>{task.title}</a> : task.title}
|
|
49
|
+
</td>
|
|
50
|
+
</tr>
|
|
51
|
+
),
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
vi.mock("@/components/tasks/task-row", () => ({
|
|
55
|
+
TaskRow: () => <div data-testid="task-row" />,
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
function makeTask(overrides: Partial<Task>): Task {
|
|
59
|
+
return {
|
|
60
|
+
id: overrides.id ?? "t1",
|
|
61
|
+
title: overrides.title ?? "Task",
|
|
62
|
+
status: overrides.status ?? "TODO",
|
|
63
|
+
priority: overrides.priority ?? "medium",
|
|
64
|
+
startDate: overrides.startDate ?? null,
|
|
65
|
+
dueDate: overrides.dueDate ?? null,
|
|
66
|
+
assigneeType: overrides.assigneeType ?? "HUMAN",
|
|
67
|
+
claimedBy: overrides.claimedBy ?? null,
|
|
68
|
+
claimedByAlias: overrides.claimedByAlias ?? null,
|
|
69
|
+
assignee: overrides.assignee ?? null,
|
|
70
|
+
note: overrides.note ?? { id: "n1", title: "Launch" },
|
|
71
|
+
createdAt: overrides.createdAt,
|
|
72
|
+
updatedAt: overrides.updatedAt,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
beforeEach(() => {
|
|
77
|
+
pushMock.mockReset();
|
|
78
|
+
refreshMock.mockReset();
|
|
79
|
+
pathname = "/list";
|
|
80
|
+
searchParams = new URLSearchParams();
|
|
81
|
+
window.localStorage.clear();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
afterEach(() => {
|
|
85
|
+
cleanup();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe("TaskList", () => {
|
|
89
|
+
it("shows a clearer bulk-selection bar after selecting a task", async () => {
|
|
90
|
+
const user = userEvent.setup();
|
|
91
|
+
|
|
92
|
+
render(<TaskList tasks={[makeTask({ id: "t1", title: "Alpha" })]} />);
|
|
93
|
+
|
|
94
|
+
await user.click(screen.getByLabelText("Select Alpha"));
|
|
95
|
+
|
|
96
|
+
expect(screen.getByText("1 task selected")).toBeInTheDocument();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("applies the overdue saved view preset", async () => {
|
|
100
|
+
const user = userEvent.setup();
|
|
101
|
+
|
|
102
|
+
render(
|
|
103
|
+
<TaskList
|
|
104
|
+
tasks={[
|
|
105
|
+
makeTask({ id: "t1", title: "Overdue task", dueDate: "2026-06-01T00:00:00.000Z" }),
|
|
106
|
+
makeTask({ id: "t2", title: "Fresh task", dueDate: "2026-06-20T00:00:00.000Z" }),
|
|
107
|
+
]}
|
|
108
|
+
/>
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
await user.click(screen.getByRole("button", { name: "Overdue" }));
|
|
112
|
+
|
|
113
|
+
expect(screen.getAllByTestId("task-row")).toHaveLength(1);
|
|
114
|
+
expect(screen.getByText("Overdue task")).toBeInTheDocument();
|
|
115
|
+
expect(screen.queryByText("Fresh task")).not.toBeInTheDocument();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("loads saved sort preferences on first render", () => {
|
|
119
|
+
window.localStorage.setItem("brief:list-sort-field", JSON.stringify("updatedAt"));
|
|
120
|
+
window.localStorage.setItem("brief:list-sort-direction", JSON.stringify("desc"));
|
|
121
|
+
|
|
122
|
+
render(
|
|
123
|
+
<TaskList
|
|
124
|
+
tasks={[
|
|
125
|
+
makeTask({ id: "t1", title: "Older task", updatedAt: "2026-06-10T10:00:00.000Z" }),
|
|
126
|
+
makeTask({ id: "t2", title: "Newer task", updatedAt: "2026-06-12T10:00:00.000Z" }),
|
|
127
|
+
]}
|
|
128
|
+
/>
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
expect(screen.getAllByTestId("task-row").map((row) => row.textContent)).toEqual([
|
|
132
|
+
"Newer task",
|
|
133
|
+
"Older task",
|
|
134
|
+
]);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("persists sort preferences after a user changes the table sort", async () => {
|
|
138
|
+
const user = userEvent.setup();
|
|
139
|
+
|
|
140
|
+
render(
|
|
141
|
+
<TaskList
|
|
142
|
+
tasks={[
|
|
143
|
+
makeTask({ id: "t1", title: "Bravo" }),
|
|
144
|
+
makeTask({ id: "t2", title: "Alpha" }),
|
|
145
|
+
]}
|
|
146
|
+
/>
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
await user.click(screen.getByRole("columnheader", { name: /title/i }));
|
|
150
|
+
await user.click(screen.getByRole("columnheader", { name: /title/i }));
|
|
151
|
+
|
|
152
|
+
expect(window.localStorage.getItem("brief:list-sort-field")).toBe(JSON.stringify("title"));
|
|
153
|
+
expect(window.localStorage.getItem("brief:list-sort-direction")).toBe(JSON.stringify("desc"));
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it("shows filtered empty-state guidance when no tasks match the current view", () => {
|
|
157
|
+
searchParams = new URLSearchParams("status=DONE");
|
|
158
|
+
|
|
159
|
+
render(<TaskList tasks={[]} />);
|
|
160
|
+
|
|
161
|
+
expect(screen.getByText("No tasks match this view.")).toBeInTheDocument();
|
|
162
|
+
expect(
|
|
163
|
+
screen.getByText("Clear one or more filters, or create tasks from a note.")
|
|
164
|
+
).toBeInTheDocument();
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("passes a task detail link for the title", () => {
|
|
168
|
+
render(<TaskList tasks={[makeTask({ id: "t1", title: "Alpha" })]} />);
|
|
169
|
+
|
|
170
|
+
expect(screen.getByRole("link", { name: "Alpha" })).toHaveAttribute(
|
|
171
|
+
"href",
|
|
172
|
+
"/tasks/t1?from=%2Flist%3F"
|
|
173
|
+
);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { usePathname, useSearchParams, useRouter } from "next/navigation";
|
|
6
|
+
import { useKanbanStatuses } from "@/components/kanban/kanban-status-context";
|
|
7
|
+
import { isOverdue } from "@/lib/task-utils";
|
|
8
|
+
import { loadPreference, savePreference } from "@/lib/view-preferences";
|
|
9
|
+
import { TaskRow } from "./task-row";
|
|
10
|
+
import { TaskTableRow } from "./task-table-row";
|
|
11
|
+
import type { Task, SortField, SortDirection, Props } from "./task-list-types";
|
|
12
|
+
|
|
13
|
+
type SavedView = "all" | "overdue" | "unscheduled" | "agent";
|
|
14
|
+
|
|
15
|
+
// Table header component with sort indicators
|
|
16
|
+
function TableHeader({ field, label, className = "", sortField, sortDirection, onSortClick }: {
|
|
17
|
+
field: SortField;
|
|
18
|
+
label: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
sortField: SortField;
|
|
21
|
+
sortDirection: SortDirection;
|
|
22
|
+
onSortClick: (field: SortField) => void;
|
|
23
|
+
}) {
|
|
24
|
+
const isActive = sortField === field;
|
|
25
|
+
return (
|
|
26
|
+
<th
|
|
27
|
+
onClick={() => onSortClick(field)}
|
|
28
|
+
className={`cursor-pointer px-4 py-3 text-left text-xs font-medium text-zinc-400 hover:text-zinc-200 transition-colors ${className}`}
|
|
29
|
+
>
|
|
30
|
+
<div className="flex items-center gap-1">
|
|
31
|
+
{label}
|
|
32
|
+
{isActive && (
|
|
33
|
+
<span className="text-zinc-300">
|
|
34
|
+
{sortDirection === "asc" ? "↑" : "↓"}
|
|
35
|
+
</span>
|
|
36
|
+
)}
|
|
37
|
+
</div>
|
|
38
|
+
</th>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function TaskList({ tasks, groupBy = "status" }: Props) {
|
|
43
|
+
const router = useRouter();
|
|
44
|
+
const pathname = usePathname();
|
|
45
|
+
const searchParams = useSearchParams();
|
|
46
|
+
const kanbanStatuses = useKanbanStatuses();
|
|
47
|
+
const statusOrder = kanbanStatuses.filter((s) => s.isVisible).map((s) => s.key);
|
|
48
|
+
const statusOptions = kanbanStatuses.map((s) => s.key);
|
|
49
|
+
const [optimistic, setOptimistic] = useState<Record<string, string>>({});
|
|
50
|
+
const [updating, setUpdating] = useState<string | null>(null);
|
|
51
|
+
const [statusError, setStatusError] = useState<string | null>(null);
|
|
52
|
+
|
|
53
|
+
// Sorting state
|
|
54
|
+
const [sortField, setSortField] = useState<SortField>(() =>
|
|
55
|
+
loadPreference("brief:list-sort-field", "dueDate")
|
|
56
|
+
);
|
|
57
|
+
const [sortDirection, setSortDirection] = useState<SortDirection>(() =>
|
|
58
|
+
loadPreference("brief:list-sort-direction", "asc")
|
|
59
|
+
);
|
|
60
|
+
const [savedView, setSavedView] = useState<SavedView>(() =>
|
|
61
|
+
loadPreference("brief:list-saved-view", "all")
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
// Selected tasks for bulk actions
|
|
65
|
+
const [selectedTasks, setSelectedTasks] = useState<Set<string>>(new Set());
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
savePreference("brief:list-sort-field", sortField);
|
|
69
|
+
savePreference("brief:list-sort-direction", sortDirection);
|
|
70
|
+
}, [sortDirection, sortField]);
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
savePreference("brief:list-saved-view", savedView);
|
|
74
|
+
}, [savedView]);
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
setSelectedTasks(new Set());
|
|
78
|
+
}, [savedView]);
|
|
79
|
+
|
|
80
|
+
function getStatus(t: Task): string {
|
|
81
|
+
return optimistic[t.id] ?? t.status;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function taskDetailHref(taskId: string) {
|
|
85
|
+
const from = `${pathname}?${searchParams.toString()}`;
|
|
86
|
+
return `/tasks/${taskId}?from=${encodeURIComponent(from)}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Sorting function
|
|
90
|
+
function sortTasks(tasksToSort: Task[]): Task[] {
|
|
91
|
+
return [...tasksToSort].sort((a, b) => {
|
|
92
|
+
let comparison = 0;
|
|
93
|
+
|
|
94
|
+
switch (sortField) {
|
|
95
|
+
case "title":
|
|
96
|
+
comparison = a.title.localeCompare(b.title);
|
|
97
|
+
break;
|
|
98
|
+
case "status":
|
|
99
|
+
const aStatusIndex = statusOrder.indexOf(getStatus(a));
|
|
100
|
+
const bStatusIndex = statusOrder.indexOf(getStatus(b));
|
|
101
|
+
comparison = (aStatusIndex === -1 ? 999 : aStatusIndex) - (bStatusIndex === -1 ? 999 : bStatusIndex);
|
|
102
|
+
break;
|
|
103
|
+
case "dueDate":
|
|
104
|
+
const aDue = a.dueDate ? new Date(a.dueDate).getTime() : Infinity;
|
|
105
|
+
const bDue = b.dueDate ? new Date(b.dueDate).getTime() : Infinity;
|
|
106
|
+
comparison = aDue - bDue;
|
|
107
|
+
break;
|
|
108
|
+
case "priority":
|
|
109
|
+
const priorityOrder = { critical: 0, high: 1, medium: 2, low: 3 };
|
|
110
|
+
const aPriority = priorityOrder[(a.priority?.toLowerCase() || "medium") as keyof typeof priorityOrder] ?? 2;
|
|
111
|
+
const bPriority = priorityOrder[(b.priority?.toLowerCase() || "medium") as keyof typeof priorityOrder] ?? 2;
|
|
112
|
+
comparison = aPriority - bPriority;
|
|
113
|
+
break;
|
|
114
|
+
case "assignee":
|
|
115
|
+
const aAssignee = a.assignee?.name || a.claimedByAlias || "";
|
|
116
|
+
const bAssignee = b.assignee?.name || b.claimedByAlias || "";
|
|
117
|
+
comparison = aAssignee.localeCompare(bAssignee);
|
|
118
|
+
break;
|
|
119
|
+
case "note":
|
|
120
|
+
comparison = a.note.title.localeCompare(b.note.title);
|
|
121
|
+
break;
|
|
122
|
+
case "updatedAt":
|
|
123
|
+
const aUpdated = a.updatedAt ? new Date(a.updatedAt).getTime() : 0;
|
|
124
|
+
const bUpdated = b.updatedAt ? new Date(b.updatedAt).getTime() : 0;
|
|
125
|
+
comparison = aUpdated - bUpdated;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return sortDirection === "asc" ? comparison : -comparison;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Handle column header click for sorting
|
|
134
|
+
function handleSortClick(field: SortField) {
|
|
135
|
+
if (sortField === field) {
|
|
136
|
+
setSortDirection(sortDirection === "asc" ? "desc" : "asc");
|
|
137
|
+
} else {
|
|
138
|
+
setSortField(field);
|
|
139
|
+
setSortDirection("asc");
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Toggle task selection
|
|
144
|
+
function toggleTaskSelection(taskId: string) {
|
|
145
|
+
const newSelected = new Set(selectedTasks);
|
|
146
|
+
if (newSelected.has(taskId)) {
|
|
147
|
+
newSelected.delete(taskId);
|
|
148
|
+
} else {
|
|
149
|
+
newSelected.add(taskId);
|
|
150
|
+
}
|
|
151
|
+
setSelectedTasks(newSelected);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Select/deselect all tasks
|
|
155
|
+
function toggleAllTasks() {
|
|
156
|
+
if (selectedTasks.size === filteredTasks.length) {
|
|
157
|
+
setSelectedTasks(new Set());
|
|
158
|
+
} else {
|
|
159
|
+
setSelectedTasks(new Set(filteredTasks.map((task) => task.id)));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async function changeStatus(taskId: string, newStatus: string) {
|
|
164
|
+
const prevStatus = getStatus(tasks.find((t) => t.id === taskId)!);
|
|
165
|
+
setOptimistic((prev) => ({ ...prev, [taskId]: newStatus }));
|
|
166
|
+
setUpdating(taskId);
|
|
167
|
+
setStatusError(null);
|
|
168
|
+
try {
|
|
169
|
+
const res = await fetch(`/api/tasks/${taskId}`, {
|
|
170
|
+
method: "PATCH",
|
|
171
|
+
headers: { "Content-Type": "application/json" },
|
|
172
|
+
body: JSON.stringify({ status: newStatus }),
|
|
173
|
+
});
|
|
174
|
+
if (!res.ok) throw new Error(`${res.status}`);
|
|
175
|
+
router.refresh();
|
|
176
|
+
} catch {
|
|
177
|
+
// Revert optimistic state and surface the error
|
|
178
|
+
setOptimistic((prev) => ({ ...prev, [taskId]: prevStatus }));
|
|
179
|
+
setStatusError("Couldn't update status — please try again.");
|
|
180
|
+
} finally {
|
|
181
|
+
setUpdating(null);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Inline edit handlers (Tasks 2.3.1-2.3.3)
|
|
186
|
+
async function updateDueDate(taskId: string, dueDate: string | null) {
|
|
187
|
+
try {
|
|
188
|
+
const res = await fetch(`/api/tasks/${taskId}`, {
|
|
189
|
+
method: "PATCH",
|
|
190
|
+
headers: { "Content-Type": "application/json" },
|
|
191
|
+
body: JSON.stringify({ dueDate }),
|
|
192
|
+
});
|
|
193
|
+
if (!res.ok) throw new Error(`${res.status}`);
|
|
194
|
+
router.refresh();
|
|
195
|
+
} catch {
|
|
196
|
+
setStatusError("Couldn't update due date — please try again.");
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async function updateAssignee(taskId: string, assigneeType: "HUMAN" | "AGENT", assigneeId?: string) {
|
|
201
|
+
try {
|
|
202
|
+
const body: Record<string, unknown> = { assigneeType };
|
|
203
|
+
if (assigneeType === "AGENT") {
|
|
204
|
+
body.assigneeId = null;
|
|
205
|
+
} else {
|
|
206
|
+
// Explicitly send assigneeId (or null to unassign)
|
|
207
|
+
body.assigneeId = assigneeId ?? null;
|
|
208
|
+
}
|
|
209
|
+
const res = await fetch(`/api/tasks/${taskId}`, {
|
|
210
|
+
method: "PATCH",
|
|
211
|
+
headers: { "Content-Type": "application/json" },
|
|
212
|
+
body: JSON.stringify(body),
|
|
213
|
+
});
|
|
214
|
+
if (!res.ok) throw new Error(`${res.status}`);
|
|
215
|
+
router.refresh();
|
|
216
|
+
} catch {
|
|
217
|
+
setStatusError("Couldn't update assignee — please try again.");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const errorBanner = statusError ? (
|
|
222
|
+
<div className="flex items-center justify-between gap-2 border-b border-red-800/40 bg-red-950/40 px-3 md:px-6 py-2">
|
|
223
|
+
<span className="text-sm text-red-300">{statusError}</span>
|
|
224
|
+
<button onClick={() => setStatusError(null)} className="text-zinc-500 hover:text-zinc-300 text-xs">✕</button>
|
|
225
|
+
</div>
|
|
226
|
+
) : null;
|
|
227
|
+
|
|
228
|
+
const hasActiveFilters = [
|
|
229
|
+
"note",
|
|
230
|
+
"folder",
|
|
231
|
+
"status",
|
|
232
|
+
"assigneeType",
|
|
233
|
+
"overdue",
|
|
234
|
+
"hasDueDate",
|
|
235
|
+
].some((key) => {
|
|
236
|
+
const value = searchParams.get(key);
|
|
237
|
+
return value !== null && value !== "";
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
const filteredTasks = tasks.filter((task) => {
|
|
241
|
+
if (savedView === "overdue") {
|
|
242
|
+
return isOverdue({ ...task, status: getStatus(task) });
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (savedView === "unscheduled") {
|
|
246
|
+
return !task.startDate && !task.dueDate;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (savedView === "agent") {
|
|
250
|
+
return task.assigneeType === "AGENT";
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return true;
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
const showFilteredEmptyState = hasActiveFilters || savedView !== "all";
|
|
257
|
+
const savedViewOptions: { key: SavedView; label: string }[] = [
|
|
258
|
+
{ key: "all", label: "All" },
|
|
259
|
+
{ key: "overdue", label: "Overdue" },
|
|
260
|
+
{ key: "unscheduled", label: "Unscheduled" },
|
|
261
|
+
{ key: "agent", label: "Agent" },
|
|
262
|
+
];
|
|
263
|
+
|
|
264
|
+
const savedViewBar = (
|
|
265
|
+
<div className="flex flex-wrap items-center gap-2 border-b border-zinc-800/60 px-3 py-3 md:px-6">
|
|
266
|
+
<span className="text-xs uppercase tracking-wide text-zinc-500">Views</span>
|
|
267
|
+
<div className="inline-flex flex-wrap rounded-md border border-zinc-800 bg-zinc-950 p-1">
|
|
268
|
+
{savedViewOptions.map((option) => (
|
|
269
|
+
<button
|
|
270
|
+
key={option.key}
|
|
271
|
+
type="button"
|
|
272
|
+
onClick={() => setSavedView(option.key)}
|
|
273
|
+
className={
|
|
274
|
+
savedView === option.key
|
|
275
|
+
? "rounded px-2 py-1 text-xs bg-zinc-800 text-zinc-200"
|
|
276
|
+
: "rounded px-2 py-1 text-xs text-zinc-500 hover:text-zinc-300"
|
|
277
|
+
}
|
|
278
|
+
>
|
|
279
|
+
{option.label}
|
|
280
|
+
</button>
|
|
281
|
+
))}
|
|
282
|
+
</div>
|
|
283
|
+
</div>
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
if (filteredTasks.length === 0) {
|
|
287
|
+
return (
|
|
288
|
+
<>
|
|
289
|
+
{errorBanner}
|
|
290
|
+
{savedViewBar}
|
|
291
|
+
<div className="flex flex-col items-center justify-center gap-3 py-24 text-center">
|
|
292
|
+
{showFilteredEmptyState ? (
|
|
293
|
+
<>
|
|
294
|
+
<p className="text-zinc-500">No tasks match this view.</p>
|
|
295
|
+
<p className="text-sm text-zinc-600">
|
|
296
|
+
Clear one or more filters, or create tasks from a note.
|
|
297
|
+
</p>
|
|
298
|
+
</>
|
|
299
|
+
) : (
|
|
300
|
+
<>
|
|
301
|
+
<p className="text-zinc-500">No tasks yet.</p>
|
|
302
|
+
<p className="text-sm text-zinc-600">
|
|
303
|
+
Write{" "}
|
|
304
|
+
<code className="rounded bg-zinc-800 px-1 py-0.5 text-xs text-zinc-400">
|
|
305
|
+
- [ ] task
|
|
306
|
+
</code>{" "}
|
|
307
|
+
in a note to create tasks automatically.
|
|
308
|
+
</p>
|
|
309
|
+
</>
|
|
310
|
+
)}
|
|
311
|
+
</div>
|
|
312
|
+
</>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (groupBy === "note") {
|
|
317
|
+
const noteMap = new Map<string, { title: string; tasks: Task[] }>();
|
|
318
|
+
for (const t of filteredTasks) {
|
|
319
|
+
if (!noteMap.has(t.note.id)) {
|
|
320
|
+
noteMap.set(t.note.id, { title: t.note.title, tasks: [] });
|
|
321
|
+
}
|
|
322
|
+
noteMap.get(t.note.id)!.tasks.push(t);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return (
|
|
326
|
+
<>
|
|
327
|
+
{errorBanner}
|
|
328
|
+
{savedViewBar}
|
|
329
|
+
<div className="divide-y divide-zinc-800/60">
|
|
330
|
+
{[...noteMap.entries()].map(([noteId, { title, tasks: noteTasks }]) => (
|
|
331
|
+
<div key={noteId} className="px-3 md:px-6 py-4">
|
|
332
|
+
<div className="mb-3 flex items-center gap-2">
|
|
333
|
+
<Link href={`/notes/${noteId}`} className="text-sm font-medium text-zinc-300 hover:text-white">
|
|
334
|
+
{title}
|
|
335
|
+
</Link>
|
|
336
|
+
<span className="text-xs text-zinc-600">{noteTasks.length}</span>
|
|
337
|
+
</div>
|
|
338
|
+
<div className="space-y-1">
|
|
339
|
+
{noteTasks
|
|
340
|
+
.sort((a, b) => statusOrder.indexOf(getStatus(a)) - statusOrder.indexOf(getStatus(b)))
|
|
341
|
+
.map((task) => (
|
|
342
|
+
<TaskRow
|
|
343
|
+
key={task.id}
|
|
344
|
+
task={task}
|
|
345
|
+
status={getStatus(task)}
|
|
346
|
+
overdue={isOverdue({ ...task, status: getStatus(task) })}
|
|
347
|
+
updating={updating === task.id}
|
|
348
|
+
detailHref={taskDetailHref(task.id)}
|
|
349
|
+
onStatusChange={changeStatus}
|
|
350
|
+
/>
|
|
351
|
+
))}
|
|
352
|
+
</div>
|
|
353
|
+
</div>
|
|
354
|
+
))}
|
|
355
|
+
</div>
|
|
356
|
+
</>
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// When groupBy === "status", show sortable table view
|
|
361
|
+
// Collect orphaned tasks (status not in visible statusOrder) so they aren't shown twice
|
|
362
|
+
const visibleTasks = filteredTasks.filter((t) => statusOrder.includes(getStatus(t)));
|
|
363
|
+
const orphanedTasks = filteredTasks.filter((t) => !statusOrder.includes(getStatus(t)));
|
|
364
|
+
const sortedTasks = sortTasks(visibleTasks);
|
|
365
|
+
const sortedOrphanedTasks = sortTasks(orphanedTasks);
|
|
366
|
+
|
|
367
|
+
// Return sortable table view for status grouping
|
|
368
|
+
return (
|
|
369
|
+
<>
|
|
370
|
+
{errorBanner}
|
|
371
|
+
{savedViewBar}
|
|
372
|
+
|
|
373
|
+
{/* Bulk action bar */}
|
|
374
|
+
{selectedTasks.size > 0 && (
|
|
375
|
+
<div className="sticky top-0 z-10 flex items-center gap-4 border-b border-blue-900/30 bg-blue-950/30 px-4 py-3">
|
|
376
|
+
<span className="text-sm text-blue-100">
|
|
377
|
+
{selectedTasks.size} task{selectedTasks.size === 1 ? "" : "s"} selected
|
|
378
|
+
</span>
|
|
379
|
+
<div className="flex items-center gap-2">
|
|
380
|
+
<select
|
|
381
|
+
onChange={(e) => {
|
|
382
|
+
if (e.target.value) {
|
|
383
|
+
// Bulk status change - would need API endpoint
|
|
384
|
+
alert(`Would change ${selectedTasks.size} tasks to ${e.target.value}`);
|
|
385
|
+
e.target.value = "";
|
|
386
|
+
}
|
|
387
|
+
}}
|
|
388
|
+
className="rounded border border-blue-900/40 bg-zinc-900 px-2 py-1 text-xs text-zinc-200"
|
|
389
|
+
>
|
|
390
|
+
<option value="">Set status...</option>
|
|
391
|
+
{statusOptions.map((s) => (
|
|
392
|
+
<option key={s} value={s}>{s}</option>
|
|
393
|
+
))}
|
|
394
|
+
</select>
|
|
395
|
+
<button
|
|
396
|
+
onClick={() => setSelectedTasks(new Set())}
|
|
397
|
+
className="text-xs text-blue-200/80 hover:text-blue-100"
|
|
398
|
+
>
|
|
399
|
+
Clear
|
|
400
|
+
</button>
|
|
401
|
+
</div>
|
|
402
|
+
</div>
|
|
403
|
+
)}
|
|
404
|
+
|
|
405
|
+
{/* Sortable Table View */}
|
|
406
|
+
<div className="overflow-x-auto">
|
|
407
|
+
<table className="w-full">
|
|
408
|
+
<thead className="border-b border-zinc-800 bg-zinc-900/50">
|
|
409
|
+
<tr>
|
|
410
|
+
<th className="px-3 py-3 w-8">
|
|
411
|
+
<input
|
|
412
|
+
type="checkbox"
|
|
413
|
+
checked={selectedTasks.size === filteredTasks.length && filteredTasks.length > 0}
|
|
414
|
+
onChange={toggleAllTasks}
|
|
415
|
+
className="rounded border-zinc-600 bg-zinc-800 text-blue-600"
|
|
416
|
+
/>
|
|
417
|
+
</th>
|
|
418
|
+
<TableHeader field="title" label="Title" className="w-[35%]" sortField={sortField} sortDirection={sortDirection} onSortClick={handleSortClick} />
|
|
419
|
+
<TableHeader field="status" label="Status" sortField={sortField} sortDirection={sortDirection} onSortClick={handleSortClick} />
|
|
420
|
+
<TableHeader field="dueDate" label="Due" sortField={sortField} sortDirection={sortDirection} onSortClick={handleSortClick} />
|
|
421
|
+
<TableHeader field="priority" label="Priority" sortField={sortField} sortDirection={sortDirection} onSortClick={handleSortClick} />
|
|
422
|
+
<TableHeader field="assignee" label="Assignee" sortField={sortField} sortDirection={sortDirection} onSortClick={handleSortClick} />
|
|
423
|
+
<TableHeader field="note" label="Note/Folder" sortField={sortField} sortDirection={sortDirection} onSortClick={handleSortClick} />
|
|
424
|
+
<TableHeader field="updatedAt" label="Updated" sortField={sortField} sortDirection={sortDirection} onSortClick={handleSortClick} />
|
|
425
|
+
</tr>
|
|
426
|
+
</thead>
|
|
427
|
+
<tbody className="divide-y divide-zinc-800/60">
|
|
428
|
+
{sortedTasks.map((task) => (
|
|
429
|
+
<TaskTableRow
|
|
430
|
+
key={task.id}
|
|
431
|
+
task={task}
|
|
432
|
+
status={getStatus(task)}
|
|
433
|
+
overdue={isOverdue({ ...task, status: getStatus(task) })}
|
|
434
|
+
updating={updating === task.id}
|
|
435
|
+
onStatusChange={changeStatus}
|
|
436
|
+
isSelected={selectedTasks.has(task.id)}
|
|
437
|
+
onSelect={() => toggleTaskSelection(task.id)}
|
|
438
|
+
kanbanStatuses={kanbanStatuses}
|
|
439
|
+
detailHref={taskDetailHref(task.id)}
|
|
440
|
+
onUpdateDueDate={updateDueDate}
|
|
441
|
+
onUpdateAssignee={updateAssignee}
|
|
442
|
+
/>
|
|
443
|
+
))}
|
|
444
|
+
</tbody>
|
|
445
|
+
</table>
|
|
446
|
+
</div>
|
|
447
|
+
|
|
448
|
+
{/* Orphaned tasks section */}
|
|
449
|
+
{sortedOrphanedTasks.length > 0 && (
|
|
450
|
+
<div className="mt-6 border-t border-zinc-800">
|
|
451
|
+
<div className="px-4 py-3 bg-zinc-900/30">
|
|
452
|
+
<span className="inline-flex items-center rounded border border-zinc-600 bg-zinc-800/60 px-2 py-0.5 text-xs font-medium text-zinc-400">
|
|
453
|
+
Uncategorized
|
|
454
|
+
</span>
|
|
455
|
+
<span className="ml-2 text-xs text-zinc-600">{sortedOrphanedTasks.length} tasks with custom status</span>
|
|
456
|
+
</div>
|
|
457
|
+
<table className="w-full">
|
|
458
|
+
<tbody className="divide-y divide-zinc-800/60">
|
|
459
|
+
{sortedOrphanedTasks.map((task) => (
|
|
460
|
+
<TaskTableRow
|
|
461
|
+
key={task.id}
|
|
462
|
+
task={task}
|
|
463
|
+
status={getStatus(task)}
|
|
464
|
+
overdue={isOverdue({ ...task, status: getStatus(task) })}
|
|
465
|
+
updating={updating === task.id}
|
|
466
|
+
onStatusChange={changeStatus}
|
|
467
|
+
isSelected={selectedTasks.has(task.id)}
|
|
468
|
+
onSelect={() => toggleTaskSelection(task.id)}
|
|
469
|
+
kanbanStatuses={kanbanStatuses}
|
|
470
|
+
detailHref={taskDetailHref(task.id)}
|
|
471
|
+
onUpdateDueDate={updateDueDate}
|
|
472
|
+
onUpdateAssignee={updateAssignee}
|
|
473
|
+
/>
|
|
474
|
+
))}
|
|
475
|
+
</tbody>
|
|
476
|
+
</table>
|
|
477
|
+
</div>
|
|
478
|
+
)}
|
|
479
|
+
</>
|
|
480
|
+
);
|
|
481
|
+
}
|