From a6489c671275fc9bf21ec6bdd7db4cb47da86f2c Mon Sep 17 00:00:00 2001 From: Blaster4385 Date: Tue, 16 Aug 2022 16:35:00 +0530 Subject: Mega random super bullshit --- client/src/pages/Enrollment/Address/Address.jsx | 1 - client/src/pages/Enrollment/Enrollment.jsx | 2 +- client/src/pages/Enrollment/FormOne/FormOne.jsx | 1 - client/src/pages/Enrollment/FormTwo/FormTwo.jsx | 4 ---- 4 files changed, 1 insertion(+), 7 deletions(-) (limited to 'client/src/pages/Enrollment') diff --git a/client/src/pages/Enrollment/Address/Address.jsx b/client/src/pages/Enrollment/Address/Address.jsx index 571d7ad..b6c3809 100644 --- a/client/src/pages/Enrollment/Address/Address.jsx +++ b/client/src/pages/Enrollment/Address/Address.jsx @@ -206,7 +206,6 @@ const Address = ({ formData, setFormData }) => { }) }} placeholder={t('ENTER_YOUR_AREA_PINCODE')} - pattern="[0-9]+" /> diff --git a/client/src/pages/Enrollment/Enrollment.jsx b/client/src/pages/Enrollment/Enrollment.jsx index 76461d2..d4b0a2a 100644 --- a/client/src/pages/Enrollment/Enrollment.jsx +++ b/client/src/pages/Enrollment/Enrollment.jsx @@ -16,7 +16,7 @@ import { validMobileNumber, validPincode, validString -} from '../../components/RegEx/RegEx' +} from '../../constants/RegEx' import { createUser } from '../../services/apiservice' import { useTranslation } from 'react-i18next' diff --git a/client/src/pages/Enrollment/FormOne/FormOne.jsx b/client/src/pages/Enrollment/FormOne/FormOne.jsx index dd336d8..c59621d 100644 --- a/client/src/pages/Enrollment/FormOne/FormOne.jsx +++ b/client/src/pages/Enrollment/FormOne/FormOne.jsx @@ -59,7 +59,6 @@ const FormOne = ({ formData, setFormData }) => { }) }} placeholder={t('ENTER_YOUR_FULL_NAME')} - pattern="[a-zA-z]+" />
diff --git a/client/src/pages/Enrollment/FormTwo/FormTwo.jsx b/client/src/pages/Enrollment/FormTwo/FormTwo.jsx index 6bc6223..205b3d9 100644 --- a/client/src/pages/Enrollment/FormTwo/FormTwo.jsx +++ b/client/src/pages/Enrollment/FormTwo/FormTwo.jsx @@ -21,9 +21,6 @@ const FormTwo = ({ formData, setFormData }) => { }) }} placeholder={t('ENTER_YOUR_MOBILE_NUMBER')} - pattern="[0-9]+" - maxLength="10" - minLength="10" /> { }) }} placeholder={t('ENTER_YOUR_EMAIL_ID')} - pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$" />
-- cgit From 045bcc1af6579e1a6023f199fbb6e9ca725bd497 Mon Sep 17 00:00:00 2001 From: Blaster4385 Date: Wed, 17 Aug 2022 09:27:12 +0530 Subject: Replace alerts with toasts and fix header image size --- client/package.json | 1 + client/src/components/Header/Header.jsx | 2 +- client/src/components/Header/Header.module.css | 5 +++ client/src/pages/Enrollment/Enrollment.jsx | 41 ++++++++++++---------- .../src/pages/Update/Demographic/Demographic.jsx | 39 ++++++++++---------- 5 files changed, 50 insertions(+), 38 deletions(-) (limited to 'client/src/pages/Enrollment') diff --git a/client/package.json b/client/package.json index 9769511..3a75fec 100644 --- a/client/package.json +++ b/client/package.json @@ -25,6 +25,7 @@ "react-router-dom": "^6.3.0", "react-scripts": "5.0.1", "react-select": "^5.4.0", + "react-toastify": "^9.0.8", "react-webcam": "^7.0.1", "web-vitals": "^2.1.4" }, diff --git a/client/src/components/Header/Header.jsx b/client/src/components/Header/Header.jsx index d5e08c4..a6e8523 100644 --- a/client/src/components/Header/Header.jsx +++ b/client/src/components/Header/Header.jsx @@ -4,7 +4,7 @@ import styles from './Header.module.css' const Header = ({ subheading }) => { return (
- +

{subheading}

) diff --git a/client/src/components/Header/Header.module.css b/client/src/components/Header/Header.module.css index 2214f1b..c67df95 100644 --- a/client/src/components/Header/Header.module.css +++ b/client/src/components/Header/Header.module.css @@ -13,3 +13,8 @@ font-size: var(--font-medium); font-weight: 400; } + +.header__image { + width: 150px; + height: 150px; +} diff --git a/client/src/pages/Enrollment/Enrollment.jsx b/client/src/pages/Enrollment/Enrollment.jsx index d4b0a2a..18529a4 100644 --- a/client/src/pages/Enrollment/Enrollment.jsx +++ b/client/src/pages/Enrollment/Enrollment.jsx @@ -19,6 +19,8 @@ import { } from '../../constants/RegEx' import { createUser } from '../../services/apiservice' import { useTranslation } from 'react-i18next' +import { ToastContainer, toast } from 'react-toastify' +import 'react-toastify/dist/ReactToastify.css' const Enrollment = () => { const { t } = useTranslation() @@ -55,51 +57,51 @@ const Enrollment = () => { const handleSubmit = () => { if (page === 0) { if (formData.indianResident === '') { - return alert(t('PLEASE_SELECT_YOUR_RESIDENCY')) + toast.error(t('PLEASE_SELECT_YOUR_RESIDENCY')) } else if (formData.name === '' || formData.name.length < 1) { - return alert(t('PLEASE_ENTER_YOUR_NAME')) + toast.error(t('PLEASE_ENTER_YOUR_NAME')) } else if (!validString.test(formData.name)) { - return alert(t('PLEASE_ENTER_VALID_NAME')) + toast.error(t('PLEASE_ENTER_VALID_NAME')) } else if (formData.gender === '') { - return alert(t('PLEASE_SELECT_YOUR_GENDER')) + toast.error(t('PLEASE_SELECT_YOUR_GENDER')) } else { setPage(page + 1) } } else if (page === 1) { if (formData.mobile === '') { - return alert(t('PLEASE_ENTER_YOUR_MOBILE_NUMBER')) + toast.error(t('PLEASE_ENTER_YOUR_MOBILE_NUMBER')) } else if (!validMobileNumber.test(formData.mobile)) { - return alert(t('PLEASE_ENTER_VALID_MOBILE_NUMBER')) + toast.error(t('PLEASE_ENTER_VALID_MOBILE_NUMBER')) } else if (formData.email === '') { - return alert(t('PLEASE_ENTER_YOUR_EMAIL')) + toast.error(t('PLEASE_ENTER_YOUR_EMAIL')) } else if (!validEmail.test(formData.email)) { - return alert(t('PLEASE_ENTER_VALID_EMAIL')) + toast.error(t('PLEASE_ENTER_VALID_EMAIL')) } else { setPage(page + 1) } } else if (page === 2) { if (formData.country === '') { - return alert(t('PLEASE_SELECT_YOUR_COUNTRY')) + toast.error(t('PLEASE_SELECT_YOUR_COUNTRY')) } else if (formData.state === '') { - return alert(t('PLEASE_SELECT_YOUR_STATE')) + toast.error(t('PLEASE_SELECT_YOUR_STATE')) } else if (formData.district === '') { - return alert(t('PLEASE_SELECT_YOUR_DISTRICT')) + toast.error(t('PLEASE_SELECT_YOUR_DISTRICT')) } else if (formData.village === '') { - return alert(t('PLEASE_ENTER_YOUR_VILLAGE')) + toast.error(t('PLEASE_ENTER_YOUR_VILLAGE')) } else if (formData.houseNo === '') { - return alert(t('PLEASE_ENTER_YOUR_HOUSE_NUMBER')) + toast.error(t('PLEASE_ENTER_YOUR_HOUSE_NUMBER')) } else if (formData.street === '') { - return alert(t('PLEASE_ENTER_YOUR_STREET')) + toast.error(t('PLEASE_ENTER_YOUR_STREET')) } else if (formData.locality === '') { - return alert(t('PLEASE_ENTER_YOUR_LOCALITY')) + toast.error(t('PLEASE_ENTER_YOUR_LOCALITY')) } else if (formData.postOffice === '') { - return alert(t('PLEASE_ENTER_YOUR_AREA_POST_OFFICE')) + toast.error(t('PLEASE_ENTER_YOUR_AREA_POST_OFFICE')) } else if (formData.landmark === '') { - return alert(t('PLEASE_ENTER_NEAREST_LANDMARK')) + toast.error(t('PLEASE_ENTER_NEAREST_LANDMARK')) } else if (formData.pincode === '') { - return alert(t('PLEASE_ENTER_YOUR_AREA_PINCODE')) + toast.error(t('PLEASE_ENTER_YOUR_AREA_PINCODE')) } else if (!validPincode.test(formData.pincode)) { - return alert(t('PLEASE_ENTER_VALID_PINCODE')) + toast.error(t('PLEASE_ENTER_VALID_PINCODE')) } else { setFormData({ ...formData, @@ -188,6 +190,7 @@ const Enrollment = () => { } return ( <> + {conditionalComponent()} {conditionalButton()} diff --git a/client/src/pages/Update/Demographic/Demographic.jsx b/client/src/pages/Update/Demographic/Demographic.jsx index 6640cd3..8853678 100644 --- a/client/src/pages/Update/Demographic/Demographic.jsx +++ b/client/src/pages/Update/Demographic/Demographic.jsx @@ -14,6 +14,8 @@ import { import UpdateSelect from '../UpdateSelect/UpdateSelect' import { useTranslation } from 'react-i18next' import { userContext } from '../../../context/User' +import { ToastContainer, toast } from 'react-toastify' +import 'react-toastify/dist/ReactToastify.css' const Demographic = () => { const { t } = useTranslation() @@ -80,45 +82,45 @@ const Demographic = () => { const handleSubmit = () => { if (page === 0) { if (formData.name === '' || formData.name.length < 1) { - return alert(t('PLEASE_ENTER_YOUR_NAME')) + toast.error(t('PLEASE_ENTER_YOUR_NAME')) } else if (!validString.test(formData.name)) { - return alert(t('PLEASE_ENTER_VALID_NAME')) + toast.error(t('PLEASE_ENTER_VALID_NAME')) } else if (formData.gender === '') { - return alert(t('PLEASE_SELECT_YOUR_GENDER')) + toast.error(t('PLEASE_SELECT_YOUR_GENDER')) } else if (formData.mobile === '') { - return alert(t('PLEASE_ENTER_YOUR_MOBILE_NUMBER')) + toast.error(t('PLEASE_ENTER_YOUR_MOBILE_NUMBER')) } else if (!validMobileNumber.test(formData.mobile)) { - return alert(t('PLEASE_ENTER_VALID_MOBILE_NUMBER')) + toast.error(t('PLEASE_ENTER_VALID_MOBILE_NUMBER')) } else if (formData.email === '') { - return alert(t('PLEASE_ENTER_YOUR_EMAIL')) + toast.error(t('PLEASE_ENTER_YOUR_EMAIL')) } else if (!validEmail.test(formData.email)) { - return alert(t('PLEASE_ENTER_VALID_EMAIL')) + toast.error(t('PLEASE_ENTER_VALID_EMAIL')) } else { setPage(page + 1) } } else if (page === 1) { if (formData.country === '') { - return alert(t('PLEASE_SELECT_YOUR_COUNTRY')) + toast.error(t('PLEASE_SELECT_YOUR_COUNTRY')) } else if (formData.state === '') { - return alert(t('PLEASE_SELECT_YOUR_STATE')) + toast.error(t('PLEASE_SELECT_YOUR_STATE')) } else if (formData.district === '') { - return alert(t('PLEASE_SELECT_YOUR_DISTRICT')) + toast.error(t('PLEASE_SELECT_YOUR_DISTRICT')) } else if (formData.village === '') { - return alert(t('PLEASE_ENTER_YOUR_VILLAGE')) + toast.error(t('PLEASE_ENTER_YOUR_VILLAGE')) } else if (formData.houseNo === '') { - return alert(t('PLEASE_ENTER_YOUR_HOUSE_NUMBER')) + toast.error(t('PLEASE_ENTER_YOUR_HOUSE_NUMBER')) } else if (formData.street === '') { - return alert(t('PLEASE_ENTER_YOUR_STREET')) + toast.error(t('PLEASE_ENTER_YOUR_STREET')) } else if (formData.locality === '') { - return alert(t('PLEASE_ENTER_YOUR_LOCALITY')) + toast.error(t('PLEASE_ENTER_YOUR_LOCALITY')) } else if (formData.postOffice === '') { - return alert(t('PLEASE_ENTER_YOUR_AREA_POST_OFFICE')) + toast.error(t('PLEASE_ENTER_YOUR_AREA_POST_OFFICE')) } else if (formData.landmark === '') { - return alert(t('PLEASE_ENTER_NEAREST_LANDMARK')) + toast.error(t('PLEASE_ENTER_NEAREST_LANDMARK')) } else if (formData.pincode === '') { - return alert(t('PLEASE_ENTER_YOUR_AREA_PINCODE')) + toast.error(t('PLEASE_ENTER_YOUR_AREA_PINCODE')) } else if (!validPincode.test(formData.pincode)) { - return alert(t('PLEASE_ENTER_VALID_PINCODE')) + toast.error(t('PLEASE_ENTER_VALID_PINCODE')) } else { setFormData({ ...formData, @@ -158,6 +160,7 @@ const Demographic = () => { } return ( <> + {conditionalComponent()} {conditionalButton()} -- cgit