@@ -19,7 +19,8 @@ import { getQuery, updateQuery } from 'utils/url';
19
19
import { withOptimizely } from '@optimizely/react-sdk' ;
20
20
import './jobLisingStyles.scss' ;
21
21
22
- const CONTENT_PREVIEW_LENGTH = 175 ;
22
+ const cookies = require ( 'browser-cookies' ) ;
23
+
23
24
const GIGS_PER_PAGE = 10 ;
24
25
// Sort by dropdown
25
26
const sortByOptions = [
@@ -47,7 +48,7 @@ class RecruitCRMJobsContainer extends React.Component {
47
48
this . onFilter = this . onFilter . bind ( this ) ;
48
49
this . onLocation = this . onLocation . bind ( this ) ;
49
50
this . onSort = this . onSort . bind ( this ) ;
50
- this . onHotlistApply = this . onHotlistApply . bind ( this ) ;
51
+ this . onHotlistClick = this . onHotlistClick . bind ( this ) ;
51
52
}
52
53
53
54
componentDidMount ( ) {
@@ -121,9 +122,14 @@ class RecruitCRMJobsContainer extends React.Component {
121
122
} ) ;
122
123
}
123
124
124
- onHotlistApply ( ) {
125
+ onHotlistClick ( job ) {
125
126
const { optimizely } = this . props ;
126
127
optimizely . track ( 'Hotlist ads click' ) ;
128
+ cookies . set ( '_tc.hcl' , JSON . stringify ( {
129
+ slug : job . slug ,
130
+ } ) , {
131
+ expires : 0 ,
132
+ } ) ;
127
133
}
128
134
129
135
render ( ) {
@@ -151,7 +157,8 @@ class RecruitCRMJobsContainer extends React.Component {
151
157
// optimizely decide
152
158
let decision = { enabled : true } ;
153
159
if ( isomorphy . isClientSide ( ) ) {
154
- decision = optimizely . decide ( 'gig_listing_hotlist' ) ;
160
+ // decision = optimizely.decide('gig_listing_hotlist');
161
+ decision = optimizely . decide ( 'gig_listing_hotlist_center' ) ;
155
162
}
156
163
let jobsToDisplay = jobs ;
157
164
// build hotlist of jobs if present
@@ -216,6 +223,23 @@ class RecruitCRMJobsContainer extends React.Component {
216
223
jobsToDisplay ,
217
224
page * GIGS_PER_PAGE , ( page * GIGS_PER_PAGE ) + GIGS_PER_PAGE ,
218
225
) ;
226
+ // hot list of gigs
227
+ let isHotlistRendered = false ;
228
+ const hotlist = ( ) => (
229
+ < div styleName = "hotlist" >
230
+ < div styleName = "hotlist-items" >
231
+ {
232
+ hotlistJobs . map ( ( hjob , indx ) => (
233
+ < Link styleName = { `hotlist-item-${ indx + 1 } ` } to = { `${ config . GIGS_PAGES_PATH } /${ hjob . slug } ` } key = { `hotlist-item-${ indx + 1 } ` } onClick = { ( ) => this . onHotlistClick ( hjob ) } >
234
+ < div styleName = "location" > < IconBlackLocation /> { hjob . country } </ div >
235
+ < h5 styleName = "job-title" > { hjob . name } </ h5 >
236
+ < div styleName = "job-money" > ${ hjob . min_annual_salary } - { hjob . max_annual_salary } / { getSalaryType ( hjob . salary_type ) } </ div >
237
+ </ Link >
238
+ ) )
239
+ }
240
+ </ div >
241
+ </ div >
242
+ ) ;
219
243
220
244
return (
221
245
< div styleName = { hotlistJobs . length && decision . enabled ? 'container-with-hotlist' : 'container' } >
@@ -228,58 +252,34 @@ class RecruitCRMJobsContainer extends React.Component {
228
252
< div styleName = "jobs-list-container" >
229
253
{
230
254
jobsToDisplay . length
231
- ? jobsToDisplay . map ( job => < JobListCard job = { job } key = { job . slug } /> )
232
- : < span styleName = "no-results" > No Results</ span >
255
+ ? jobsToDisplay . map ( ( job , indx ) => {
256
+ const featured = getCustomField ( job . custom_fields , 'Featured' ) ;
257
+ if ( ( featured === 'n/a' || indx === 2 ) && ! isHotlistRendered && hotlistJobs . length && decision . enabled ) {
258
+ isHotlistRendered = true ;
259
+ return (
260
+ < React . Fragment >
261
+ { hotlist ( ) }
262
+ < JobListCard job = { job } key = { job . slug } />
263
+ </ React . Fragment >
264
+ ) ;
265
+ }
266
+ return < JobListCard job = { job } key = { job . slug } /> ;
267
+ } )
268
+ : (
269
+ < React . Fragment >
270
+ {
271
+ hotlistJobs . length && decision . enabled && hotlist ( )
272
+ }
273
+ < span styleName = "no-results" > No Results</ span >
274
+ </ React . Fragment >
275
+ )
233
276
}
234
277
</ div >
235
278
{
236
279
jobsToDisplay . length
237
280
? < Paginate onChange = { this . onPaginate } pages = { pages } page = { page } /> : null
238
281
}
239
282
</ div >
240
- {
241
- hotlistJobs . length && decision . enabled && (
242
- < div styleName = "hotlist" >
243
- < h5 > HOT THIS WEEK</ h5 >
244
- < div styleName = "hotlist-items" >
245
- {
246
- hotlistJobs . map ( ( hjob , indx ) => ( indx <= 1 ? (
247
- < Link styleName = { `hotlist-item-${ indx + 1 } ` } to = { `${ config . GIGS_PAGES_PATH } /${ hjob . slug } ` } key = { `hotlist-item-${ indx + 1 } ` } onClick = { this . onHotlistApply } >
248
- < div styleName = "location" > < IconBlackLocation /> { hjob . country } </ div >
249
- < h5 styleName = "job-title" > { hjob . name } </ h5 >
250
- < div styleName = "job-money" > ${ hjob . min_annual_salary } - { hjob . max_annual_salary } / { getSalaryType ( hjob . salary_type ) } </ div >
251
- {
252
- getCustomField ( hjob . custom_fields , 'Hotlist excerpt' ) !== 'n/a' ? (
253
- < div styleName = "job-desc" >
254
- {
255
- `${ getCustomField ( hjob . custom_fields , 'Hotlist excerpt' ) . substring ( 0 , CONTENT_PREVIEW_LENGTH ) } ${ getCustomField ( hjob . custom_fields , 'Hotlist excerpt' ) . length > CONTENT_PREVIEW_LENGTH ? '...' : '' } `
256
- }
257
- </ div >
258
- ) : null
259
- }
260
- </ Link >
261
- ) : (
262
- < div styleName = { `hotlist-item-${ indx + 1 } ` } to = { `${ config . GIGS_PAGES_PATH } /${ hjob . slug } ` } key = { `hotlist-item-${ indx + 1 } ` } >
263
- < div styleName = "location" > < IconBlackLocation /> { hjob . country } </ div >
264
- < h5 styleName = "job-title" > { hjob . name } </ h5 >
265
- < div styleName = "job-money" > ${ hjob . min_annual_salary } - { hjob . max_annual_salary } / { getSalaryType ( hjob . salary_type ) } </ div >
266
- {
267
- getCustomField ( hjob . custom_fields , 'Hotlist excerpt' ) !== 'n/a' ? (
268
- < div styleName = "job-desc" >
269
- {
270
- `${ getCustomField ( hjob . custom_fields , 'Hotlist excerpt' ) . substring ( 0 , CONTENT_PREVIEW_LENGTH ) } ${ getCustomField ( hjob . custom_fields , 'Hotlist excerpt' ) . length > CONTENT_PREVIEW_LENGTH ? '...' : '' } `
271
- }
272
- </ div >
273
- ) : null
274
- }
275
- < Link styleName = { `hotlist-item-button-${ indx + 1 } ` } to = { `${ config . GIGS_PAGES_PATH } /${ hjob . slug } ` } onClick = { this . onHotlistApply } > Apply Now</ Link >
276
- </ div >
277
- ) ) )
278
- }
279
- </ div >
280
- </ div >
281
- )
282
- }
283
283
</ div >
284
284
) ;
285
285
}
0 commit comments