Skip to content

Commit

Permalink
fix: democracy
Browse files Browse the repository at this point in the history
  • Loading branch information
2nthony committed Apr 3, 2024
1 parent 39fa9b1 commit 8e51225
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,40 @@ import { AvatarContextProvider } from "next-common/context/avatar";
import nextApi from "next-common/services/nextApi";
import { delegationDemocracyDelegatesAddressApi } from "next-common/services/url";
import useRealAddress from "next-common/utils/hooks/useRealAddress";
import { useEffect, useState } from "react";
import { useAsync } from "react-use";
import MemberCardListContainer from "../../common/cardListContainer";
import DemocracyDelegateCard from "../../democracy/card";
import Announcement from "./announcement";

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

useEffect(() => {
nextApi
const state = useAsync(async () => {
return await nextApi
.fetch(delegationDemocracyDelegatesAddressApi(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 (data) {
if (state.loading) {
return null;
}

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

0 comments on commit 8e51225

Please sign in to comment.