add tai lieu system
All checks were successful
Deploy on Master Change / deploy (push) Successful in 43s

This commit is contained in:
2026-07-01 14:47:46 +07:00
parent 6919513165
commit dd766206f7
15 changed files with 952 additions and 140 deletions

View File

@@ -1,4 +1,4 @@
export const API_BASE = import.meta.env.VITE_API_BASE || 'http://127.0.0.1:8080/api';
export const API_BASE = import.meta.env.VITE_API_BASE || 'https://sv.rikkeiraia.org/api';
export function getWsUrl(path: string): string {
try {
@@ -269,6 +269,14 @@ export interface StatsResponse {
totalStudents: number;
}
export interface GuideLinkItem {
id: number;
createdAt: string;
updatedAt: string;
title: string;
url: string;
}
export interface PaginatedResponse<T> {
data: T[];
total: number;
@@ -362,6 +370,33 @@ export const api = {
return res.json();
},
listGuideLinks: async (): Promise<{ data: GuideLinkItem[] }> => {
const res = await staffFetch('/guide-links');
if (!res.ok) throw new Error('Không thể tải danh sách tài liệu');
return res.json();
},
createGuideLink: async (title: string, url: string): Promise<{ data: GuideLinkItem }> => {
const res = await staffFetch('/guide-links', {
method: 'POST',
body: JSON.stringify({ title, url }),
});
if (!res.ok) await parseError(res, 'Thêm tài liệu thất bại');
return res.json();
},
updateGuideLink: async (id: number, title: string, url: string): Promise<{ data: GuideLinkItem }> => {
const res = await staffFetch(`/guide-links/${id}`, {
method: 'PUT',
body: JSON.stringify({ title, url }),
});
if (!res.ok) await parseError(res, 'Cập nhật tài liệu thất bại');
return res.json();
},
deleteGuideLink: async (id: number): Promise<{ ok: boolean }> => {
const res = await staffFetch(`/guide-links/${id}`, { method: 'DELETE' });
if (!res.ok) await parseError(res, 'Xóa tài liệu thất bại');
return res.json();
},
getClasses: async (params: {
page: number;
pageSize: number;