Skip to content

Commit dfc8cf4

Browse files
committed
IIASA-fix-lead-naming-order
1 parent 3c789c2 commit dfc8cf4

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

client/src/containers/about-container/members-picture-module.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,26 @@ import Image from "next/image";
22
import { coChairs, otherPeople } from "@/lib/config/about/iiasa-members";
33

44
export const MembersPictureModule = () => {
5-
const getLastName = (name: string) => name.split(" ").at(-1) ?? name;
5+
const getLastName = (name: string) => {
6+
const parts = name.split(" ");
7+
// Handle prefixed surnames like "van Vuuren", "van Ruijven"
8+
const prefixes = ["van", "de", "von", "den", "der"];
9+
const prefixIndex = parts.findIndex((p) => prefixes.includes(p.toLowerCase()));
10+
if (prefixIndex > 0) {
11+
return parts.slice(prefixIndex).join(" ");
12+
}
13+
return parts.at(-1) ?? name;
14+
};
615

7-
const sortedOthers = [...otherPeople].sort((a, b) => {
8-
const aIsLead = !!a.role;
9-
const bIsLead = !!b.role;
10-
if (aIsLead !== bIsLead) return aIsLead ? -1 : 1;
11-
return getLastName(a.name).localeCompare(getLastName(b.name));
12-
});
16+
const leads = [...otherPeople]
17+
.filter((m) => !!m.role)
18+
.sort((a, b) => getLastName(a.name).localeCompare(getLastName(b.name)));
1319

14-
const members = [...coChairs, ...sortedOthers];
20+
const nonLeads = [...otherPeople]
21+
.filter((m) => !m.role)
22+
.sort((a, b) => getLastName(a.name).localeCompare(getLastName(b.name)));
23+
24+
const members = [...coChairs, ...leads, ...nonLeads];
1525

1626
return (
1727
<div className="content-container grid w-full grid-cols-2 flex-col gap-x-6 gap-y-10 sm:grid-cols-3 md:grid-cols-3 lg:grid-cols-5 xl:grid-cols-6">

client/src/lib/config/about/iiasa-members.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ export const otherPeople: IIASAMembers[] = [
185185
name: "Philipp Verpoort",
186186
initials: "PV",
187187
organization: "Potsdam Institute for Climate Impact Research",
188-
role: "Lead",
189188
group: "Energy Working Group",
190189
image: "/images/members/philipp_verpoort.webp",
191190
},

0 commit comments

Comments
 (0)