diff --git a/package.json b/package.json index 8e7d22a..d31565e 100644 --- a/package.json +++ b/package.json @@ -16,15 +16,22 @@ "@radix-ui/react-scroll-area": "^1.2.0", "@radix-ui/react-select": "^2.1.2", "@radix-ui/react-slot": "^1.1.0", + "@tanstack/react-query": "^5.61.0", + "@types/leaflet": "^1.9.14", + "@types/react-leaflet": "^3.0.0", "axios": "^1.7.7", "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", + "leaflet": "^1.9.4", "lucide-react": "^0.446.0", "react": "^18.3.1", "react-dom": "^18.3.1", + "react-hot-toast": "^2.4.1", + "react-leaflet": "^4.2.1", "react-router-dom": "^6.28.0", "tailwind-merge": "^2.5.2", - "tailwindcss-animate": "^1.0.7" + "tailwindcss-animate": "^1.0.7", + "zustand": "^5.0.1" }, "devDependencies": { "@eslint/js": "^9.9.0", diff --git a/src/App.tsx b/src/App.tsx index 35caae8..7be3705 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,21 +1,53 @@ import { BrowserRouter, Route, Routes } from 'react-router-dom'; import './App.css'; +import 'leaflet/dist/leaflet.css'; import { Sidebar } from './components/sidebar'; -import Dashboard from './pages/dashboard.page'; import { TagsPage } from './pages/tags.page'; +import { MapPage } from './pages/map.page'; +import { Toaster } from 'react-hot-toast'; +import { SettingsPage } from './pages/settings.page'; +import DashboardSidebar from './modules/dashboard-sidebar.module'; +import { DashboardPage } from './pages/dashboard.page'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { AddPlacePage } from './pages/add-place.page'; + + +const queryClient = new QueryClient(); function App() { return ( - - - } > - } /> - } /> - } /> - - - + + + + } > + } > + } /> + + } /> + } /> + } /> + } /> + + + + + ); } diff --git a/src/api/places.api.ts b/src/api/places.api.ts deleted file mode 100644 index dc43f79..0000000 --- a/src/api/places.api.ts +++ /dev/null @@ -1,27 +0,0 @@ -import axios from 'axios'; -import { Place } from '@/interfaces/place.interface'; - -const API_URL = 'https://dishdash.ru'; - -export const fetchPlaces = async (): Promise => { - try { - const response = await axios.get(`${API_URL}/api/v1/places`); - return response.data; - } catch (err) { - console.error('Error fetching tags:', err); - return undefined; - } -}; - -export const updatePlace = async (place: Place): Promise => { - try { - const response = await axios.put(`${API_URL}/api/v1/places`, { - ...place, - tags: place.tags.flatMap((x) => x.id), - }); - return response.data; - } catch (err) { - console.error('Error fetching tags:', err); - return undefined; - } -}; diff --git a/src/components/sidebar.tsx b/src/components/sidebar.tsx index 92181aa..b6b0bde 100644 --- a/src/components/sidebar.tsx +++ b/src/components/sidebar.tsx @@ -1,9 +1,20 @@ -import { Command, Inbox, Settings2, Tag } from "lucide-react" +import { useDashboardStore } from "@/shared/stores/places.store"; +import { Command, Inbox, Map, MapPinPlus, Settings2, Tag } from "lucide-react" +import { useEffect } from "react"; import { Outlet, useNavigate } from "react-router-dom" +import { fetchTags } from "@/shared/api/tags.api"; export const Sidebar = () => { const navigate = useNavigate(); + const { setTags } = useDashboardStore(); + + useEffect(() => { + fetchTags().then((x) => { + if (x) setTags(x); + }); + }, [setTags]); + return (
@@ -17,6 +28,12 @@ export const Sidebar = () => {
navigate('/tags')} className="h-8 w-8 hover:bg-gray-100 cursor-pointer p-2 rounded-md flex items-center justify-center">
+
navigate('/add-place')} className="h-8 w-8 hover:bg-gray-100 cursor-pointer p-2 rounded-md flex items-center justify-center"> + +
+
navigate('/map')} className="h-8 w-8 hover:bg-gray-100 cursor-pointer p-2 rounded-md flex items-center justify-center"> + +
navigate('/settings')} className="h-8 w-8 hover:bg-gray-100 cursor-pointer p-2 rounded-md flex items-center justify-center">
diff --git a/src/components/tag.tsx b/src/components/tag.tsx index c135e64..de8d758 100644 --- a/src/components/tag.tsx +++ b/src/components/tag.tsx @@ -1,9 +1,9 @@ import { Tag } from "@/interfaces/place.interface" export const TagComponent = ({ tag, onClick }: { tag: Tag, onClick?: () => void }) => { - return
- -

+ return

+ +

{tag.name}

diff --git a/src/components/ui/textarea.tsx b/src/components/ui/textarea.tsx index b2ea616..7b2593f 100644 --- a/src/components/ui/textarea.tsx +++ b/src/components/ui/textarea.tsx @@ -11,7 +11,7 @@ const Textarea = React.forwardRef( return (