Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

107 Broken Members Dropdown #115

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions next/components/header/header.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
letter-spacing: 1px;
}

.nav a:last-child {
border: 1px solid white;
border-radius: 999px;
padding: 0.25rem 1rem;
}

@media (max-width: 800px) {
.header {
flex-direction: column;
Expand All @@ -37,3 +31,4 @@
position: relative;
}
}

37 changes: 26 additions & 11 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,20 +47,28 @@ 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 }) => (
<Link href={`/members/${CommitteeYear}`} key={CommitteeYear}>
{CommitteeYear}
</Link>
))}
<div
className="group-hover:flex hidden absolute top-full bg-white p-2 rounded-md items-center text-b-dark-blue flex-col py-1 px-2">
{/* align years vertically */}
{/* Render sorted members */}
{data.members.map(
({ CommitteeYear }: { CommitteeYear: number }) => (
<Link
href={`/members/${CommitteeYear}`}
key={CommitteeYear}
className="my-1 min-w-16 text-center"
>
{CommitteeYear}
</Link>
),
)}
</div>
</div>

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.
Loading