Skip to content

Commit

Permalink
post PR tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
tplocic20 committed Jan 10, 2024
1 parent 59c94e8 commit 63ee2e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/(routes)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const Page = () => {
Mento
</div>
<div className="hidden gap-x3 md:flex">
<Button theme="clear" href="/create-proposal" disabled={!walletAddress}>
<Button theme="clear" href="/create-proposal">
Create new proposal
</Button>
<Button theme="clear" href="/my-voting-power" disabled={!walletAddress}>
Expand Down
18 changes: 5 additions & 13 deletions app/store/proposal-details.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface ProposalDetailsStore {
proposal?: IProposal;
isFetching: boolean;
fetch: (id: string) => Promise<void>;
refetchVotes: () => Promise<void>;
fetchVotes: () => Promise<void>;
votes: ProposalVotesMap;
vote: (type: IVoteType, value: number, address: string) => Promise<void>;
create: (proposal: IProposal) => Promise<void>;
Expand All @@ -29,27 +29,19 @@ export const useProposalDetailsStore = create<ProposalDetailsStore>((set, get) =
set({isFetching: true})

const proposalResponse = await fetch(`/api/proposals/${id}`);
const votesResponse = await fetch(`/api/proposals/${id}/votes`);

const proposalResponseJson = await proposalResponse.json();

const votesResponseJson = await votesResponse.json();

const votes: ProposalVotesMap = {
for: votesResponseJson.filter((vote: IVote) => vote.type === 'for'),
against: votesResponseJson.filter((vote: IVote) => vote.type === 'against'),
abstain: votesResponseJson.filter((vote: IVote) => vote.type === 'abstain'),
};

const proposal = {
...proposalResponseJson,
createdAt: new Date(proposalResponseJson.createdAt),
deadlineAt: new Date(proposalResponseJson.deadlineAt),
} as IProposal

set({proposal, votes, isFetching: false})
set({proposal});
await get().fetchVotes();
},
refetchVotes: async () => {
fetchVotes: async () => {
set({isFetching: true})

const id = get().proposal?.id;
Expand Down Expand Up @@ -86,7 +78,7 @@ export const useProposalDetailsStore = create<ProposalDetailsStore>((set, get) =
},
});

await get().refetchVotes();
await get().fetchVotes();
},
create: async (proposal) => {
await fetch(`/api/proposals`, {
Expand Down

0 comments on commit 63ee2e8

Please sign in to comment.