Skip to content

Commit

Permalink
added toast messages and modal for confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
shreya-mishra committed Aug 9, 2023
1 parent 151d5e7 commit 70db8c3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
7 changes: 3 additions & 4 deletions src/components/Modal/CustomModal.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { Alert, Modal, StyleSheet, Text, Pressable, View } from 'react-native';
const message = "Press Done button once you verify yourself from My-site"
const message = 'Press Done button once you verify yourself from My-site';

const CustomModal = ({ modalVisible, setModalVisible }) => {
console.log('mess',message)
console.log('mess', message);
return (
<Modal
animationType="slide"
Expand Down Expand Up @@ -49,7 +49,6 @@ const styles = StyleSheet.create({
shadowOpacity: 0.25,
shadowRadius: 4,
elevation: 5,

},
button: {
borderRadius: 20,
Expand All @@ -69,7 +68,7 @@ const styles = StyleSheet.create({
modalText: {
marginBottom: 15,
textAlign: 'center',
color:'black'
color: 'black',
},
});

Expand Down
31 changes: 18 additions & 13 deletions src/screens/AuthScreen/AuthScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import AuthApis from '../../constants/apiConstant/AuthApi';
import { CameraScreen } from 'react-native-camera-kit';
import CustomModal from '../../components/Modal/CustomModal';



const AuthScreen = () => {
// TODO: will revamp github signIn feature
const { setLoggedInUserData } = useContext(AuthContext);
Expand All @@ -36,7 +34,6 @@ const AuthScreen = () => {
const [scannedUserId, setScannedUserID] = useState('');
const [modalVisible, setModalVisible] = useState(false);


const activateCamera = async () => {
try {
// await Camera.requestCameraPermission(); // Request camera permission
Expand Down Expand Up @@ -80,9 +77,9 @@ const AuthScreen = () => {
const getAuthStatus = async () => {
const deviceInfo = await DeviceInfo.getDeviceName();
const deviceId = await DeviceInfo.getUniqueId();
console.log("device info",deviceInfo)
console.log("device id",deviceId)
console.log('userID',scannedUserId)
console.log('device info', deviceInfo);
console.log('device id', deviceId);
console.log('userID', scannedUserId);
setLoading(true);
try {
const data = await fetch(AuthApis.QR_AUTH_API, {
Expand All @@ -102,16 +99,22 @@ const AuthScreen = () => {
if (data.ok) {
const dataJson = await data.json();
console.log('Post call successful', dataJson);
Alert.alert('Please Confirm',dataJson.message, [
Alert.alert('Please Confirm', dataJson.message, [
{
text: 'Cancel',
onPress: () => setCameraActive(false)
onPress: () => setCameraActive(false),
},
{ text: 'OK', onPress: () => {setCameraActive(false); setModalVisible(true)}}, // ok -> Modal (press done button once you verify yourself from mysite) -> Done > loader? -> get call implementation =?> userdata => autorize -> if fail ? toast msgs ? homscreen
{
text: 'OK',
onPress: () => {
setCameraActive(false);
setModalVisible(true);
},
}, // ok -> Modal (press done button once you verify yourself from mysite) -> Done > loader? -> get call implementation =?> userdata => autorize -> if fail ? toast msgs ? homscreen
]);
} else {
const dataJson = await data.json();
console.log('data in else', dataJson.message)
console.log('data in else', dataJson.message);
Toast.show({
type: 'error',
text1: 'Something went wrong, please try again',
Expand Down Expand Up @@ -238,9 +241,11 @@ const AuthScreen = () => {
/>
)}

{ modalVisible && (
<CustomModal modalVisible={modalVisible} setModalVisible={setModalVisible} />

{modalVisible && (
<CustomModal
modalVisible={modalVisible}
setModalVisible={setModalVisible}
/>
)}
</ScrollView>
);
Expand Down

0 comments on commit 70db8c3

Please sign in to comment.