Skip to content

Commit

Permalink
Merge pull request #198 from Real-Dev-Squad/updatedQrConfirmations
Browse files Browse the repository at this point in the history
updated popups and conirmation boxes
  • Loading branch information
shreya-mishra authored Aug 10, 2023
2 parents 49a2b61 + 65bd90b commit a12c013
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/Modal/CustomModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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 CustomModal = ({ modalVisible, setModalVisible }) => {
const CustomModal = ({ modalVisible, setModalVisible, qrCodeLogin}) => {
console.log('mess', message);
return (
<Modal
Expand All @@ -19,7 +19,7 @@ const CustomModal = ({ modalVisible, setModalVisible }) => {
<Text style={styles.modalText}>{message}</Text>
<Pressable
style={[styles.button, styles.buttonClose]}
onPress={() => setModalVisible(!modalVisible)}
onPress={ qrCodeLogin}
>
<Text style={styles.textStyle}>Done</Text>
</Pressable>
Expand Down
37 changes: 37 additions & 0 deletions src/screens/AuthScreen/AuthScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,42 @@ const AuthScreen = () => {
}
};

const qrCodeLogin = async () => {
const deviceId = await DeviceInfo.getUniqueId();

const url = `${AuthApis.QR_AUTH_API}?device_id=${deviceId}`;
// {"data": {"authorization_status": "NOT_INIT", "device_id": "389e089e7e6feb38", "device_info": "Shreya", "user_id": "T7IL7MB8YriniTw4bt39"}, "message": "Authentication document retrieved successfully."}
try {
const userInfo = await fetch(url);
const userInfoJson = await userInfo.json();
console.log('userInfoJson', userInfoJson);

if (!userInfoJson.token) {
const userDetailsInfo = await fetch(
`https://api.realdevsquad.com/users/userId/${scannedUserId}`,
);
const userDetailsInfoJson = await userDetailsInfo.json();
console.log('userDetailsInfoJson', userDetailsInfoJson);
await storeData('userData', JSON.stringify(userDetailsInfoJson.user));
const {picture,id,username,status} = userDetailsInfoJson.user
setLoggedInUserData({
id: id,
name: username,
profileUrl: picture.url,
status: status,
});
}
} catch (err) {
console.error(err);
Toast.show({
type: 'error',
text1: 'Something went wrong, please try again later',
position: 'bottom',
bottomOffset: 80,
});
}
};

const getAuthStatus = async () => {
const deviceInfo = await DeviceInfo.getDeviceName();
const deviceId = await DeviceInfo.getUniqueId();
Expand Down Expand Up @@ -245,6 +281,7 @@ const AuthScreen = () => {
<CustomModal
modalVisible={modalVisible}
setModalVisible={setModalVisible}
qrCodeLogin={qrCodeLogin}
/>
)}
</ScrollView>
Expand Down

0 comments on commit a12c013

Please sign in to comment.