feat(frontend): Day 7 - frontend complete layout finished

This commit is contained in:
AI Clinical Dev Team
2025-10-10 17:52:47 +08:00
parent df20300190
commit fef8feb9db
11 changed files with 872 additions and 129 deletions

View File

@@ -0,0 +1,69 @@
import { create } from 'zustand';
export interface Project {
id: string;
name: string;
background: string;
researchType: 'observational' | 'interventional';
createdAt: string;
updatedAt: string;
}
interface ProjectState {
// 当前选中的项目
currentProject: Project | null;
// 所有项目列表
projects: Project[];
// 是否显示创建项目对话框
showCreateDialog: boolean;
// 是否显示编辑项目对话框
showEditDialog: boolean;
// Actions
setCurrentProject: (project: Project | null) => void;
setProjects: (projects: Project[]) => void;
addProject: (project: Project) => void;
updateProject: (id: string, updates: Partial<Project>) => void;
deleteProject: (id: string) => void;
setShowCreateDialog: (show: boolean) => void;
setShowEditDialog: (show: boolean) => void;
}
export const useProjectStore = create<ProjectState>((set) => ({
currentProject: null,
projects: [],
showCreateDialog: false,
showEditDialog: false,
setCurrentProject: (project) => set({ currentProject: project }),
setProjects: (projects) => set({ projects }),
addProject: (project) => set((state) => ({
projects: [...state.projects, project],
})),
updateProject: (id, updates) => set((state) => ({
projects: state.projects.map((p) =>
p.id === id ? { ...p, ...updates } : p
),
currentProject:
state.currentProject?.id === id
? { ...state.currentProject, ...updates }
: state.currentProject,
})),
deleteProject: (id) => set((state) => ({
projects: state.projects.filter((p) => p.id !== id),
currentProject:
state.currentProject?.id === id ? null : state.currentProject,
})),
setShowCreateDialog: (show) => set({ showCreateDialog: show }),
setShowEditDialog: (show) => set({ showEditDialog: show }),
}));