@@ -12,8 +12,12 @@ import Dropdown from 'components/GUIKit/Dropdown';
12
12
import PT from 'prop-types' ;
13
13
import React from 'react' ;
14
14
import { connect } from 'react-redux' ;
15
+ import { getSalaryType , getCustomField } from 'utils/gigs' ;
16
+ import IconBlackLocation from 'assets/images/icon-black-location.svg' ;
17
+ import { config , Link } from 'topcoder-react-utils' ;
15
18
import './jobLisingStyles.scss' ;
16
19
20
+ const CONTENT_PREVIEW_LENGTH = 175 ;
17
21
const GIGS_PER_PAGE = 10 ;
18
22
// Sort by dropdown
19
23
const sortByOptions = [
@@ -120,6 +124,13 @@ class RecruitCRMJobsContainer extends React.Component {
120
124
}
121
125
122
126
let jobsToDisplay = jobs ;
127
+ // build hotlist of jobs if present
128
+ let hotlistJobs = _ . filter ( jobs , ( job ) => {
129
+ const showInHotlist = _ . find ( job . custom_fields , [ 'field_name' , 'Show in Hotlist' ] ) ;
130
+ return showInHotlist && showInHotlist . value ;
131
+ } ) ;
132
+ hotlistJobs = hotlistJobs . sort ( ( a , b ) => new Date ( b . updated_on ) - new Date ( a . updated_on ) ) ;
133
+ hotlistJobs = _ . slice ( hotlistJobs , 0 , 4 ) ;
123
134
// build current locations dropdown based on all data
124
135
// and filter by selected location
125
136
jobsToDisplay = _ . filter ( jobs , ( job ) => {
@@ -160,7 +171,14 @@ class RecruitCRMJobsContainer extends React.Component {
160
171
} ) ;
161
172
}
162
173
// Sort controlled by sortBy state
163
- jobsToDisplay = jobsToDisplay . sort ( ( a , b ) => new Date ( b [ sortBy ] ) - new Date ( a [ sortBy ] ) ) ;
174
+ jobsToDisplay = jobsToDisplay . sort ( ( a , b ) => {
175
+ // sort tags first no matter the sortBy
176
+ const tagA = getCustomField ( a . custom_fields , 'Job Tag' ) ;
177
+ const tagB = getCustomField ( b . custom_fields , 'Job Tag' ) ;
178
+ if ( tagB !== 'n/a' && tagA === 'n/a' ) return Number . MAX_VALUE ;
179
+ if ( tagB === 'n/a' && tagA !== 'n/a' ) return - Number . MIN_VALUE ;
180
+ return new Date ( b [ sortBy ] ) - new Date ( a [ sortBy ] ) ;
181
+ } ) ;
164
182
// Calc pages
165
183
const pages = Math . ceil ( jobsToDisplay . length / GIGS_PER_PAGE ) ;
166
184
// Paginate the results
@@ -170,22 +188,54 @@ class RecruitCRMJobsContainer extends React.Component {
170
188
) ;
171
189
172
190
return (
173
- < div styleName = "container" >
174
- < div styleName = "filters" >
175
- < SearchCombo placeholder = "Search Gig Listings by Name, Skills, or Location" onSearch = { this . onSearch } term = { term } />
176
- < Dropdown label = "Location" onChange = { this . onLocation } options = { locations } size = "xs" />
177
- < Dropdown label = "Sort by" onChange = { this . onSort } options = { sortByOptions } size = "xs" />
178
- </ div >
179
- < div styleName = "jobs-list-container" >
191
+ < div styleName = { hotlistJobs . length ? 'container-with-hotlist' : 'container' } >
192
+ < div styleName = "gigs" >
193
+ < div styleName = "filters" >
194
+ < SearchCombo placeholder = "Search Gig Listings by Name or Skills" onSearch = { this . onSearch } term = { term } />
195
+ < Dropdown label = "Location" onChange = { this . onLocation } options = { locations } size = "xs" />
196
+ < Dropdown label = "Sort by" onChange = { this . onSort } options = { sortByOptions } size = "xs" />
197
+ </ div >
198
+ < div styleName = "jobs-list-container" >
199
+ {
200
+ jobsToDisplay . length
201
+ ? jobsToDisplay . map ( job => < JobListCard job = { job } key = { job . slug } /> )
202
+ : < span styleName = "no-results" > No Results</ span >
203
+ }
204
+ </ div >
180
205
{
181
206
jobsToDisplay . length
182
- ? jobsToDisplay . map ( job => < JobListCard job = { job } key = { job . slug } /> )
183
- : < span styleName = "no-results" > No Results</ span >
207
+ ? < Paginate onChange = { this . onPaginate } pages = { pages } page = { page } /> : null
184
208
}
185
209
</ div >
186
210
{
187
- jobsToDisplay . length
188
- ? < Paginate onChange = { this . onPaginate } pages = { pages } page = { page } /> : null
211
+ hotlistJobs . length && (
212
+ < div styleName = "hotlist" >
213
+ < h5 > HOT THIS WEEK</ h5 >
214
+ < div styleName = "hotlist-items" >
215
+ {
216
+ hotlistJobs . map ( ( hjob , indx ) => ( indx <= 1 ? (
217
+ < Link styleName = { `hotlist-item-${ indx + 1 } ` } to = { `${ config . GIGS_PAGES_PATH } /${ hjob . slug } ` } key = { `hotlist-item-${ indx + 1 } ` } >
218
+ < div styleName = "location" > < IconBlackLocation /> { hjob . country } </ div >
219
+ < h5 styleName = "job-title" > { hjob . name } </ h5 >
220
+ < div styleName = "job-money" > ${ hjob . min_annual_salary } - ${ hjob . max_annual_salary } / { getSalaryType ( hjob . salary_type ) } </ div >
221
+ </ Link >
222
+ ) : (
223
+ < div styleName = { `hotlist-item-${ indx + 1 } ` } to = { `${ config . GIGS_PAGES_PATH } /${ hjob . slug } ` } key = { `hotlist-item-${ indx + 1 } ` } >
224
+ < div styleName = "location" > < IconBlackLocation /> { hjob . country } </ div >
225
+ < h5 styleName = "job-title" > { hjob . name } </ h5 >
226
+ < div styleName = "job-money" > ${ hjob . min_annual_salary } - ${ hjob . max_annual_salary } / { getSalaryType ( hjob . salary_type ) } </ div >
227
+ < div styleName = "job-desc" >
228
+ {
229
+ `${ getCustomField ( hjob . custom_fields , 'Hotlist excerpt' ) === 'n/a' ? '' : `${ getCustomField ( hjob . custom_fields , 'Hotlist excerpt' ) . substring ( 0 , CONTENT_PREVIEW_LENGTH ) } ...` } `
230
+ }
231
+ </ div >
232
+ < Link styleName = { `hotlist-item-button-${ indx + 1 } ` } to = { `${ config . GIGS_PAGES_PATH } /${ hjob . slug } ` } > Apply Now</ Link >
233
+ </ div >
234
+ ) ) )
235
+ }
236
+ </ div >
237
+ </ div >
238
+ )
189
239
}
190
240
</ div >
191
241
) ;
0 commit comments