@@ -417,16 +417,16 @@ export class ProjectManagementService {
417417 ) {
418418 const exists = await prisma . task . findUnique ( { where : { id } } ) ;
419419 if ( ! exists ) throw new NotFoundException ( "Task not found" ) ;
420-
420+ let project : any = null ;
421421 // validate projectId if present and not null (null means detach project)
422422 if (
423423 typeof payload . projectId !== "undefined" &&
424424 payload . projectId !== null
425425 ) {
426- const p = await prisma . project . findUnique ( {
426+ project = await prisma . project . findUnique ( {
427427 where : { id : payload . projectId } ,
428428 } ) ;
429- if ( ! p ) throw new NotFoundException ( "Project not found" ) ;
429+ if ( ! project ) throw new NotFoundException ( "Project not found" ) ;
430430 }
431431 let assignee : any = null ;
432432 // validate assignee if present and not null
@@ -482,25 +482,11 @@ export class ProjectManagementService {
482482 } ) ;
483483
484484 //send email to team members
485- const team = await prisma . teamMember . findFirst ( {
486- where : { userId, isTrash : false } ,
487- } ) ;
488-
489- if ( ! team ) throw new NotFoundException ( "Team not found" ) ;
490-
491485 const teams = await prisma . teamMember . findMany ( {
492- where : { workspaceId : team . workspaceId , isTrash : false } ,
486+ where : { workspaceId : project . workspaceId , isTrash : false } ,
493487 select : { email : true } ,
494488 } ) ;
495489
496- // Ambil nama project (optional, tapi lebih keren)
497- const project = await prisma . project . findFirst ( {
498- where : { id : payload . projectId ?? "" } ,
499- select : { name : true } ,
500- } ) ;
501-
502- if ( ! project ) throw new NotFoundException ( "Project not found" ) ;
503-
504490 const projectName = project ?. name ?? "No Project" ;
505491
506492 const toEmails = teams . map ( ( t ) => t . email ?. trim ( ) ) . filter ( Boolean ) ;
0 commit comments