From 49f94f9edfc847cd23b5bd58800b974f78330276 Mon Sep 17 00:00:00 2001 From: timoclsn Date: Fri, 31 May 2024 20:45:14 +0200 Subject: [PATCH] Add getWebsiteMember Function --- lib/members.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/members.ts b/lib/members.ts index 5f9cf22..e2362ae 100644 --- a/lib/members.ts +++ b/lib/members.ts @@ -159,6 +159,21 @@ export const getWebsiteMembers = async (): Promise => { return websiteMembers; }; +export const getWebsiteMember = async (name: string) => { + const members = await getWebsiteMembers(); + + const member = members.find((member) => { + const fullname = `${member.firstName} ${member.familyName}`; + return fullname === name; + }); + + if (!member) { + throw new Error(`Member ${name} not found`); + } + + return member; +}; + export const getMembersCount = async () => { const result = await getActiveMembers(); return result.length;