Calendar: - GET /api/domains/[domainId]/calendar/events?from=&to= — returns tasks, habits, projects, milestones - PATCH /api/domains/[domainId]/tasks/[id]/schedule — drag-to-reschedule with activity feed - Calendar UI with month/week/day views via react-big-calendar - Drag-to-reschedule with SSE updates - Filter by entity type and domain - Keyboard shortcuts: t=today, m/w/d=view, ←/→=navigate - Mobile: auto-switches to day view on small screens Dashboard: - GET/PUT /api/domains/[domainId]/dashboard — layout stored in domain custom_fields - 8 per-widget data endpoints (today-tasks, habit-checklist, weekly-stats, project-progress, upcoming-calendar, recent-notes, activity-feed, quick-capture) - react-grid-layout with responsive breakpoints (12/8/4 cols) - Drag-to-reorder, resize, add/remove widgets - Edit mode toggle, per-workspace layout persistence - Widget error boundary Search: - tsvector columns + GIN indexes on tasks, notes, projects, habits, domains - GET /api/search?q=&types=&domain= — ranked results with ts_headline snippets - Dedicated search page with grouped results, filters, recent searches (localStorage) - Empty state with hints Schema: - Added custom_fields jsonb column to domains table (migration 0002) - Removed stale root app/ directory Build: passes, typecheck: passes, tests: 18/18 wikilink-parser tests pass
63 lines
1.9 KiB
TypeScript
63 lines
1.9 KiB
TypeScript
import { create } from 'zustand';
|
|
import { persist } from 'zustand/middleware';
|
|
|
|
interface WidgetConfig {
|
|
id: string;
|
|
type: string;
|
|
x: number;
|
|
y: number;
|
|
w: number;
|
|
h: number;
|
|
visible: boolean;
|
|
}
|
|
|
|
interface DashboardState {
|
|
widgets: WidgetConfig[];
|
|
|
|
// Actions
|
|
setWidgets: (widgets: WidgetConfig[]) => void;
|
|
updateWidget: (id: string, updates: Partial<WidgetConfig>) => void;
|
|
addWidget: (widget: WidgetConfig) => void;
|
|
removeWidget: (id: string) => void;
|
|
resetLayout: () => void;
|
|
}
|
|
|
|
const defaultWidgets: WidgetConfig[] = [
|
|
{ id: 'today-tasks', type: "Today's Tasks", x: 0, y: 0, w: 6, h: 4, visible: true },
|
|
{ id: 'habit-checklist', type: 'Habit Checklist', x: 6, y: 0, w: 3, h: 4, visible: true },
|
|
{ id: 'weekly-stats', type: 'Weekly Stats', x: 9, y: 0, w: 3, h: 4, visible: true },
|
|
{ id: 'project-progress', type: 'Project Progress', x: 0, y: 4, w: 4, h: 3, visible: true },
|
|
{ id: 'upcoming-calendar', type: 'Upcoming Calendar', x: 4, y: 4, w: 4, h: 3, visible: true },
|
|
{ id: 'recent-notes', type: 'Recent Notes', x: 8, y: 4, w: 4, h: 3, visible: true },
|
|
{ id: 'activity-feed', type: 'Activity Feed', x: 0, y: 7, w: 6, h: 3, visible: true },
|
|
{ id: 'quick-capture', type: 'Quick Capture', x: 6, y: 7, w: 3, h: 3, visible: true },
|
|
];
|
|
|
|
export const useDashboardStore = create<DashboardState>()(
|
|
persist(
|
|
(set) => ({
|
|
widgets: defaultWidgets,
|
|
|
|
setWidgets: (widgets) => set({ widgets }),
|
|
updateWidget: (id, updates) =>
|
|
set((state) => ({
|
|
widgets: state.widgets.map((w) =>
|
|
w.id === id ? { ...w, ...updates } : w
|
|
),
|
|
})),
|
|
addWidget: (widget) =>
|
|
set((state) => ({
|
|
widgets: [...state.widgets, widget],
|
|
})),
|
|
removeWidget: (id) =>
|
|
set((state) => ({
|
|
widgets: state.widgets.filter((w) => w.id !== id),
|
|
})),
|
|
resetLayout: () => set({ widgets: defaultWidgets }),
|
|
}),
|
|
{
|
|
name: 'project-e-dashboard',
|
|
}
|
|
)
|
|
);
|