website refactor
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
export { useCurrentSession } from './useCurrentSession';
|
||||
export { useLogin } from './useLogin';
|
||||
export { useLogout } from './useLogout';
|
||||
export { useSignup } from './useSignup';
|
||||
export { useForgotPassword } from './useForgotPassword';
|
||||
export { useResetPassword } from './useResetPassword';
|
||||
@@ -12,7 +12,15 @@ export function useCurrentSession(
|
||||
|
||||
const queryResult = useQuery({
|
||||
queryKey: ['currentSession'],
|
||||
queryFn: () => sessionService.getSession(),
|
||||
queryFn: async () => {
|
||||
const result = await sessionService.getSession();
|
||||
if (result.isErr()) {
|
||||
const error = result.getError();
|
||||
throw new ApiError(error.message, 'SERVER_ERROR', { timestamp: new Date().toISOString() });
|
||||
}
|
||||
const session = result.unwrap();
|
||||
return session ? new SessionViewModel(session.user) : null;
|
||||
},
|
||||
initialData: options?.initialData,
|
||||
...options,
|
||||
});
|
||||
|
||||
@@ -9,7 +9,13 @@ export function useLogout(
|
||||
const authService = useInject(AUTH_SERVICE_TOKEN);
|
||||
|
||||
return useMutation<void, ApiError, void>({
|
||||
mutationFn: () => authService.logout(),
|
||||
mutationFn: async () => {
|
||||
const result = await authService.logout();
|
||||
if (result.isErr()) {
|
||||
const error = result.getError();
|
||||
throw new ApiError(error.message, 'SERVER_ERROR', { timestamp: new Date().toISOString() });
|
||||
}
|
||||
},
|
||||
...options,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user