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

Commit 3fd55ba

Browse files
authored
Merge pull request #389 from mbaghel/dev
fix: #383
2 parents ac33c90 + 1a112c0 commit 3fd55ba

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

src/constants/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,5 @@ export const MAX_ALLOWED_INTERVIEWS = 3;
367367
* Custom role names to remove from RoleList component
368368
*/
369369
export const CUSTOM_ROLE_NAMES = ["custom", "niche"];
370+
371+
export const MIN_DURATION = 4;

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
validateMin,
2020
composeValidators,
2121
} from "./utils/validator";
22+
import { MIN_DURATION } from "constants";
2223

2324
const Error = ({ name }) => {
2425
const {
@@ -87,7 +88,7 @@ function EditRoleForm({ onChange, role }) {
8788
</td>
8889
<td>
8990
<Field
90-
validate={composeValidators(validateExists, validateMin(4, 'Talent as a Service engagements have a 4 week minimum commitment.'))}
91+
validate={composeValidators(validateExists, validateMin(MIN_DURATION, `Talent as a Service engagements have a ${MIN_DURATION} week minimum commitment.`))}
9192
name="durationWeeks"
9293
initialValue={role.durationWeeks}
9394
>

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { isUuid } from "utils/helpers";
2+
import { MIN_DURATION } from "constants";
23

34
const validateName = (name) => {
45
if (!name || name.trim().length === 0) {
@@ -25,7 +26,7 @@ const validateGreaterThan = (number, min) => {
2526
if (isInvalidNum) return isInvalidNum;
2627

2728
return number < min
28-
? "Talent as a Service engagements have a 4 week minimum commitment."
29+
? `Talent as a Service engagements have a ${MIN_DURATION} week minimum commitment.`
2930
: undefined;
3031
};
3132

@@ -46,7 +47,7 @@ const validateMonth = (monthString) => {
4647
const validateRole = (role) => {
4748
const roleErrors = {};
4849
roleErrors.numberOfResources = validateNumber(role.numberOfResources);
49-
roleErrors.durationWeeks = validateGreaterThan(role.durationWeeks, 4);
50+
roleErrors.durationWeeks = validateGreaterThan(role.durationWeeks, MIN_DURATION);
5051
if (role.startMonth) {
5152
roleErrors.startMonth = validateMonth(role.startMonth);
5253
}

src/routes/JobForm/utils.js

+13
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
RESOURCE_TYPE_OPTIONS,
1212
FORM_ROW_TYPE,
1313
FORM_FIELD_TYPE,
14+
MIN_DURATION,
1415
} from "../../constants";
1516

1617
const EDIT_JOB_ROWS = [
@@ -25,6 +26,17 @@ const EDIT_JOB_ROWS = [
2526
{ type: FORM_ROW_TYPE.SINGLE, fields: ["status"] },
2627
];
2728

29+
const validateDuration = (x, y, {duration}) => {
30+
if (duration === undefined) return undefined;
31+
const converted = Number(duration);
32+
33+
if (isNaN(converted) || converted !== Math.floor(converted) || converted < MIN_DURATION) {
34+
return `Talent as a Service engagements have a ${MIN_DURATION} week minimum commitment.`;
35+
}
36+
37+
return undefined;
38+
}
39+
2840
/**
2941
* return edit job configuration
3042
* @param {any} skillOptions skill options
@@ -92,6 +104,7 @@ export const getEditJobConfig = (
92104
placeholder: "Duration",
93105
disabled: onlyEnableStatus,
94106
step: 1,
107+
customValidator: validateDuration,
95108
},
96109
{
97110
label: "Resource Type",

0 commit comments

Comments
 (0)