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

Commit 9ae7e03

Browse files
committed
xx
1 parent ca24b14 commit 9ae7e03

File tree

4 files changed

+50
-19
lines changed

4 files changed

+50
-19
lines changed

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

+21-5
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,19 @@ const Error = ({ name }) => {
2727
return dirty && error ? <span styleName="error">{error}</span> : null;
2828
};
2929

30-
function EditRoleForm({ submitForm, role }) {
30+
function EditRoleForm({ onChange, role }) {
3131
const [startMonthVisible, setStartMonthVisible] = useState(false);
32+
const onRoleChange = (state) => {
33+
if (state.hasValidationErrors) {
34+
return;
35+
}
36+
37+
onChange(state.values);
38+
};
3239

3340
return (
3441
<Form
35-
onSubmit={submitForm}
42+
onSubmit={() => {}}
3643
mutators={{
3744
clearField: ([fieldName], state, { changeValue }) => {
3845
changeValue(state, fieldName, () => undefined);
@@ -67,7 +74,10 @@ function EditRoleForm({ submitForm, role }) {
6774
<NumberInput
6875
name={input.name}
6976
value={input.value}
70-
onChange={input.onChange}
77+
onChange={(v) => {
78+
input.onChange(v);
79+
onRoleChange(getState());
80+
}}
7181
onBlur={input.onBlur}
7282
onFocus={input.onFocus}
7383
min="1"
@@ -87,7 +97,10 @@ function EditRoleForm({ submitForm, role }) {
8797
<NumberInput
8898
name={input.name}
8999
value={input.value}
90-
onChange={input.onChange}
100+
onChange={(v) => {
101+
input.onChange(v);
102+
onRoleChange(getState());
103+
}}
91104
onBlur={input.onBlur}
92105
onFocus={input.onFocus}
93106
min="4"
@@ -105,7 +118,10 @@ function EditRoleForm({ submitForm, role }) {
105118
<MonthPicker
106119
name={props.input.name}
107120
value={props.input.value}
108-
onChange={props.input.onChange}
121+
onChange={(v) => {
122+
props.input.onChange(v);
123+
onRoleChange(getState());
124+
}}
109125
onBlur={props.input.onBlur}
110126
onFocus={props.input.onFocus}
111127
/>

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function formatPercent(value) {
2727
return `${Math.round(value * 100)}%`;
2828
}
2929

30-
function ResultCard({ role, currentRole, onSubmitEditRole }) {
30+
function ResultCard({ role, currentRole, onSaveEditRole }) {
3131
const {
3232
numberOfMembersAvailable,
3333
isExternalMember,
@@ -269,7 +269,7 @@ function ResultCard({ role, currentRole, onSubmitEditRole }) {
269269
</div>
270270
</div>
271271
{currentRole && (
272-
<EditRoleForm role={currentRole} submitForm={onSubmitEditRole} />
272+
<EditRoleForm role={currentRole} onChange={onSaveEditRole} />
273273
)}
274274
</div>
275275
)}
@@ -280,7 +280,7 @@ function ResultCard({ role, currentRole, onSubmitEditRole }) {
280280
ResultCard.propTypes = {
281281
role: PT.object,
282282
currentRole: PT.object,
283-
onSubmitEditRole: PT.func,
283+
onSaveEditRole: PT.func,
284284
};
285285

286286
export default ResultCard;

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,15 @@ function SearchAndSubmit(props) {
5757
const name = _.get(res, "data.name");
5858
const searchId = _.get(res, "data.roleSearchRequestId");
5959
if (name && !isCustomRole({ name })) {
60-
dispatch(addSearchedRole({ searchId, name, numberOfResources: 1, durationWeeks: 4 }));
61-
setIsNewRole(true)
60+
dispatch(
61+
addSearchedRole({
62+
searchId,
63+
name,
64+
numberOfResources: 1,
65+
durationWeeks: 4,
66+
})
67+
);
68+
setIsNewRole(true);
6269
} else if (searchId) {
6370
dispatch(addRoleSearchId(searchId));
6471
}

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

+17-9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
import React, { useCallback, useState, useMemo, useEffect } from "react";
99
import PT from "prop-types";
10+
import _ from "lodash";
1011
import { useDispatch } from "react-redux";
1112
import { editRoleAction } from "../../actions";
1213
import AddedRolesAccordion from "../AddedRolesAccordion";
@@ -38,14 +39,17 @@ function SearchContainer({
3839

3940
useEffect(() => {
4041
if (isNewRole) {
41-
setShowEditModal(true)
42+
setShowEditModal(true);
4243
}
4344
}, [isNewRole]);
4445

45-
const onSubmitEditRole = useCallback((role) => {
46-
setShowEditModal(false)
47-
dispatch(editRoleAction({...role, searchId: previousSearchId}))
48-
}, [addedRoles, previousSearchId]);
46+
const onSaveEditRole = useCallback(
47+
(role) => {
48+
setShowEditModal(false);
49+
dispatch(editRoleAction({ ...role, searchId: previousSearchId }));
50+
},
51+
[addedRoles, previousSearchId]
52+
);
4953

5054
const onSubmit = useCallback(() => {
5155
setAddAnotherOpen(false);
@@ -58,10 +62,14 @@ function SearchContainer({
5862

5963
const renderLeftSide = () => {
6064
if (searchState === "searching") return <SearchCard />;
61-
if (!isCustomRole(matchingRole)) return <ResultCard
62-
role={matchingRole}
63-
onSubmitEditRole={onSubmitEditRole}
64-
currentRole={currentRole}/>;
65+
if (!isCustomRole(matchingRole))
66+
return (
67+
<ResultCard
68+
role={matchingRole}
69+
onSaveEditRole={onSaveEditRole}
70+
currentRole={currentRole}
71+
/>
72+
);
6573
return <NoMatchingProfilesResultCard role={matchingRole} />;
6674
};
6775

0 commit comments

Comments
 (0)