Download screenshot42-taskmanager-projectdetail/environment/app/frontend/src/api.js from ApolloTeam/fullstackbench-tasks: direct link, hf CLI and curl.
- Browser
- Download file 4 kB
-
https://huggingface.co/datasets/ApolloTeam/fullstackbench-tasks/resolve/main/screenshot42-taskmanager-projectdetail/environment/app/frontend/src/api.js
- Command line
-
hf download hf://datasets/ApolloTeam/fullstackbench-tasks/screenshot42-taskmanager-projectdetail/environment/app/frontend/src/api.js
-
curl -L -o api.js https://huggingface.co/datasets/ApolloTeam/fullstackbench-tasks/resolve/main/screenshot42-taskmanager-projectdetail/environment/app/frontend/src/api.js
4 kB
| const BASE_URL = import.meta.env.VITE_API_URL || `http://localhost:${import.meta.env.VITE_API_PORT || 5101}/api`; | |
| async function request(path, options = {}) { | |
| const res = await fetch(`${BASE_URL}${path}`, { | |
| headers: { 'Content-Type': 'application/json' }, | |
| ...options, | |
| }); | |
| if (!res.ok) { | |
| const err = await res.json().catch(() => ({ error: res.statusText })); | |
| throw new Error(err.error || 'Request failed'); | |
| } | |
| return res.json(); | |
| } | |
| // Users | |
| export function getUsers() { | |
| return request('/users'); | |
| } | |
| export function createUser(name, email) { | |
| return request('/users', { | |
| method: 'POST', | |
| body: JSON.stringify({ name, email }), | |
| }); | |
| } | |
| // Tags | |
| export function getTags() { | |
| return request('/tags'); | |
| } | |
| export function createTag(name, color) { | |
| return request('/tags', { | |
| method: 'POST', | |
| body: JSON.stringify({ name, color }), | |
| }); | |
| } | |
| export function deleteTag(tagId) { | |
| return request(`/tags/${tagId}`, { method: 'DELETE' }); | |
| } | |
| // Projects | |
| export function getProjects(includeArchived = false) { | |
| const qs = includeArchived ? '?include_archived=true' : ''; | |
| return request(`/projects${qs}`); | |
| } | |
| export function createProject(name, description, memberIds) { | |
| return request('/projects', { | |
| method: 'POST', | |
| body: JSON.stringify({ name, description, member_ids: memberIds }), | |
| }); | |
| } | |
| export function getProjectDetail(projectId) { | |
| return request(`/projects/${projectId}`); | |
| } | |
| export function updateProject(projectId, data) { | |
| return request(`/projects/${projectId}`, { | |
| method: 'PUT', | |
| body: JSON.stringify(data), | |
| }); | |
| } | |
| export function getProjectStats(projectId) { | |
| return request(`/projects/${projectId}/stats`); | |
| } | |
| export function getProjectActivities(projectId, limit = 20) { | |
| return request(`/projects/${projectId}/activities?limit=${limit}`); | |
| } | |
| export function addProjectMember(projectId, userId, role = 'member') { | |
| return request(`/projects/${projectId}/members`, { | |
| method: 'POST', | |
| body: JSON.stringify({ user_id: userId, role }), | |
| }); | |
| } | |
| export function removeProjectMember(projectId, userId) { | |
| return request(`/projects/${projectId}/members/${userId}`, { | |
| method: 'DELETE', | |
| }); | |
| } | |
| // Tasks | |
| export function getProjectTasks(projectId, filters = {}) { | |
| const params = new URLSearchParams(); | |
| if (filters.status) params.set('status', filters.status); | |
| if (filters.priority) params.set('priority', filters.priority); | |
| if (filters.assigned_to) params.set('assigned_to', filters.assigned_to); | |
| if (filters.tag) params.set('tag', filters.tag); | |
| if (filters.sort) params.set('sort', filters.sort); | |
| const qs = params.toString() ? `?${params.toString()}` : ''; | |
| return request(`/projects/${projectId}/tasks${qs}`); | |
| } | |
| export function createTask(projectId, data) { | |
| return request(`/projects/${projectId}/tasks`, { | |
| method: 'POST', | |
| body: JSON.stringify(data), | |
| }); | |
| } | |
| export function getTask(taskId) { | |
| return request(`/tasks/${taskId}`); | |
| } | |
| export function updateTask(taskId, data) { | |
| return request(`/tasks/${taskId}`, { | |
| method: 'PUT', | |
| body: JSON.stringify(data), | |
| }); | |
| } | |
| export function deleteTask(taskId) { | |
| return request(`/tasks/${taskId}`, { | |
| method: 'DELETE', | |
| }); | |
| } | |
| // Task Tags | |
| export function addTaskTag(taskId, tagId) { | |
| return request(`/tasks/${taskId}/tags`, { | |
| method: 'POST', | |
| body: JSON.stringify({ tag_id: tagId }), | |
| }); | |
| } | |
| export function removeTaskTag(taskId, tagId) { | |
| return request(`/tasks/${taskId}/tags/${tagId}`, { | |
| method: 'DELETE', | |
| }); | |
| } | |
| // Comments | |
| export function createComment(taskId, userId, text) { | |
| return request(`/tasks/${taskId}/comments`, { | |
| method: 'POST', | |
| body: JSON.stringify({ user_id: userId, text }), | |
| }); | |
| } | |
| export function getComments(taskId) { | |
| return request(`/tasks/${taskId}/comments`); | |
| } | |
| // Activities | |
| export function getTaskActivities(taskId) { | |
| return request(`/tasks/${taskId}/activities`); | |
| } | |
| // Search | |
| export function searchTasks(query) { | |
| return request(`/search?q=${encodeURIComponent(query)}`); | |
| } | |