Skip to content

Commit

Permalink
fix: referenda
Browse files Browse the repository at this point in the history
  • Loading branch information
2nthony committed Apr 3, 2024
1 parent 61cceb9 commit 39fa9b1
Showing 1 changed file with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
import { useEffect, useState } from "react";
import Announcement from "./announcement";
import useRealAddress from "next-common/utils/hooks/useRealAddress";
import { AvatarContextProvider } from "next-common/context/avatar";
import nextApi from "next-common/services/nextApi";
import { delegationReferendaDelegatesAddressApi } from "next-common/services/url";
import ReferendaDelegateCard from "../../referenda/card";
import useRealAddress from "next-common/utils/hooks/useRealAddress";
import { useAsync } from "react-use";
import MemberCardListContainer from "../../common/cardListContainer";
import { AvatarContextProvider } from "next-common/context/avatar";
import ReferendaDelegateCard from "../../referenda/card";
import Announcement from "./announcement";

export default function ReferendaAnnouncement() {
const [data, setData] = useState();
const realAddress = useRealAddress();

useEffect(() => {
nextApi
const state = useAsync(async () => {
return await nextApi
.fetch(delegationReferendaDelegatesAddressApi(realAddress))
.then((resp) => {
if (resp.result) {
setData(resp.result);
return resp.result;
}
});
}, [realAddress]);

const addressAvatarMap = new Map([[data?.address, data?.manifesto?.image]]);
const addressAvatarMap = new Map([
[state.value?.address, state.value?.manifesto?.image],
]);

if (state.loading) {
return null;
}

if (data) {
if (state.value) {
return (
<AvatarContextProvider addressAvatarMap={addressAvatarMap}>
<MemberCardListContainer>
<ReferendaDelegateCard delegate={data} showDelegateButton={false} />
<ReferendaDelegateCard
delegate={state.value}
showDelegateButton={false}
/>
</MemberCardListContainer>
</AvatarContextProvider>
);
Expand Down

0 comments on commit 39fa9b1

Please sign in to comment.