Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a31b36686d | |||
| 00f4e1b565 | |||
| 6d302def04 |
+5
-2
@@ -11,10 +11,13 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 6030:5173
|
- 6030:5173
|
||||||
expose:
|
expose:
|
||||||
- "5173"
|
- "5173"
|
||||||
|
extra_hosts:
|
||||||
|
- digifi-apidev.chiefsoft.net:10.10.33.15
|
||||||
|
- backend.wrenchboard.api.test:10.10.33.15
|
||||||
environment:
|
environment:
|
||||||
- PORT=${DIGIFI_PORT}
|
- PORT=${DIGIFI_PORT}
|
||||||
tty: true
|
tty: true
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
volumes:
|
volumes:
|
||||||
src:
|
src:
|
||||||
|
|||||||
@@ -21,7 +21,11 @@ const validationSchema = Yup.object().shape({
|
|||||||
.min(11, "must be 11 digits")
|
.min(11, "must be 11 digits")
|
||||||
.max(11, "must be 11 digits"),
|
.max(11, "must be 11 digits"),
|
||||||
otp: Yup.string()
|
otp: Yup.string()
|
||||||
.required("OTP is required")
|
// .when('require_otp', {
|
||||||
|
// is: true,
|
||||||
|
// then: Yup.string().required("OTP is required")
|
||||||
|
// })
|
||||||
|
// .required("OTP is required")
|
||||||
.test("no-e", "Invalid number", (value:any) => {
|
.test("no-e", "Invalid number", (value:any) => {
|
||||||
if (value && /^[0-9]*$/.test(value) == false) {
|
if (value && /^[0-9]*$/.test(value) == false) {
|
||||||
return false;
|
return false;
|
||||||
@@ -55,10 +59,7 @@ const LetsGetStarted: React.FC = () => {
|
|||||||
// bvn: "",
|
// bvn: "",
|
||||||
// otp: "",
|
// otp: "",
|
||||||
// });
|
// });
|
||||||
|
// const otpInputRef = React.useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
const firstInputRef = React.useRef<HTMLInputElement>(null);
|
|
||||||
const secondInputRef = React.useRef<HTMLInputElement>(null);
|
|
||||||
|
|
||||||
const [requestStatusBVN, setRequestStatusBVN] = React.useState<RequestStatus>({loading:false, status:undefined, message:''});
|
const [requestStatusBVN, setRequestStatusBVN] = React.useState<RequestStatus>({loading:false, status:undefined, message:''});
|
||||||
|
|
||||||
@@ -67,29 +68,29 @@ const LetsGetStarted: React.FC = () => {
|
|||||||
valid: undefined
|
valid: undefined
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleInput = (e: React.FormEvent<HTMLInputElement>) => {
|
|
||||||
let { value } = e.target as HTMLInputElement;
|
// e: React.FormEvent<HTMLInputElement>
|
||||||
let bvn = value
|
// let { value } = e.target as HTMLInputElement;
|
||||||
if(value.length == 11){
|
const bvnValidation = (values:any) => { // Function to Validate BVN
|
||||||
setRequestStatusBVN({loading:true, status:false, message:''})
|
let bvn = values.bvn
|
||||||
validateBVN({bvn}).then(res => {
|
setRequestStatusBVN({loading:true, status:false, message:''})
|
||||||
if(!res || !res.data.call_return){
|
validateBVN({bvn}).then(res => {
|
||||||
setBvnIsValid({verification_id:'', valid: false})
|
if(!res || !res.data.call_return){
|
||||||
setRequestStatusBVN({loading:false, status:false, message:'unable to verify BVN'})
|
|
||||||
return setTimeout(()=>{
|
|
||||||
setRequestStatusBVN({loading:false, status:false, message:''})
|
|
||||||
}, 4000)
|
|
||||||
}
|
|
||||||
setBvnIsValid({verification_id:res.data.verification_id, valid: true})
|
|
||||||
setRequestStatusBVN({loading:false, status:true, message:'verified'})
|
|
||||||
}).catch(err => {
|
|
||||||
setBvnIsValid({verification_id:'', valid: false})
|
setBvnIsValid({verification_id:'', valid: false})
|
||||||
console.log(err)
|
setRequestStatusBVN({loading:false, status:false, message:'unable to verify BVN'})
|
||||||
})
|
return setTimeout(()=>{
|
||||||
}
|
setRequestStatusBVN({loading:false, status:false, message:''})
|
||||||
|
}, 4000)
|
||||||
|
}
|
||||||
|
setBvnIsValid({verification_id:res.data.verification_id, valid: true})
|
||||||
|
setRequestStatusBVN({loading:false, status:true, message:'verified'})
|
||||||
|
}).catch(err => {
|
||||||
|
setBvnIsValid({verification_id:'', valid: false})
|
||||||
|
console.log(err)
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = (values:any) => {
|
const handleSubmit = (values:any) => { // Function to VERIFY OTP AND LOGIN USER
|
||||||
// console.log('values', values)
|
// console.log('values', values)
|
||||||
verifyOTP({...values, verification_id:bvnIsValid.verification_id}).then(res=>{
|
verifyOTP({...values, verification_id:bvnIsValid.verification_id}).then(res=>{
|
||||||
console.log(res.data)
|
console.log(res.data)
|
||||||
@@ -103,7 +104,7 @@ const LetsGetStarted: React.FC = () => {
|
|||||||
<Formik
|
<Formik
|
||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
validationSchema={validationSchema}
|
validationSchema={validationSchema}
|
||||||
onSubmit={handleSubmit}
|
onSubmit={bvnIsValid.valid ? handleSubmit : bvnValidation}
|
||||||
>
|
>
|
||||||
{(props:any) => (
|
{(props:any) => (
|
||||||
<Form className="">
|
<Form className="">
|
||||||
@@ -129,9 +130,6 @@ const LetsGetStarted: React.FC = () => {
|
|||||||
inputClass="w-full h-[3.625rem] rounded bg-[#EFEFEF] px-4"
|
inputClass="w-full h-[3.625rem] rounded bg-[#EFEFEF] px-4"
|
||||||
value={props.values.bvn}
|
value={props.values.bvn}
|
||||||
onChange={props.handleChange}
|
onChange={props.handleChange}
|
||||||
onInput={handleInput}
|
|
||||||
ref={firstInputRef}
|
|
||||||
maxLength={11}
|
|
||||||
error={(props.errors.bvn && props.touched.bvn) && props.errors.bvn}
|
error={(props.errors.bvn && props.touched.bvn) && props.errors.bvn}
|
||||||
/>
|
/>
|
||||||
<p className={`p-2 ${!requestStatusBVN.status ? 'text-red-500' : 'text-emerald-500'}`}>{requestStatusBVN.loading ? 'verifying...' : requestStatusBVN.message}</p>
|
<p className={`p-2 ${!requestStatusBVN.status ? 'text-red-500' : 'text-emerald-500'}`}>{requestStatusBVN.loading ? 'verifying...' : requestStatusBVN.message}</p>
|
||||||
@@ -150,18 +148,17 @@ const LetsGetStarted: React.FC = () => {
|
|||||||
inputClass="w-full h-[3.625rem] rounded bg-[#EFEFEF] px-4"
|
inputClass="w-full h-[3.625rem] rounded bg-[#EFEFEF] px-4"
|
||||||
value={props.values.otp}
|
value={props.values.otp}
|
||||||
onChange={props.handleChange}
|
onChange={props.handleChange}
|
||||||
ref={secondInputRef}
|
|
||||||
maxLength={11}
|
|
||||||
error={(props.errors.otp && props.touched.otp) && props.errors.otp}
|
error={(props.errors.otp && props.touched.otp) && props.errors.otp}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<button
|
<button
|
||||||
type='submit'
|
type='submit'
|
||||||
className="w-full h-[3.625rem] rounded bg-[#FBB700] rounded-2 px-4 text-[18px] text-[#282828] font-semibold disabled:text-[#282828] disabled:text-opacity-50"
|
className="w-full h-[3.625rem] rounded bg-[#FBB700] rounded-2 px-4 text-[18px] text-[#282828] font-semibold disabled:text-[#282828] disabled:text-opacity-50"
|
||||||
disabled={!props.values.otp || requestStatusBVN.loading}
|
disabled={requestStatusBVN.loading || (!props.values.otp && bvnIsValid.valid)}
|
||||||
>
|
>
|
||||||
Enter
|
Enter
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
||||||
{bvnIsValid.valid || bvnIsValid.valid == undefined ? (
|
{bvnIsValid.valid || bvnIsValid.valid == undefined ? (
|
||||||
<p className="text-[#5C2684] mt-[1.5625rem] w-fit">
|
<p className="text-[#5C2684] mt-[1.5625rem] w-fit">
|
||||||
|
|||||||
Reference in New Issue
Block a user