summaryrefslogtreecommitdiff
path: root/client/src/pages/Enrollment/Enrollment.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/pages/Enrollment/Enrollment.jsx')
-rw-r--r--client/src/pages/Enrollment/Enrollment.jsx153
1 files changed, 151 insertions, 2 deletions
diff --git a/client/src/pages/Enrollment/Enrollment.jsx b/client/src/pages/Enrollment/Enrollment.jsx
index 4d8fad2..f3b4c88 100644
--- a/client/src/pages/Enrollment/Enrollment.jsx
+++ b/client/src/pages/Enrollment/Enrollment.jsx
@@ -36,6 +36,7 @@ const Enrollment = () => {
const { userData, setUserData } = userContext()
const navigate = useNavigate()
const [unverified, setUnverified] = useState(true)
+ const language = localStorage.getItem('i18nextLng')
const [model, setModel] = useState()
@@ -92,54 +93,170 @@ const Enrollment = () => {
sendMessage(payload)
})
+ let audio
+
const handleSubmit = () => {
if (page === 0) {
if (userData.indianResident === '') {
toast.error(t('PLEASE_SELECT_YOUR_RESIDENCY'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/select-residency-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/select-residency-hindi.mp3`)
+ }
+ audio.play()
} else if (userData.name === '' || userData.name.length < 1) {
toast.error(t('PLEASE_ENTER_YOUR_NAME'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-name-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-name-hindi.mp3`)
+ }
+ audio.play()
} else if (!validString.test(userData.name)) {
toast.error(t('PLEASE_ENTER_VALID_NAME'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-valid-name-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-valid-name-hindi.mp3`)
+ }
+ audio.play()
} else if (userData.gender === '') {
toast.error(t('PLEASE_SELECT_YOUR_GENDER'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-select-your-gender-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-select-your-gender-hindi.mp3`)
+ }
+ audio.play()
} else if (userData.dob === '') {
toast.error(t('PLEASE_SELECT_YOUR_DOB'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-select-dob-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-select-dob-hindi.mp3`)
+ }
+ audio.play()
} else {
setPage(page + 1)
}
} else if (page === 1) {
if (userData.mobile === '') {
toast.error(t('PLEASE_ENTER_YOUR_MOBILE_NUMBER'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-select-mobile-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-select-mobile-hindi.mp3`)
+ }
+ audio.play()
} else if (!validMobileNumber.test(userData.mobile)) {
toast.error(t('PLEASE_ENTER_VALID_MOBILE_NUMBER'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-select-valid-mobile-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-select-valid-mobile-hindi.mp3`)
+ }
+ audio.play()
} else if (userData.email === '') {
toast.error(t('PLEASE_ENTER_YOUR_EMAIL'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-email-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-email-hindi.mp3`)
+ }
+ audio.play()
} else if (!validEmail.test(userData.email)) {
toast.error(t('PLEASE_ENTER_VALID_EMAIL'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-valid-email-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-valid-email-hindi.mp3`)
+ }
+ audio.play()
} else {
setPage(page + 1)
}
} else if (page === 2) {
if (userData.address.houseNo === '') {
toast.error(t('PLEASE_ENTER_YOUR_HOUSE_NUMBER'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-house-no-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-house-no-hindi.mp3`)
+ }
+ audio.play()
} else if (userData.address.street === '') {
toast.error(t('PLEASE_ENTER_YOUR_STREET'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-street-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-street-hindi.mp3`)
+ }
+ audio.play()
} else if (userData.address.locality === '') {
toast.error(t('PLEASE_ENTER_YOUR_LOCALITY'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-locality-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-locality-hindi.mp3`)
+ }
+ audio.play()
} else if (userData.address.village === '') {
toast.error(t('PLEASE_ENTER_YOUR_VILLAGE'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-village-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-village-hindi.mp3`)
+ }
+ audio.play()
} else if (userData.address.postOffice === '') {
toast.error(t('PLEASE_ENTER_YOUR_AREA_POST_OFFICE'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-post-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-post-hindi.mp3`)
+ }
+ audio.play()
} else if (userData.address.pincode === '') {
toast.error(t('PLEASE_ENTER_YOUR_AREA_PINCODE'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-pin-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-pin-hindi.mp3`)
+ }
+ audio.play()
} else if (!validPincode.test(userData.address.pincode)) {
toast.error(t('PLEASE_ENTER_VALID_PINCODE'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-valid-pin-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-enter-valid-pin-hindi.mp3`)
+ }
+ audio.play()
} else if (!userData.address.state.name) {
toast.error(t('PLEASE_SELECT_YOUR_STATE'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-select-state-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-select-state-hindi.mp3`)
+ }
+ audio.play()
} else if (!userData.address.district.name) {
toast.error(t('PLEASE_SELECT_YOUR_DISTRICT'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-select-district-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-select-district-hindi.mp3`)
+ }
+ audio.play()
} else if (userData.address.landmark === '') {
toast.error(t('PLEASE_ENTER_NEAREST_LANDMARK'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-select-landmark-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-select-landmark-hindi.mp3`)
+ }
+ audio.play()
} else {
setPage(page + 1)
}
@@ -154,21 +271,45 @@ const Enrollment = () => {
if (predictions.length > 0) {
if (!userData.photo) {
toast.error(t('PLEASE_CAPTURE_PHOTOGRAPH'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-capture-photo-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-capture-photo-hindi.mp3`)
+ }
+ audio.play()
} else if (
predictions[0].class === 'person' &&
- predictions[0].score > 0.7
+ predictions[0].score > 0.5
) {
setPage(page + 1)
} else {
toast.error(t('PLEASE_CAPTURE_CLEAR_PHOTOGRAPH'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-capture-clear-photo-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-capture-clear-photo-hindi.mp3`)
+ }
+ audio.play()
}
} else {
toast.error(t('PLEASE_CAPTURE_CLEAR_PHOTOGRAPH'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-capture-clear-photo-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-capture-clear-photo-hindi.mp3`)
+ }
+ audio.play()
}
}, 1000)
} else if (page === 4) {
if (!userData.documents.POI) {
toast.error(t('SCAN_YOUR_DOCUMENT'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/scan-documents-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/scan-documents-hindi.mp3`)
+ }
+ audio.play()
} else {
setPage(page + 1)
}
@@ -179,6 +320,12 @@ const Enrollment = () => {
} else if (page === 7) {
if (unverified) {
toast.error(t('PLEASE_VERIFY_OTP'))
+ if (language === 'en') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-verify-otp-english.mp3`)
+ } else if (language === 'hi') {
+ audio = new Audio(`${process.env.PUBLIC_URL}/assets/audios/please-verify-otp-hindi.mp3`)
+ }
+ audio.play()
} else {
mutate({
indianResident: userData.indianResident,
@@ -272,9 +419,11 @@ const Enrollment = () => {
return (
<>
<ToastContainer
- autoClose={1000}
+ autoClose={5000}
hideProgressBar={true}
theme={'colored'}
+ position="top-center"
+ style={{ fontSize: '1.5rem' }}
/>
{conditionalComponent()}
{conditionalButton()}