diff --git a/pages/dao/[symbol]/proposal/components/instructions/SplGov/RevokeGoverningTokens.tsx b/pages/dao/[symbol]/proposal/components/instructions/SplGov/RevokeGoverningTokens.tsx index 77b029d4..0e01915a 100644 --- a/pages/dao/[symbol]/proposal/components/instructions/SplGov/RevokeGoverningTokens.tsx +++ b/pages/dao/[symbol]/proposal/components/instructions/SplGov/RevokeGoverningTokens.tsx @@ -82,23 +82,8 @@ const RevokeGoverningTokens: FC<{ } }, [query]) - // If there's only one membership type, we can just select that for the user. - // @asktree style note: I create a new variable rather than using `setForm` here because I don't like side effects - const selectedMembershipType = useMemo( - () => - form.membershipPopulation ?? Object.keys(membershipTypes).length === 1 - ? Object.keys(membershipTypes)[0] - : undefined, - [form.membershipPopulation, membershipTypes] - ) - - const selectedMint = useMemo( - () => - selectedMembershipType === undefined - ? undefined - : (membershipTypes[selectedMembershipType] as PublicKey | undefined), - [membershipTypes, selectedMembershipType] - ) + const [selectedMint, setSelectedMint] = useState(undefined) + const [selectedMembershipType, setSelectedMembershipType] = useState(undefined) const { data: mintInfo } = useMintInfoByPubkeyQuery(selectedMint) const governance = useGovernanceForGovernedAddress(selectedMint) @@ -228,6 +213,14 @@ const RevokeGoverningTokens: FC<{ [connection] ) + const updateMembershipType = (x: "council" | "community" | undefined) => { + setForm((p) => ({ ...p, membershipPopulation: x })) + setSelectedMembershipType(x) + if (x) { + setSelectedMint(membershipTypes[x]) + } + } + return ( <> setForm((p) => ({ ...p, membershipPopulation: x }))} + onChange={(x) => updateMembershipType(x)} > {Object.keys(membershipTypes).map((x) => (