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

Commit 0987996

Browse files
committed
fix: issue #365
1 parent 9ae7e03 commit 0987996

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

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

+6-16
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ function EditRoleForm({ onChange, role }) {
3131
const [startMonthVisible, setStartMonthVisible] = useState(false);
3232
const onRoleChange = (state) => {
3333
if (state.hasValidationErrors) {
34-
return;
34+
onChange(false);
35+
}else {
36+
onChange(true, state.values);
3537
}
36-
37-
onChange(state.values);
3838
};
3939

4040
return (
@@ -48,15 +48,13 @@ function EditRoleForm({ onChange, role }) {
4848
validate={validator}
4949
>
5050
{({
51-
handleSubmit,
52-
hasValidationErrors,
5351
form: {
5452
mutators: { clearField },
5553
getState,
5654
},
5755
}) => {
5856
return (
59-
<div styleName="modal-body">
57+
<div styleName="table-container">
6058
<table styleName="table">
6159
<tr>
6260
<th># of resources</th>
@@ -66,7 +64,7 @@ function EditRoleForm({ onChange, role }) {
6664
<tr styleName="role-row">
6765
<td>
6866
<Field
69-
validate={composeValidators(validateExists, validateMin(1))}
67+
validate={composeValidators(validateExists, validateMin(1, 'should be greater then 1'))}
7068
name="numberOfResources"
7169
initialValue={role.numberOfResources}
7270
>
@@ -89,7 +87,7 @@ function EditRoleForm({ onChange, role }) {
8987
</td>
9088
<td>
9189
<Field
92-
validate={composeValidators(validateExists, validateMin(4))}
90+
validate={composeValidators(validateExists, validateMin(4, 'Talent as a Service engagements have a 4 week minimum commitment.'))}
9391
name="durationWeeks"
9492
initialValue={role.durationWeeks}
9593
>
@@ -146,14 +144,6 @@ function EditRoleForm({ onChange, role }) {
146144
</td>
147145
</tr>
148146
</table>
149-
<Button
150-
type="primary"
151-
size="medium"
152-
onClick={handleSubmit}
153-
disabled={hasValidationErrors}
154-
>
155-
Save
156-
</Button>
157147
</div>
158148
);
159149
}}

src/routes/CreateNewTeam/components/EditRoleForm/styles.module.scss

+9-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@
3636

3737
.role-row {
3838
td {
39+
> div {
40+
margin-left: auto;
41+
margin-right: auto;
42+
}
43+
3944
padding: 18px 18px 18px 0;
45+
width: 30%;
4046
vertical-align: top;
4147
@include font-barlow;
4248
font-weight: 600;
@@ -90,11 +96,12 @@
9096
}
9197
}
9298

93-
.modal-body {
99+
.table-container {
94100
> button {
95101
margin: 0 auto;
96102
}
97-
overflow-x: auto;
103+
padding: 0 30px;
104+
width: 80%;
98105
textarea {
99106
height: 95px;
100107
}

src/routes/CreateNewTeam/components/EditRoleForm/utils/validator.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const composeValidators = (...validators) => (value) =>
22
validators.reduce((error, validator) => error || validator(value), undefined);
33

4-
const validateMin = (min) => (value) =>
5-
isNaN(value) || value >= min ? undefined : `Should be greater than ${min}`;
4+
const validateMin = (min, message) => (value) =>
5+
isNaN(value) || value >= min ? undefined : message;
66

77
const validateName = (name) => {
88
if (!name || name.trim().length === 0) {

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function SearchContainer({
3131
}) {
3232
const [addAnotherOpen, setAddAnotherOpen] = useState(false);
3333
const [showEditModal, setShowEditModal] = useState(false);
34+
const [buttonClickable, setButtonClickable] = useState(true);
3435

3536
const dispatch = useDispatch();
3637
const currentRole = useMemo(() => {
@@ -44,9 +45,11 @@ function SearchContainer({
4445
}, [isNewRole]);
4546

4647
const onSaveEditRole = useCallback(
47-
(role) => {
48-
setShowEditModal(false);
49-
dispatch(editRoleAction({ ...role, searchId: previousSearchId }));
48+
(isValid, role) => {
49+
setButtonClickable(isValid)
50+
if (isValid) {
51+
dispatch(editRoleAction({ ...role, searchId: previousSearchId }));
52+
}
5053
},
5154
[addedRoles, previousSearchId]
5255
);
@@ -86,6 +89,7 @@ function SearchContainer({
8689
<AddedRolesAccordion addedRoles={addedRoles} />
8790
<Completeness
8891
isDisabled={
92+
!buttonClickable ||
8993
searchState === "searching" ||
9094
(searchState === "done" && (!addedRoles || !addedRoles.length))
9195
}

0 commit comments

Comments
 (0)