diff --git a/src/components/ChallengeEditor/SkillsField/index.js b/src/components/ChallengeEditor/SkillsField/index.js index 8025519a..522fcf24 100644 --- a/src/components/ChallengeEditor/SkillsField/index.js +++ b/src/components/ChallengeEditor/SkillsField/index.js @@ -4,7 +4,7 @@ import Select from '../../Select' import { searchSkills } from '../../../services/skills' import cn from 'classnames' import styles from './styles.module.scss' -import { AUTOCOMPLETE_DEBOUNCE_TIME_MS } from '../../../config/constants' +import { AUTOCOMPLETE_DEBOUNCE_TIME_MS, SKILLS_OPTIONAL_BILLING_ACCOUNT_IDS } from '../../../config/constants' import _ from 'lodash' const fetchSkills = _.debounce((inputValue, callback) => { @@ -27,12 +27,15 @@ const SkillsField = ({ readOnly, challenge, onUpdateSkills }) => { value: skill.id })), [challenge.skills]) const existingSkills = useMemo(() => selectedSkills.map(item => item.label).join(','), [selectedSkills]) + const billingAccountId = _.get(challenge, 'billing.billingAccountId') + const normalizedBillingAccountId = _.isNil(billingAccountId) ? null : String(billingAccountId) + const skillsRequired = normalizedBillingAccountId ? !SKILLS_OPTIONAL_BILLING_ACCOUNT_IDS.includes(normalizedBillingAccountId) : true return ( <>
- +
@@ -58,7 +61,7 @@ const SkillsField = ({ readOnly, challenge, onUpdateSkills }) => {
- { !readOnly && challenge.submitTriggered && (!selectedSkills || !selectedSkills.length) &&
+ { !readOnly && skillsRequired && challenge.submitTriggered && (!selectedSkills || !selectedSkills.length) &&
Select at least one skill diff --git a/src/components/ChallengeEditor/index.js b/src/components/ChallengeEditor/index.js index 66aa89bb..2c6be99b 100644 --- a/src/components/ChallengeEditor/index.js +++ b/src/components/ChallengeEditor/index.js @@ -26,7 +26,8 @@ import { PHASE_PRODUCT_CHALLENGE_ID_FIELD, QA_TRACK_ID, DESIGN_CHALLENGE_TYPES, ROUND_TYPES, MULTI_ROUND_CHALLENGE_TEMPLATE_ID, DS_TRACK_ID, - CHALLENGE_STATUS + CHALLENGE_STATUS, + SKILLS_OPTIONAL_BILLING_ACCOUNT_IDS } from '../../config/constants' import { getDomainTypes, @@ -867,14 +868,20 @@ class ChallengeEditor extends Component { return false } + const billingAccountId = _.get(challenge, 'billing.billingAccountId') + const normalizedBillingAccountId = _.isNil(billingAccountId) ? null : String(billingAccountId) + const isSkillsRequired = normalizedBillingAccountId ? !SKILLS_OPTIONAL_BILLING_ACCOUNT_IDS.includes(normalizedBillingAccountId) : true + const requiredFields = [ 'trackId', 'typeId', 'name', 'description', - 'skills', 'prizeSets' ] + if (isSkillsRequired) { + requiredFields.push('skills') + } let isRequiredMissing = false requiredFields.forEach((key) => { diff --git a/src/config/constants.js b/src/config/constants.js index 5067c12a..38b1c3ab 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -40,6 +40,7 @@ export const { export const CREATE_FORUM_TYPE_IDS = typeof process.env.CREATE_FORUM_TYPE_IDS === 'string' ? process.env.CREATE_FORUM_TYPE_IDS.split(',') : process.env.CREATE_FORUM_TYPE_IDS export const PROJECTS_API_URL = process.env.PROJECTS_API_URL || process.env.PROJECT_API_URL +export const SKILLS_OPTIONAL_BILLING_ACCOUNT_IDS = ['80000062'] /** * Filepicker config