@@ -4,7 +4,6 @@ import { useProjectContext } from 'components/v2v3/V2V3Project/ProjectDashboard/
4
4
import { useProjectMetadata } from 'components/v2v3/V2V3Project/ProjectDashboard/hooks/useProjectMetadata'
5
5
import { timeSecondsToDateString } from 'components/v2v3/V2V3Project/ProjectDashboard/utils/timeSecondsToDateString'
6
6
import { useProjectUpcomingFundingCycle } from 'hooks/v2v3/contractReader/useProjectUpcomingFundingCycle'
7
- import { BallotState } from 'models/v2v3/fundingCycle'
8
7
import { useMemo } from 'react'
9
8
10
9
export const useCurrentUpcomingSubPanel = ( type : 'current' | 'upcoming' ) => {
@@ -16,14 +15,8 @@ export const useCurrentUpcomingSubPanel = (type: 'current' | 'upcoming') => {
16
15
const {
17
16
data : upcomingFundingCycleData ,
18
17
loading : upcomingFundingCycleLoading ,
19
- } = useProjectUpcomingFundingCycle ( {
20
- projectId,
21
- /**
22
- * if the current cycle is unlocked, force the use of latestConfiguredFundingCycleOf.
23
- */
24
- useLatestConfigured : fundingCycle ?. duration ?. isZero ( ) ?? false ,
25
- } )
26
- const [ upcomingFundingCycle , , ballotState ] = upcomingFundingCycleData ?? [ ]
18
+ } = useProjectUpcomingFundingCycle ( { projectId } )
19
+ const [ upcomingFundingCycle ] = upcomingFundingCycleData ?? [ ]
27
20
const { timeRemainingText } = useFundingCycleCountdown ( )
28
21
29
22
const cycleNumber = useMemo ( ( ) => {
@@ -40,6 +33,12 @@ export const useCurrentUpcomingSubPanel = (type: 'current' | 'upcoming') => {
40
33
return upcomingFundingCycle ?. duration ?. isZero ( ) ?? true
41
34
} , [ fundingCycle ?. duration , type , upcomingFundingCycle ?. duration ] )
42
35
36
+ /** Determines if the CURRENT cycle is unlocked.
37
+ * This is used to check if the upcoming cycle can start at any time. */
38
+ const currentCycleUnlocked = useMemo ( ( ) => {
39
+ return fundingCycle ?. duration ?. isZero ( ) ?? true
40
+ } , [ fundingCycle ?. duration ] )
41
+
43
42
const upcomingCycleLength = useMemo ( ( ) => {
44
43
if ( ! upcomingFundingCycle ) return
45
44
if ( cycleUnlocked ) return '-'
@@ -49,12 +48,15 @@ export const useCurrentUpcomingSubPanel = (type: 'current' | 'upcoming') => {
49
48
)
50
49
} , [ cycleUnlocked , upcomingFundingCycle ] )
51
50
52
- /** Determines if the CURRENT cycle is unlocked.
53
- * This is used to check if the upcoming cycle can start at any time. */
54
- const currentCycleUnlocked = fundingCycle ?. duration ?. isZero ( ) ?? true
51
+ const status = useMemo ( ( ) => {
52
+ if ( cycleUnlocked ) return t `Unlocked`
53
+ return t `Locked`
54
+ } , [ cycleUnlocked ] )
55
55
56
- const status = cycleUnlocked ? t `Unlocked` : t `Locked`
57
- const remainingTime = cycleUnlocked ? '-' : timeRemainingText
56
+ const remainingTime = useMemo ( ( ) => {
57
+ if ( cycleUnlocked ) return '-'
58
+ return timeRemainingText
59
+ } , [ cycleUnlocked , timeRemainingText ] )
58
60
59
61
// Short circuit current for faster loading
60
62
if ( type === 'current' ) {
@@ -82,14 +84,5 @@ export const useCurrentUpcomingSubPanel = (type: 'current' | 'upcoming') => {
82
84
cycleLength : upcomingCycleLength ,
83
85
cycleUnlocked,
84
86
currentCycleUnlocked,
85
- hasPendingConfiguration :
86
- /**
87
- * If a cycle is unlocked, it may have a pending change.
88
- * The only way it would, is if the ballot state of the latestConfiguredFC is `approved`.
89
- */
90
- cycleUnlocked &&
91
- typeof ballotState !== 'undefined' &&
92
- ballotState !== null &&
93
- ballotState === BallotState . approved ,
94
87
}
95
88
}
0 commit comments