feat: delete users - not tested

This commit is contained in:
Eric Gullickson
2025-12-22 18:20:25 -06:00
parent 91b4534e76
commit 4897f0a52c
73 changed files with 4923 additions and 62 deletions

View 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);
},
});
};

View File

@@ -0,0 +1,54 @@
/**
* @ai-summary React Query hook for email verification status with polling
*/
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { useAuth0 } from '@auth0/auth0-react';
import toast from 'react-hot-toast';
import { authApi } from '../api/auth.api';
interface ApiError {
response?: {
data?: {
error?: string;
message?: string;
};
};
message?: string;
}
export const useVerifyStatus = (options?: { enablePolling?: boolean; onVerified?: () => void }) => {
const { isAuthenticated, isLoading } = useAuth0();
const query = useQuery({
queryKey: ['verifyStatus'],
queryFn: authApi.getVerifyStatus,
enabled: isAuthenticated && !isLoading,
refetchInterval: options?.enablePolling ? 5000 : false, // Poll every 5 seconds if enabled
refetchIntervalInBackground: false,
retry: 2,
});
// Call onVerified callback when verification completes
if (query.data?.emailVerified && options?.onVerified) {
options.onVerified();
}
return query;
};
export const useResendVerification = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: () => authApi.resendVerification(),
onSuccess: (data) => {
toast.success(data.message || 'Verification email sent. Please check your inbox.');
queryClient.invalidateQueries({ queryKey: ['verifyStatus'] });
},
onError: (error: ApiError) => {
const errorMessage = error.response?.data?.error || error.response?.data?.message || error.message || 'Failed to resend verification email';
toast.error(errorMessage);
},
});
};