notifications big

This commit is contained in:
alma 2026-01-11 22:45:06 +01:00
parent 95fc180d3c
commit f8a4b14a96
2 changed files with 26 additions and 7 deletions

View File

@ -1,6 +1,6 @@
import React, { memo, useState, useEffect } from 'react'; import React, { memo, useState, useEffect } from 'react';
import Link from 'next/link'; import Link from 'next/link';
import { Bell, Check, ExternalLink, AlertCircle, LogIn, Kanban } from 'lucide-react'; import { Bell, Check, ExternalLink, AlertCircle, LogIn, Kanban, MessageSquare } from 'lucide-react';
import { Badge } from '@/components/ui/badge'; import { Badge } from '@/components/ui/badge';
import { useNotifications } from '@/hooks/use-notifications'; import { useNotifications } from '@/hooks/use-notifications';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
@ -209,12 +209,20 @@ export const NotificationBadge = memo(function NotificationBadge({ className }:
Agilité Agilité
</Badge> </Badge>
)} )}
{notification.source === 'rocketchat' && (
<Badge variant="outline" className="ml-2 text-[10px] py-0 px-1.5 bg-blue-50 text-blue-700 border-blue-200 flex items-center">
<MessageSquare className="mr-1 h-2.5 w-2.5" />
Parole
</Badge>
)}
</div> </div>
<p className="text-xs text-muted-foreground"> <p className="text-xs text-muted-foreground">
{formatDistanceToNow(new Date(notification.timestamp), { addSuffix: true })} {formatDistanceToNow(new Date(notification.timestamp), { addSuffix: true })}
{notification.source && ( {notification.source && (
<span className="ml-1 opacity-75"> <span className="ml-1 opacity-75">
{notification.source === 'leantime' ? 'Leantime' : notification.source} {notification.source === 'leantime' ? 'Leantime' :
notification.source === 'rocketchat' ? 'Parole' :
notification.source}
</span> </span>
)} )}
</p> </p>

View File

@ -454,22 +454,33 @@ export class RocketChatAdapter implements NotificationAdapter {
if (subscription.t === 'd') roomTypePath = 'direct'; if (subscription.t === 'd') roomTypePath = 'direct';
else if (subscription.t === 'p') roomTypePath = 'group'; else if (subscription.t === 'p') roomTypePath = 'group';
// Format title similar to Leantime (simple and consistent)
const title = subscription.t === 'd'
? 'Message'
: subscription.t === 'p'
? 'Message de groupe'
: 'Message de canal';
// Format message with sender and room info
const senderName = messageUser.name || messageUser.username || 'Utilisateur';
const formattedMessage = subscription.t === 'd'
? `${senderName}: ${latestMessage.msg || ''}`
: `${senderName} dans ${roomName}: ${latestMessage.msg || ''}`;
const notification: Notification = { const notification: Notification = {
id: `rocketchat-${latestMessage._id}`, id: `rocketchat-${latestMessage._id}`,
source: 'rocketchat', source: 'rocketchat',
sourceId: latestMessage._id, sourceId: latestMessage._id,
type: 'message', type: 'message',
title: subscription.t === 'd' title: title,
? `Message de ${messageUser.name || messageUser.username || 'Utilisateur'}` message: formattedMessage,
: `${messageUser.name || messageUser.username || 'Utilisateur'} dans ${roomName}`,
message: latestMessage.msg || '',
link: `${this.baseUrl}/${roomTypePath}/${subscription.name}`, link: `${this.baseUrl}/${roomTypePath}/${subscription.name}`,
isRead: false, // All messages here are unread isRead: false, // All messages here are unread
timestamp: new Date(latestMessage.ts), timestamp: new Date(latestMessage.ts),
priority: subscription.alert ? 'high' : 'normal', priority: subscription.alert ? 'high' : 'normal',
user: { user: {
id: messageUser._id || '', id: messageUser._id || '',
name: messageUser.name || messageUser.username || 'Utilisateur', name: senderName,
}, },
metadata: { metadata: {
roomId: subscription.rid, roomId: subscription.rid,