feat: Add initial local Docker Swarm deployment setup and frontend application structure with project state management.
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -16,8 +16,17 @@ interface ProjectState {
|
||||
setExpandedKeys: (keys: string[]) => void;
|
||||
setSelectedKey: (key: string | null) => void;
|
||||
expandNode: (key: string) => void;
|
||||
fetchProjects: () => Promise<void>;
|
||||
}
|
||||
|
||||
const DUMMY_PROJECTS: Project[] = [
|
||||
{ id: '1', name: 'Genel Merkez', path: 'root', parentId: null },
|
||||
{ id: '2', name: 'Yazılım Departmanı', path: 'root.software', parentId: '1' },
|
||||
{ id: '3', name: 'İnsan Kaynakları', path: 'root.hr', parentId: '1' },
|
||||
{ id: '4', name: 'Evrak Projesi', path: 'root.software.evrak', parentId: '2' },
|
||||
{ id: '5', name: 'Website Yenileme', path: 'root.software.website', parentId: '2' },
|
||||
];
|
||||
|
||||
export const useProjectStore = create<ProjectState>((set) => ({
|
||||
projects: [],
|
||||
expandedKeys: [],
|
||||
@@ -31,4 +40,19 @@ export const useProjectStore = create<ProjectState>((set) => ({
|
||||
? state.expandedKeys
|
||||
: [...state.expandedKeys, key],
|
||||
})),
|
||||
fetchProjects: async () => {
|
||||
try {
|
||||
const response = await fetch('http://localhost:3000/projects');
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
set({ projects: data });
|
||||
} else {
|
||||
console.error('Failed to fetch projects');
|
||||
set({ projects: DUMMY_PROJECTS });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching projects:', error);
|
||||
set({ projects: DUMMY_PROJECTS });
|
||||
}
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user