Skip to content

Commit 646093b

Browse files
committed
Add Skills Found popup to Job Description search page
1 parent 491038e commit 646093b

File tree

7 files changed

+159
-138
lines changed

7 files changed

+159
-138
lines changed

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

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,71 @@
11
import { Router } from "@reach/router";
2-
import React from "react";
3-
import { useSelector } from "react-redux";
2+
import _ from "lodash";
3+
import React, { useCallback, useState } from "react";
4+
import { useDispatch, useSelector } from "react-redux";
5+
import { searchRoles } from "services/teams";
6+
import { isCustomRole, setCurrentStage } from "utils/helpers";
7+
import { addRoleSearchId, addSearchedRole } from "../../actions";
48
import SearchContainer from "../SearchContainer";
59
import SubmitContainer from "../SubmitContainer";
610

711
function SearchAndSubmit(props) {
12+
const { stages, setStages, searchObject, onClick } = props;
13+
14+
const [searchState, setSearchState] = useState(null);
15+
const [matchingRole, setMatchingRole] = useState(null);
16+
817
const { addedRoles, previousSearchId } = useSelector(
918
(state) => state.searchedRoles
1019
);
1120

21+
const dispatch = useDispatch();
22+
23+
const search = useCallback(() => {
24+
setCurrentStage(1, stages, setStages);
25+
setSearchState("searching");
26+
setMatchingRole(null);
27+
const searchObjectCopy = { ...searchObject };
28+
if (previousSearchId) {
29+
searchObjectCopy.previousRoleSearchRequestId = previousSearchId;
30+
}
31+
searchRoles(searchObjectCopy)
32+
.then((res) => {
33+
const name = _.get(res, "data.name");
34+
const searchId = _.get(res, "data.roleSearchRequestId");
35+
if (name && !isCustomRole({ name })) {
36+
dispatch(addSearchedRole({ searchId, name }));
37+
} else if (searchId) {
38+
dispatch(addRoleSearchId(searchId));
39+
}
40+
setMatchingRole(res.data);
41+
})
42+
.catch((err) => {
43+
console.error(err);
44+
})
45+
.finally(() => {
46+
setCurrentStage(2, stages, setStages);
47+
setSearchState("done");
48+
});
49+
// eslint-disable-next-line react-hooks/exhaustive-deps
50+
}, [dispatch, previousSearchId, searchObject]);
51+
1252
return (
1353
<Router>
1454
<SearchContainer
1555
path="/"
1656
addedRoles={addedRoles}
1757
previousSearchId={previousSearchId}
58+
search={search}
59+
searchState={searchState}
60+
matchingRole={matchingRole}
61+
{...props}
62+
/>
63+
<SubmitContainer
64+
path="result"
65+
addedRoles={addedRoles}
66+
matchingRole={matchingRole}
1867
{...props}
1968
/>
20-
<SubmitContainer path="result" addedRoles={addedRoles} {...props} />
2169
</Router>
2270
);
2371
}

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

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,70 +5,34 @@
55
* search pages. Contains logic and supporting
66
* components for searching for roles.
77
*/
8-
import React, { useCallback, useState } from "react";
8+
import React, { useCallback } from "react";
99
import PT from "prop-types";
10-
import _ from "lodash";
11-
import { useDispatch } from "react-redux";
1210
import AddedRolesAccordion from "../AddedRolesAccordion";
1311
import Completeness from "../Completeness";
1412
import SearchCard from "../SearchCard";
1513
import ResultCard from "../ResultCard";
1614
import NoMatchingProfilesResultCard from "../NoMatchingProfilesResultCard";
17-
import { searchRoles } from "services/teams";
18-
import { isCustomRole, setCurrentStage } from "utils/helpers";
19-
import { addRoleSearchId, addSearchedRole } from "../../actions";
15+
import { isCustomRole } from "utils/helpers";
2016
import "./styles.module.scss";
2117

2218
function SearchContainer({
2319
stages,
24-
setStages,
2520
isCompletenessDisabled,
2621
toRender,
27-
searchObject,
22+
onClick,
23+
search,
2824
completenessStyle,
2925
navigate,
3026
addedRoles,
31-
previousSearchId,
27+
searchState,
28+
matchingRole,
3229
}) {
33-
const [searchState, setSearchState] = useState(null);
34-
const [matchingRole, setMatchingRole] = useState(null);
35-
36-
const dispatch = useDispatch();
37-
3830
const onSubmit = useCallback(() => {
39-
navigate("result", { state: { matchingRole } });
40-
}, [navigate, matchingRole]);
41-
42-
const search = () => {
43-
setCurrentStage(1, stages, setStages);
44-
setSearchState("searching");
45-
setMatchingRole(null);
46-
const searchObjectCopy = { ...searchObject };
47-
if (previousSearchId) {
48-
searchObjectCopy.previousRoleSearchRequestId = previousSearchId;
49-
}
50-
searchRoles(searchObjectCopy)
51-
.then((res) => {
52-
const name = _.get(res, "data.name");
53-
const searchId = _.get(res, "data.roleSearchRequestId");
54-
if (name && !isCustomRole({ name })) {
55-
dispatch(addSearchedRole({ searchId, name }));
56-
} else if (searchId) {
57-
dispatch(addRoleSearchId(searchId));
58-
}
59-
setMatchingRole(res.data);
60-
})
61-
.catch((err) => {
62-
console.error(err);
63-
})
64-
.finally(() => {
65-
setCurrentStage(2, stages, setStages);
66-
setSearchState("done");
67-
});
68-
};
31+
navigate("result");
32+
}, [navigate]);
6933

7034
const renderLeftSide = () => {
71-
if (!searchState) return toRender;
35+
if (!searchState) return toRender(search);
7236
if (searchState === "searching") return <SearchCard />;
7337
if (!isCustomRole(matchingRole)) return <ResultCard role={matchingRole} />;
7438
return <NoMatchingProfilesResultCard role={matchingRole} />;
@@ -92,7 +56,7 @@ function SearchContainer({
9256
searchState === "searching" ||
9357
(searchState === "done" && isCustomRole(matchingRole))
9458
}
95-
onClick={searchState ? onSubmit : search}
59+
onClick={searchState ? onSubmit : onClick ? onClick : search}
9660
extraStyleName={completenessStyle}
9761
buttonLabel={searchState ? "Submit Request" : "Search"}
9862
stages={stages}
@@ -105,14 +69,15 @@ function SearchContainer({
10569

10670
SearchContainer.propTypes = {
10771
stages: PT.array,
108-
setStages: PT.func,
10972
isCompletenessDisabled: PT.bool,
110-
searchObject: PT.object,
111-
toRender: PT.node,
73+
onClick: PT.func,
74+
search: PT.func,
75+
toRender: PT.func,
11276
completenessStyle: PT.string,
11377
navigate: PT.func,
11478
addedRoles: PT.array,
115-
previousSearchId: PT.string,
79+
searchState: PT.string,
80+
matchingRole: PT.object,
11681
};
11782

11883
export default SearchContainer;

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ function SubmitContainer({
3232
stages,
3333
setStages,
3434
completenessStyle,
35-
location,
35+
matchingRole,
3636
addedRoles,
3737
}) {
38-
const matchingRole = location?.state?.matchingRole;
39-
4038
const [addAnotherOpen, setAddAnotherOpen] = useState(true);
4139
const [teamDetailsOpen, setTeamDetailsOpen] = useState(false);
4240
const [teamObject, setTeamObject] = useState(null);
@@ -147,8 +145,8 @@ SubmitContainer.propTypes = {
147145
stages: PT.array,
148146
setStages: PT.func,
149147
completenessStyle: PT.string,
150-
location: PT.object,
151148
addedRoles: PT.array,
149+
matchingRole: PT.object,
152150
};
153151

154152
export default withAuthentication(SubmitContainer);

src/routes/CreateNewTeam/pages/InputJobDescription/components/SkillListPopup/index.jsx

Lines changed: 33 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,67 +5,50 @@
55
import React from "react";
66
import _ from "lodash";
77
import PT from "prop-types";
8-
import Modal from "react-responsive-modal";
98
import Button from "components/Button";
10-
import IconCrossLight from "../../../../../../assets/images/icon-cross-light.svg";
119
import IconSingleManAdd from "../../../../../../assets/images/icon-single-man-add.svg";
1210
import "./styles.module.scss";
13-
import CenteredSpinner from "components/CenteredSpinner";
11+
import BaseCreateModal from "../../../../components/BaseCreateModal";
1412

15-
const modalStyle = {
16-
borderRadius: "8px",
17-
padding: "32px 32px 22px 32px",
18-
maxWidth: "460px",
19-
width: "100%",
20-
margin: 0,
21-
"overflow-x": "hidden",
22-
};
23-
24-
const containerStyle = {
25-
padding: "10px",
26-
};
13+
function SkillListPopup({ open, skills, isLoading, onClose, onContinueClick }) {
14+
const Buttons = (
15+
<>
16+
<Button type="secondary" size="medium" onClick={onClose}>
17+
Edit Job Description
18+
</Button>
19+
<Button
20+
disabled={isLoading || !skills.length}
21+
type="primary"
22+
size="medium"
23+
onClick={onContinueClick}
24+
>
25+
Continue
26+
</Button>
27+
</>
28+
);
2729

28-
function SkillListPopup({ open, skills, onClose, isLoading, onContinueClick }) {
2930
return (
30-
<Modal
31+
<BaseCreateModal
3132
open={open}
32-
center
3333
onClose={onClose}
34-
closeIcon={
35-
<IconCrossLight height="18px" width="18px" styleName="cross" />
34+
headerIcon={<IconSingleManAdd />}
35+
title="Skills"
36+
subtitle={
37+
skills.length
38+
? "These skills are found in your Job Description"
39+
: "No skills are found in your Job Description"
3640
}
37-
styles={{
38-
modal: modalStyle,
39-
modalContainer: containerStyle,
40-
}}
41+
isLoading={isLoading}
42+
loadingMessage="Loading skills..."
43+
maxWidth="460px"
44+
buttons={Buttons}
4145
>
42-
<div styleName="modal-body">
43-
{isLoading ? (
44-
<>
45-
<CenteredSpinner />
46-
<h5>loading skills</h5>
47-
</>
48-
) : (
49-
<>
50-
<IconSingleManAdd />
51-
<h5>skills</h5>
52-
{_.map(skills, (s) => {
53-
return <div>{s.tag}</div>;
54-
})}
55-
</>
56-
)}
57-
</div>
58-
<div styleName="button-group">
59-
<Button
60-
type="primary"
61-
size="medium"
62-
disabled={isLoading}
63-
onClick={onContinueClick}
64-
>
65-
Continue
66-
</Button>
46+
<div>
47+
{_.map(skills, (s) => {
48+
return <div>{s.tag}</div>;
49+
})}
6750
</div>
68-
</Modal>
51+
</BaseCreateModal>
6952
);
7053
}
7154

0 commit comments

Comments
 (0)