Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaning code #200

Merged
merged 4 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 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 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 @@
}),
});

// {"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 @@ -149,8 +144,7 @@
}, // 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();

Check failure on line 147 in src/screens/AuthScreen/AuthScreen.tsx

View workflow job for this annotation

GitHub Actions / build (16.x)

'dataJson' is assigned a value but never used
console.log('data in else', dataJson.message);
Toast.show({
type: 'error',
text1: 'Something went wrong, please try again',
Expand All @@ -159,7 +153,6 @@
});
}
} catch (err) {
console.error(err);
Toast.show({
type: 'error',
text1: 'Something went wrong, please try again later',
Expand Down
Loading