From 5678d910ec74269c37c8a598531b608365d19f92 Mon Sep 17 00:00:00 2001 From: Aman Chaturvedi Date: Thu, 8 Dec 2022 11:24:39 +0530 Subject: [PATCH] Fixes for Login screen --- ProtectedRouter.tsx | 3 ++- RN-UI-LIB | 2 +- src/action/authActions.ts | 7 ++++--- src/components/countdown/index.tsx | 4 ++-- src/components/login/OtpText.tsx | 10 ++++++---- src/components/login/index.tsx | 4 ++-- src/components/login/loginSlice.ts | 5 ++--- src/components/utlis/apiHelper.ts | 12 ++++++------ src/constants/config.js | 1 + src/reducer/commonSlice.ts | 2 -- 10 files changed, 26 insertions(+), 24 deletions(-) create mode 100644 src/constants/config.js diff --git a/ProtectedRouter.tsx b/ProtectedRouter.tsx index ce14f53e..2f9849b4 100644 --- a/ProtectedRouter.tsx +++ b/ProtectedRouter.tsx @@ -13,6 +13,7 @@ import userData from './src/data/userData.json'; import {getUniqueId} from 'react-native-device-info'; import {useAppDispatch} from './src/hooks'; import {setAuthData} from './src/reducer/commonSlice'; +import { _map } from './RN-UI-LIB/src/utlis/common'; const Stack = createNativeStackNavigator(); @@ -50,7 +51,7 @@ const ProtectedRouter = () => { header: () => null, }} /> - {Object.keys(data.widgets).map(key => ( + {_map(data.widgets, key => ( { + // TODO: Fix status from BE if (err.response.status === 404) { dispatch( - setGetOTPError('Enter a registered mobile number'), + setOTPError('Enter a registered mobile number'), ); } else { - dispatch(setGetOTPError(err.response?.data?.message)); + dispatch(setOTPError(err.response?.data?.message)); } }); }; diff --git a/src/components/countdown/index.tsx b/src/components/countdown/index.tsx index 68b98b2e..83844f75 100644 --- a/src/components/countdown/index.tsx +++ b/src/components/countdown/index.tsx @@ -26,11 +26,11 @@ export const Countdown = (props: CountdownProps) => { if (newTickerValue < stopAt) { clearTimeout(intervalRef.current); - onComplete && onComplete(); + onComplete && typeof onComplete === 'function' && onComplete(); return; } - step && step(newTickerValue); + step && typeof onComplete === 'function' && step(newTickerValue); setTicker(newTickerValue); }; diff --git a/src/components/login/OtpText.tsx b/src/components/login/OtpText.tsx index 2fb4c974..16a12df1 100644 --- a/src/components/login/OtpText.tsx +++ b/src/components/login/OtpText.tsx @@ -20,6 +20,10 @@ const OtpText = () => { dispatch(generateOTP({phoneNumber}, true)); }; + const handleCountdownComplete = () => { + setCountDownComplete(true) + }; + if (verifyOTPError) { return ( @@ -44,12 +48,10 @@ const OtpText = () => { Resend OTP in{' '} { - setCountDownComplete(true); - }} + onComplete={handleCountdownComplete} startFrom={30} />{' '} - second + second(s) ); }; diff --git a/src/components/login/index.tsx b/src/components/login/index.tsx index efb87725..7fff4c24 100644 --- a/src/components/login/index.tsx +++ b/src/components/login/index.tsx @@ -52,7 +52,7 @@ const Login = () => { keyboardType="phone-pad" placeholder="Enter here" onBlur={onBlur} - onChangeText={value => onChange(value)} + onChangeText={onChange} value={value} maxLength={10} defaultValue={phoneNumber} @@ -61,7 +61,7 @@ const Login = () => { /> )} name="phoneNumber" - rules={{required: true, minLength: 10}} + rules={{required: true, minLength: 10, maxLength: 10}} />