Files
ProjectE/apps/web/lib/stores/use-dashboard-store.ts
T
mbatchelder 8f55626e03 refactor: migrate to monorepo structure with Docker, PocketBase, and e2e tests
- Reorganize into apps/, packages/, docs/, e2e/, pocketbase/ directories
- Add Dockerfiles for web, worker, and PocketBase services
- Add docker-compose.yml for local orchestration
- Add turbo.json for monorepo task management
- Add Playwright e2e test infrastructure
- Add PocketBase backend with migrations
- Remove Vite/Next.js/ESLint/PostCSS config files
- Update package.json with workspace dependencies
- Add .env.example and .dockerignore
2026-07-16 06:19:58 -04:00

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: 'TodayTasks', x: 0, y: 0, w: 6, h: 4, visible: true },
{ id: 'habit-checklist', type: 'HabitChecklist', x: 6, y: 0, w: 3, h: 4, visible: true },
{ id: 'weekly-stats', type: 'WeeklyStats', x: 9, y: 0, w: 3, h: 4, visible: true },
{ id: 'project-progress', type: 'ProjectProgress', x: 0, y: 4, w: 4, h: 3, visible: true },
{ id: 'habit-streaks', type: 'HabitStreaks', x: 4, y: 4, w: 4, h: 3, visible: true },
{ id: 'calendar-mini', type: 'CalendarMini', x: 8, y: 4, w: 4, h: 3, visible: true },
{ id: 'quick-add', type: 'QuickAdd', x: 0, y: 7, w: 3, h: 3, visible: true },
{ id: 'recent-activity', type: 'RecentActivity', x: 3, y: 7, w: 9, 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',
}
)
);