removed carrots from dependencies and fixes
This commit is contained in:
16
package.json
16
package.json
@@ -13,20 +13,20 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-native-async-storage/async-storage": "1.17.11",
|
||||
"@react-native-firebase/app": "^16.4.6",
|
||||
"@react-native-firebase/database": "^16.4.6",
|
||||
"@react-navigation/native": "^6.0.16",
|
||||
"@react-navigation/native-stack": "^6.9.4",
|
||||
"@react-native-firebase/app": "16.4.6",
|
||||
"@react-native-firebase/database": "16.4.6",
|
||||
"@react-navigation/native": "6.0.16",
|
||||
"@react-navigation/native-stack": "6.9.4",
|
||||
"@reduxjs/toolkit": "1.9.1",
|
||||
"axios": "^1.2.1",
|
||||
"axios": "1.2.1",
|
||||
"react": "18.1.0",
|
||||
"react-hook-form": "7.40.0",
|
||||
"react-native": "0.70.6",
|
||||
"react-native-device-info": "^10.3.0",
|
||||
"react-native-device-info": "10.3.0",
|
||||
"react-native-image-picker": "4.10.2",
|
||||
"react-native-pager-view": "6.1.2",
|
||||
"react-native-safe-area-context": "^4.4.1",
|
||||
"react-native-screens": "^3.18.2",
|
||||
"react-native-safe-area-context": "4.4.1",
|
||||
"react-native-screens": "3.18.2",
|
||||
"react-native-svg": "13.6.0",
|
||||
"react-native-tab-view": "3.3.2",
|
||||
"react-native-toast-message": "2.1.5",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, {useState} from 'react';
|
||||
import React from 'react';
|
||||
import {Controller, useForm} from 'react-hook-form';
|
||||
import {StyleSheet} from 'react-native';
|
||||
import {SafeAreaView} from 'react-native-safe-area-context';
|
||||
@@ -11,14 +11,13 @@ import BackArrowIcon from '../../../RN-UI-LIB/src/Icons/BackArrowIcon';
|
||||
import {GenericStyles} from '../../../RN-UI-LIB/src/styles';
|
||||
import {COLORS} from '../../../RN-UI-LIB/src/styles/colors';
|
||||
import {
|
||||
generateOTP,
|
||||
verifyOTP,
|
||||
VerifyOTPPayload,
|
||||
} from '../../action/authActions';
|
||||
import {useAppDispatch} from '../../hooks';
|
||||
import {RootState} from '../../store/store';
|
||||
import {Countdown} from '../countdown';
|
||||
import {navigateToScreen} from '../utlis/navigationUtlis';
|
||||
import OtpText from './OtpText';
|
||||
|
||||
interface IOtpForm {
|
||||
otp: string;
|
||||
@@ -35,8 +34,6 @@ const OtpInput = () => {
|
||||
(state: RootState) => state.loginInfo,
|
||||
);
|
||||
|
||||
const [countDownComplete, setCountDownComplete] = useState<boolean>(false);
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const handleVerifyOTP = (data: IOtpForm) => {
|
||||
@@ -51,49 +48,6 @@ const OtpInput = () => {
|
||||
navigateToScreen('Login');
|
||||
};
|
||||
|
||||
const handleResendOTP = () => {
|
||||
dispatch(generateOTP({phoneNumber}, true));
|
||||
};
|
||||
|
||||
const renderOTPText = () => {
|
||||
if (verifyOTPError) {
|
||||
return (
|
||||
<Text style={styles.errorText}>
|
||||
{verifyOTPError}{' '}
|
||||
<Text
|
||||
style={styles.clickableText}
|
||||
onPress={handleResendOTP}>
|
||||
Resend OTP
|
||||
</Text>
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
if (countDownComplete) {
|
||||
return (
|
||||
<Text light>
|
||||
Enter 4 digits OTP or{' '}
|
||||
<Text
|
||||
style={styles.clickableText}
|
||||
onPress={handleResendOTP}>
|
||||
Resend OTP
|
||||
</Text>
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Text light>
|
||||
Resend OTP in{' '}
|
||||
<Countdown
|
||||
onComplete={() => {
|
||||
setCountDownComplete(true);
|
||||
}}
|
||||
startFrom={30}
|
||||
/>{' '}
|
||||
second
|
||||
</Text>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<SafeAreaView
|
||||
style={[
|
||||
@@ -128,7 +82,7 @@ const OtpInput = () => {
|
||||
name="otp"
|
||||
rules={{required: true, minLength: 4}}
|
||||
/>
|
||||
{renderOTPText()}
|
||||
<OtpText />
|
||||
<Button
|
||||
title="Verify OTP"
|
||||
onPress={handleSubmit(handleVerifyOTP)}
|
||||
@@ -144,9 +98,6 @@ const styles = StyleSheet.create({
|
||||
clickableText: {
|
||||
color: COLORS.BASE.BLUE,
|
||||
},
|
||||
errorText: {
|
||||
color: COLORS.TEXT.RED,
|
||||
},
|
||||
});
|
||||
|
||||
export default OtpInput;
|
||||
|
||||
66
src/components/login/OtpText.tsx
Normal file
66
src/components/login/OtpText.tsx
Normal file
@@ -0,0 +1,66 @@
|
||||
import React, {useState} from 'react';
|
||||
import {useSelector} from 'react-redux';
|
||||
import {generateOTP} from '../../action/authActions';
|
||||
import {useAppDispatch} from '../../hooks';
|
||||
import {RootState} from '../../store/store';
|
||||
import Text from '../../../RN-UI-LIB/src/components/Text';
|
||||
import {Countdown} from '../countdown';
|
||||
import {StyleSheet} from 'react-native';
|
||||
import {COLORS} from '../../../RN-UI-LIB/src/styles/colors';
|
||||
|
||||
const OtpText = () => {
|
||||
const [countDownComplete, setCountDownComplete] = useState<boolean>(false);
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const {phoneNumber, verifyOTPError} = useSelector(
|
||||
(state: RootState) => state.loginInfo,
|
||||
);
|
||||
|
||||
const handleResendOTP = () => {
|
||||
dispatch(generateOTP({phoneNumber}, true));
|
||||
};
|
||||
|
||||
if (verifyOTPError) {
|
||||
return (
|
||||
<Text style={styles.errorText}>
|
||||
{verifyOTPError}{' '}
|
||||
<Text style={styles.clickableText} onPress={handleResendOTP}>
|
||||
Resend OTP
|
||||
</Text>
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
if (countDownComplete) {
|
||||
return (
|
||||
<Text light>
|
||||
Enter 4 digits OTP or{' '}
|
||||
<Text style={styles.clickableText} onPress={handleResendOTP}>
|
||||
Resend OTP
|
||||
</Text>
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Text light>
|
||||
Resend OTP in{' '}
|
||||
<Countdown
|
||||
onComplete={() => {
|
||||
setCountDownComplete(true);
|
||||
}}
|
||||
startFrom={30}
|
||||
/>{' '}
|
||||
second
|
||||
</Text>
|
||||
);
|
||||
};
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
clickableText: {
|
||||
color: COLORS.BASE.BLUE,
|
||||
},
|
||||
errorText: {
|
||||
color: COLORS.TEXT.RED,
|
||||
},
|
||||
});
|
||||
|
||||
export default OtpText;
|
||||
@@ -17,8 +17,8 @@ export enum ApiKeys {
|
||||
}
|
||||
|
||||
const API_URLS: Record<ApiKeys, string> = {} as Record<ApiKeys, string>;
|
||||
API_URLS[ApiKeys.GENERATE_OTP] = '/auth/otp/generateOtp';
|
||||
API_URLS[ApiKeys.VERIFY_OTP] = '/auth/otp/verifyOtp';
|
||||
API_URLS[ApiKeys.GENERATE_OTP] = '/auth/otp/generate';
|
||||
API_URLS[ApiKeys.VERIFY_OTP] = '/auth/otp/verify';
|
||||
|
||||
const MOCK_API_URLS: Record<ApiKeys, string> = {} as Record<ApiKeys, string>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user