This commit is contained in:
2026-07-01 12:39:59 +02:00
parent b054e36df0
commit 8a0fa70c10
26 changed files with 1804 additions and 724 deletions
+35
View File
@@ -0,0 +1,35 @@
import { supa } from './supabase'
import { Pole, Profile, NotificationKind, memberPoles } from './types'
/**
* Crée une notification pour chaque membre du pôle destinataire
* (sauf l'auteur de l'action). Utilisé lorsqu'une tâche ou un bug
* est confié à un pôle.
*/
export async function notifyPole(opts: {
projectId: string
pole: Pole
kind: NotificationKind
title: string // ex : « Nouvelle tâche »
body: string // titre de la tâche / du bug
entityId: string
actorId: string | null
members: Profile[]
}): Promise<void> {
const recipients = opts.members.filter(
(m) => memberPoles(m).includes(opts.pole) && m.id !== opts.actorId
)
if (recipients.length === 0) return
const rows = recipients.map((m) => ({
user_id: m.id,
project_id: opts.projectId,
kind: opts.kind,
title: opts.title,
body: opts.body,
entity_id: opts.entityId,
pole: opts.pole
}))
await supa().from('notifications').insert(rows)
}