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

fix: #383 #389

Merged
merged 2 commits into from
Jul 20, 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
2 changes: 2 additions & 0 deletions src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,5 @@ export const MAX_ALLOWED_INTERVIEWS = 3;
* Custom role names to remove from RoleList component
*/
export const CUSTOM_ROLE_NAMES = ["custom", "niche"];

export const MIN_DURATION = 4;
3 changes: 2 additions & 1 deletion src/routes/CreateNewTeam/components/EditRoleForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
validateMin,
composeValidators,
} from "./utils/validator";
import { MIN_DURATION } from "constants";

const Error = ({ name }) => {
const {
Expand Down Expand Up @@ -87,7 +88,7 @@ function EditRoleForm({ onChange, role }) {
</td>
<td>
<Field
validate={composeValidators(validateExists, validateMin(4, 'Talent as a Service engagements have a 4 week minimum commitment.'))}
validate={composeValidators(validateExists, validateMin(MIN_DURATION, `Talent as a Service engagements have a ${MIN_DURATION} week minimum commitment.`))}
name="durationWeeks"
initialValue={role.durationWeeks}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isUuid } from "utils/helpers";
import { MIN_DURATION } from "constants";

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

return number < min
? "Talent as a Service engagements have a 4 week minimum commitment."
? `Talent as a Service engagements have a ${MIN_DURATION} week minimum commitment.`
: undefined;
};

Expand All @@ -46,7 +47,7 @@ const validateMonth = (monthString) => {
const validateRole = (role) => {
const roleErrors = {};
roleErrors.numberOfResources = validateNumber(role.numberOfResources);
roleErrors.durationWeeks = validateGreaterThan(role.durationWeeks, 4);
roleErrors.durationWeeks = validateGreaterThan(role.durationWeeks, MIN_DURATION);
if (role.startMonth) {
roleErrors.startMonth = validateMonth(role.startMonth);
}
Expand Down
13 changes: 13 additions & 0 deletions src/routes/JobForm/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
RESOURCE_TYPE_OPTIONS,
FORM_ROW_TYPE,
FORM_FIELD_TYPE,
MIN_DURATION,
} from "../../constants";

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

const validateDuration = (x, y, {duration}) => {
if (duration === undefined) return undefined;
const converted = Number(duration);

if (isNaN(converted) || converted !== Math.floor(converted) || converted < MIN_DURATION) {
return `Talent as a Service engagements have a ${MIN_DURATION} week minimum commitment.`;
}

return undefined;
}

/**
* return edit job configuration
* @param {any} skillOptions skill options
Expand Down Expand Up @@ -92,6 +104,7 @@ export const getEditJobConfig = (
placeholder: "Duration",
disabled: onlyEnableStatus,
step: 1,
customValidator: validateDuration,
},
{
label: "Resource Type",
Expand Down