Skip to content

Commit

Permalink
Merge pull request #221 from The-Fellowship-of-the-matzip/hotfix/issu…
Browse files Browse the repository at this point in the history
…e219

Issue219 alert가 3번 발생하는 이슈가 해결되지 않은 것 해결
  • Loading branch information
jinyoung234 authored Jul 13, 2024
2 parents 75ed2c1 + 0038a38 commit 27267c5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Spinner from "components/common/Spinner/Spinner";
import StoreList from "components/common/StoreList/StoreList";
import StoreListItemWithoutHeart from "components/common/StoreListItem/\bStoreListItemWithoutHeart";
import Text from "components/common/Text/Text";
import { useToastContext } from "components/common/Toast/provider/ToastProvider";

function BookmarkListPage() {
const navigate = useNavigate();
Expand All @@ -34,9 +35,11 @@ function BookmarkListPage() {

const bookmarkedStoreData = data ?? [];

const showToast = useToastContext();

useEffect(() => {
if (error instanceof Error && error.message === MESSAGES.LOGIN_RETRY) {
alert(error.message);
if (error instanceof Error && error.message === MESSAGES.LOGIN_REQUIRED) {
showToast(error.message);
navigate(PATHNAME.HOME);
}
}, [error]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import SlideCarousel from "components/common/SlideCarousel/SlideCarousel";
import Spinner from "components/common/Spinner/Spinner";
import StoreListItemWithoutHeart from "components/common/StoreListItem/\bStoreListItemWithoutHeart";
import Text from "components/common/Text/Text";
import { useToastContext } from "components/common/Toast/provider/ToastProvider";

function BookmarkMapPage() {
const campusName = useContext(campusContext);
Expand All @@ -41,9 +42,11 @@ function BookmarkMapPage() {

const navigate = useNavigate();

const showToast = useToastContext();

useEffect(() => {
if (error instanceof Error && error.message === MESSAGES.LOGIN_RETRY) {
alert(error.message);
if (error instanceof Error && error.message === MESSAGES.LOGIN_REQUIRED) {
showToast(error.message);
navigate(PATHNAME.HOME);
}
}, [error]);
Expand Down
17 changes: 10 additions & 7 deletions src/components/pages/MyPage/MyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Spinner from "components/common/Spinner/Spinner";
import StoreList from "components/common/StoreList/StoreList";
import StoreListItemWithoutHeart from "components/common/StoreListItem/\bStoreListItemWithoutHeart";
import Text from "components/common/Text/Text";
import { useToastContext } from "components/common/Toast/provider/ToastProvider";

function MyPage() {
const navigate = useNavigate();
Expand Down Expand Up @@ -57,32 +58,34 @@ function MyPage() {
}
);

const showToast = useToastContext();

useEffect(() => {
if (
userProfileError instanceof Error &&
userProfileError.message === MESSAGES.LOGIN_RETRY
userProfileError.message === MESSAGES.LOGIN_REQUIRED
) {
alert(userProfileError.message);
navigate(PATHNAME.HOME);
showToast(userProfileError.message);
logout();
navigate(PATHNAME.HOME);
return;
}

if (
bookmarkedStoreError instanceof Error &&
bookmarkedStoreError.message === MESSAGES.LOGIN_RETRY
bookmarkedStoreError.message === MESSAGES.LOGIN_REQUIRED
) {
alert(bookmarkedStoreError.message);
showToast(bookmarkedStoreError.message);
logout();
navigate(PATHNAME.HOME);
return;
}

if (
userReviewError instanceof Error &&
userReviewError.message === MESSAGES.LOGIN_RETRY
userReviewError.message === MESSAGES.LOGIN_REQUIRED
) {
alert(userReviewError.message);
showToast(userReviewError.message);
logout();
navigate(PATHNAME.HOME);
}
Expand Down
1 change: 1 addition & 0 deletions src/components/pages/MyPage/MyReviewItem/MyReviewItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function MyReviewItem({
{
onSuccess,
onError: (error) => {
console.log(error.message);
if (error.message === MESSAGES.LOGIN_REQUIRED) {
showToast(error.message);
logout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import ErrorText from "components/common/ErrorText/ErrorText";
import InfiniteScroll from "components/common/InfiniteScroll/InfiniteScroll";
import Spinner from "components/common/Spinner/Spinner";
import Text from "components/common/Text/Text";
import { useToastContext } from "components/common/Toast/provider/ToastProvider";

function MyReviewListPage() {
const { data, error, isLoading, isError, fetchNextPage, isFetching } =
Expand All @@ -45,9 +46,11 @@ function MyReviewListPage() {

const navigate = useNavigate();

const showToast = useToastContext();

useEffect(() => {
if (error instanceof Error && error.message === MESSAGES.LOGIN_RETRY) {
alert(error.message);
if (error instanceof Error && error.message === MESSAGES.LOGIN_REQUIRED) {
showToast(error.message);
navigate(PATHNAME.HOME);
}
}, [error]);
Expand Down

0 comments on commit 27267c5

Please sign in to comment.