Skip to content

Commit 6a6aade

Browse files
author
vikasrohit
authored
Merge pull request #4418 from appirio-tech/hotfix/taas-min-weeks
[PROD][HOTFIX] restrict the duration field on Jobs to a 4 week minimum
2 parents 6376c2d + 6cd2252 commit 6a6aade

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

src/config/constants.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,3 +1224,8 @@ export const MILESTONE_DEFAULT_VALUES = {
12241224
export const PHASE_PRODUCT_TEMPLATE_ID = process.env.PHASE_PRODUCT_TEMPLATE_ID
12251225

12261226
export const DEFAULT_NDA_UUID = process.env.DEFAULT_NDA_UUID
1227+
1228+
/**
1229+
* The minimal duration of a TaaS Job in weeks
1230+
*/
1231+
export const TAAS_MIN_JOB_DURATION = 4

src/projects/detail/components/JobPickerRow/JobPickerRow.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import SelectDropdown from 'appirio-tech-react-components/components/SelectDropd
1010
import DescriptionField from '../DescriptionField'
1111

1212
import styles from './JobPickerRow.scss'
13+
import { TAAS_MIN_JOB_DURATION } from '../../../../config/constants'
1314

1415
const always = () => true
1516
const never = () => false
@@ -102,7 +103,7 @@ class JobPickerRow extends React.PureComponent {
102103

103104
render() {
104105
const { value, rowIndex } = this.props
105-
const isRowIncomplete = value.title.trim().length > 0 || value.people > 0 || value.duration > 0 || (value.skills && value.skills.length)
106+
const isRowIncomplete = value.title.trim().length > 0 || value.people > 0 || value.duration >= TAAS_MIN_JOB_DURATION || (value.skills && value.skills.length)
106107
||(value.role && value.role.value !== null) ||(value.workLoad && value.workLoad.value !== null) || (value.description.trim().length > 0)
107108

108109
/* Different columns are defined here and used in componsing mobile/desktop views below */
@@ -164,12 +165,14 @@ class JobPickerRow extends React.PureComponent {
164165
</label>
165166
<PositiveNumberInput
166167
styleName="noMargin"
167-
className={cn('tc-file-field__inputs', {error: isRowIncomplete && value.duration <= 0 })}
168+
className={cn('tc-file-field__inputs', {error: isRowIncomplete && value.duration < TAAS_MIN_JOB_DURATION })}
168169
max={MAX_NUMBER}
170+
min={TAAS_MIN_JOB_DURATION}
169171
value={value.duration || ''}
170172
onChange={this.handleDurationChange}
171173
onBlur={this.resetDuration}
172174
/>
175+
{isRowIncomplete && value.duration < TAAS_MIN_JOB_DURATION ? <p className="error-message">Please, choose at least {TAAS_MIN_JOB_DURATION} weeks</p> : null}
173176
</div>
174177
)
175178

src/projects/detail/components/JobsPickerQuestion/JobsPickerQuestion.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import cn from 'classnames'
55

66
import JobPickerRow from '../JobPickerRow/JobPickerRow.jsx'
77
import './JobsPickerQuestion.scss'
8+
import { TAAS_MIN_JOB_DURATION } from '../../../../config/constants.js'
89

910
class JobsPickerQuestion extends Component {
1011

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

2122
const { getValue } = props
22-
let values = getValue()
23+
let values = getValue()
2324
if (values) {
2425
values = _.map(values, (v) => {
2526
return {
@@ -33,7 +34,7 @@ class JobsPickerQuestion extends Component {
3334
}
3435

3536
this.state = {
36-
values
37+
values
3738
}
3839
}
3940

@@ -49,13 +50,13 @@ class JobsPickerQuestion extends Component {
4950
return true
5051
}
5152
return _.some(value, (v) => {
52-
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
53+
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
5354
}) // validation body
5455
},
5556
noPartialFillsExist: (formValues, value) => {
5657
return _.every(value, v => {
57-
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
58-
return isAllValuesFilled
58+
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
59+
return isAllValuesFilled
5960
})
6061
}
6162
}

0 commit comments

Comments
 (0)