Download src/services/api.js from SyedFouzan/taskflow-titan-workflow-wizardry: direct link, hf CLI and curl.
- Browser
- Download file 2.72 kB
-
https://huggingface.co/spaces/SyedFouzan/taskflow-titan-workflow-wizardry/resolve/main/src/services/api.js
- Command line
-
hf download hf://spaces/SyedFouzan/taskflow-titan-workflow-wizardry/src/services/api.js
-
curl -L -o api.js https://huggingface.co/spaces/SyedFouzan/taskflow-titan-workflow-wizardry/resolve/main/src/services/api.js
2.72 kB
| import axios from 'axios'; | |
| const API_BASE_URL = process.env.REACT_APP_API_BASE_URL || 'http://localhost:8080/api'; | |
| const api = axios.create({ | |
| baseURL: API_BASE_URL, | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| }, | |
| }); | |
| api.interceptors.request.use((config) => { | |
| const token = localStorage.getItem('token'); | |
| if (token) { | |
| config.headers.Authorization = `Bearer ${token}`; | |
| } | |
| return config; | |
| }); | |
| api.interceptors.response.use( | |
| (response) => response, | |
| (error) => { | |
| if (error.response?.status === 401) { | |
| localStorage.removeItem('token'); | |
| window.location.href = '/login'; | |
| } | |
| return Promise.reject(error); | |
| } | |
| ); | |
| export const authAPI = { | |
| login: (credentials) => api.post('/auth/login', credentials), | |
| register: (userData) => api.post('/auth/register', userData), | |
| logout: () => api.post('/auth/logout'), | |
| verifyToken: () => api.get('/auth/verify'), | |
| resetPassword: (email) => api.post('/auth/reset-password', { email }), | |
| }; | |
| export const tasksAPI = { | |
| getAll: (params) => api.get('/tasks', { params }), | |
| getById: (id) => api.get(`/tasks/${id}`), | |
| create: (taskData) => api.post('/tasks', taskData), | |
| update: (id, taskData) => api.put(`/tasks/${id}`, taskData), | |
| delete: (id) => api.delete(`/tasks/${id}`), | |
| addComment: (id, comment) => api.post(`/tasks/${id}/comments`, { comment }), | |
| updateStatus: (id, status) => api.patch(`/tasks/${id}/status`, { status }), | |
| }; | |
| export const usersAPI = { | |
| getAll: () => api.get('/users'), | |
| getById: (id) => api.get(`/users/${id}`), | |
| create: (userData) => api.post('/users', userData), | |
| update: (id, userData) => api.put(`/users/${id}`, userData), | |
| delete: (id) => api.delete(`/users/${id}`), | |
| updateProfile: (userData) => api.put('/users/profile', userData), | |
| }; | |
| export const documentsAPI = { | |
| getAll: () => api.get('/documents'), | |
| getById: (id) => api.get(`/documents/${id}`), | |
| upload: (formData) => api.post('/documents/upload', formData, { | |
| headers: { | |
| 'Content-Type': 'multipart/form-data', | |
| }, | |
| }), | |
| delete: (id) => api.delete(`/documents/${id}`), | |
| }; | |
| export const analyticsAPI = { | |
| getOverview: () => api.get('/analytics/overview'), | |
| getPerformance: (params) => api.get('/analytics/performance', { params }), | |
| getTaskStats: () => api.get('/analytics/tasks'), | |
| getUserStats: () => api.get('/analytics/users'), | |
| }; | |
| export const reportsAPI = { | |
| generateTaskReport: (params) => api.get('/reports/tasks', { | |
| params, | |
| responseType: 'blob' | |
| }), | |
| generateUserReport: (params) => api.get('/reports/users', { | |
| params, | |
| responseType: 'blob' | |
| }), | |
| generatePerformanceReport: (params) => api.get('/reports/performance', { | |
| params, | |
| responseType: 'blob' | |
| }), | |
| }; | |
| export default api; |