Skip to content

Commit

Permalink
fix: issue #393
Browse files Browse the repository at this point in the history
  • Loading branch information
whtsupbab3 committed Jan 7, 2025
1 parent 7dccc7b commit e70cb6f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 21 deletions.
8 changes: 7 additions & 1 deletion src/components/bounty/ClaimList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default function ClaimList({
}) {
const isVotingOrAcceptedBounty =
!!votingClaim || claims.some((claim) => claim.accepted);

return (
<>
<div
Expand All @@ -40,7 +41,12 @@ export default function ClaimList({
)}
</div>
<div className='grid grid-cols-12'>
{votingClaim && <Voting bountyId={bountyId} />}
{votingClaim && (
<Voting
bountyId={bountyId}
isAcceptedBounty={claims.some((claim) => claim.accepted)}
/>
)}
</div>

<div className='container mx-auto px-0 py-12 flex flex-col gap-12 lg:grid lg:grid-cols-12 lg:gap-12 lg:px-0'>
Expand Down
50 changes: 30 additions & 20 deletions src/components/bounty/Voting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import { useAccount, useSwitchChain, useWriteContract } from 'wagmi';
import abi from '@/constant/abi/abi';
import { useMutation, useQuery } from '@tanstack/react-query';

export default function Voting({ bountyId }: { bountyId: string }) {
export default function Voting({
bountyId,
isAcceptedBounty,
}: {
bountyId: string;
isAcceptedBounty: boolean;
}) {
const account = useAccount();
const chain = useGetChain();
const writeContract = useWriteContract({});
Expand Down Expand Up @@ -153,30 +159,34 @@ export default function Voting({ bountyId }: { bountyId: string }) {
</button>
</>
) : (
<button
className='border mt-5 border-white rounded-full px-5 py-2 flex justify-between items-center backdrop-blur-sm bg-[#D1ECFF]/20 w-fit'
onClick={() => {
if (account.address) {
resolveVoteMutation.mutate(BigInt(bountyId));
} else {
toast.error('Please connect wallet to continue');
}
}}
>
resolve vote
</button>
!isAcceptedBounty && (
<button
className='border mt-5 border-white rounded-full px-5 py-2 flex justify-between items-center backdrop-blur-sm bg-[#D1ECFF]/20 w-fit'
onClick={() => {
if (account.address) {
resolveVoteMutation.mutate(BigInt(bountyId));
} else {
toast.error('Please connect wallet to continue');
}
}}
>
resolve vote
</button>
)
)}
</div>

<div className='mt-5 '>
Deadline:{' '}
{new Date(
parseInt(voting.data.deadline ?? '0') * 1000
).toLocaleString()}
</div>
{!isAcceptedBounty && (
<div className='mt-5 '>
Deadline:{' '}
{new Date(
parseInt(voting.data.deadline ?? '0') * 1000
).toLocaleString()}
</div>
)}
</>
) : (
<div>Loading voting data...</div>
<div className='animate-pulse'>Loading voting data...</div>
)}
</div>
);
Expand Down

0 comments on commit e70cb6f

Please sign in to comment.