Started to work on media upload and organization

This commit is contained in:
cdricms
2025-01-23 20:10:15 +01:00
parent f9dce4b40b
commit cdd8e34096
21 changed files with 1069 additions and 159 deletions

View File

@@ -10,7 +10,7 @@ export interface ApiResponse<T> {
data?: T;
}
async function request<T>(
export async function request<T>(
url: string,
options: {
method?: "GET" | "POST" | "PATCH" | "DELETE";
@@ -81,14 +81,14 @@ async function mutationHandler<T, A>(
}
export function useApi<T>(
url: string,
endpoint: string,
config?: SWRConfiguration,
requiresAuth: boolean = true,
csrfToken?: boolean,
) {
const swr = useSWR<ApiResponse<T>>(
url,
() => fetcher(url, requiresAuth, csrfToken),
endpoint,
() => fetcher(endpoint, requiresAuth, csrfToken),
config,
);