feat: unanswered ticket badges, dashboard counts, cross-department ticket creation

- Add /tickets/unanswered-counts API endpoint for staff/admin
- Show red badge with unanswered count on sidebar nav (staff tickets, admin tickets)
- Add summary cards (unanswered/answered/total) to staff tickets page
- Highlight unanswered count in admin tickets stats cards
- Staff can create tickets to OTHER departments only (not their own)
- Frontend hides own department from ticket creation dropdown
- Sidebar badges auto-refresh every 30 seconds
This commit is contained in:
keyhan
2026-04-06 13:55:15 +03:30
parent a1dbd0a85f
commit a64f8407b9
6 changed files with 123 additions and 23 deletions
+13
View File
@@ -119,6 +119,19 @@ export class TicketsService {
await this.ticketsRepo.update(ticketId, data);
}
// ─── Unanswered ticket counts ───
async getUnansweredCounts(): Promise<{ technical: number; sales: number; total: number }> {
const unanswered = await this.ticketsRepo.find({
where: [
{ status: TicketStatus.OPEN },
{ status: TicketStatus.WAITING },
],
});
const technical = unanswered.filter((t) => t.department === TicketDepartment.TECHNICAL).length;
const sales = unanswered.filter((t) => t.department === TicketDepartment.SALES).length;
return { technical, sales, total: technical + sales };
}
// ─── Staff: List department tickets ───
async findByDepartment(department: TicketDepartment, status?: TicketStatus): Promise<Ticket[]> {
const where: any = { department };