Skip to content

Commit

Permalink
Merge pull request #200 from Real-Dev-Squad/cleaningCode
Browse files Browse the repository at this point in the history
Cleaning code
  • Loading branch information
shreya-mishra authored Aug 18, 2023
2 parents c342f6a + bf4e03f commit 773e2e3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"lint": "eslint . --fix --ext .js,.jsx,.ts,.tsx",
"format-check": "prettier --check ./src",
"format-fix": "prettier --write ./src",
"precommit-check": "yarn run format-fix && yarn run lint && yarn run test"
"precommit-check": "yarn run format-fix && yarn run lint && yarn run test",
"build": "npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res; cd android ; ./gradlew assembleDebug"
},
"dependencies": {
"@react-native-async-storage/async-storage": "^1.15.16",
Expand All @@ -25,6 +26,7 @@
"react": "17.0.2",
"react-native": "0.67.0",
"react-native-app-auth": "^6.4.2",
"react-native-asset": "^2.1.1",
"react-native-camera-kit": "^13.0.0",
"react-native-date-picker": "^4.2.13",
"react-native-datepicker": "^1.7.2",
Expand Down
3 changes: 3 additions & 0 deletions react-native.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
assets: ['./assets'],
};
2 changes: 1 addition & 1 deletion src/components/Modal/CustomModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const CustomModal = ({ modalVisible, setModalVisible, qrCodeLogin}) => {
<Text style={styles.modalText}>{message}</Text>
<Pressable
style={[styles.button, styles.buttonClose]}
onPress={ qrCodeLogin}
onPress={qrCodeLogin}
>
<Text style={styles.textStyle}>Done</Text>
</Pressable>
Expand Down
27 changes: 10 additions & 17 deletions src/screens/AuthScreen/AuthScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ const AuthScreen = () => {
const updateUserData = async (url: string) => {
try {
const res = await getUserData(url);
console.log('respponse', url, res);
await storeData('userData', JSON.stringify(res));
setLoggedInUserData({
id: res?.id,
Expand All @@ -78,29 +77,31 @@ const AuthScreen = () => {
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) {
if (userInfoJson.data.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
const { picture, id, username, status } = userDetailsInfoJson.user;
setLoggedInUserData({
id: id,
name: username,
profileUrl: picture.url,
profileUrl: picture?.url,
status: status,
});
} else {
Toast.show({
type: 'error',
text1: 'Please authorize from my-site by giving confirmations',
position: 'bottom',
bottomOffset: 80,
});
}
} catch (err) {
console.error(err);
Toast.show({
type: 'error',
text1: 'Something went wrong, please try again later',
Expand All @@ -113,9 +114,6 @@ 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);
setLoading(true);
try {
const data = await fetch(AuthApis.QR_AUTH_API, {
Expand All @@ -130,11 +128,8 @@ const AuthScreen = () => {
}),
});

// {"message": "User Device Info added successfully!", "userDeviceInfoData": {"authorization_status": "NOT_INIT", "device_id": "389e089e7e6feb38", "device_info": "Shreya", "user_id": "T7IL7MB8YriniTw4bt39"}}

if (data.ok) {
const dataJson = await data.json();
console.log('Post call successful', dataJson);
Alert.alert('Please Confirm', dataJson.message, [
{
text: 'Cancel',
Expand All @@ -150,7 +145,6 @@ const AuthScreen = () => {
]);
} else {
const dataJson = await data.json();
console.log('data in else', dataJson.message);
Toast.show({
type: 'error',
text1: 'Something went wrong, please try again',
Expand All @@ -159,7 +153,6 @@ const AuthScreen = () => {
});
}
} catch (err) {
console.error(err);
Toast.show({
type: 'error',
text1: 'Something went wrong, please try again later',
Expand Down

0 comments on commit 773e2e3

Please sign in to comment.