Skip to content

Commit

Permalink
🐛 fix broken members dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
kk7-py committed Aug 20, 2024
1 parent 0bbb204 commit 9c31c75
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions next/components/header/header.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@
position: relative;
}
}

28 changes: 21 additions & 7 deletions next/components/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ import styles from "./header.module.css";
async function getHeaderData() {
const resData = await fetchStrapi("header", headerSchema);
const membersData = await fetchStrapi("member-teams", z.any());
const members = membersData.sort(
(a: any, b: any) => a.CommitteeYear - b.CommitteeYear,
);

// Ensure membersData is an array and sort in descending order
const members = Array.isArray(membersData)
? membersData
.map((item: any) => ({
...item,
CommitteeYear: Number(item.CommitteeYear), // Convert to number for sorting
}))
.sort((a, b) => b.CommitteeYear - a.CommitteeYear) // Sort in descending order
: []; // Default to an empty array if not an array

return {
...resData,
Expand Down Expand Up @@ -40,16 +47,23 @@ export default async function Header() {
<div className="group relative">
<Link
href={
data.members[0]
data.members.length > 0
? `/members/${data.members[0].CommitteeYear}`
: "/"
}
>
MEMBERS
</Link>
<div className="group-hover:flex hidden absolute top-full bg-white p-2 rounded-md items-center text-b-dark-blue">
{/* @ts-ignore */}
{data.members.map(({ CommitteeYear }) => (
<div
className="group-hover:flex hidden absolute top-full bg-white p-2 rounded-md items-center text-b-dark-blue"
style={{
flexDirection: "column", // Stack the years vertically
alignItems: "center", // Center the text horizontally
padding: "0.25rem 0.5rem", // Adjust padding to fit the text better
}}
>
{/* Render sorted members */}
{data.members.map(({ CommitteeYear }: { CommitteeYear: number }) => (
<Link href={`/members/${CommitteeYear}`} key={CommitteeYear}>
{CommitteeYear}
</Link>
Expand Down
Binary file modified strapi/.tmp/data.db
Binary file not shown.
Binary file added strapi/public/uploads/IMG_1421_59dd4f2cd3.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9c31c75

Please sign in to comment.