store dna all done

This commit is contained in:
CPM
2025-07-30 10:35:06 +05:30
commit b0399b39c6
157 changed files with 35444 additions and 0 deletions
+98
View File
@@ -0,0 +1,98 @@
import React, { useEffect, useState } from 'react';
import { View, Text, Image, Platform, ImageBackground } from 'react-native';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
import IMAGES from '../../../constants/Images';
import { styles } from './style';
import { useDispatch } from 'react-redux';
import CustomTextInput from '../../../components/CustomTextInput';
import CustomButton from '../../../components/CustomButton';
import Loader from '../../../constants/Loader';
import { ApiURL } from '../../../api/ApiConstant';
import { toastError, toastSuccess } from '../../../constants/Toast';
import axios from 'axios';
import { SafeAreaView } from 'react-native-safe-area-context';
import { GlobalTheme } from '../../../theme';
import Geolocation from '@react-native-community/geolocation';
const Login = ({ navigation }) => {
const [loading, setLoading] = useState(false);
const dispatch = useDispatch();
const [username, setUsername] = useState('testah');
// geo loc
useEffect(() => {
Geolocation.getCurrentPosition(info => console.log("Location infoooo====>", JSON.stringify(info)));
}, [])
// end geo loc
const onSubmit = () => {
setLoading(true);
getOTP();
setTimeout(() => {
setLoading(false);
}, 100);
};
const getOTP = async () => {
try {
const params = {
"UserId": username
};
const config = {
method: 'post',
url: ApiURL.getotpApi,
headers: {
'api_key': '9a1f056fecb84eaf8eb4152dda22ab0501955c4f9bbe7daa8780740459fdde7a',
'Content-Type': 'application/json'
},
data: params
};
const response = await axios.request(config);
const res = response.data || [];
console.log('OTP is ===> ', res?.SendOTP);
if (res?.SendOTP[0].OTP === '0' || res?.SendOTP[0].OTP === 0) {
toastError("Alert", "Invalid User");
} else {
toastSuccess("Alert", res?.SendOTP[0]?.Messages);
navigation.navigate('VerifyOTP', { username: username });
}
// console.log('getotpApi res==>', JSON.stringify(res?.SendOTP[0]));
} catch (error) {
console.log("❌ OTP API error:", error);
}
};
return (
<SafeAreaView style={styles.container}>
<KeyboardAwareScrollView keyboardShouldPersistTaps="handled" enableOnAndroid={true} contentContainerStyle={{ justifyContent: 'center', flexGrow: 1, marginTop: 0 }} style={styles.container}>
<View style={{ backgroundColor: GlobalTheme.colors.primary, height: 40 }} />
<Image style={styles.appLogo} source={IMAGES.AuthTopBGNew} resizeMode='contain' />
<View style={styles.card}>
<Text style={styles.loginTitle}>Login</Text>
<CustomTextInput
label="Username"
placeholder="Enter username"
value={username}
onChangeText={setUsername}
containerStyle={styles.inputWrapper}
/>
<CustomButton onPress={() => onSubmit()} title={'Continue'} style={styles.btnbg} textstyle={styles.btntext} />
<ImageBackground source={IMAGES.AuthBottomBG} style={styles.AuthBottomBG} >
<Text style={{ position: 'absolute', textAlign: 'center', alignContent: 'center', alignSelf: 'center', bottom: 0, color: GlobalTheme.colors.gray }}> Copyright CPM India - 2025</Text>
{/* <Image source={IMAGES.Logo} style={styles.footerImage} resizeMode="contain"/> */}
</ImageBackground>
</View>
</KeyboardAwareScrollView>
<Loader visible={loading} loadingtext={'Loading ...'} />
</SafeAreaView>
);
};
export default Login;
+82
View File
@@ -0,0 +1,82 @@
import { StyleSheet, Dimensions } from 'react-native';
import { GlobalTheme } from '../../../theme';
import { normalize } from '../../../utilis/responsive';
const { width, height } = Dimensions.get('window');
export const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: GlobalTheme.colors.primary,
},
logoContainer: {
width: '100%',
},
appLogo: {
height: normalize(170),
width: '100%',
resizeMode: 'contain',
},
titleContainer: {
alignSelf: 'center',
marginBottom: normalize(10),
},
titleText: {
fontSize: normalize(20),
fontWeight: 'bold',
color: GlobalTheme.colors.black,
},
card: {
backgroundColor: GlobalTheme.colors.white,
borderTopLeftRadius: GlobalTheme.borderRadius.xxlg || normalize(20),
borderTopRightRadius: GlobalTheme.borderRadius.xxlg || normalize(20),
padding: normalize(20),
width: width,
alignSelf: 'center',
// marginTop: normalize(30),
shadowColor: '#000',
shadowOpacity: 0.05,
shadowOffset: { width: 0, height: 4 },
shadowRadius: 8,
elevation: 4,
flex: 1,
},
btnbg: {
backgroundColor: GlobalTheme.colors.secondary,
borderRadius: GlobalTheme.borderRadius.md,
marginTop: normalize(30),
paddingVertical: normalize(12),
alignItems: 'center',
},
btntext: {
color: GlobalTheme.colors.white,
fontSize: normalize(GlobalTheme.typography.fontSize.small),
fontWeight: GlobalTheme.typography.fontWeight.regular,
},
footer: {
marginTop: normalize(60),
alignItems: 'center',
},
footerImage: {
width: '100%',
height: normalize(80),
resizeMode: 'contain',
marginTop : normalize(160),
},
AuthBottomBG: {
width: '100%',
resizeMode: 'contain',
height: normalize(300),
justifyContent: 'center',
},
loginTitle: {
color: GlobalTheme.colors.black,
fontSize: normalize(GlobalTheme.typography.fontSize.large),
fontWeight: GlobalTheme.typography.fontWeight.medium,
textAlign: 'center',
marginBottom: normalize(20),
},
mainContainer: {
flex: 1,
backgroundColor: '#EAF0FF',
},
});
+95
View File
@@ -0,0 +1,95 @@
import { View, Text, Image, Dimensions, StyleSheet } from 'react-native';
import React, { useEffect } from 'react';
import IMAGES from '../../../constants/Images';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { useDispatch } from 'react-redux';
import { setUser } from '../../../redux/slices/userSlice';
const SplashScreen = ({ navigation }) => {
const dispatch = useDispatch();
useEffect(() => {
const checkLoginStatus = async () => {
try {
const isuserlogin = await AsyncStorage.getItem('@Dabur_DNA_User');
console.log("isuserlogin", isuserlogin)
const parsedUser = JSON.parse(isuserlogin);
if (isuserlogin) {
dispatch(setUser(parsedUser));
navigation.reset({
index: 0,
routes: [{ name: 'Welcome' }],
});
} else {
navigation.reset({
index: 0,
routes: [{ name: 'Login' }],
});
}
} catch (error) {
console.error('Error checking login status:', error);
}
};
checkLoginStatus();
}, []);
return (
<View style={styles.container}>
<View style={styles.backgroundContainer}>
<Image
source={IMAGES.splashFullImg}
resizeMode="stretch"
style={styles.backdrop}
/>
</View>
<View style={styles.overlay}>
<Image style={styles.logo} source={IMAGES.AppLogo} />
</View>
</View>
);
};
export default SplashScreen;
const styles = StyleSheet.create({
backgroundContainer: {
position: 'absolute',
top: 0,
bottom: 0,
left: 0,
right: 0,
},
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
overlay: {
opacity: 1,
alignItems: 'center',
justifyContent: 'center',
},
logo: {
backgroundColor: 'rgba(0,0,0,0)',
height: 200,
width: 200,
overflow: 'hidden',
resizeMode: 'contain',
marginTop: 5,
justifyContent: 'center',
},
backdrop: {
flex: 1,
width: '100%',
height: '100%',
},
headline: {
fontSize: 18,
textAlign: 'center',
backgroundColor: 'black',
color: 'white',
//borderWidth:1
},
});
+219
View File
@@ -0,0 +1,219 @@
import React, { useEffect, useState } from 'react';
import { View, Text, Image, TouchableOpacity, ImageBackground } from 'react-native';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
import { useDispatch } from 'react-redux';
import { OtpInput } from "react-native-otp-entry";
import CustomButton from '../../../components/CustomButton';
import Background from '../../../components/Background';
import IMAGES from '../../../constants/Images';
import { GlobalTheme } from '../../../theme';
import { styles } from './style';
import { toastError, toastSuccess } from '../../../constants/Toast';
import Loader from '../../../constants/Loader';
import { ApiURL } from '../../../api/ApiConstant';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { setUser } from '../../../redux/slices/userSlice';
import axios from 'axios';
import { SafeAreaView } from 'react-native-safe-area-context';
const VerifyOTP = ({ navigation, route }) => {
const [loading, setLoading] = useState(false);
const dispatch = useDispatch();
const [otp, setOTP] = useState('');
const [timer, setTimer] = useState(300); // 5 minutes = 300 seconds
const [showResend, setShowResend] = useState(false);
const username = route.params.username;
useEffect(() => {
if (timer === 0) {
setShowResend(true);
return;
}
const interval = setInterval(() => {
setTimer(prev => prev - 1);
}, 1000);
return () => clearInterval(interval);
}, [timer]);
const formatTime = (secs) => {
const minutes = Math.floor(secs / 60);
const seconds = secs % 60;
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
};
const handle_validate = () => {
if (otp.length < 6) {
toastError('Alert', "Please enter 6 digit PIN");
} else {
onSubmit();
}
}
const resendOTP = async () => {
try {
const params = {
"UserId": username
}
const config = {
method: 'post',
url: ApiURL.getotpApi,
headers: {
'api_key': '9a1f056fecb84eaf8eb4152dda22ab0501955c4f9bbe7daa8780740459fdde7a',
'Content-Type': 'application/json'
},
data: params
};
const response = await axios.request(config);
const res = response.data || [];
// console.log('storeSearchApi====>', res);
if (res?.SendOTP[0].OTP === '0' || res?.SendOTP[0].OTP === 0) {
toastError("Alert", res?.SendOTP[0]?.Messages)
} else {
toastSuccess("Alert", res?.SendOTP[0]?.Messages)
navigation.navigate('VerifyOTP', { username: username });
}
// console.log('getotpApi res==>', JSON.stringify(res?.SendOTP[0]));
// setLoading(false)
} catch (error) {
// setLoading(false)
console.log("❌ Filter API error:", error);
}
};
const resend_OTP = () => {
setTimer(300);
setShowResend(false);
toastSuccess('Resend OTP Successfully.')
resendOTP();
}
const onSubmit = () => {
setLoading(true)
VerifyOTP();
setTimeout(() => {
setLoading(false)
}, 100);
}
const VerifyOTP = async () => {
try {
const params = {
"UserId": username,
"OTP": otp
}
const config = {
method: 'post',
url: ApiURL.verifyotpApi,
headers: {
'api_key': '9a1f056fecb84eaf8eb4152dda22ab0501955c4f9bbe7daa8780740459fdde7a',
'Content-Type': 'application/json'
},
data: params
};
const response = await axios.request(config);
const res = response.data || [];
if (res?.AuthenticateOTP[0].Message == 'OTP is matched') {
toastSuccess("Alert", res?.AuthenticateOTP[0]?.Message || "Alert", "Login Successfully.")
await AsyncStorage.setItem('@Dabur_DNA_User', JSON.stringify(res?.AuthenticateOTP[0]));
dispatch(setUser(res?.AuthenticateOTP[0]));
navigation.reset({ index: 0, routes: [{ name: 'Welcome' }] })
} else {
toastError("Alert", res?.AuthenticateOTP[0]?.Message);
}
} catch (error) {
// setLoading(false)
console.log("❌ Filter API error:", error);
}
}
return (
<SafeAreaView style={styles.container}>
<TouchableOpacity onPress={() => navigation.goBack()}>
<View style={styles.backTextView}>
<Image source={IMAGES.leftArrowIcon} style={styles.iconStyle} />
<Text style={styles.backIconText}>Back</Text>
</View>
</TouchableOpacity>
<KeyboardAwareScrollView keyboardShouldPersistTaps="handled" enableOnAndroid={true} style={styles.container} contentContainerStyle={{ justifyContent: 'center', flex: 1 }}>
<View style={{ backgroundColor: GlobalTheme.colors.primary, height: 40 }} />
<Image style={styles.appLogo} source={IMAGES.AuthTopBGNew} resizeMode='contain' />
<View style={styles.card}>
<View style={styles.titleContainer}>
<Text style={styles.titleText}>Enter the OTP sent to your {"\n"} registered contact</Text>
</View>
<View style={{ marginTop: 50 }}>
<OtpInput
numberOfDigits={6}
focusColor={GlobalTheme.colors.primary}
autoFocus={false}
hideStick={true}
placeholder=""
blurOnFilled={true}
disabled={false}
type="numeric"
secureTextEntry={false}
focusStickBlinkingDuration={500}
// onFocus={() => console.log("Focused")}
// onBlur={() => console.log("Blurred")}
onTextChange={(text) => setOTP(text)}
onFilled={(text) => {
setOTP(text);
console.log(`OTP is ${text}`);
}}
textInputProps={{
accessibilityLabel: "One-Time Password",
}}
textProps={{
accessibilityRole: "text",
accessibilityLabel: "OTP digit",
allowFontScaling: false,
}}
theme={{
containerStyle: styles.container,
pinCodeContainerStyle: styles.pinCodeContainer,
pinCodeTextStyle: styles.pinCodeText,
focusStickStyle: styles.focusStick,
focusedPinCodeContainerStyle: styles.activePinCodeContainer,
placeholderTextStyle: styles.placeholderText,
filledPinCodeContainerStyle: styles.filledPinCodeContainer,
disabledPinCodeContainerStyle: styles.disabledPinCodeContainer,
}}
/>
</View>
<View style={{ marginTop: 100}}>
<CustomButton onPress={handle_validate} title={'Verify'} style={styles.btnbg} textstyle={styles.btntext} />
</View>
<View style={{ alignItems: 'center', marginTop: 20 }}>
{!showResend ? (
<Text style={{ color: GlobalTheme.colors.darkGray }}>Resend OTP in {formatTime(timer)}</Text>
) : (
<TouchableOpacity onPress={resend_OTP}>
<Text style={styles.resendOTP} >
Resend OTP
</Text>
</TouchableOpacity>
)}
</View>
<ImageBackground source={IMAGES.AuthBottomBG} style={styles.AuthBottomBG} >
{/* <Image source={IMAGES.Logo} style={styles.footerImage} resizeMode="contain"/> */}
<Text style={{ position : 'absolute', textAlign:'center', alignContent:'center',alignSelf:'center', bottom:0 , color : GlobalTheme.colors.gray}}> Copyright CPM India - 2025</Text>
</ImageBackground>
</View>
</KeyboardAwareScrollView>
<Loader visible={loading} />
</SafeAreaView>
);
};
export default VerifyOTP;
+149
View File
@@ -0,0 +1,149 @@
import { Dimensions, StyleSheet } from 'react-native';
import { GlobalTheme, Screen } from '../../../theme';
import { normalize } from '../../../utilis/responsive';
const { width, height } = Dimensions.get('window');
export const styles = StyleSheet.create({
container: {
// flex: 1,
// paddingHorizontal: 5
flex: 1,
backgroundColor: GlobalTheme.colors.primary,
},
logoContainer: {
alignItems: 'center',
},
appLogo: {
height: normalize(170),
width: '100%',
resizeMode: 'contain',
marginTop: 40
},
titleContainer: {
alignSelf: 'center',
},
titleText: {
fontSize: 18,
fontWeight: '500',
color: GlobalTheme.colors.black,
textAlign: 'center'
},
btnbg: {
backgroundColor: GlobalTheme.colors.secondary, borderRadius: GlobalTheme.borderRadius.md
},
btntext: {
color: GlobalTheme.colors.white,
fontSize: GlobalTheme.typography.fontSize.medium
},
otp_inputStyle: {
textAlign: 'center',
backgroundColor: 'red',
width: 100,
borderRadius: 4,
paddingVertical: 10,
paddingHorizontal: 15,
height: 50,
color: 'red',
marginBottom: 10,
marginRight: 10,
fontSize: 25,
},
// OTP
pinCodeContainer: {
width: 45,
height: 55,
borderWidth: 1,
borderColor: '#D8E3F1',
borderRadius: 8,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#fff',
},
activePinCodeContainer: {
borderColor: GlobalTheme.colors.primary,
borderWidth: 2,
},
filledPinCodeContainer: {
backgroundColor: '#D8E3F1',
},
disabledPinCodeContainer: {
backgroundColor: '#f0f0f0',
borderColor: '#ddd',
},
pinCodeText: {
fontSize: 20,
fontWeight: 'bold',
color: '#333',
},
focusStick: {
height: 2,
width: 20,
backgroundColor: GlobalTheme.colors.primary,
marginTop: 4,
},
placeholderText: {
color: '#aaa',
fontSize: 18,
},
resendText: {
color: GlobalTheme.colors.primary,
fontWeight: 'bold',
fontSize: 14,
marginTop: 20,
textAlign: 'center',
},
timerText: {
color: 'gray',
fontSize: 14,
marginTop: 20,
textAlign: 'center',
},
resendOTP: {
color: GlobalTheme.colors.secondary, fontWeight: GlobalTheme.typography.fontWeight.medium, fontSize: GlobalTheme.typography.fontSize.small
},
iconStyle: {
height: 20,
width: 20,
resizeMode: 'contain',
tintColor: GlobalTheme.colors.white
},
backIconText: { fontSize: GlobalTheme.typography.fontSize.small, color: GlobalTheme.colors.white, fontWeight: GlobalTheme.typography.fontWeight.medium, marginLeft: 8 },
backTextView: {
flexDirection: 'row', alignItems: 'center', paddingTop: 20, paddingHorizontal: 10
},
card: {
backgroundColor: GlobalTheme.colors.white,
borderTopLeftRadius: GlobalTheme.borderRadius.xxlg || normalize(20),
borderTopRightRadius: GlobalTheme.borderRadius.xxlg || normalize(20),
padding: normalize(20),
width: width,
alignSelf: 'center',
// marginTop: normalize(30),
shadowColor: '#000',
shadowOpacity: 0.05,
shadowOffset: { width: 0, height: 4 },
shadowRadius: 8,
elevation: 4,
flex: 1,
minHeight : height * 0.7
},
footer: {
marginTop: 60,
alignItems: 'center',
},
footerImage: {
width: '100%',
height: normalize(80),
resizeMode: 'contain',
marginTop: normalize(160),
},
AuthBottomBG: {
width: '100%',
resizeMode: 'contain',
height: normalize(270),
justifyContent: 'center',
marginTop: normalize(-40),
},
});