Skip to content

Commit 78a6a1a

Browse files
committed
feat: display funding status per priority and its epochs (#40)
close #40
1 parent 9988856 commit 78a6a1a

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/components/v1/EpochPreview.tsx

+23-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useContractRead } from "wagmi"
22
import Sector3DAOPriority from '../../../abis/v1/Sector3DAOPriority.json'
33
import { useIsMounted } from "@/hooks/useIsMounted"
44
import Link from "next/link"
5+
import { CircleStackIcon, ExclamationCircleIcon } from "@heroicons/react/24/outline"
56

67
export function EpochPreview({ priorityAddress, currentEpochNumber, epochNumber }: any) {
78
console.log('EpochPreview')
@@ -22,7 +23,15 @@ export function EpochPreview({ priorityAddress, currentEpochNumber, epochNumber
2223
epochContributions = data
2324
}
2425

25-
if (!useIsMounted() || isLoading) {
26+
const { data: isEpochFundedData, isError: isEpochFundedError, isLoading: isEpochFundedLoading } = useContractRead({
27+
address: priorityAddress,
28+
abi: Sector3DAOPriority.abi,
29+
functionName: 'isEpochFunded',
30+
args: [ epochNumber ]
31+
})
32+
console.log('isEpochFundedData:', isEpochFundedData)
33+
34+
if (!useIsMounted() || isLoading || isEpochFundedLoading) {
2635
return (
2736
<span className="inline-block h-4 w-4 animate-spin rounded-full border-4 border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]"></span>
2837
)
@@ -42,7 +51,19 @@ export function EpochPreview({ priorityAddress, currentEpochNumber, epochNumber
4251

4352
return (
4453
<>
45-
<div className='text-gray-400 mt-4'>Contributions: {epochContributions.length} ({epochHours}h)</div>
54+
{((epochContributions.length > 0) && (epochNumber != currentEpochNumber)) && (
55+
!isEpochFundedData ? (
56+
<span className='float-right inline-flex bg-amber-900 text-amber-500 font-bold uppercase text-sm rounded-lg px-2 py-1'>
57+
<ExclamationCircleIcon className='h-5 w-5' /> Not yet funded
58+
</span>
59+
) : (
60+
<span className='float-right inline-flex bg-emerald-900 text-emerald-500 font-bold uppercase text-sm rounded-lg px-2 py-1'>
61+
<CircleStackIcon className='h-5 w-5' /> Funded
62+
</span>
63+
)
64+
)}
65+
66+
<div className='text-gray-400 mt-4'>Contributions: {epochContributions.length} (⏱️{epochHours}h)</div>
4667
{(epochContributions.length > 0) && (
4768
<>
4869
<div>

0 commit comments

Comments
 (0)