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

Commit 27c890e

Browse files
authored
Merge pull request #414 from yoution/issue-397
fix: #397
2 parents b210ce1 + 354d948 commit 27c890e

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ function SearchAndSubmit(props) {
107107
<SubmitContainer
108108
path="result"
109109
addedRoles={addedRoles}
110+
previousSearchId={previousSearchId}
110111
matchingRole={matchingRole}
111112
{...props}
112113
/>

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

+32-8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import React, {
88
useCallback,
99
useEffect,
10+
useMemo,
1011
useLayoutEffect,
1112
useState,
1213
} from "react";
@@ -24,7 +25,7 @@ import ConfirmationModal from "../ConfirmationModal";
2425
import { withBusinessAuthentication } from "../../../../hoc/withAuthentication";
2526
import "./styles.module.scss";
2627
import { isCustomRole, isUuid, setCurrentStage } from "utils/helpers";
27-
import { clearSearchedRoles } from "../../actions";
28+
import { clearSearchedRoles, editRoleAction } from "../../actions";
2829
import { postTeamRequest } from "services/teams";
2930
import NoMatchingProfilesResultCard from "../NoMatchingProfilesResultCard";
3031

@@ -33,15 +34,30 @@ function SubmitContainer({
3334
setStages,
3435
progressStyle,
3536
matchingRole,
37+
previousSearchId,
3638
addedRoles,
3739
}) {
3840
const [addAnotherOpen, setAddAnotherOpen] = useState(false);
3941
const [teamDetailsOpen, setTeamDetailsOpen] = useState(true);
4042
const [teamObject, setTeamObject] = useState(null);
4143
const [requestLoading, setRequestLoading] = useState(false);
44+
const [buttonClickable, setButtonClickable] = useState(true);
4245

4346
const dispatch = useDispatch();
4447

48+
const currentRole = useMemo(() => {
49+
return _.find(addedRoles, { searchId: previousSearchId });
50+
}, [addedRoles, previousSearchId]);
51+
52+
const onSaveEditRole = useCallback(
53+
(isValid, role) => {
54+
setButtonClickable(isValid);
55+
if (isValid) {
56+
dispatch(editRoleAction({ ...role, searchId: previousSearchId }));
57+
}
58+
},
59+
[dispatch, previousSearchId]
60+
);
4561
useEffect(() => {
4662
setCurrentStage(2, stages, setStages);
4763
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -114,7 +130,11 @@ function SubmitContainer({
114130
return (
115131
<div styleName="page">
116132
{!isCustomRole(matchingRole) ? (
117-
<ResultCard role={matchingRole} />
133+
<ResultCard
134+
role={matchingRole}
135+
onSaveEditRole={onSaveEditRole}
136+
currentRole={currentRole}
137+
/>
118138
) : (
119139
<NoMatchingProfilesResultCard role={matchingRole} />
120140
)}
@@ -123,6 +143,7 @@ function SubmitContainer({
123143
<Progress
124144
onClick={() => setAddAnotherOpen(true)}
125145
extraStyleName={progressStyle}
146+
isDisabled={!buttonClickable}
126147
buttonLabel="Continue"
127148
stages={stages}
128149
percentage="98"
@@ -135,12 +156,14 @@ function SubmitContainer({
135156
onContinueClick={openTeamDetails}
136157
addAnother={addAnother}
137158
/>
138-
<TeamDetailsModal
139-
open={teamDetailsOpen}
140-
onClose={() => setTeamDetailsOpen(false)}
141-
submitForm={assembleTeam}
142-
addedRoles={addedRoles}
143-
/>
159+
{teamDetailsOpen && (
160+
<TeamDetailsModal
161+
open={teamDetailsOpen}
162+
onClose={() => setTeamDetailsOpen(false)}
163+
submitForm={assembleTeam}
164+
addedRoles={addedRoles}
165+
/>
166+
)}
144167
<ConfirmationModal
145168
open={!!teamObject}
146169
onClose={() => setTeamObject(null)}
@@ -156,6 +179,7 @@ SubmitContainer.propTypes = {
156179
setStages: PT.func,
157180
progressStyle: PT.string,
158181
addedRoles: PT.array,
182+
previousSearchId: PT.string,
159183
matchingRole: PT.object,
160184
};
161185

0 commit comments

Comments
 (0)