From f7701abcbe05510c3672c4768df03fee535956e3 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Tue, 30 Jan 2024 09:03:20 +0700 Subject: handling form form --- src/lib/form/components/KunjunganService.jsx | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/lib/form/components/KunjunganService.jsx') diff --git a/src/lib/form/components/KunjunganService.jsx b/src/lib/form/components/KunjunganService.jsx index 1cb0b446..0e1d1ab3 100644 --- a/src/lib/form/components/KunjunganService.jsx +++ b/src/lib/form/components/KunjunganService.jsx @@ -8,6 +8,9 @@ import { toast } from 'react-hot-toast' import * as Yup from 'yup' import createLeadApi from '../api/createLeadApi' import PageContent from '@/lib/content/components/PageContent' +import { useRouter } from 'next/router' + +import useAuth from '@/core/hooks/useAuth' const CreateKunjunganService = () => { const { @@ -22,10 +25,17 @@ const CreateKunjunganService = () => { }) const [cities, setCities] = useState([]) const [company_unit, setCompany_unit] = useState([]) + + const router = useRouter() + + const auth = useAuth() const recaptchaRef = useRef(null) useEffect(() => { + if(!auth) { + router.push('/login') + } const loadCities = async () => { let dataCities = await cityApi() dataCities = dataCities.map((city) => ({ value: city.id, label: city.name })) -- cgit v1.2.3 From 2e38ec15d42201c26c48f9bcf856750204db0582 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Fri, 9 Feb 2024 10:19:28 +0700 Subject: fixing error form form sales --- src/lib/form/components/KunjunganService.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib/form/components/KunjunganService.jsx') diff --git a/src/lib/form/components/KunjunganService.jsx b/src/lib/form/components/KunjunganService.jsx index 0e1d1ab3..5720d14e 100644 --- a/src/lib/form/components/KunjunganService.jsx +++ b/src/lib/form/components/KunjunganService.jsx @@ -33,7 +33,7 @@ const CreateKunjunganService = () => { const recaptchaRef = useRef(null) useEffect(() => { - if(!auth) { + if(auth == false) { router.push('/login') } const loadCities = async () => { @@ -42,7 +42,7 @@ const CreateKunjunganService = () => { setCities(dataCities) } loadCities() - }, []) + }, [auth]) const onSubmitHandler = async (values) => { const recaptchaValue = recaptchaRef.current.getValue() -- cgit v1.2.3