Add detailed console logging to diagnose Epic creation issue where no request is being sent to backend. Changes: - Add form submission event logging in epic-form.tsx - Add API request/response logging in epicsApi.create - Add HTTP client interceptor logging for all requests/responses - Log authentication status, payload, and error details - Log form validation state and errors This will help identify: - Whether form submit event fires - Whether validation passes - Whether API call is triggered - Whether authentication token exists - What errors occur (if any) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
124 lines
3.5 KiB
TypeScript
124 lines
3.5 KiB
TypeScript
import { api } from './client';
|
|
import type {
|
|
Epic,
|
|
CreateEpicDto,
|
|
UpdateEpicDto,
|
|
Story,
|
|
CreateStoryDto,
|
|
UpdateStoryDto,
|
|
Task,
|
|
CreateTaskDto,
|
|
UpdateTaskDto,
|
|
WorkItemStatus,
|
|
} from '@/types/project';
|
|
|
|
// ==================== Epics API ====================
|
|
export const epicsApi = {
|
|
list: async (projectId?: string): Promise<Epic[]> => {
|
|
if (!projectId) {
|
|
throw new Error('projectId is required for listing epics');
|
|
}
|
|
return api.get(`/api/v1/projects/${projectId}/epics`);
|
|
},
|
|
|
|
get: async (id: string): Promise<Epic> => {
|
|
return api.get(`/api/v1/epics/${id}`);
|
|
},
|
|
|
|
create: async (data: CreateEpicDto): Promise<Epic> => {
|
|
console.log('[epicsApi.create] Sending request', { url: '/api/v1/epics', data });
|
|
try {
|
|
const result = await api.post('/api/v1/epics', data);
|
|
console.log('[epicsApi.create] Request successful', result);
|
|
return result;
|
|
} catch (error) {
|
|
console.error('[epicsApi.create] Request failed', error);
|
|
throw error;
|
|
}
|
|
},
|
|
|
|
update: async (id: string, data: UpdateEpicDto): Promise<Epic> => {
|
|
return api.put(`/api/v1/epics/${id}`, data);
|
|
},
|
|
|
|
delete: async (id: string): Promise<void> => {
|
|
return api.delete(`/api/v1/epics/${id}`);
|
|
},
|
|
|
|
changeStatus: async (id: string, status: WorkItemStatus): Promise<Epic> => {
|
|
return api.put(`/api/v1/epics/${id}/status`, { status });
|
|
},
|
|
|
|
assign: async (id: string, assigneeId: string): Promise<Epic> => {
|
|
return api.put(`/api/v1/epics/${id}/assign`, { assigneeId });
|
|
},
|
|
};
|
|
|
|
// ==================== Stories API ====================
|
|
export const storiesApi = {
|
|
list: async (epicId?: string): Promise<Story[]> => {
|
|
if (!epicId) {
|
|
throw new Error('epicId is required for listing stories');
|
|
}
|
|
return api.get(`/api/v1/epics/${epicId}/stories`);
|
|
},
|
|
|
|
get: async (id: string): Promise<Story> => {
|
|
return api.get(`/api/v1/stories/${id}`);
|
|
},
|
|
|
|
create: async (data: CreateStoryDto): Promise<Story> => {
|
|
return api.post('/api/v1/stories', data);
|
|
},
|
|
|
|
update: async (id: string, data: UpdateStoryDto): Promise<Story> => {
|
|
return api.put(`/api/v1/stories/${id}`, data);
|
|
},
|
|
|
|
delete: async (id: string): Promise<void> => {
|
|
return api.delete(`/api/v1/stories/${id}`);
|
|
},
|
|
|
|
changeStatus: async (id: string, status: WorkItemStatus): Promise<Story> => {
|
|
return api.put(`/api/v1/stories/${id}/status`, { status });
|
|
},
|
|
|
|
assign: async (id: string, assigneeId: string): Promise<Story> => {
|
|
return api.put(`/api/v1/stories/${id}/assign`, { assigneeId });
|
|
},
|
|
};
|
|
|
|
// ==================== Tasks API ====================
|
|
export const tasksApi = {
|
|
list: async (storyId?: string): Promise<Task[]> => {
|
|
if (!storyId) {
|
|
throw new Error('storyId is required for listing tasks');
|
|
}
|
|
return api.get(`/api/v1/stories/${storyId}/tasks`);
|
|
},
|
|
|
|
get: async (id: string): Promise<Task> => {
|
|
return api.get(`/api/v1/tasks/${id}`);
|
|
},
|
|
|
|
create: async (data: CreateTaskDto): Promise<Task> => {
|
|
return api.post('/api/v1/tasks', data);
|
|
},
|
|
|
|
update: async (id: string, data: UpdateTaskDto): Promise<Task> => {
|
|
return api.put(`/api/v1/tasks/${id}`, data);
|
|
},
|
|
|
|
delete: async (id: string): Promise<void> => {
|
|
return api.delete(`/api/v1/tasks/${id}`);
|
|
},
|
|
|
|
changeStatus: async (id: string, status: WorkItemStatus): Promise<Task> => {
|
|
return api.put(`/api/v1/tasks/${id}/status`, { status });
|
|
},
|
|
|
|
assign: async (id: string, assigneeId: string): Promise<Task> => {
|
|
return api.put(`/api/v1/tasks/${id}/assign`, { assigneeId });
|
|
},
|
|
};
|