From b94f197dee1a8b806ad97ff7db37716ba58da332 Mon Sep 17 00:00:00 2001 From: mertbagt Date: Mon, 8 Jun 2026 22:48:47 -0400 Subject: [PATCH 01/10] add form --- components/legislator/LegislatorPage.tsx | 2 +- .../SidebarComponents/Biography.tsx | 132 +++++++++++++++++- .../SidebarComponents/LegislatorSidebar.tsx | 4 +- public/locales/en/legislators.json | 1 + 4 files changed, 134 insertions(+), 5 deletions(-) diff --git a/components/legislator/LegislatorPage.tsx b/components/legislator/LegislatorPage.tsx index 35f2b5251..4b1111815 100644 --- a/components/legislator/LegislatorPage.tsx +++ b/components/legislator/LegislatorPage.tsx @@ -120,7 +120,7 @@ export function LegislatorPage(props: { id: string }) { - + diff --git a/components/legislator/SidebarComponents/Biography.tsx b/components/legislator/SidebarComponents/Biography.tsx index 90cf3f5e0..5988943cc 100644 --- a/components/legislator/SidebarComponents/Biography.tsx +++ b/components/legislator/SidebarComponents/Biography.tsx @@ -1,3 +1,131 @@ -export function Biography() { - return
- Biography
+import { useTranslation } from "next-i18next" +import { useEffect, useState } from "react" +import { useForm } from "react-hook-form" +import styled from "styled-components" + +import { Form, Row, Spinner } from "../../bootstrap" +import { Profile, useProfile } from "../../db" +import Input from "../../forms/Input" + +import { useAuth } from "components/auth" + +type UpdateProfileData = { + legislatorBio: string +} + +export function Biography({ pageId }: { pageId: string }) { + const { user } = useAuth() + const uid = user?.uid + // `useProfile` needs to be replaced with a function that uses the pageId + // instead of the current user's id + const result = useProfile() + + let pageOwner = false + + if (uid === pageId) { + pageOwner = true + } + + if (result.loading) { + return ( + + + + ) + } + + if (result?.profile && pageOwner) { + // the user is the legislator whose page this is + // therefore they get edit privledges + return + } + + // the user is not the legislator whose page this is + // therefore they get read-only privledges + return +} + +function LegislatorBiography() { + return
Sample Biography
+} + +const BioBlock = styled.div` + background-color: white; + border: "1px #ced4da solid"; + border-radius: 5px; + margin-top: 8px; + padding: 8px 16px; +` + +const BioButton = styled.button` + font-size: 11px; +` + +const BioTitle = styled.div` + font-size: 11px; + font-weight: 700; + color: #0b0a3e; + text-transform: uppercase; + letter-spacing: 0.05em; + margin-bottom: 10px; +` + +function SelfBiography({ + pageId, + profile +}: { + pageId: string + profile: Profile +}) { + const { + register, + formState: { errors, isDirty }, + handleSubmit + } = useForm() + + // `about` should be replaced with a property along the lines of legislatorBio + // or whatever is appropriate + const { about }: Profile = profile + + const onSubmit = handleSubmit(async update => { + // await updateProfile({ actions }, update) + location.assign(`/legislators/profile?id=${pageId}`) + setFormUpdated(false) + }) + + const { t } = useTranslation("legislators") + const [formUpdated, setFormUpdated] = useState(false) + + useEffect(() => { + setFormUpdated(isDirty) + }, [isDirty, setFormUpdated]) + + return ( + +
+
+ + Biography + + + Submit + +
+ +
+
+ ) } diff --git a/components/legislator/SidebarComponents/LegislatorSidebar.tsx b/components/legislator/SidebarComponents/LegislatorSidebar.tsx index 39f77168e..0b568bfab 100644 --- a/components/legislator/SidebarComponents/LegislatorSidebar.tsx +++ b/components/legislator/SidebarComponents/LegislatorSidebar.tsx @@ -2,13 +2,13 @@ import { Biography } from "./Biography" import { OtherTestimony } from "./OtherTestimony" import { UpcomingHearings } from "./UpcomingHearings" -export function LegislatorSidebar() { +export function LegislatorSidebar({ pageId }: { pageId: string }) { return ( <> Sidebar Components - + ) } diff --git a/public/locales/en/legislators.json b/public/locales/en/legislators.json index 4974cfc9d..6f6ab2958 100644 --- a/public/locales/en/legislators.json +++ b/public/locales/en/legislators.json @@ -1,6 +1,7 @@ { "billsSponsored": "Bills Sponsored", "cosponsored": "Cosponsored", + "editBio": "Edit your biography", "fundsRaised": "Funds Raised", "home": "Home", "legislators": "Legislators", From 66d56315fe308a35af80cea94fcc6c4f4a6f7da9 Mon Sep 17 00:00:00 2001 From: mertbagt Date: Mon, 8 Jun 2026 23:17:19 -0400 Subject: [PATCH 02/10] read-only alternate display component --- .../SidebarComponents/Biography.tsx | 75 +++++++++++-------- public/locales/en/legislators.json | 2 + 2 files changed, 47 insertions(+), 30 deletions(-) diff --git a/components/legislator/SidebarComponents/Biography.tsx b/components/legislator/SidebarComponents/Biography.tsx index 5988943cc..df2ca3f77 100644 --- a/components/legislator/SidebarComponents/Biography.tsx +++ b/components/legislator/SidebarComponents/Biography.tsx @@ -13,11 +13,33 @@ type UpdateProfileData = { legislatorBio: string } +const BioBlock = styled.div` + background-color: white; + border: "1px #ced4da solid"; + border-radius: 5px; + margin-top: 8px; + padding: 8px 16px; +` + +const BioButton = styled.button` + font-size: 11px; +` + +const BioTitle = styled.div` + font-size: 11px; + font-weight: 700; + color: #0b0a3e; + text-transform: uppercase; + letter-spacing: 0.05em; + margin-bottom: 10px; +` + export function Biography({ pageId }: { pageId: string }) { const { user } = useAuth() const uid = user?.uid - // `useProfile` needs to be replaced with a function that uses the pageId - // instead of the current user's id + // `useProfile` ought to be replaced with a function that uses the pageId + // instead of the current user's id but not strictly neccessary + // since the display conditions should only occur when (pageOwner = true) const result = useProfile() let pageOwner = false @@ -40,35 +62,28 @@ export function Biography({ pageId }: { pageId: string }) { return } - // the user is not the legislator whose page this is - // therefore they get read-only privledges - return -} - -function LegislatorBiography() { - return
Sample Biography
+ if (result?.profile) { + // the user is not the legislator whose page this is + // therefore they get read-only privledges + return + } } -const BioBlock = styled.div` - background-color: white; - border: "1px #ced4da solid"; - border-radius: 5px; - margin-top: 8px; - padding: 8px 16px; -` - -const BioButton = styled.button` - font-size: 11px; -` +function LegislatorBiography({ profile }: { profile: Profile }) { + // `about` should be replaced with a property along the lines of legislatorBio + // or whatever is appropriate + const { about }: Profile = profile + const { t } = useTranslation("legislators") -const BioTitle = styled.div` - font-size: 11px; - font-weight: 700; - color: #0b0a3e; - text-transform: uppercase; - letter-spacing: 0.05em; - margin-bottom: 10px; -` + return ( + + {t("biography")} + {/* `about` should be replaced with a property along the lines of * + * legislatorBio // or whatever is appropriate */} +
{about}
+
+ ) +} function SelfBiography({ pageId, @@ -105,14 +120,14 @@ function SelfBiography({
- Biography + {t("biography")} - Submit + {t("submit")}
Date: Mon, 8 Jun 2026 23:21:19 -0400 Subject: [PATCH 03/10] cleanup --- .../SidebarComponents/Biography.tsx | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/components/legislator/SidebarComponents/Biography.tsx b/components/legislator/SidebarComponents/Biography.tsx index df2ca3f77..86aa11899 100644 --- a/components/legislator/SidebarComponents/Biography.tsx +++ b/components/legislator/SidebarComponents/Biography.tsx @@ -37,9 +37,8 @@ const BioTitle = styled.div` export function Biography({ pageId }: { pageId: string }) { const { user } = useAuth() const uid = user?.uid - // `useProfile` ought to be replaced with a function that uses the pageId - // instead of the current user's id but not strictly neccessary - // since the display conditions should only occur when (pageOwner = true) + // `useProfile` needs to be replaced with a function that uses + // the pageId instead of the current user's id const result = useProfile() let pageOwner = false @@ -70,16 +69,16 @@ export function Biography({ pageId }: { pageId: string }) { } function LegislatorBiography({ profile }: { profile: Profile }) { - // `about` should be replaced with a property along the lines of legislatorBio - // or whatever is appropriate + // `about` should be replaced with a property such as + // legislatorBio or whatever is appropriate const { about }: Profile = profile const { t } = useTranslation("legislators") return ( {t("biography")} - {/* `about` should be replaced with a property along the lines of * - * legislatorBio // or whatever is appropriate */} + {/* `about` should be replaced with a property such as * + * legislatorBio or whatever is appropriate */}
{about}
) @@ -98,8 +97,8 @@ function SelfBiography({ handleSubmit } = useForm() - // `about` should be replaced with a property along the lines of legislatorBio - // or whatever is appropriate + // `about` should be replaced with a property such as + // legislatorBio or whatever is appropriate const { about }: Profile = profile const onSubmit = handleSubmit(async update => { @@ -136,8 +135,8 @@ function SelfBiography({ style={{ height: "10rem" }} className="mt-3" label={t("editBio")} - // `about` should be replaced with a property along the lines of legislatorBio - // or whatever is appropriate + // `about` should be replaced with a property such as + // legislatorBio or whatever is appropriate defaultValue={about} /> From b746049864730a9be6aca129a478784078c04ce1 Mon Sep 17 00:00:00 2001 From: mertbagt Date: Tue, 9 Jun 2026 15:31:13 -0400 Subject: [PATCH 04/10] usePublicProfile is a thing and it's great --- .../EditProfilePage/PersonalInfoTab.tsx | 4 +- components/db/profile/urlCleanup.ts | 2 +- components/legislator/LegislatorPage.tsx | 2 +- .../SidebarComponents/Biography.tsx | 52 ++++++++++--------- .../SidebarComponents/LegislatorSidebar.tsx | 11 +++- 5 files changed, 41 insertions(+), 30 deletions(-) diff --git a/components/EditProfilePage/PersonalInfoTab.tsx b/components/EditProfilePage/PersonalInfoTab.tsx index b6d70364c..111aa5038 100644 --- a/components/EditProfilePage/PersonalInfoTab.tsx +++ b/components/EditProfilePage/PersonalInfoTab.tsx @@ -10,7 +10,7 @@ import { TooltipButton } from "components/buttons" import { useTranslation } from "next-i18next" import styled from "styled-components" -type UpdateProfileData = { +export type UpdateProfileData = { fullName: string aboutYou: string twitter: string @@ -37,7 +37,7 @@ type Props = { legislatorsProps?: YourLegislatorsProps } -async function updateProfile( +export async function updateProfile( { profile, actions, uid }: Props, data: UpdateProfileData ) { diff --git a/components/db/profile/urlCleanup.ts b/components/db/profile/urlCleanup.ts index 26d09b13a..f2fe17e5c 100644 --- a/components/db/profile/urlCleanup.ts +++ b/components/db/profile/urlCleanup.ts @@ -7,7 +7,7 @@ export function cleanSocialLinks(network: keyof SocialLinks, link: string) { const index: number = path.indexOf(".com/") + 5 path = path.substring(index) } - if (network === "mastodon" && path.startsWith("@")) { + if (path && network === "mastodon" && path.startsWith("@")) { path = path.substring(1) } } diff --git a/components/legislator/LegislatorPage.tsx b/components/legislator/LegislatorPage.tsx index 4b1111815..562cc0ca3 100644 --- a/components/legislator/LegislatorPage.tsx +++ b/components/legislator/LegislatorPage.tsx @@ -120,7 +120,7 @@ export function LegislatorPage(props: { id: string }) { - + diff --git a/components/legislator/SidebarComponents/Biography.tsx b/components/legislator/SidebarComponents/Biography.tsx index 86aa11899..aaf37b0c6 100644 --- a/components/legislator/SidebarComponents/Biography.tsx +++ b/components/legislator/SidebarComponents/Biography.tsx @@ -4,14 +4,14 @@ import { useForm } from "react-hook-form" import styled from "styled-components" import { Form, Row, Spinner } from "../../bootstrap" -import { Profile, useProfile } from "../../db" +import { Profile, ProfileHook, useProfile } from "../../db" import Input from "../../forms/Input" import { useAuth } from "components/auth" - -type UpdateProfileData = { - legislatorBio: string -} +import { + updateProfile, + UpdateProfileData +} from "components/EditProfilePage/PersonalInfoTab" const BioBlock = styled.div` background-color: white; @@ -34,12 +34,16 @@ const BioTitle = styled.div` margin-bottom: 10px; ` -export function Biography({ pageId }: { pageId: string }) { +export function Biography({ + pageId, + publicProfile +}: { + pageId: string + publicProfile: Profile | undefined +}) { const { user } = useAuth() const uid = user?.uid - // `useProfile` needs to be replaced with a function that uses - // the pageId instead of the current user's id - const result = useProfile() + const pageOwnerResult = useProfile() let pageOwner = false @@ -47,7 +51,7 @@ export function Biography({ pageId }: { pageId: string }) { pageOwner = true } - if (result.loading) { + if (pageOwnerResult.loading) { return ( @@ -55,39 +59,43 @@ export function Biography({ pageId }: { pageId: string }) { ) } - if (result?.profile && pageOwner) { + if (pageOwnerResult.profile && pageOwner) { // the user is the legislator whose page this is // therefore they get edit privledges - return + return ( + + ) } - if (result?.profile) { + if (publicProfile) { // the user is not the legislator whose page this is // therefore they get read-only privledges - return + return } } function LegislatorBiography({ profile }: { profile: Profile }) { - // `about` should be replaced with a property such as - // legislatorBio or whatever is appropriate const { about }: Profile = profile const { t } = useTranslation("legislators") return ( {t("biography")} - {/* `about` should be replaced with a property such as * - * legislatorBio or whatever is appropriate */}
{about}
) } function SelfBiography({ + actions, pageId, profile }: { + actions: ProfileHook pageId: string profile: Profile }) { @@ -97,12 +105,10 @@ function SelfBiography({ handleSubmit } = useForm() - // `about` should be replaced with a property such as - // legislatorBio or whatever is appropriate const { about }: Profile = profile const onSubmit = handleSubmit(async update => { - // await updateProfile({ actions }, update) + await updateProfile({ profile, actions }, update) location.assign(`/legislators/profile?id=${pageId}`) setFormUpdated(false) }) @@ -131,12 +137,10 @@ function SelfBiography({ diff --git a/components/legislator/SidebarComponents/LegislatorSidebar.tsx b/components/legislator/SidebarComponents/LegislatorSidebar.tsx index 0b568bfab..32094bc51 100644 --- a/components/legislator/SidebarComponents/LegislatorSidebar.tsx +++ b/components/legislator/SidebarComponents/LegislatorSidebar.tsx @@ -1,14 +1,21 @@ import { Biography } from "./Biography" import { OtherTestimony } from "./OtherTestimony" import { UpcomingHearings } from "./UpcomingHearings" +import { Profile } from "../../db" -export function LegislatorSidebar({ pageId }: { pageId: string }) { +export function LegislatorSidebar({ + pageId, + publicProfile +}: { + pageId: string + publicProfile: Profile | undefined +}) { return ( <> Sidebar Components - + ) } From d50341110a29ba6f4a2cf4708ec3e818799506d0 Mon Sep 17 00:00:00 2001 From: mertbagt Date: Tue, 9 Jun 2026 16:13:50 -0400 Subject: [PATCH 05/10] not claimed state added --- components/legislator/SidebarComponents/Biography.tsx | 6 +++++- public/locales/en/legislators.json | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/components/legislator/SidebarComponents/Biography.tsx b/components/legislator/SidebarComponents/Biography.tsx index aaf37b0c6..1292824fc 100644 --- a/components/legislator/SidebarComponents/Biography.tsx +++ b/components/legislator/SidebarComponents/Biography.tsx @@ -85,7 +85,11 @@ function LegislatorBiography({ profile }: { profile: Profile }) { return ( {t("biography")} -
{about}
+ {!about ? ( +
{about}
+ ) : ( +
{t("notClaimed")}
+ )}
) } diff --git a/public/locales/en/legislators.json b/public/locales/en/legislators.json index 57f3420f8..5e3569e64 100644 --- a/public/locales/en/legislators.json +++ b/public/locales/en/legislators.json @@ -6,6 +6,7 @@ "fundsRaised": "Funds Raised", "home": "Home", "legislators": "Legislators", + "notClaimed": "This legislator has not claimed their MAPLE account", "submit": "Submit", "tabs": { "bills": "Bills", From 549a617bade46d0bade7e40a141b296b4ee0bde9 Mon Sep 17 00:00:00 2001 From: mertbagt Date: Tue, 9 Jun 2026 16:20:56 -0400 Subject: [PATCH 06/10] font size tweaks --- components/legislator/SidebarComponents/Biography.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/legislator/SidebarComponents/Biography.tsx b/components/legislator/SidebarComponents/Biography.tsx index 1292824fc..4186962b7 100644 --- a/components/legislator/SidebarComponents/Biography.tsx +++ b/components/legislator/SidebarComponents/Biography.tsx @@ -17,16 +17,17 @@ const BioBlock = styled.div` background-color: white; border: "1px #ced4da solid"; border-radius: 5px; + font-size: 11px; margin-top: 8px; padding: 8px 16px; ` const BioButton = styled.button` - font-size: 11px; + font-size: 9px; + padding: 2px; ` const BioTitle = styled.div` - font-size: 11px; font-weight: 700; color: #0b0a3e; text-transform: uppercase; @@ -85,7 +86,7 @@ function LegislatorBiography({ profile }: { profile: Profile }) { return ( {t("biography")} - {!about ? ( + {about ? (
{about}
) : (
{t("notClaimed")}
@@ -133,7 +134,7 @@ function SelfBiography({ {t("submit")} @@ -142,7 +143,7 @@ function SelfBiography({ Date: Tue, 9 Jun 2026 16:35:11 -0400 Subject: [PATCH 07/10] cleanup --- components/legislator/SidebarComponents/Biography.tsx | 8 ++++---- .../legislator/SidebarComponents/LegislatorSidebar.tsx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/legislator/SidebarComponents/Biography.tsx b/components/legislator/SidebarComponents/Biography.tsx index 4186962b7..d02cb84f9 100644 --- a/components/legislator/SidebarComponents/Biography.tsx +++ b/components/legislator/SidebarComponents/Biography.tsx @@ -64,7 +64,7 @@ export function Biography({ // the user is the legislator whose page this is // therefore they get edit privledges return ( - + return } } -function LegislatorBiography({ profile }: { profile: Profile }) { +function ReadonlyBiography({ profile }: { profile: Profile }) { const { about }: Profile = profile const { t } = useTranslation("legislators") @@ -95,7 +95,7 @@ function LegislatorBiography({ profile }: { profile: Profile }) { ) } -function SelfBiography({ +function EditableBiography({ actions, pageId, profile diff --git a/components/legislator/SidebarComponents/LegislatorSidebar.tsx b/components/legislator/SidebarComponents/LegislatorSidebar.tsx index 32094bc51..b4fc1eda4 100644 --- a/components/legislator/SidebarComponents/LegislatorSidebar.tsx +++ b/components/legislator/SidebarComponents/LegislatorSidebar.tsx @@ -1,7 +1,7 @@ +import { Profile } from "../../db" import { Biography } from "./Biography" import { OtherTestimony } from "./OtherTestimony" import { UpcomingHearings } from "./UpcomingHearings" -import { Profile } from "../../db" export function LegislatorSidebar({ pageId, From a81e21c3e0448b68d861cfcdfa4ab7438f6d3718 Mon Sep 17 00:00:00 2001 From: mertbagt Date: Tue, 9 Jun 2026 16:36:28 -0400 Subject: [PATCH 08/10] polish --- components/legislator/SidebarComponents/LegislatorSidebar.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/components/legislator/SidebarComponents/LegislatorSidebar.tsx b/components/legislator/SidebarComponents/LegislatorSidebar.tsx index b4fc1eda4..e9ca0994a 100644 --- a/components/legislator/SidebarComponents/LegislatorSidebar.tsx +++ b/components/legislator/SidebarComponents/LegislatorSidebar.tsx @@ -12,7 +12,6 @@ export function LegislatorSidebar({ }) { return ( <> - Sidebar Components From 1882781fe1f8484bd3522a46bd8903ee4885ab30 Mon Sep 17 00:00:00 2001 From: mertbagt Date: Tue, 9 Jun 2026 16:47:41 -0400 Subject: [PATCH 09/10] ocd --- .../SidebarComponents/Biography.tsx | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/components/legislator/SidebarComponents/Biography.tsx b/components/legislator/SidebarComponents/Biography.tsx index d02cb84f9..fec5daa92 100644 --- a/components/legislator/SidebarComponents/Biography.tsx +++ b/components/legislator/SidebarComponents/Biography.tsx @@ -79,22 +79,6 @@ export function Biography({ } } -function ReadonlyBiography({ profile }: { profile: Profile }) { - const { about }: Profile = profile - const { t } = useTranslation("legislators") - - return ( - - {t("biography")} - {about ? ( -
{about}
- ) : ( -
{t("notClaimed")}
- )} -
- ) -} - function EditableBiography({ actions, pageId, @@ -152,3 +136,19 @@ function EditableBiography({
) } + +function ReadonlyBiography({ profile }: { profile: Profile }) { + const { about }: Profile = profile + const { t } = useTranslation("legislators") + + return ( + + {t("biography")} + {about ? ( +
{about}
+ ) : ( +
{t("notClaimed")}
+ )} +
+ ) +} From b32e7ce7ee8f6a7062770434bc992fc64007f07d Mon Sep 17 00:00:00 2001 From: mertbagt Date: Tue, 9 Jun 2026 17:49:10 -0400 Subject: [PATCH 10/10] add you bio message for legislators --- components/legislator/SidebarComponents/Biography.tsx | 10 ++++------ public/locales/en/legislators.json | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/components/legislator/SidebarComponents/Biography.tsx b/components/legislator/SidebarComponents/Biography.tsx index fec5daa92..32e4e6440 100644 --- a/components/legislator/SidebarComponents/Biography.tsx +++ b/components/legislator/SidebarComponents/Biography.tsx @@ -130,7 +130,7 @@ function EditableBiography({ style={{ fontSize: "11px", height: "10rem" }} className="mt-3" label={t("editBio")} - defaultValue={about} + defaultValue={about ? about : t("addBio")} /> @@ -144,11 +144,9 @@ function ReadonlyBiography({ profile }: { profile: Profile }) { return ( {t("biography")} - {about ? ( -
{about}
- ) : ( -
{t("notClaimed")}
- )} +
+ {about ? about : t("notClaimed")} +
) } diff --git a/public/locales/en/legislators.json b/public/locales/en/legislators.json index 5e3569e64..1c3ac5397 100644 --- a/public/locales/en/legislators.json +++ b/public/locales/en/legislators.json @@ -1,4 +1,5 @@ { + "addBio": "Add your biography", "billsSponsored": "Bills Sponsored", "biography": "Biography", "cosponsored": "Cosponsored",