From 0bf8530459b87ad420dd73117238bc3800917ec7 Mon Sep 17 00:00:00 2001 From: Ghayoor ul Haq Date: Thu, 30 May 2024 12:10:11 +0500 Subject: [PATCH] Ticket Label UI issues (#319) * Fix ticket status label in Edit label Dropdown + optimise code for dropdown * fix width for ticket status/label container so width dont change on changing label --- apps/client/pages/ticket/[id].tsx | 242 +++++++----------------------- 1 file changed, 52 insertions(+), 190 deletions(-) diff --git a/apps/client/pages/ticket/[id].tsx b/apps/client/pages/ticket/[id].tsx index b61c53672..999888531 100644 --- a/apps/client/pages/ticket/[id].tsx +++ b/apps/client/pages/ticket/[id].tsx @@ -30,6 +30,13 @@ function classNames(...classes: any) { return classes.filter(Boolean).join(" "); } +const ticketStatusMapping = { + needs_support: "Needs Support", + in_progress: "In Progress", + in_review: "In Review", + done: "Done", +}; + export default function Ticket() { const router = useRouter(); const { t } = useTranslation("peppermint"); @@ -456,18 +463,7 @@ export default function Ticket() { />
- {data.ticket.status === "needs_support" && ( - Needs Support - )} - {data.ticket.status === "in_progress" && ( - In Progress - )} - {data.ticket.status === "in_review" && ( - In Review - )} - {data.ticket.status === "done" && ( - Done - )} + {ticketStatusMapping[data.ticket.status]}
@@ -928,25 +924,14 @@ export default function Ticket() { />
- {data.ticket.status === "needs_support" && ( - Needs Support - )} - {data.ticket.status === "in_progress" && ( - In Progress - )} - {data.ticket.status === "in_review" && ( - In Review - )} - {data.ticket.status === "done" && ( - Done - )} + {ticketStatusMapping[data.ticket.status]}
)} ) : ( - <> +
{({ open }) => ( <> @@ -1110,8 +1095,8 @@ export default function Ticket() {
{ticketStatus - ? ticketStatus - : data.ticket.status} + ? ticketStatusMapping[ticketStatus] + : ticketStatusMapping[data.ticket.status]}
- - classNames( - active - ? "bg-indigo-600 text-white" - : "text-gray-900", - "relative cursor-default select-none py-2 pl-3 pr-9" - ) - } - value="needs_support" - > - {({ selected, active }) => ( - <> - - Needs Support - - - {selected ? ( - - - ) : null} - - )} - - - classNames( - active - ? "bg-indigo-600 text-white" - : "text-gray-900", - "relative cursor-default select-none py-2 pl-3 pr-9" - ) - } - value="in_progress" - > - {({ selected, active }) => ( - <> - - In Progress - - - {selected ? ( - - - ) : null} - - )} - - - classNames( - active - ? "bg-indigo-600 text-white" - : "text-gray-900", - "relative cursor-default select-none py-2 pl-3 pr-9" - ) - } - value="in_review" - > - {({ selected, active }) => ( - <> - - In Review - - - {selected ? ( + {Object.keys(ticketStatusMapping).map((status) => ( + + classNames( + active + ? "bg-indigo-600 text-white" + : "text-gray-900", + "relative cursor-default select-none py-2 pl-3 pr-9" + ) + } + value={status} + > + {({ selected, active }) => ( + <> - - ) : null} - - )} - - - classNames( - active - ? "bg-indigo-600 text-white" - : "text-gray-900", - "relative cursor-default select-none py-2 pl-3 pr-9" - ) - } - value="done" - > - {({ selected, active }) => ( - <> - - Done - - {selected ? ( - - - ) : null} - - )} - + {selected ? ( + + + ) : null} + + )} + + ))}
)} - + )}