feat: updade workspace

This commit is contained in:
thanhnv
2026-07-11 15:56:31 +09:00
parent 4fc72332f5
commit 193a449829
120 changed files with 868 additions and 350 deletions
+54
View File
@@ -0,0 +1,54 @@
import axios from 'axios';
import type {
ApiResponse,
CreateObjectivePayload,
KeyResult,
LoginResult,
Objective,
UpdateProgressPayload,
User,
} from '../types/okr.types.js';
const apiBaseUrl =
import.meta.env.VITE_API_BASE_URL ??
`${window.location.protocol}//${window.location.hostname === '127.0.0.1' ? '127.0.0.1' : 'localhost'}:3000/api/v1`;
const client = axios.create({
baseURL: apiBaseUrl,
withCredentials: true,
});
export async function login(username: string, password: string): Promise<LoginResult> {
const response = await client.post<ApiResponse<LoginResult>>('/auth/login', { username, password });
return response.data.data;
}
export async function listUsers(): Promise<User[]> {
const response = await client.get<ApiResponse<User[]>>('/users');
return response.data.data;
}
export async function listObjectives(quarter?: string): Promise<Objective[]> {
const response = await client.get<ApiResponse<Objective[]>>('/objectives', { params: { quarter } });
return response.data.data;
}
export async function getObjective(id: number): Promise<Objective> {
const response = await client.get<ApiResponse<Objective>>(`/objectives/${id}`);
return response.data.data;
}
export async function createObjective(payload: CreateObjectivePayload): Promise<Objective> {
const response = await client.post<ApiResponse<Objective>>('/objectives', payload);
return response.data.data;
}
export async function getKeyResult(id: number): Promise<KeyResult & { objective: Objective }> {
const response = await client.get<ApiResponse<KeyResult & { objective: Objective }>>(`/key-results/${id}`);
return response.data.data;
}
export async function updateKeyResultProgress(id: number, payload: UpdateProgressPayload): Promise<KeyResult> {
const response = await client.patch<ApiResponse<KeyResult>>(`/key-results/${id}/progress`, payload);
return response.data.data;
}
+10
View File
@@ -0,0 +1,10 @@
import { QueryClient } from '@tanstack/react-query';
export const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 30_000,
retry: 1,
},
},
});