File tree Expand file tree Collapse file tree 3 files changed +24
-55
lines changed
app/api/tools/workday/create-prehire Expand file tree Collapse file tree 3 files changed +24
-55
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,16 @@ export async function POST(request: NextRequest) {
3232 const body = await request . json ( )
3333 const data = RequestSchema . parse ( body )
3434
35+ if ( ! data . email && ! data . phoneNumber && ! data . address ) {
36+ return NextResponse . json (
37+ {
38+ success : false ,
39+ error : 'At least one contact method (email, phone, or address) is required' ,
40+ } ,
41+ { status : 400 }
42+ )
43+ }
44+
3545 const parts = data . legalName . trim ( ) . split ( / \s + / )
3646 const firstName = parts [ 0 ] ?? ''
3747 const lastName = parts . length > 1 ? parts . slice ( 1 ) . join ( ' ' ) : ( parts [ 0 ] ?? '' )
@@ -44,16 +54,6 @@ export async function POST(request: NextRequest) {
4454 data . password
4555 )
4656
47- if ( ! data . email && ! data . phoneNumber && ! data . address ) {
48- return NextResponse . json (
49- {
50- success : false ,
51- error : 'At least one contact method (email, phone, or address) is required' ,
52- } ,
53- { status : 400 }
54- )
55- }
56-
5757 const contactData : Record < string , unknown > = { }
5858 if ( data . email ) {
5959 contactData . Email_Address_Data = [
Original file line number Diff line number Diff line change @@ -349,18 +349,27 @@ Output: {"businessTitle": "Senior Engineer"}`,
349349 config : {
350350 tool : ( params ) => `workday_${ params . operation } ` ,
351351 params : ( params ) => {
352- const { operation, orgType, fields, ...rest } = params
352+ const {
353+ operation,
354+ orgType,
355+ fields,
356+ positionId,
357+ jobProfileId,
358+ locationId,
359+ managerId,
360+ ...rest
361+ } = params
353362
354363 if ( rest . limit != null && rest . limit !== '' ) rest . limit = Number ( rest . limit )
355364 if ( rest . offset != null && rest . offset !== '' ) rest . offset = Number ( rest . offset )
356365
357366 if ( orgType ) rest . type = orgType
358367
359368 if ( operation === 'change_job' ) {
360- if ( rest . positionId ) rest . newPositionId = rest . positionId
361- if ( rest . jobProfileId ) rest . newJobProfileId = rest . jobProfileId
362- if ( rest . locationId ) rest . newLocationId = rest . locationId
363- if ( rest . managerId ) rest . newManagerId = rest . managerId
369+ if ( positionId ) rest . newPositionId = positionId
370+ if ( jobProfileId ) rest . newJobProfileId = jobProfileId
371+ if ( locationId ) rest . newLocationId = locationId
372+ if ( managerId ) rest . newManagerId = managerId
364373 }
365374
366375 if ( fields && operation === 'update_worker' ) {
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments