Komunikator: sortowanie wg nieprzeczytanych/nazwy i grupowanie wg roli z zakładkami w topmenu (role w API rozmów)

This commit is contained in:
tisachi
2026-09-11 17:39:12 +02:00
parent 0ac6224a82
commit d211b092f2
10 changed files with 363 additions and 81 deletions

View File

@@ -25,7 +25,7 @@ export function createMessageRoutes({ prisma }: AppDeps) {
* @openapi
* /messages/conversations:
* get:
* summary: My ACTIVE coaching relations as conversations (last message + unread count)
* summary: My ACTIVE coaching relations as conversations (my role + last message + unread count)
* tags: [Messages]
* responses:
* 200: { description: OK }

View File

@@ -3,6 +3,8 @@ import { badRequest, notFound } from '../lib/errors.js';
export interface ConversationListItem {
coachingId: string;
/** Moja rola w relacji (odwrotna dla drugiej strony: podopieczny/trener). */
role: 'trainer' | 'trainee';
other: { id: string; firstName: string | null; lastName: string | null; nickname: string | null };
lastMessage: { body: string; createdAt: string; senderId: string } | null;
unreadCount: number;
@@ -65,6 +67,7 @@ export async function listConversations(prisma: PrismaClient, userId: string) {
const last = lastByCoaching.get(c.id) ?? null;
return {
coachingId: c.id,
role: c.trainerId === userId ? ('trainer' as const) : ('trainee' as const),
other: other
? { id: other.id, firstName: other.firstName, lastName: other.lastName, nickname: other.nickname }
: { id: otherId, firstName: null, lastName: null, nickname: null },