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

This commit is contained in:
gitmuhammedalbayrak
2025-11-24 05:15:49 +03:00
parent 84a265ea14
commit 066c16221d
4 changed files with 153 additions and 2 deletions

View File

@@ -2,17 +2,24 @@ import React from 'react';
import { Layout } from 'antd';
import Sidebar from './components/Sidebar';
import MindMap from './components/MindMap';
import { useProjectStore } from './store/useProjectStore';
const { Sider, Content } = Layout;
const App: React.FC = () => {
const { fetchProjects } = useProjectStore();
React.useEffect(() => {
fetchProjects();
}, [fetchProjects]);
return (
<Layout style={{ height: '100vh' }}>
<Sider width={300} theme="light">
<Sider width={300} theme="light" style={{ borderRight: '1px solid #f0f0f0' }}>
<Sidebar />
</Sider>
<Layout>
<Content>
<Content style={{ background: '#fff' }}>
<MindMap />
</Content>
</Layout>

View File

@@ -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 });
}
},
}));