feat(ui): add cv application frontend and configuration

This commit is contained in:
Tuan-Dat Tran
2026-02-23 13:47:08 +01:00
parent cbf40908a6
commit 7f06ee7f53
43 changed files with 2849 additions and 0 deletions

71
src/lib/api.js Normal file
View File

@@ -0,0 +1,71 @@
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:3001';
import { authHeaders } from './auth';
export async function fetchCV() {
const response = await fetch(`${API_URL}/api/cv`);
if (!response.ok) {
throw new Error(`Failed to fetch CV: ${response.statusText}`);
}
return response.json();
}
export async function updateCV(data) {
const response = await fetch(`${API_URL}/api/cv`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
...authHeaders(),
},
body: JSON.stringify(data),
});
if (!response.ok) {
throw new Error(`Failed to update CV: ${response.statusText}`);
}
return response.json();
}
export async function exportCV() {
const response = await fetch(`${API_URL}/api/cv/export`);
if (!response.ok) {
throw new Error(`Failed to export CV: ${response.statusText}`);
}
return response.blob();
}
export async function importCV(data) {
const response = await fetch(`${API_URL}/api/cv/import`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...authHeaders(),
},
body: JSON.stringify(data),
});
if (!response.ok) {
throw new Error(`Failed to import CV: ${response.statusText}`);
}
return response.json();
}
export async function getAuthConfig() {
const response = await fetch(`${API_URL}/api/auth/config`);
if (!response.ok) {
throw new Error(`Failed to get auth config: ${response.statusText}`);
}
return response.json();
}
export async function login(password) {
const response = await fetch(`${API_URL}/api/auth/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ password }),
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'Login failed');
}
return response.json();
}