Fix control order under a category
close #54 Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
@@ -154,12 +154,21 @@ function FrameworkOverviewPageContent({
|
|||||||
|
|
||||||
const controlCards = Object.entries(controlsByCategory)
|
const controlCards = Object.entries(controlsByCategory)
|
||||||
.sort(([categoryA], [categoryB]) => categoryA.localeCompare(categoryB))
|
.sort(([categoryA], [categoryB]) => categoryA.localeCompare(categoryB))
|
||||||
.map(([category, controls]) => ({
|
.map(([category, controls]) => {
|
||||||
title: category,
|
const sortedControls = [...controls].sort((a, b) => {
|
||||||
controls,
|
if (a?.state === "IMPLEMENTED" && b?.state !== "IMPLEMENTED") return -1;
|
||||||
completed: controls.filter((c) => c?.state === "IMPLEMENTED").length,
|
if (a?.state !== "IMPLEMENTED" && b?.state === "IMPLEMENTED") return 1;
|
||||||
total: controls.length,
|
|
||||||
}));
|
return (a?.name || "").localeCompare(b?.name || "");
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: category,
|
||||||
|
controls: sortedControls,
|
||||||
|
completed: controls.filter((c) => c?.state === "IMPLEMENTED").length,
|
||||||
|
total: controls.length,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
const totalImplemented = controls.filter(
|
const totalImplemented = controls.filter(
|
||||||
(c) => c?.state === "IMPLEMENTED"
|
(c) => c?.state === "IMPLEMENTED"
|
||||||
|
|||||||
Reference in New Issue
Block a user