From 354d948a8e946959b9b70150a6b2a9be593a1ee0 Mon Sep 17 00:00:00 2001 From: yoution Date: Thu, 29 Jul 2021 08:29:38 +0800 Subject: [PATCH] fix: #397 --- .../components/SearchAndSubmit/index.jsx | 1 + .../components/SubmitContainer/index.jsx | 40 +++++++++++++++---- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/routes/CreateNewTeam/components/SearchAndSubmit/index.jsx b/src/routes/CreateNewTeam/components/SearchAndSubmit/index.jsx index cd55604d..4a1063fb 100644 --- a/src/routes/CreateNewTeam/components/SearchAndSubmit/index.jsx +++ b/src/routes/CreateNewTeam/components/SearchAndSubmit/index.jsx @@ -107,6 +107,7 @@ function SearchAndSubmit(props) { diff --git a/src/routes/CreateNewTeam/components/SubmitContainer/index.jsx b/src/routes/CreateNewTeam/components/SubmitContainer/index.jsx index f00a6bc6..32247548 100644 --- a/src/routes/CreateNewTeam/components/SubmitContainer/index.jsx +++ b/src/routes/CreateNewTeam/components/SubmitContainer/index.jsx @@ -7,6 +7,7 @@ import React, { useCallback, useEffect, + useMemo, useLayoutEffect, useState, } from "react"; @@ -24,7 +25,7 @@ import ConfirmationModal from "../ConfirmationModal"; import { withBusinessAuthentication } from "../../../../hoc/withAuthentication"; import "./styles.module.scss"; import { isCustomRole, isUuid, setCurrentStage } from "utils/helpers"; -import { clearSearchedRoles } from "../../actions"; +import { clearSearchedRoles, editRoleAction } from "../../actions"; import { postTeamRequest } from "services/teams"; import NoMatchingProfilesResultCard from "../NoMatchingProfilesResultCard"; @@ -33,15 +34,30 @@ function SubmitContainer({ setStages, progressStyle, matchingRole, + previousSearchId, addedRoles, }) { const [addAnotherOpen, setAddAnotherOpen] = useState(false); const [teamDetailsOpen, setTeamDetailsOpen] = useState(true); const [teamObject, setTeamObject] = useState(null); const [requestLoading, setRequestLoading] = useState(false); + const [buttonClickable, setButtonClickable] = useState(true); const dispatch = useDispatch(); + const currentRole = useMemo(() => { + return _.find(addedRoles, { searchId: previousSearchId }); + }, [addedRoles, previousSearchId]); + + const onSaveEditRole = useCallback( + (isValid, role) => { + setButtonClickable(isValid); + if (isValid) { + dispatch(editRoleAction({ ...role, searchId: previousSearchId })); + } + }, + [dispatch, previousSearchId] + ); useEffect(() => { setCurrentStage(2, stages, setStages); // eslint-disable-next-line react-hooks/exhaustive-deps @@ -114,7 +130,11 @@ function SubmitContainer({ return (
{!isCustomRole(matchingRole) ? ( - + ) : ( )} @@ -123,6 +143,7 @@ function SubmitContainer({ setAddAnotherOpen(true)} extraStyleName={progressStyle} + isDisabled={!buttonClickable} buttonLabel="Continue" stages={stages} percentage="98" @@ -135,12 +156,14 @@ function SubmitContainer({ onContinueClick={openTeamDetails} addAnother={addAnother} /> - setTeamDetailsOpen(false)} - submitForm={assembleTeam} - addedRoles={addedRoles} - /> + {teamDetailsOpen && ( + setTeamDetailsOpen(false)} + submitForm={assembleTeam} + addedRoles={addedRoles} + /> + )} setTeamObject(null)} @@ -156,6 +179,7 @@ SubmitContainer.propTypes = { setStages: PT.func, progressStyle: PT.string, addedRoles: PT.array, + previousSearchId: PT.string, matchingRole: PT.object, };