@@ -19,7 +19,8 @@ import { getQuery, updateQuery } from 'utils/url';
1919import { withOptimizely } from '@optimizely/react-sdk' ;
2020import './jobLisingStyles.scss' ;
2121
22- const CONTENT_PREVIEW_LENGTH = 175 ;
22+ const cookies = require ( 'browser-cookies' ) ;
23+
2324const GIGS_PER_PAGE = 10 ;
2425// Sort by dropdown
2526const sortByOptions = [
@@ -47,7 +48,7 @@ class RecruitCRMJobsContainer extends React.Component {
4748 this . onFilter = this . onFilter . bind ( this ) ;
4849 this . onLocation = this . onLocation . bind ( this ) ;
4950 this . onSort = this . onSort . bind ( this ) ;
50- this . onHotlistApply = this . onHotlistApply . bind ( this ) ;
51+ this . onHotlistClick = this . onHotlistClick . bind ( this ) ;
5152 }
5253
5354 componentDidMount ( ) {
@@ -121,9 +122,14 @@ class RecruitCRMJobsContainer extends React.Component {
121122 } ) ;
122123 }
123124
124- onHotlistApply ( ) {
125+ onHotlistClick ( job ) {
125126 const { optimizely } = this . props ;
126127 optimizely . track ( 'Hotlist ads click' ) ;
128+ cookies . set ( '_tc.hcl' , JSON . stringify ( {
129+ slug : job . slug ,
130+ } ) , {
131+ expires : 0 ,
132+ } ) ;
127133 }
128134
129135 render ( ) {
@@ -151,7 +157,8 @@ class RecruitCRMJobsContainer extends React.Component {
151157 // optimizely decide
152158 let decision = { enabled : true } ;
153159 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' ) ;
155162 }
156163 let jobsToDisplay = jobs ;
157164 // build hotlist of jobs if present
@@ -216,6 +223,23 @@ class RecruitCRMJobsContainer extends React.Component {
216223 jobsToDisplay ,
217224 page * GIGS_PER_PAGE , ( page * GIGS_PER_PAGE ) + GIGS_PER_PAGE ,
218225 ) ;
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+ ) ;
219243
220244 return (
221245 < div styleName = { hotlistJobs . length && decision . enabled ? 'container-with-hotlist' : 'container' } >
@@ -228,58 +252,34 @@ class RecruitCRMJobsContainer extends React.Component {
228252 < div styleName = "jobs-list-container" >
229253 {
230254 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+ )
233276 }
234277 </ div >
235278 {
236279 jobsToDisplay . length
237280 ? < Paginate onChange = { this . onPaginate } pages = { pages } page = { page } /> : null
238281 }
239282 </ 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- }
283283 </ div >
284284 ) ;
285285 }
0 commit comments