login register updated
This commit is contained in:
@@ -7,6 +7,7 @@ import { apiRequest } from '@/shared/request/apiRequest';
|
||||
import { links } from '@/shared/request/links';
|
||||
import { useLoginModal } from '@/shared/zustand/auth';
|
||||
import { toast } from 'react-toastify';
|
||||
import { useRouter } from '@/shared/config/i18n/navigation';
|
||||
|
||||
interface LoginData {
|
||||
phone: string;
|
||||
@@ -15,6 +16,7 @@ interface LoginData {
|
||||
export function useLoginForm() {
|
||||
const [phone, setPhone] = useState('');
|
||||
const [error, setError] = useState('');
|
||||
const route = useRouter();
|
||||
const toggleLoginModal = useLoginModal((state) => state.toggleLoginModal);
|
||||
const loginReqest = useMutation({
|
||||
mutationKey: ['login'],
|
||||
@@ -23,6 +25,7 @@ export function useLoginForm() {
|
||||
console.log('Login successful:', data);
|
||||
toggleLoginModal();
|
||||
toast.success('Kirish muvaffaqiyatli!');
|
||||
route.push('/plagat');
|
||||
},
|
||||
onError: (err) => {
|
||||
setError(err instanceof Error ? err.message : 'Unknown error');
|
||||
|
||||
@@ -8,6 +8,7 @@ import { useMutation } from '@tanstack/react-query';
|
||||
import { apiRequest } from '@/shared/request/apiRequest';
|
||||
import { links } from '@/shared/request/links';
|
||||
import { toast } from 'react-toastify';
|
||||
import { useRouter } from '@/shared/config/i18n/navigation';
|
||||
|
||||
interface RegisterData {
|
||||
name: string;
|
||||
@@ -20,6 +21,7 @@ export function useRegisterForm() {
|
||||
useRegisterZustand();
|
||||
const [errors, setErrors] = useState<RegisterErrors>({});
|
||||
const [success, setSuccess] = useState(false);
|
||||
const route = useRouter();
|
||||
const toggleRegisterModal = useRegisterModal(
|
||||
(state) => state.toggleRegisterModal,
|
||||
);
|
||||
@@ -33,6 +35,7 @@ export function useRegisterForm() {
|
||||
toggleRegisterModal();
|
||||
setSuccess(true);
|
||||
toast.success("Ro'yxatdan o'tish muvaffaqiyatli!");
|
||||
route.push('/plagat');
|
||||
},
|
||||
onError: (err) => {
|
||||
// toggleLoginModal();
|
||||
|
||||
Reference in New Issue
Block a user