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

fix: #397 #414

Merged
merged 1 commit into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ function SearchAndSubmit(props) {
<SubmitContainer
path="result"
addedRoles={addedRoles}
previousSearchId={previousSearchId}
matchingRole={matchingRole}
{...props}
/>
Expand Down
40 changes: 32 additions & 8 deletions src/routes/CreateNewTeam/components/SubmitContainer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import React, {
useCallback,
useEffect,
useMemo,
useLayoutEffect,
useState,
} from "react";
Expand All @@ -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";

Expand All @@ -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
Expand Down Expand Up @@ -114,7 +130,11 @@ function SubmitContainer({
return (
<div styleName="page">
{!isCustomRole(matchingRole) ? (
<ResultCard role={matchingRole} />
<ResultCard
role={matchingRole}
onSaveEditRole={onSaveEditRole}
currentRole={currentRole}
/>
) : (
<NoMatchingProfilesResultCard role={matchingRole} />
)}
Expand All @@ -123,6 +143,7 @@ function SubmitContainer({
<Progress
onClick={() => setAddAnotherOpen(true)}
extraStyleName={progressStyle}
isDisabled={!buttonClickable}
buttonLabel="Continue"
stages={stages}
percentage="98"
Expand All @@ -135,12 +156,14 @@ function SubmitContainer({
onContinueClick={openTeamDetails}
addAnother={addAnother}
/>
<TeamDetailsModal
open={teamDetailsOpen}
onClose={() => setTeamDetailsOpen(false)}
submitForm={assembleTeam}
addedRoles={addedRoles}
/>
{teamDetailsOpen && (
<TeamDetailsModal
open={teamDetailsOpen}
onClose={() => setTeamDetailsOpen(false)}
submitForm={assembleTeam}
addedRoles={addedRoles}
/>
)}
<ConfirmationModal
open={!!teamObject}
onClose={() => setTeamObject(null)}
Expand All @@ -156,6 +179,7 @@ SubmitContainer.propTypes = {
setStages: PT.func,
progressStyle: PT.string,
addedRoles: PT.array,
previousSearchId: PT.string,
matchingRole: PT.object,
};

Expand Down