From 428ecf807b0c0e797010cbb49a205cec70077f97 Mon Sep 17 00:00:00 2001 From: chark1es Date: Fri, 15 Mar 2024 20:59:04 -0700 Subject: [PATCH] show officer based on selection --- src/components/react/OfficerCard.jsx | 23 +++++++++++++ src/components/react/OfficerTabs.jsx | 50 ++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 src/components/react/OfficerCard.jsx create mode 100644 src/components/react/OfficerTabs.jsx diff --git a/src/components/react/OfficerCard.jsx b/src/components/react/OfficerCard.jsx new file mode 100644 index 0000000..a6a53f0 --- /dev/null +++ b/src/components/react/OfficerCard.jsx @@ -0,0 +1,23 @@ +import React from "react"; + +const OfficerCard = ({ picture, name, position, email }) => ( +
+ {`Picture +
+

{name}

+

{position}

+ + {email} + +
+
+); + +export default OfficerCard; diff --git a/src/components/react/OfficerTabs.jsx b/src/components/react/OfficerTabs.jsx new file mode 100644 index 0000000..4f1138d --- /dev/null +++ b/src/components/react/OfficerTabs.jsx @@ -0,0 +1,50 @@ +import React, { useState } from "react"; +import OfficerCard from "./OfficerCard.jsx"; +import { AnimatePresence } from "framer-motion"; + +const OfficerTabs = ({ officers }) => { + const [selectedType, setSelectedType] = useState("All"); + + const uniqueTypes = [ + "All", + ...new Set(officers.flatMap((officer) => officer.type || [])), + ]; + + const filteredOfficers = + selectedType === "All" + ? officers + : officers.filter((officer) => + officer.type?.includes(selectedType) + ); + + return ( +
+
+ {uniqueTypes.map((type) => ( + + ))} +
+ +
+ {filteredOfficers.map((officer) => ( + + ))} +
+
+ ); +}; + +export default OfficerTabs;