@@ -4,7 +4,7 @@ import SkillsCheckboxGroup from './SkillsCheckboxGroup'
44import Select from '../../../../components/Select/Select'
55import './SkillsQuestion.scss'
66import { axiosInstance as axios } from '../../../../api/requestInterceptor'
7- import { TC_API_URL , SKILL_PROVIDER_ID } from '../../../../config/constants'
7+ import { TC_API_URL } from '../../../../config/constants'
88import { createFilter } from 'react-select'
99
1010let cachedOptions
@@ -21,9 +21,6 @@ let cachedOptions
2121 * @returns {Array } available options
2222 */
2323const getAvailableOptions = ( categoriesMapping , selectedCategories , skillsCategories , options ) => {
24- // NOTE:
25- // Disable filtering skills by categories for now, because V5 Skills API doesn't have categories for now.
26- /*
2724 let mappedCategories
2825 if ( categoriesMapping ) {
2926 mappedCategories = _ . map ( selectedCategories , ( category ) => categoriesMapping [ category ] ? categoriesMapping [ category ] . toLowerCase ( ) : null )
@@ -34,7 +31,6 @@ const getAvailableOptions = (categoriesMapping, selectedCategories, skillsCatego
3431 if ( mappedCategories ) {
3532 return options . filter ( option => _ . intersection ( ( option . categories || [ ] ) . map ( c => c . toLowerCase ( ) ) , mappedCategories ) . length > 0 )
3633 }
37- */
3834 return options
3935}
4036
@@ -52,15 +48,12 @@ class SkillsQuestion extends React.PureComponent {
5248
5349 componentWillMount ( ) {
5450 if ( ! cachedOptions ) {
55- axios . get ( `${ TC_API_URL } /v5/skills?skillProviderId= ${ SKILL_PROVIDER_ID } &perPage=100 ` )
51+ axios . get ( `${ TC_API_URL } /v3/tags/?domain=SKILLS&status=APPROVED ` )
5652 . then ( resp => {
57- const options = _ . get ( resp , 'data ' , [ ] )
53+ const options = _ . get ( resp . data , 'result.content ' , { } )
5854
59- cachedOptions = options . map ( ( option ) => ( {
60- skillId : option . id ,
61- name : option . name
62- } ) )
63- this . updateOptions ( cachedOptions )
55+ cachedOptions = options
56+ this . updateOptions ( options )
6457 } )
6558 } else {
6659 this . updateOptions ( cachedOptions )
@@ -84,7 +77,7 @@ class SkillsQuestion extends React.PureComponent {
8477 this . setState ( { options } )
8578 this . updateAvailableOptions ( this . props , options )
8679 if ( onSkillsLoaded ) {
87- onSkillsLoaded ( options )
80+ onSkillsLoaded ( options . map ( ( option ) => _ . pick ( option , [ 'id' , 'name' ] ) ) )
8881 }
8982 }
9083
@@ -100,6 +93,7 @@ class SkillsQuestion extends React.PureComponent {
10093
10194 // if have a mapping for categories, then filter options, otherwise use all options
10295 const availableOptions = getAvailableOptions ( categoriesMapping , selectedCategories , skillsCategories , options )
96+ . map ( option => _ . pick ( option , [ 'id' , 'name' ] ) )
10397 this . setState ( { availableOptions } )
10498 }
10599
@@ -188,17 +182,17 @@ class SkillsQuestion extends React.PureComponent {
188182 const selectedCategories = _ . get ( currentProjectData , categoriesField , [ ] )
189183
190184 let currentValues = getValue ( ) || [ ]
191- // remove from currentValues not available options but still keep created custom options without 'skillId'
192- currentValues = currentValues . filter ( skill => _ . some ( availableOptions , skill ) || ! skill . skillId )
185+ // remove from currentValues not available options but still keep created custom options without id
186+ currentValues = currentValues . filter ( skill => _ . some ( availableOptions , skill ) || ! skill . id )
193187
194188 const questionDisabled = isFormDisabled ( ) || disabled || ( selectedCategories . length === 0 && _ . isUndefined ( skillsCategories ) )
195189 const hasError = ! isPristine ( ) && ! isValid ( )
196190 const errorMessage = getErrorMessage ( ) || validationError
197191
198- const checkboxGroupOptions = availableOptions . filter ( option => frequentSkills . indexOf ( option . skillId ) > - 1 )
199- const checkboxGroupValues = currentValues . filter ( val => _ . some ( checkboxGroupOptions , option => option . skillId === val . skillId ) )
192+ const checkboxGroupOptions = availableOptions . filter ( option => frequentSkills . indexOf ( option . id ) > - 1 )
193+ const checkboxGroupValues = currentValues . filter ( val => _ . some ( checkboxGroupOptions , option => option . id === val . id ) )
200194
201- const selectGroupOptions = availableOptions . filter ( option => frequentSkills . indexOf ( option . skillId ) === - 1 )
195+ const selectGroupOptions = availableOptions . filter ( option => frequentSkills . indexOf ( option . id ) === - 1 )
202196 if ( customOptionValue ) {
203197 selectGroupOptions . unshift ( { name : customOptionValue } )
204198 }
0 commit comments