@@ -181,7 +181,7 @@ export const createNewTask = async (
181181 return { success : false , error : "Required fields are missing (title, column, and skill category)" } ;
182182 }
183183
184- const { error } = await supabase . from ( "tasks" ) . insert ( [
184+ const { data : newTask , error } = await supabase . from ( "tasks" ) . insert ( [
185185 {
186186 title,
187187 description,
@@ -197,7 +197,7 @@ export const createNewTask = async (
197197 created_by,
198198 deadline,
199199 } ,
200- ] ) ;
200+ ] ) . select ( "id" ) . single ( ) ;
201201
202202 if ( error ) {
203203 console . error ( "Error creating task:" , error ) ;
@@ -219,6 +219,28 @@ export const createNewTask = async (
219219
220220 if ( boardData ?. project_id ) {
221221 revalidatePath ( `/home/kanban/${ boardData . project_id } /${ columnData . board_id } ` ) ;
222+
223+ // Send notification if task is assigned to someone other than the creator
224+ if ( codev_id && newTask ?. id ) {
225+ const { data : { user } } = await supabase . auth . getUser ( ) ;
226+
227+ // Only send notification if assigning to someone else
228+ if ( user && user . id !== codev_id ) {
229+ await createNotificationAction ( {
230+ recipientId : codev_id ,
231+ title : "New Task Assignment" ,
232+ message : `You've been assigned to task: "${ title } "` ,
233+ type : "task" ,
234+ priority : "normal" ,
235+ projectId : boardData . project_id ,
236+ actionUrl : `/home/kanban/${ boardData . project_id } /${ columnData . board_id } ?taskId=${ newTask . id } ` ,
237+ metadata : {
238+ taskId : newTask . id ,
239+ assignedAt : new Date ( ) . toISOString ( )
240+ }
241+ } ) ;
242+ }
243+ }
222244 }
223245 }
224246
@@ -298,6 +320,7 @@ export const updateTask = async (
298320 // Get current user to avoid self-notification
299321 const { data : { user } } = await supabase . auth . getUser ( ) ;
300322
323+ // Only send notification if assigning to someone else
301324 if ( user && user . id !== codev_id ) {
302325 // Fetch project info to build the action URL
303326 const { data : colData } = await supabase
@@ -308,8 +331,8 @@ export const updateTask = async (
308331
309332 await createNotificationAction ( {
310333 recipientId : codev_id ,
311- title : "Task Assigned " ,
312- message : `You've been assigned to: ${ title || existingTask . title } ` ,
334+ title : "Task Assignment Update " ,
335+ message : `You've been assigned to task: " ${ title || existingTask . title } " ` ,
313336 type : "task" ,
314337 priority : "normal" ,
315338 projectId : ( colData ?. kanban_boards as any ) ?. project_id ,
@@ -1028,11 +1051,12 @@ export const promoteDraft = async (
10281051 // Get current user to avoid self-notification
10291052 const { data : { user } } = await supabase . auth . getUser ( ) ;
10301053
1054+ // Only send notification if assigning to someone else
10311055 if ( user && user . id !== draft . codev_id ) {
10321056 await createNotificationAction ( {
10331057 recipientId : draft . codev_id ,
1034- title : "Task Assigned (from Draft) " ,
1035- message : `The draft "${ draft . title } " has been published and assigned to you.` ,
1058+ title : "Draft Published & Assigned " ,
1059+ message : `Task "${ draft . title } " has been published and assigned to you.` ,
10361060 type : "task" ,
10371061 priority : "normal" ,
10381062 projectId : draft . project_id ,
0 commit comments