From 148762279e9f7dbce904e0ba17e323c31d1f0e5c Mon Sep 17 00:00:00 2001 From: Destroyer795 Date: Thu, 12 Mar 2026 03:08:20 +0530 Subject: [PATCH] Add expandable Support Tickets UI and admin replies --- .../src/pages/dashboard/SupportTickets.tsx | 98 +++++++++++++++---- 1 file changed, 77 insertions(+), 21 deletions(-) diff --git a/frontend/src/pages/dashboard/SupportTickets.tsx b/frontend/src/pages/dashboard/SupportTickets.tsx index 03802b1..aa03c2e 100644 --- a/frontend/src/pages/dashboard/SupportTickets.tsx +++ b/frontend/src/pages/dashboard/SupportTickets.tsx @@ -25,6 +25,8 @@ export default function SupportTickets() { const [description, setDescription] = useState('') const [priority, setPriority] = useState<'LOW' | 'MEDIUM' | 'HIGH'>('MEDIUM') const [submitting, setSubmitting] = useState(false) + const [expandedId, setExpandedId] = useState(null) + const [replyText, setReplyText] = useState('') const load = useCallback(async () => { setLoading(true) @@ -69,11 +71,18 @@ export default function SupportTickets() { } } - const advanceStatus = async (ticket: Ticket) => { + const advanceStatus = async (ticket: Ticket, note?: string) => { const next = ticket.status === 'OPEN' ? 'IN_PROGRESS' : 'RESOLVED' + const payload: { status: string; adminNote?: string } = { status: next } + if (note) payload.adminNote = note + try { - await adminAPI.updateTicket(ticket.id, { status: next }) + await adminAPI.updateTicket(ticket.id, payload) toast.success(`Ticket moved to ${next.replace('_', ' ').toLowerCase()}`) + if (next === 'RESOLVED') { + setExpandedId(null) + setReplyText('') + } load() } catch { toast.error(t('failedUpdateTicket')) @@ -156,27 +165,74 @@ export default function SupportTickets() {
{t('noTicketsYet')}
) : (
- {tickets.map((ticket) => ( -
-
-
-

{ticket.subject}

-

{ticket.description}

-

{new Date(ticket.createdAt).toLocaleDateString()} · {ticket.priority}

-
-
- - {ticket.status.replace('_', ' ')} - - {isAdmin && ticket.status !== 'RESOLVED' && ticket.status !== 'CLOSED' && ( - - )} + {tickets.map((ticket) => { + const isExpanded = expandedId === ticket.id + return ( +
+
{ + setExpandedId(isExpanded ? null : ticket.id) + if (!isExpanded) setReplyText('') + }} + > +
+

{ticket.subject}

+ {!isExpanded && ( +

{ticket.description}

+ )} +

{new Date(ticket.createdAt).toLocaleDateString()} · {ticket.priority}

+
+
+ + {ticket.status.replace('_', ' ')} + +
+ + {isExpanded && ( +
+

Description

+

{ticket.description}

+ + {ticket.adminNote && ( +
+

Admin Reply

+

{ticket.adminNote}

+
+ )} + + {isAdmin && ticket.status !== 'RESOLVED' && ticket.status !== 'CLOSED' && ( +
+ {ticket.status === 'IN_PROGRESS' && ( +