show officer based on selection
This commit is contained in:
parent
b546a48905
commit
428ecf807b
2 changed files with 73 additions and 0 deletions
23
src/components/react/OfficerCard.jsx
Normal file
23
src/components/react/OfficerCard.jsx
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const OfficerCard = ({ picture, name, position, email }) => (
|
||||||
|
<div className={`flex flex-col items-center w-64 rounded-lg `}>
|
||||||
|
<img
|
||||||
|
className="w-26 h-auto sm:h-64 object-cover rounded-3xl"
|
||||||
|
src={picture}
|
||||||
|
alt={`Picture of ${name}`}
|
||||||
|
/>
|
||||||
|
<div className="p-4">
|
||||||
|
<h3 className="text-lg font-bold text-center">{name}</h3>
|
||||||
|
<p className="text-center text-sm text-gray-600">{position}</p>
|
||||||
|
<a
|
||||||
|
href={`mailto:${email}`}
|
||||||
|
className="block text-center mt-2 text-sm text-blue-500 hover:underline"
|
||||||
|
>
|
||||||
|
{email}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default OfficerCard;
|
50
src/components/react/OfficerTabs.jsx
Normal file
50
src/components/react/OfficerTabs.jsx
Normal file
|
@ -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 (
|
||||||
|
<div>
|
||||||
|
<div className="tabs flex justify-center items-center">
|
||||||
|
{uniqueTypes.map((type) => (
|
||||||
|
<button
|
||||||
|
key={type}
|
||||||
|
onClick={() => setSelectedType(type)}
|
||||||
|
className={`px-5 py-1 border-b-2 ${
|
||||||
|
selectedType === type
|
||||||
|
? "border-ieee"
|
||||||
|
: "hover:border-ieee"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{type}
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
key={selectedType}
|
||||||
|
className="officers flex-row flex flex-wrap items-center justify-center space-x-16 p-12"
|
||||||
|
>
|
||||||
|
{filteredOfficers.map((officer) => (
|
||||||
|
<OfficerCard key={officer.email} {...officer} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default OfficerTabs;
|
Loading…
Reference in a new issue