@@ -61,7 +61,8 @@ async function getMyJobApplications(currentUser, criteria) {
6161 min : job . minSalary ,
6262 max : job . maxSalary ,
6363 frequency : job . rateType ,
64- currency : job . currency ,
64+ // currency: job.currency,
65+ currency : "$" ,
6566 } ,
6667 hoursPerWeek : job . hoursPerWeek ,
6768 location : job . jobLocation ,
@@ -96,6 +97,51 @@ getMyJobApplications.schema = Joi.object()
9697 } )
9798 . required ( ) ;
9899
100+ async function getJob ( currentUser , criteria ) {
101+ const emptyResult = {
102+ synced : false ,
103+ } ;
104+ // we expect logged-in users
105+ if ( currentUser . isMachine ) {
106+ return emptyResult ;
107+ }
108+ // get user id by calling taas-api with current user's token
109+ const { id : userId } = await helper . getCurrentUserDetails (
110+ currentUser . jwtToken
111+ ) ;
112+ if ( ! userId ) {
113+ throw new errors . NotFoundError (
114+ `Id for user: ${ currentUser . userId } not found`
115+ ) ;
116+ }
117+ // get job based on the jobExternalId
118+ const { result : jobs } = await helper . getJobs ( criteria ) ;
119+ if ( jobs && jobs . length ) {
120+ const candidates = jobs [ 0 ] . candidates || [ ] ;
121+ const newJob = candidates . find ( ( item ) => item . userId == userId ) ;
122+ if ( newJob ) {
123+ return {
124+ synced : true ,
125+ } ;
126+ }
127+ }
128+ return {
129+ synced : false ,
130+ } ;
131+ }
132+
133+ getJob . schema = Joi . object ( )
134+ . keys ( {
135+ currentUser : Joi . object ( ) . required ( ) ,
136+ criteria : Joi . object ( )
137+ . keys ( {
138+ externalId : Joi . string ( ) ,
139+ } )
140+ . required ( ) ,
141+ } )
142+ . required ( ) ;
143+
99144module . exports = {
100145 getMyJobApplications,
146+ getJob,
101147} ;
0 commit comments