From 339a883a1d30ae2af12aa12e343b6a6f5ce243b7 Mon Sep 17 00:00:00 2001 From: Corentin Mors Date: Mon, 4 Mar 2024 09:54:20 +0100 Subject: [PATCH] Sort enroll and manage fields --- website/src/app/page.tsx | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/website/src/app/page.tsx b/website/src/app/page.tsx index 8205dfe..d547d57 100644 --- a/website/src/app/page.tsx +++ b/website/src/app/page.tsx @@ -10,7 +10,7 @@ import dashlaneIcon from "../../public/dashlane.svg"; import enrollIcon from "../../public/enroll.svg"; import manageIcon from "../../public/manage.svg"; -type SortedField = "domain" | "name"; +type SortedField = "domain" | "name" | "enroll" | "manage"; const Page = () => { const [searchTerm, setSearchTerm] = useState(""); @@ -30,8 +30,8 @@ const Page = () => { const sortedData = sortedField ? [...filteredData].sort((a, b) => { - const fieldA = a[sortedField].toLowerCase(); - const fieldB = b[sortedField].toLowerCase(); + const fieldA = { ...a.endpoints, ...a }[sortedField].toLowerCase(); + const fieldB = { ...b.endpoints, ...b }[sortedField].toLowerCase(); if (fieldA < fieldB) return sortedAscending ? -1 : 1; if (fieldA > fieldB) return sortedAscending ? 1 : -1; @@ -86,7 +86,7 @@ const Page = () => { > Domain {sortedField === "domain" && ( - {sortedAscending ? "▲" : "▼"} + {sortedAscending ? "▼" : "▲"} )} { > Name {sortedField === "name" && ( - {sortedAscending ? "▲" : "▼"} + {sortedAscending ? "▼" : "▲"} )} Description - + sortData("enroll")} + > Enroll + {sortedField === "enroll" && ( + {sortedAscending ? "▼" : "▲"} + )} - + sortData("manage")} + > Manage + {sortedField === "manage" && ( + {sortedAscending ? "▼" : "▲"} + )}