@@ -17,15 +17,22 @@ const changeExRole = async (
1717 return updatedUser ;
1818} ;
1919
20- export async function GET ( req : NextRequest , props : { params : Promise < { work_id : string } > } ) {
20+ export async function GET (
21+ req : NextRequest ,
22+ props : { params : Promise < { work_id : string } > }
23+ ) {
2124 const params = await props . params ;
2225 const searchParams = req . nextUrl . searchParams ;
2326 const monthlyStatus = searchParams . has ( "monthly-status" ) ;
2427
2528 const user = await prisma . users . findFirst ( {
26- where : {
27- work_id : params . work_id ,
28- } ,
29+ where : params . work_id . includes ( "ID" )
30+ ? {
31+ work_id : params . work_id ,
32+ }
33+ : {
34+ id : Number ( params . work_id ) ,
35+ } ,
2936 select : {
3037 name : true ,
3138 work_id : true ,
@@ -45,12 +52,15 @@ export async function GET(req: NextRequest, props: { params: Promise<{ work_id:
4552 if ( ! user ) return NextResponse . json ( null ) ;
4653
4754 user . profile_picture = user . profile_picture
48- ? `${ process . env . APP_URL } /api/public ${ user . profile_picture } `
55+ ? `${ process . env . APP_URL } /api/images/ ${ user . profile_picture } `
4956 : null ;
5057 return NextResponse . json ( user ) ;
5158}
5259
53- export async function DELETE ( req : NextRequest , props : { params : Promise < { work_id : string } > } ) {
60+ export async function DELETE (
61+ req : NextRequest ,
62+ props : { params : Promise < { work_id : string } > }
63+ ) {
5464 const params = await props . params ;
5565 const user = await prisma . users . findFirst ( {
5666 where : {
@@ -83,9 +93,13 @@ export async function DELETE(req: NextRequest, props: { params: Promise<{ work_i
8393 return NextResponse . json ( { message : "Deleted" , data : { deleted } } ) ;
8494}
8595
86- export async function PUT ( req : NextRequest , props : { params : Promise < { work_id : string } > } ) {
96+ export async function PUT (
97+ req : NextRequest ,
98+ props : { params : Promise < { work_id : string } > }
99+ ) {
87100 const params = await props . params ;
88- const { name, job_position_id, gender, role, password, toEx, unEx } = await req . json ( ) ;
101+ const { name, job_position_id, gender, role, password, toEx, unEx } =
102+ await req . json ( ) ;
89103
90104 let user = await prisma . users . findFirst ( {
91105 where : {
@@ -124,7 +138,11 @@ export async function PUT(req: NextRequest, props: { params: Promise<{ work_id:
124138 }
125139 }
126140 // if its not unique return error
127- if ( ! unique ) return NextResponse . json ( { error : "PIN already in use" } , { status : 409 } ) ;
141+ if ( ! unique )
142+ return NextResponse . json (
143+ { error : "PIN already in use" } ,
144+ { status : 409 }
145+ ) ;
128146 await prisma . users . update ( {
129147 where : {
130148 id : user . id ,
0 commit comments