Skip to content

Commit

Permalink
Handled error fetch child by token, #13
Browse files Browse the repository at this point in the history
  • Loading branch information
Elhamne committed Feb 11, 2023
1 parent 3879a6f commit 8359e20
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pages/child/SearchResult.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -111,6 +114,7 @@ const SearchResult = () => {
}
}, [invitationToken]);

// FIXME
useEffect(() => {
if (
!successRandomSearch &&
Expand All @@ -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) => {
Expand Down

0 comments on commit 8359e20

Please sign in to comment.