summaryrefslogtreecommitdiff
path: root/client/src/pages/Update/Update.jsx
blob: 577573df96ee77dab897589c3ea64aeea7cc12aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import React from 'react'
import Header from '../../components/Header/Header'
import styles from './Update.module.css'
import Input from '../../components/Input/Input'
import { Grid, Button } from '@mui/material'
import { userContext } from '../../context/User'
import { useNavigate } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { ToastContainer, toast } from 'react-toastify'
import { validAadhaar } from '../../constants/RegEx'
import AudioAutoplay from '../../components/AudioAutoplay/AudioAutoplay'

const Update = () => {
  const { aadhaarNumber, setAadhaarNumber } = userContext()

  const navigate = useNavigate()
  const { t } = useTranslation()

  return (
    <>
      <ToastContainer
        autoClose={1000}
        hideProgressBar={true}
        theme={'colored'}
      />
      <Header subheading={`${t('UPDATE')}`} />
      <AudioAutoplay
        audio={`${process.env.PUBLIC_URL}/assets/audios/enter-aadhaar-no`}
      />
      <div className={styles.subheading__container}>
        <h3 className={styles.subheading}>
          {t('PROVIDE_YOUR_AADHAAR_NUMBER')}
        </h3>
        <Input
          type="number"
          id="aadhaarNumber"
          value={aadhaarNumber}
          onChange={(e) => setAadhaarNumber(e.target.value)}
          placeholder={`${t('ENTER_YOUR_AADHAAR_NUMBER')}`}
          required
        />
        <Grid container columnSpacing={10} justifyContent="center">
          <Grid item>
            <Button
              color="primary"
              size="large"
              type="submit"
              variant="contained"
              onClick={() => {
                if (!validAadhaar.test(aadhaarNumber)) {
                  toast.error(t('Please enter a valid aadhaar number'))
                } else {
                  navigate('/update/otp')
                }
              }}
            >
              {t('SUBMIT')}
            </Button>
          </Grid>
        </Grid>
      </div>
    </>
  )
}

export default Update