Skip to content

Commit

Permalink
[KAN-139] 전체 > 에러생길 때 토스트메시지 추가 (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkyoungdeok authored Jun 1, 2024
1 parent b7779a4 commit e39d6c2
Show file tree
Hide file tree
Showing 20 changed files with 1,939 additions and 210 deletions.
2 changes: 2 additions & 0 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React, {useState} from 'react';
import {SafeAreaView, ScrollView, Text, View, StyleSheet} from 'react-native';
import MainStackNavigator from './src/navigation/MainStackNavigator';
import 'react-native-gesture-handler';
import Toast from 'react-native-toast-message';

export default function App() {
const [accessToken, setAccessToken] = useState('');
Expand Down Expand Up @@ -40,6 +41,7 @@ export default function App() {
return (
<AppContext.Provider value={tokens}>
<MainStackNavigator />
<Toast ref={(ref) => Toast.setRef(ref)} />
</AppContext.Provider>
);
}
Expand Down
1,963 changes: 1,798 additions & 165 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"react-native-reanimated": "^3.8.1",
"react-native-safe-area-context": "^4.9.0",
"react-native-screens": "^3.30.1",
"react-native-svg": "^15.1.0"
"react-native-svg": "^15.1.0",
"react-native-toast-message": "^2.2.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
6 changes: 5 additions & 1 deletion src/screens/detail/ReviewWriteScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ export default function ReviewWriteScreen(props) {
Alert.alert('오류', '이미지 업로드에 실패했습니다!', [{text: '확인'}]);
}
} catch (error) {
console.log('Error:', error);
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down
32 changes: 18 additions & 14 deletions src/screens/detail/SearchScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ export default function SearchScreen(props) {

const limitedResults = response.data.results.slice(0, 5);
setAutoCompleteData(limitedResults);
} catch (e) {
console.log('error', e);
} catch (error) {
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand All @@ -85,12 +89,12 @@ export default function SearchScreen(props) {
console.log('response:', response.data.data.recentQueries);

setRecentSearch(response.data.data.recentQueries);
} catch (e) {
if (axios.isAxiosError(e)) {
console.log('Axios error:', e.response ? e.response.data : e.message);
} else {
console.log('splash error', e.message);
}
} catch (error) {
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand All @@ -104,12 +108,12 @@ export default function SearchScreen(props) {
});

console.log('response:', response.data);
} catch (e) {
if (axios.isAxiosError(e)) {
console.log('Axios error:', e.response ? e.response.data : e.message);
} else {
console.log('splash error', e.message);
}
} catch (error) {
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down
6 changes: 5 additions & 1 deletion src/screens/detail/StoreDetailScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ export default function StoreDetailScreen(props) {

console.log('isReviewLike: ', ret.data);
} catch (error) {
console.error('Error updating review liked:', error);
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});

const rollbackReviewList = reviewList.map((item) =>
item.id === review.item.id
Expand Down
16 changes: 12 additions & 4 deletions src/screens/home/HomeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ export default function HomeScreen() {
// console.log('response:', response.data.data.restaurants.content[0]);

setkingoPassData(response.data.data.restaurants.content);
} catch (e) {
console.log('error', e);
} catch (error) {
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand All @@ -85,8 +89,12 @@ export default function HomeScreen() {
console.log('response:', response.data.data.restaurants);

setTodaysPick(response.data.data.restaurants);
} catch (e) {
console.log('error', e);
} catch (error) {
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down
8 changes: 6 additions & 2 deletions src/screens/list/ListMainScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,12 @@ export default function ListMainScreen() {
...response.data.data.restaurants.content,
]);
}
} catch (e) {
console.log('error', e);
} catch (error) {
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down
8 changes: 6 additions & 2 deletions src/screens/map/MapScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,12 @@ export default function MapScreen() {
console.log('response:', response.data.data.restaurants.content[0]);

setStoreDartDatas(response.data.data.restaurants.content);
} catch (e) {
console.log('error', e);
} catch (error) {
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down
6 changes: 5 additions & 1 deletion src/screens/mypage/MypageScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ export default function MyPageScreen() {
setProfileImageUrl(response.data.data.userDto.profileImageUrl);
setEmail(response.data.data.userDto.email);
} catch (error) {
console.error('Failed to fetch user info:', error);
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down
24 changes: 20 additions & 4 deletions src/screens/mypage/UserDataChangeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ export default function UserDataChangeScreen(props) {
setNickname(response.data.data.userDto.nickname);
setEmail(response.data.data.userDto.email);
} catch (error) {
console.error('Failed to fetch user info:', error);
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand All @@ -84,6 +88,11 @@ export default function UserDataChangeScreen(props) {
} catch (error) {
setDuplicateMessage('이미 사용 중인 닉네임입니다.');
setMessageColor(COLOR_RED);
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down Expand Up @@ -142,8 +151,11 @@ export default function UserDataChangeScreen(props) {
]);
}
} catch (error) {
console.error('Failed to delete user:', error);
Alert.alert('오류', '회원탈퇴 중 오류가 발생했습니다.', [{text: '확인'}]);
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down Expand Up @@ -197,7 +209,11 @@ export default function UserDataChangeScreen(props) {
}),
);
} catch (error) {
console.log('Error during logout:', error);
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down
6 changes: 5 additions & 1 deletion src/screens/signup/CheckEmailScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ export default function CheckEmailScreen(props) {
token: response.data.data.token,
});
} catch (error) {
console.log('Error:', error);
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down
6 changes: 5 additions & 1 deletion src/screens/signup/CheckEmailScreen2.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export default function CheckEmailScreen2(props) {
token: response.data.data.token,
});
} catch (error) {
console.log('Error:', error);
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down
7 changes: 5 additions & 2 deletions src/screens/signup/FindPasswordScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ export default function FindPasswordScreen() {
});
}
} catch (error) {
const errorResponse = AxiosError.response;
console.log(errorResponse);
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down
6 changes: 5 additions & 1 deletion src/screens/signup/LoginScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ export default function LoginScreen() {

navigation.navigate('BottomTab');
} catch (error) {
console.log('Error:', error);
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down
13 changes: 10 additions & 3 deletions src/screens/signup/ProfileSetScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ export default function ProfileSetScreen(props) {

navigation.navigate('BottomTab');
} catch (error) {
console.log('Error:', error);
console.log('Error response:', error.response.data);
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down Expand Up @@ -118,7 +121,11 @@ export default function ProfileSetScreen(props) {

setProfileImage(response.data.data[0].imageUrl);
} catch (error) {
console.log('Error:', error);
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down
6 changes: 5 additions & 1 deletion src/screens/signup/ResetPasswordScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ export default function ResetPasswordScreen(props) {
navigation.navigate('Login');
}
} catch (error) {
console.log('error:', error);
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down
9 changes: 7 additions & 2 deletions src/screens/signup/SignupScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {svgXml} from '../../assets/svg';
import LongPrimaryButton from '../../components/LongPrimaryButton';
import AsyncStorage from '@react-native-async-storage/async-storage';
import AppContext from '../../components/AppContext';
import Toast from 'react-native-toast-message';

export default function SignupScreen() {
const navigation = useNavigation();
Expand Down Expand Up @@ -106,8 +107,12 @@ export default function SignupScreen() {
});
}
} catch (error) {
const errorResponse = AxiosError.response;
console.log(errorResponse);
console.log(error.response.data);
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down
8 changes: 6 additions & 2 deletions src/screens/signup/SplashScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ export default function SplashScreen() {

//화면 이동
navigation.navigate('BottomTab');
} catch (e) {
console.log('error', e);
} catch (error) {
Toast.show({
type: 'error',
text1: 'Error',
text2: error.response.data.message,
});
}
};

Expand Down
Loading

0 comments on commit e39d6c2

Please sign in to comment.