feat: delete users - not tested
This commit is contained in:
32
frontend/src/features/auth/hooks/useSignup.ts
Normal file
32
frontend/src/features/auth/hooks/useSignup.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @ai-summary React Query hook for user signup
|
||||
*/
|
||||
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import toast from 'react-hot-toast';
|
||||
import { authApi } from '../api/auth.api';
|
||||
import { SignupRequest } from '../types/auth.types';
|
||||
|
||||
interface ApiError {
|
||||
response?: {
|
||||
data?: {
|
||||
error?: string;
|
||||
message?: string;
|
||||
};
|
||||
status?: number;
|
||||
};
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export const useSignup = () => {
|
||||
return useMutation({
|
||||
mutationFn: (data: SignupRequest) => authApi.signup(data),
|
||||
onSuccess: () => {
|
||||
toast.success('Account created! Please check your email to verify your account.');
|
||||
},
|
||||
onError: (error: ApiError) => {
|
||||
const errorMessage = error.response?.data?.error || error.response?.data?.message || error.message || 'Failed to create account';
|
||||
toast.error(errorMessage);
|
||||
},
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user