feat: recreate dashboard page from previous version

This commit is contained in:
Sonny
2024-05-03 02:10:15 +02:00
committed by Sonny
parent 2cc490b611
commit 2cf8c5ae02
66 changed files with 2087 additions and 86 deletions

24
inertia/lib/request.ts Normal file
View File

@@ -0,0 +1,24 @@
import i18n from '~/i18n';
export async function makeRequest({
method = 'GET',
url,
body,
}: {
method?: RequestInit['method'];
url: string;
body?: object | any[];
}): Promise<any> {
const request = await fetch(url, {
method,
body: body ? JSON.stringify(body) : undefined,
headers: {
'Content-Type': 'application/json',
},
});
const data = await request.json();
return request.ok
? data
: Promise.reject(data?.error || i18n.t('common:generic-error'));
}