diff options
Diffstat (limited to 'src/lib/form')
| -rw-r--r-- | src/lib/form/components/KunjunganSales.jsx | 13 | ||||
| -rw-r--r-- | src/lib/form/components/KunjunganService.jsx | 12 | ||||
| -rw-r--r-- | src/lib/form/components/Merchant.jsx | 11 | ||||
| -rw-r--r-- | src/lib/form/components/PembayaranTempo.jsx | 14 | ||||
| -rw-r--r-- | src/lib/form/components/RequestForQuotation.jsx | 12 | ||||
| -rw-r--r-- | src/lib/form/components/SuratDukungan.jsx | 11 |
6 files changed, 67 insertions, 6 deletions
diff --git a/src/lib/form/components/KunjunganSales.jsx b/src/lib/form/components/KunjunganSales.jsx index 7470395a..ffa8f135 100644 --- a/src/lib/form/components/KunjunganSales.jsx +++ b/src/lib/form/components/KunjunganSales.jsx @@ -10,6 +10,9 @@ import * as Yup from 'yup' import createLeadApi from '../api/createLeadApi' import PageContent from '@/lib/content/components/PageContent' +import useAuth from '@/core/hooks/useAuth' +import { useRouter } from 'next/router' + const KunjunganSales = () => { const { register, @@ -23,10 +26,18 @@ const KunjunganSales = () => { }) const [cities, setCities] = useState([]) const [companyTypes, setCompanyTypes] = useState([]) + const router = useRouter() + + const auth = useAuth() + + const recaptchaRef = useRef(null) useEffect(() => { + if(auth == false) { + router.push('/login') + } const loadCities = async () => { let dataCities = await cityApi() dataCities = dataCities.map((obj) => ({ value: obj.name, label: obj.name })) @@ -39,7 +50,7 @@ const KunjunganSales = () => { loadCompanyTypes() loadCities() - }, []) + }, [auth]) const onSubmitHandler = async (values) => { const recaptchaValue = recaptchaRef.current.getValue() diff --git a/src/lib/form/components/KunjunganService.jsx b/src/lib/form/components/KunjunganService.jsx index 1cb0b446..5720d14e 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,17 +25,24 @@ 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 == false) { + router.push('/login') + } const loadCities = async () => { let dataCities = await cityApi() dataCities = dataCities.map((city) => ({ value: city.id, label: city.name })) setCities(dataCities) } loadCities() - }, []) + }, [auth]) const onSubmitHandler = async (values) => { const recaptchaValue = recaptchaRef.current.getValue() diff --git a/src/lib/form/components/Merchant.jsx b/src/lib/form/components/Merchant.jsx index 6c1af231..85f72bf8 100644 --- a/src/lib/form/components/Merchant.jsx +++ b/src/lib/form/components/Merchant.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 CreateMerchant = () => { const { @@ -50,8 +53,14 @@ const CreateMerchant = () => { const [company_unit, setCompany_unit] = useState(list_unit); const recaptchaRef = useRef(null); + const router = useRouter() + + const auth = useAuth() useEffect(() => { + if(auth == false) { + router.push('/login') + } const loadCities = async () => { let dataCities = await cityApi(); dataCities = dataCities.map((city) => ({ @@ -61,7 +70,7 @@ const CreateMerchant = () => { setCities(dataCities); }; loadCities(); - }, []); + }, [auth]); const onSubmitHandler = async (values) => { const recaptchaValue = recaptchaRef.current.getValue(); diff --git a/src/lib/form/components/PembayaranTempo.jsx b/src/lib/form/components/PembayaranTempo.jsx index 8c624fe2..fc4d248a 100644 --- a/src/lib/form/components/PembayaranTempo.jsx +++ b/src/lib/form/components/PembayaranTempo.jsx @@ -1,12 +1,15 @@ import getFileBase64 from '@/core/utils/getFileBase64' import { yupResolver } from '@hookform/resolvers/yup' -import React, { useRef } from 'react' +import React, { useEffect, useRef } from 'react' import ReCAPTCHA from 'react-google-recaptcha' import { useForm } from 'react-hook-form' 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 PembayaranTempo = () => { @@ -21,6 +24,15 @@ const PembayaranTempo = () => { }) const recaptchaRef = useRef(null) + const router = useRouter() + + const auth = useAuth() + + useEffect(() => { + if(auth == false) { + router.push('/login') + } + },[auth]) const onSubmitHandler = async (values) => { const recaptchaValue = recaptchaRef.current.getValue() diff --git a/src/lib/form/components/RequestForQuotation.jsx b/src/lib/form/components/RequestForQuotation.jsx index fa526d5f..68b7fa17 100644 --- a/src/lib/form/components/RequestForQuotation.jsx +++ b/src/lib/form/components/RequestForQuotation.jsx @@ -10,6 +10,9 @@ import * as Yup from 'yup' import createLeadApi from '../api/createLeadApi' import getFileBase64 from '@/core/utils/getFileBase64' import PageContent from '@/lib/content/components/PageContent' +import { useRouter } from 'next/router' + +import useAuth from '@/core/hooks/useAuth' const RequestForQuotation = () => { const { @@ -26,15 +29,22 @@ const RequestForQuotation = () => { const quotationFileRef = useRef(null) const recaptchaRef = useRef(null) + const router = useRouter() + + const auth = useAuth() + useEffect(() => { + if(auth == false) { + router.push('/login') + } const loadCities = async () => { let dataCities = await cityApi() dataCities = dataCities.map((obj) => ({ value: obj.name, label: obj.name })) setCities(dataCities) } loadCities() - }, []) + }, [auth]) const onSubmitHandler = async (values) => { const recaptchaValue = recaptchaRef.current.getValue() diff --git a/src/lib/form/components/SuratDukungan.jsx b/src/lib/form/components/SuratDukungan.jsx index d73c3fab..31e7ee83 100644 --- a/src/lib/form/components/SuratDukungan.jsx +++ b/src/lib/form/components/SuratDukungan.jsx @@ -10,6 +10,9 @@ import createLeadsApi from '../api/createLeadApi'; import PageContent from '@/lib/content/components/PageContent'; +import useAuth from '@/core/hooks/useAuth' +import { useRouter } from 'next/router'; + const CreateSuratDukungan = () => { const { register, @@ -25,8 +28,14 @@ const CreateSuratDukungan = () => { const [company_unit, setCompany_unit] = useState([]); const recaptchaRef = useRef(null); + const router = useRouter() + + const auth = useAuth() useEffect(() => { + if(auth == false) { + router.push('/login') + } const loadCities = async () => { let dataCities = await cityApi(); dataCities = dataCities.map((city) => ({ @@ -36,7 +45,7 @@ const CreateSuratDukungan = () => { setCities(dataCities); }; loadCities(); - }, []); + }, [auth]); const onSubmitHandler = async (values) => { const recaptchaValue = recaptchaRef.current.getValue(); |
