|
2 | 2 |
|
3 | 3 | import { create } from 'zustand'; |
4 | 4 | import { subscribeWithSelector } from 'zustand/middleware'; |
5 | | -import { apiClient, debounce, handleApiError } from '@/lib'; |
| 5 | +import { debounce, handleApiError } from '@/lib'; |
| 6 | +import { projectApiClient } from '@/lib/api'; |
6 | 7 | import { Project } from '@codervisor/devlog-core'; |
7 | 8 | import { DataContext, getDefaultDataContext } from '@/stores/base'; |
8 | 9 |
|
@@ -46,7 +47,7 @@ export const useProjectStore = create<ProjectState>()( |
46 | 47 | error: null, |
47 | 48 | }, |
48 | 49 | })); |
49 | | - const currentProject = await apiClient.get<Project>(`/api/projects/${currentProjectName}`); |
| 50 | + const currentProject = await projectApiClient.get(currentProjectName); |
50 | 51 | set((state) => ({ |
51 | 52 | currentProjectContext: { |
52 | 53 | ...state.currentProjectContext, |
@@ -99,7 +100,7 @@ export const useProjectStore = create<ProjectState>()( |
99 | 100 | error: null, |
100 | 101 | }, |
101 | 102 | })); |
102 | | - const projectsList = await apiClient.get<Project[]>('/api/projects'); |
| 103 | + const projectsList = await projectApiClient.list(); |
103 | 104 | set((state) => ({ |
104 | 105 | projectsContext: { |
105 | 106 | ...state.projectsContext, |
@@ -141,7 +142,7 @@ export const useProjectStore = create<ProjectState>()( |
141 | 142 |
|
142 | 143 | updateProject: async (name: string, updates: Partial<Project>) => { |
143 | 144 | try { |
144 | | - const updatedProject = await apiClient.put<Project>(`/api/projects/${name}`, updates); |
| 145 | + const updatedProject = await projectApiClient.update(name, updates); |
145 | 146 |
|
146 | 147 | // Update current project if it's the one being updated |
147 | 148 | const currentProjectName = get().currentProjectName; |
@@ -184,7 +185,7 @@ export const useProjectStore = create<ProjectState>()( |
184 | 185 |
|
185 | 186 | deleteProject: async (name: string) => { |
186 | 187 | try { |
187 | | - await apiClient.delete(`/api/projects/${name}`); |
| 188 | + await projectApiClient.delete(name); |
188 | 189 |
|
189 | 190 | // Clear current project if it's the one being deleted |
190 | 191 | const currentProjectName = get().currentProjectName; |
|
0 commit comments