From 8359e20635d32bfc9dad98ffbd29ecd7f9db6e52 Mon Sep 17 00:00:00 2001 From: Elhamne Date: Sat, 11 Feb 2023 13:09:27 +0330 Subject: [PATCH] Handled error fetch child by token, #13 --- src/pages/child/SearchResult.jsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pages/child/SearchResult.jsx b/src/pages/child/SearchResult.jsx index 5f1d1fe3..87028962 100644 --- a/src/pages/child/SearchResult.jsx +++ b/src/pages/child/SearchResult.jsx @@ -11,7 +11,10 @@ import VoiceBar from '../../components/searchResult/VoiceBar'; import InfoTabs from '../../components/searchResult/InfoTabs'; import Back from '../../components/Back'; import LeaveModal from '../../components/modals/LeaveModal'; -import { CHILD_RANDOM_SEARCH_RESET } from '../../constants/childConstants'; +import { + CHILD_RANDOM_SEARCH_RESET, + CHILD_BY_TOKEN_RESET, +} from '../../constants/childConstants'; import { fetchChildByToken } from '../../actions/childAction'; const useStyles = makeStyles({ @@ -111,6 +114,7 @@ const SearchResult = () => { } }, [invitationToken]); + // FIXME useEffect(() => { if ( !successRandomSearch && @@ -120,12 +124,15 @@ const SearchResult = () => { ) { dispatch({ type: CHILD_RANDOM_SEARCH_RESET }); history.push('/main/search'); + } else if (errorChildByToken) { + dispatch({ type: CHILD_BY_TOKEN_RESET }); + history.push('/main/search'); } else if (successRandomSearch) { setSearchedChild(theChild); } else if (successChildByToken) { setSearchedChild(child); } - }, [successRandomSearch, successChildByToken, qsValues]); + }, [successRandomSearch, successChildByToken, qsValues, errorChildByToken]); // child age const getAge = (DOB) => {