@@ -61,7 +61,8 @@ async function getMyJobApplications(currentUser, criteria) {
61
61
min : job . minSalary ,
62
62
max : job . maxSalary ,
63
63
frequency : job . rateType ,
64
- currency : job . currency ,
64
+ // currency: job.currency,
65
+ currency : "$" ,
65
66
} ,
66
67
hoursPerWeek : job . hoursPerWeek ,
67
68
location : job . jobLocation ,
@@ -96,6 +97,51 @@ getMyJobApplications.schema = Joi.object()
96
97
} )
97
98
. required ( ) ;
98
99
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
+
99
144
module . exports = {
100
145
getMyJobApplications,
146
+ getJob,
101
147
} ;
0 commit comments