Skip to content

Commit

Permalink
Merge pull request #4418 from appirio-tech/hotfix/taas-min-weeks
Browse files Browse the repository at this point in the history
[PROD][HOTFIX] restrict the duration field on Jobs to a 4 week minimum
  • Loading branch information
vikasrohit committed Jul 15, 2021
2 parents 6376c2d + 6cd2252 commit 6a6aade
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -1224,3 +1224,8 @@ export const MILESTONE_DEFAULT_VALUES = {
export const PHASE_PRODUCT_TEMPLATE_ID = process.env.PHASE_PRODUCT_TEMPLATE_ID

export const DEFAULT_NDA_UUID = process.env.DEFAULT_NDA_UUID

/**
* The minimal duration of a TaaS Job in weeks
*/
export const TAAS_MIN_JOB_DURATION = 4
7 changes: 5 additions & 2 deletions src/projects/detail/components/JobPickerRow/JobPickerRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SelectDropdown from 'appirio-tech-react-components/components/SelectDropd
import DescriptionField from '../DescriptionField'

import styles from './JobPickerRow.scss'
import { TAAS_MIN_JOB_DURATION } from '../../../../config/constants'

const always = () => true
const never = () => false
Expand Down Expand Up @@ -102,7 +103,7 @@ class JobPickerRow extends React.PureComponent {

render() {
const { value, rowIndex } = this.props
const isRowIncomplete = value.title.trim().length > 0 || value.people > 0 || value.duration > 0 || (value.skills && value.skills.length)
const isRowIncomplete = value.title.trim().length > 0 || value.people > 0 || value.duration >= TAAS_MIN_JOB_DURATION || (value.skills && value.skills.length)
||(value.role && value.role.value !== null) ||(value.workLoad && value.workLoad.value !== null) || (value.description.trim().length > 0)

/* Different columns are defined here and used in componsing mobile/desktop views below */
Expand Down Expand Up @@ -164,12 +165,14 @@ class JobPickerRow extends React.PureComponent {
</label>
<PositiveNumberInput
styleName="noMargin"
className={cn('tc-file-field__inputs', {error: isRowIncomplete && value.duration <= 0 })}
className={cn('tc-file-field__inputs', {error: isRowIncomplete && value.duration < TAAS_MIN_JOB_DURATION })}
max={MAX_NUMBER}
min={TAAS_MIN_JOB_DURATION}
value={value.duration || ''}
onChange={this.handleDurationChange}
onBlur={this.resetDuration}
/>
{isRowIncomplete && value.duration < TAAS_MIN_JOB_DURATION ? <p className="error-message">Please, choose at least {TAAS_MIN_JOB_DURATION} weeks</p> : null}
</div>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import cn from 'classnames'

import JobPickerRow from '../JobPickerRow/JobPickerRow.jsx'
import './JobsPickerQuestion.scss'
import { TAAS_MIN_JOB_DURATION } from '../../../../config/constants.js'

class JobsPickerQuestion extends Component {

Expand All @@ -19,7 +20,7 @@ class JobsPickerQuestion extends Component {
this.setValidator(props)

const { getValue } = props
let values = getValue()
let values = getValue()
if (values) {
values = _.map(values, (v) => {
return {
Expand All @@ -33,7 +34,7 @@ class JobsPickerQuestion extends Component {
}

this.state = {
values
values
}
}

Expand All @@ -49,13 +50,13 @@ class JobsPickerQuestion extends Component {
return true
}
return _.some(value, (v) => {
return v.title.trim().length && v.people !== '0' && v.duration !== '0' && v.skills.length > 0 && v.workLoad.value !== null && v.role.value !== null && v.description.trim().length
return v.title.trim().length && v.people !== '0' && parseInt(v.duration, 10) >= TAAS_MIN_JOB_DURATION && v.skills.length > 0 && v.workLoad.value !== null && v.role.value !== null && v.description.trim().length
}) // validation body
},
noPartialFillsExist: (formValues, value) => {
return _.every(value, v => {
const isAllValuesFilled = v.title.trim().length > 0 && v.people > 0 && v.duration > 0 && v.skills && v.skills.length && v.description.trim().length && v.workLoad.value !== null && v.role.value !== null
return isAllValuesFilled
const isAllValuesFilled = v.title.trim().length > 0 && v.people > 0 && v.duration >= TAAS_MIN_JOB_DURATION && v.skills && v.skills.length && v.description.trim().length && v.workLoad.value !== null && v.role.value !== null
return isAllValuesFilled
})
}
}
Expand Down

0 comments on commit 6a6aade

Please sign in to comment.