Models refactor + Basic functionnalities
Some checks failed
linter / quality (push) Failing after 3m25s
tests / ci (push) Failing after 12m2s

This commit is contained in:
2025-08-26 12:12:02 +02:00
parent 715d2a884a
commit 55a52086c1
49 changed files with 1074 additions and 269 deletions

View File

@@ -1,6 +1,36 @@
import { useFetch, UseFetchOptions } from '@vueuse/core';
import { clsx, type ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
let csrfInitialized = false
async function ensureCsrf() {
if (!csrfInitialized) {
await useFetch('/sanctum/csrf-cookie', {
credentials: 'include',
})
csrfInitialized = true
}
}
export async function httpApi<T>(url: string, options?: RequestInit, useFetchOptions?: UseFetchOptions): Promise<{data: T | null, error: any}> {
await ensureCsrf();
const { data, error } = await useFetch(url, {
credentials: 'include',
...options,
},
useFetchOptions
).json();
if (!error.value && data.value) {
return { data: data.value, error: null };
} else {
return { data: data.value, error: error.value };
}
}