1- /* eslint-disable react/destructuring-assignment */
2- /* eslint-disable @typescript-eslint/no-unused-vars */
3- /* eslint-disable arrow-body-style */
4- /* eslint-disable @typescript-eslint/typedef */
5- /* eslint-disable indent */
6- /* eslint-disable sort-keys */
7- /* eslint-disable ordered-imports/ordered-imports */
81/* eslint-disable react/jsx-no-bind */
92import {
3+ CSSProperties ,
104 FC ,
115 useState ,
12- CSSProperties
136} from 'react'
14-
15- import { components , ControlProps , Options , GroupBase , MultiValue , SingleValue , StylesConfig , ActionMeta } from 'react-select'
7+ import { components , ControlProps , GroupBase ,
8+ MultiValue , Options , SingleValue , StylesConfig } from 'react-select'
169import AsyncSelect from 'react-select/async'
10+ import PropTypes from 'prop-types'
1711
12+ import { SearchIcon } from '@heroicons/react/outline'
1813import { ContentLayout } from '~/libs/ui'
1914import { Skill } from '@talentSearch/lib/models/'
2015import MatcherService from '@talentSearch/lib/services/MatcherService'
21- import { SearchIcon } from '@heroicons/react/outline'
16+
2217import SkillPill from './components/SkillPill'
2318import styles from './TalentSearch.module.scss'
2419
2520function search ( skills :Options < Skill > ) : void {
26- alert ( "Searching skills: " + JSON . stringify ( skills ) )
21+ alert ( JSON . stringify ( skills ) )
2722}
2823
29- const Control : React . FC < ControlProps < Skill , boolean , GroupBase < Skill > > > = ( { children, ...props } ) => (
24+ // eslint-disable-next-line react/destructuring-assignment, @typescript-eslint/typedef
25+ const Control : React . FC < ControlProps < Skill , boolean , GroupBase < Skill > > > = ( { children, ...props } ) => (
3026 < components . Control { ...props } >
3127 { children }
32- < span onClick = { ( ) => search ( props . getValue ( ) ) } className = { styles . searchIconSpan } > < SearchIcon className = { styles . searchIcon } /> </ span >
28+ < span
29+ onClick = { ( ) => search ( props . getValue ( ) ) }
30+ className = { styles . searchIconSpan }
31+ >
32+ < SearchIcon className = { styles . searchIcon } />
33+ </ span >
3334 </ components . Control >
3435)
3536
37+ Control . propTypes = {
38+ children : PropTypes . node . isRequired ,
39+ getValue : PropTypes . func . isRequired ,
40+ }
41+
3642export const TalentSearch : FC = ( ) => {
3743 const [ skillsFilter , setSkillsFilter ] = useState < Array < Skill > > ( [ ] )
3844
39- function search ( ) : void {
40- alert ( "Searching for skills: " + JSON . stringify ( skillsFilter ) )
41- }
42-
43- function toggleSkill ( skill :Skill , pill :SkillPill ) : void {
45+ function toggleSkill ( skill :Skill ) : void {
4446 let newFilter : Array < Skill > = [ ]
4547 let deleted : boolean = false
4648 if ( skillsFilter ) {
4749 // Either delete the value from the list, if we're toggling one that's already in the list
4850 // Or add the new item to the list
49- skillsFilter . forEach ( ( filterSkill , index ) => {
51+ skillsFilter . forEach ( filterSkill => {
5052 if ( filterSkill . emsiId === skill . emsiId ) {
5153 deleted = true
52- }
53- else {
54+ } else {
5455 newFilter . push ( filterSkill )
5556 }
5657 } )
@@ -62,18 +63,17 @@ export const TalentSearch: FC = () => {
6263 }
6364 }
6465
65- function onChange ( options :MultiValue < Skill > | SingleValue < Skill > , meta : ActionMeta < Skill > ) : void {
66+ function onChange ( options :MultiValue < Skill > | SingleValue < Skill > ) : void {
6667 if ( Array . isArray ( options ) ) {
6768 setSkillsFilter ( options )
68- }
69- else {
69+ } else {
7070 setSkillsFilter ( [ ] )
7171 }
7272 }
7373
7474 function filteringSkill ( skill :Skill ) : boolean {
7575 let result : boolean = false
76- skillsFilter . forEach ( ( filterSkill , index ) => {
76+ skillsFilter . forEach ( filterSkill => {
7777 if ( filterSkill . emsiId === skill . emsiId ) {
7878 result = true
7979 }
@@ -82,118 +82,105 @@ export const TalentSearch: FC = () => {
8282 return result
8383 }
8484
85+ // TODO: Make this configurable, or read from a service. We need to discuss
86+ // how we want to handle this.
8587 const popularSkills :Skill [ ] [ ] = [
86- [ { name : 'Typescript ' , emsiId : 'KS441LF7187KS0CV4B6Y ' } ,
87- { name : 'Front-End Engineering ' , emsiId : 'KS1244K6176NLVWV02B6 ' } ,
88- { name : 'Bootstrap (Front-End Framework)' , emsiId : 'KS1214R5XG4X4PY7LGY6 ' } ] ,
89- [ { name : 'Cascading Style Sheets (CSS)' , emsiId : 'KS121F45VPV8C9W3QFYH ' } ,
90- { name : 'JavaScript (Programming Language)' , emsiId : 'KS1200771D9CR9LB4MWW ' } ] ,
91- [ { name : 'HyperText Markup Language (HTML)' , emsiId : 'KS1200578T5QCYT0Z98G ' } ,
92- { name : 'IOS Development ' , emsiId : 'ES86A20379CD2AD061F3 ' } ,
93- { name : 'Node.js ' , emsiId : 'KS127296VDYS7ZFWVC46 ' } ] ,
94- [ { name : '.NET Development ' , emsiId : 'ES50D03AC9CFC1A0BC93 ' } ,
95- { name : 'C++ (Programming Language)' , emsiId : 'KS1219W70LY1GXZDSKW5 ' } ,
96- { name : 'PHP Development ' , emsiId : 'KS127SZ60YZR8B5CQKV1 ' } ] ,
97- [ { name : 'Adobe Illustrator ' , emsiId : 'KS1206V6K46N1SDVJGBD ' } ,
98- { name : 'Ruby (Programming Language)' , emsiId : 'ESD07FEE22E7EC094EB8 ' } ,
99- { name : 'Java (Programming Language)' , emsiId : 'KS120076FGP5WGWYMP0F ' } ] ,
100- [ { name : 'React Native ' , emsiId : 'KSPSGF5MXB6568UIQ4BK ' } ,
101- { name : 'User Experience (UX)' , emsiId : 'KS441PL6JPXW200W0GRQ ' } ] ,
88+ [ { emsiId : 'KS441LF7187KS0CV4B6Y ' , name : 'Typescript ' } ,
89+ { emsiId : 'KS1244K6176NLVWV02B6 ' , name : 'Front-End Engineering ' } ,
90+ { emsiId : 'KS1214R5XG4X4PY7LGY6' , name : 'Bootstrap (Front-End Framework)' } ] ,
91+ [ { emsiId : 'KS121F45VPV8C9W3QFYH' , name : 'Cascading Style Sheets (CSS)' } ,
92+ { emsiId : 'KS1200771D9CR9LB4MWW' , name : 'JavaScript (Programming Language)' } ] ,
93+ [ { emsiId : 'KS1200578T5QCYT0Z98G' , name : 'HyperText Markup Language (HTML)' } ,
94+ { emsiId : 'ES86A20379CD2AD061F3 ' , name : 'IOS Development ' } ,
95+ { emsiId : 'KS127296VDYS7ZFWVC46 ' , name : 'Node.js ' } ] ,
96+ [ { emsiId : 'ES50D03AC9CFC1A0BC93 ' , name : '.NET Development ' } ,
97+ { emsiId : 'KS1219W70LY1GXZDSKW5' , name : 'C++ (Programming Language)' } ,
98+ { emsiId : 'KS127SZ60YZR8B5CQKV1 ' , name : 'PHP Development ' } ] ,
99+ [ { emsiId : 'KS1206V6K46N1SDVJGBD ' , name : 'Adobe Illustrator ' } ,
100+ { emsiId : 'ESD07FEE22E7EC094EB8' , name : 'Ruby (Programming Language)' } ,
101+ { emsiId : 'KS120076FGP5WGWYMP0F' , name : 'Java (Programming Language)' } ] ,
102+ [ { emsiId : 'KSPSGF5MXB6568UIQ4BK ' , name : 'React Native ' } ,
103+ { emsiId : 'KS441PL6JPXW200W0GRQ' , name : 'User Experience (UX)' } ] ,
102104 ]
103105
104106 const controlStyle : CSSProperties = {
105107 borderColor : 'black' ,
106- paddingTop : '10px' ,
107108 paddingBottom : '10px' ,
109+ paddingTop : '10px' ,
108110 }
109111
110112 const placeholderStyle : CSSProperties = {
111- height : '36px' ,
112- paddingTop : '4px' ,
113113 color : '#2A2A2A' ,
114- fontSize : '16' ,
115114 fontFamily : 'Roboto' ,
115+ fontSize : '16' ,
116116 fontWeight : 400 ,
117+ height : '36px' ,
118+ paddingTop : '4px' ,
117119 }
118120
119-
120121 const multiValueStyle : CSSProperties = {
121122 backgroundColor : 'white' ,
122123 border : '1px solid #d4d4d4' ,
123- color : '#333' ,
124124 borderRadius : '24px' ,
125- height : '32px ' ,
125+ color : '#333 ' ,
126126 fontFamily : 'Roboto' ,
127- fontWeight : '400' ,
128127 fontSize : '14' ,
129- paddingRight : '8px ' ,
130- paddingLeft : '8px ' ,
128+ fontWeight : '400 ' ,
129+ height : '32px ' ,
131130 marginRight : '10px' ,
131+ paddingLeft : '8px' ,
132+ paddingRight : '8px' ,
132133 }
133134
134135 const multiValueRemoveStyle : CSSProperties = {
135- width : '12px' ,
136- height : '12px' ,
137136 backgroundColor : '#d9d9d9' ,
137+ border : '1px solid #d4d4d4' ,
138+ borderRadius : '11px' ,
138139 color : '#333' ,
139- marginTop : 'auto' ,
140+ fontSize : '12' ,
141+ height : '12px' ,
140142 marginBottom : 'auto' ,
141- marginRight : '5px' ,
142143 marginLeft : '5px' ,
143- borderRadius : '11px' ,
144- border : '1px solid #d4d4d4' ,
145- fontSize : '12' ,
144+ marginRight : '5px' ,
145+ marginTop : 'auto' ,
146146 padding : '0px' ,
147+ width : '12px' ,
147148 }
148149
149150 const hiddenStyle : CSSProperties = {
150151 display : 'none' ,
151152 }
152153
153154 const selectStyle : StylesConfig < Skill > = {
154- control : ( provided , state ) => {
155- return {
155+ clearIndicator : provided => ( {
156+ ...provided ,
157+ ...hiddenStyle ,
158+ } ) ,
159+ control : provided => ( {
156160 ...provided ,
157161 ...controlStyle ,
158- }
159- } ,
160- multiValue : ( provided , state ) => {
161- return {
162- ...provided ,
163- ...multiValueStyle ,
164- }
165- } ,
166- multiValueRemove : ( provided , state ) => {
167- return {
162+ } ) ,
163+ dropdownIndicator : provided => ( {
164+ ...provided ,
165+ ...hiddenStyle ,
166+ } ) ,
167+ indicatorSeparator : provided => ( {
168+ ...provided ,
169+ ...hiddenStyle ,
170+ } ) ,
171+ multiValue : provided => ( {
172+ ...provided ,
173+ ...multiValueStyle ,
174+ } ) ,
175+ multiValueRemove : provided => ( {
168176 ...provided ,
169177 ...multiValueRemoveStyle ,
170- }
171- } ,
172- clearIndicator : ( provided , state ) => {
173- return {
174- ...provided ,
175- ...hiddenStyle ,
176- }
177- } ,
178- dropdownIndicator : ( provided , state ) => {
179- return {
180- ...provided ,
181- ...hiddenStyle ,
182- }
183- } ,
184- indicatorSeparator : ( provided , state ) => {
185- return {
186- ...provided ,
187- ...hiddenStyle ,
188- }
189- } ,
190- placeholder : ( provided , state ) => {
191- return {
192- ...provided ,
193- ...placeholderStyle ,
194- }
195- } ,
196- }
178+ } ) ,
179+ placeholder : provided => ( {
180+ ...provided ,
181+ ...placeholderStyle ,
182+ } ) ,
183+ }
197184 return (
198185 < ContentLayout
199186 contentClass = { styles . contentLayout }
@@ -225,21 +212,26 @@ export const TalentSearch: FC = () => {
225212 components = { { Control } }
226213 openMenuOnClick = { false }
227214 value = { skillsFilter }
228- onChange = { ( newValue : MultiValue < Skill > | SingleValue < Skill > , actionMeta : ActionMeta < Skill > ) =>
229- onChange ( newValue , actionMeta ) }
215+ onChange = { (
216+ newValue : MultiValue < Skill > | SingleValue < Skill > ,
217+ ) => onChange ( newValue ) }
230218 />
231219 </ div >
232220 < div className = { styles . popularSkillsContainer } >
233221 < span className = { styles . popularSkillsTitle } > Popular Skills</ span >
234222
235- { popularSkills . map ( row =>
236- < div className = { styles . pillRow } >
237- { row . map ( skill =>
238- < SkillPill skill = { skill }
239- selected = { filteringSkill ( skill ) }
240- onClick = { toggleSkill }
241- /> ) }
242- </ div >
223+ { popularSkills . map (
224+ row => (
225+ < div className = { styles . pillRow } >
226+ { row . map ( skill => (
227+ < SkillPill
228+ skill = { skill }
229+ selected = { filteringSkill ( skill ) }
230+ onClick = { toggleSkill }
231+ />
232+ ) ) }
233+ </ div >
234+ ) ,
243235 ) }
244236 </ div >
245237 </ ContentLayout >
0 commit comments