updated admin to use swr hooks instead of react-query

This commit is contained in:
dswbx
2024-12-13 16:24:55 +01:00
parent 50c5adce0c
commit 8c91dff94d
20 changed files with 380 additions and 275 deletions

View File

@@ -36,12 +36,10 @@ export class AppQueryClient {
state: (): (AuthResponse & { verified: boolean }) | undefined => {
return this.api.getAuthState() as any;
},
login: async (data: { email: string; password: string }): Promise<
ApiResponse<AuthResponse>
> => {
login: async (data: { email: string; password: string }) => {
return await this.api.auth.loginWithPassword(data);
},
register: async (data: any): Promise<ApiResponse<AuthResponse>> => {
register: async (data: any) => {
return await this.api.auth.registerWithPassword(data);
},
logout: async () => {
@@ -57,7 +55,7 @@ export class AppQueryClient {
//console.log("verifiying");
const res = await this.api.auth.me();
//console.log("verifying result", res);
if (!res.res.ok || !res.body.user) {
if (!res.ok || !res.body.user) {
throw new Error();
}
@@ -90,7 +88,7 @@ export class AppQueryClient {
typeof filename === "string" ? filename : filename.path
);
if (res.res.ok) {
if (res.ok) {
queryClient.invalidateQueries({ queryKey: ["data", "entity", "media"] });
return true;
}