Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit bc73650

Browse files
authored
Merge pull request #417 from mbaghel/dev
Reflect selected tab in URL for Position Details page when navigating…
2 parents 77753b1 + a339aab commit bc73650

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

src/constants/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,9 @@ export const MIN_DURATION = 4;
397397
* Maximum allowed numbers of selecter skills for search.
398398
*/
399399
export const MAX_SELECTED_SKILLS = 3;
400+
401+
/**
402+
* Milliseconds for each stage of role search
403+
* There are 3 stages, so total search takes 3x this number
404+
*/
405+
export const SEARCH_STAGE_TIME = 1500;

src/routes/CreateNewTeam/components/SearchAndSubmit/index.jsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Router, navigate } from "@reach/router";
22
import _ from "lodash";
33
import React, { useCallback, useState, useEffect, useMemo } from "react";
44
import { useDispatch, useSelector } from "react-redux";
5+
import { SEARCH_STAGE_TIME } from "constants/";
56
import { useData } from "hooks/useData";
67
import { getSkills } from "services/skills";
78
import { searchRoles } from "services/teams";
@@ -16,7 +17,7 @@ import InputContainer from "../InputContainer";
1617
import SearchContainer from "../SearchContainer";
1718
import SubmitContainer from "../SubmitContainer";
1819

19-
const SEARCHINGTIME = 1600;
20+
const SEARCHINGTIME = SEARCH_STAGE_TIME * 3 + 100;
2021

2122
function SearchAndSubmit(props) {
2223
const { stages, setStages, searchObject, onClick, page } = props;
@@ -109,7 +110,9 @@ function SearchAndSubmit(props) {
109110
setCurrentStage(2, stages, setStages);
110111
setSearchState("done");
111112
},
112-
Date.now() - searchingBegin > SEARCHINGTIME ? 0 : 1500
113+
Date.now() - searchingBegin > SEARCHINGTIME
114+
? 0
115+
: SEARCH_STAGE_TIME * 3
113116
);
114117
});
115118
// eslint-disable-next-line react-hooks/exhaustive-deps

src/routes/CreateNewTeam/components/SearchCard/index.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import IconEarthSearch from "../../../../assets/images/icon-earth-search.svg";
99
import WorldMapDotted from "../../../../assets/images/world-map-dotted.svg";
1010
import WorldMapSearch1 from "../../../../assets/images/world-map-search1.svg";
1111
import WorldMapSearch2 from "../../../../assets/images/world-map-search2.svg";
12+
import { SEARCH_STAGE_TIME } from "constants/";
1213

1314
function SearchCard() {
1415
const [searchState, setSearchState] = useState(null);
@@ -19,8 +20,8 @@ function SearchCard() {
1920
setSearchState("state1");
2021
timer2 = setTimeout(() => {
2122
setSearchState("state2");
22-
}, 500);
23-
}, 500);
23+
}, SEARCH_STAGE_TIME);
24+
}, SEARCH_STAGE_TIME);
2425

2526
return () => {
2627
clearTimeout(timer1);

src/routes/PositionDetails/index.jsx

+14-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import React, { useCallback, useEffect, useState } from "react";
77
import PT from "prop-types";
88
import { navigate } from "@reach/router";
9+
import _ from "lodash";
910
import Page from "components/Page";
1011
import LoadingIndicator from "components/LoadingIndicator";
1112
import PageHeader from "components/PageHeader";
@@ -26,7 +27,7 @@ const inReviewStatusFilter = _.find(CANDIDATE_STATUS_FILTERS, {
2627
const getKeyFromParam = (urlParam) => {
2728
const filter = _.find(CANDIDATE_STATUS_FILTERS, { urlParam });
2829
return filter?.key || undefined;
29-
}
30+
};
3031

3132
const PositionDetails = ({ teamId, positionId, candidateStatus }) => {
3233
// by default show "interested" tab
@@ -40,25 +41,31 @@ const PositionDetails = ({ teamId, positionId, candidateStatus }) => {
4041

4142
const onCandidateStatusChange = useCallback(
4243
(statusFilter) => {
43-
navigate(`/taas/myteams/${teamId}/positions/${positionId}/candidates/${statusFilter.urlParam}`);
44+
navigate(
45+
`/taas/myteams/${teamId}/positions/${positionId}/candidates/${statusFilter.urlParam}`,
46+
{ replace: true }
47+
);
4448
},
4549
[teamId, positionId]
4650
);
4751

4852
// if there are some candidates to review, then show "To Review" tab by default
4953
useEffect(() => {
54+
const key = getKeyFromParam(candidateStatus);
5055
if (position) {
51-
const key = getKeyFromParam(candidateStatus);
5256
if (key) {
5357
setCandidateStatusFilterKey(key);
54-
} else if (_.filter(position.candidates, (candidate) =>
55-
inReviewStatusFilter.statuses.includes(candidate.status)
58+
} else if (
59+
_.filter(position.candidates, (candidate) =>
60+
inReviewStatusFilter.statuses.includes(candidate.status)
5661
).length > 0
5762
) {
58-
setCandidateStatusFilterKey(CANDIDATE_STATUS_FILTER_KEY.TO_REVIEW);
63+
onCandidateStatusChange({ urlParam: "to-review" });
64+
} else {
65+
onCandidateStatusChange({ urlParam: "interviews" });
5966
}
6067
}
61-
}, [position, candidateStatus]);
68+
}, [position, candidateStatus, onCandidateStatusChange]);
6269

6370
return (
6471
<Page title="Job Details">

0 commit comments

Comments
 (0)