File tree Expand file tree Collapse file tree 3 files changed +79
-9
lines changed Expand file tree Collapse file tree 3 files changed +79
-9
lines changed Original file line number Diff line number Diff line change
1
+ import React , { useState , useEffect } from 'react'
2
+
3
+ interface TimeLeft {
4
+ days ?: string
5
+ hours ?: string
6
+ minutes ?: string
7
+ seconds ?: string
8
+ }
9
+
10
+ const Countdown : React . FC = ( ) => {
11
+ const calculateTimeLeft = ( ) : TimeLeft => {
12
+ const targetDate = new Date ( new Date ( ) . getFullYear ( ) , 5 , 1 ) // June 1st
13
+ const now = new Date ( )
14
+ const difference = targetDate . getTime ( ) - now . getTime ( )
15
+
16
+ let timeLeft : TimeLeft = { }
17
+
18
+ if ( difference > 0 ) {
19
+ timeLeft = {
20
+ days : Math . floor ( difference / ( 1000 * 60 * 60 * 24 ) )
21
+ . toString ( )
22
+ . padStart ( 2 , '0' ) ,
23
+ hours : Math . floor (
24
+ ( difference % ( 1000 * 60 * 60 * 24 ) ) / ( 1000 * 60 * 60 ) ,
25
+ )
26
+ . toString ( )
27
+ . padStart ( 2 , '0' ) ,
28
+ minutes : Math . floor ( ( difference % ( 1000 * 60 * 60 ) ) / ( 1000 * 60 ) )
29
+ . toString ( )
30
+ . padStart ( 2 , '0' ) ,
31
+ }
32
+ }
33
+
34
+ return timeLeft
35
+ }
36
+
37
+ const [ timeLeft , setTimeLeft ] = useState < TimeLeft > ( calculateTimeLeft ( ) )
38
+
39
+ useEffect ( ( ) => {
40
+ const timer = setInterval ( ( ) => {
41
+ setTimeLeft ( calculateTimeLeft ( ) )
42
+ } , 1000 )
43
+
44
+ return ( ) => {
45
+ clearInterval ( timer )
46
+ }
47
+ } , [ ] )
48
+
49
+ if ( timeLeft . minutes === undefined ) {
50
+ return null
51
+ }
52
+
53
+ return (
54
+ < div className = "px-6" >
55
+ < p
56
+ className = "cursor-default"
57
+ title = "Using Client smart contract is available only for new applications. Select Contract as allocation type to start using it"
58
+ >
59
+ Direct allocation of DataCap will be deprecated in{ ' ' }
60
+ < span className = "whitespace-nowrap" >
61
+ { timeLeft . days } d { timeLeft . hours } h { timeLeft . minutes } m
62
+ </ span > { ' ' }
63
+ (June 1). Start using the Client smart contract today.
64
+ </ p >
65
+ </ div >
66
+ )
67
+ }
68
+
69
+ export default Countdown
Original file line number Diff line number Diff line change @@ -20,8 +20,9 @@ import { Button } from '@/components/ui/button'
20
20
import { AllocationUnit , type Allocation , type Application } from '@/type'
21
21
import { type ReactNode , useState } from 'react'
22
22
import { bytesToiB } from '@/lib/utils'
23
+ import Countdown from './Countdown'
23
24
24
- type AllocationType = 'contract ' | 'directly '
25
+ type AllocationType = 'directly ' | 'contract '
25
26
26
27
interface AllocationConfig {
27
28
isDialogOpen : boolean
@@ -78,6 +79,7 @@ const DatacapAmountModal = ({
78
79
return (
79
80
< Dialog open = { allocationConfig . isDialogOpen } onClose = { onClose } fullWidth >
80
81
< DialogTitle > { title } </ DialogTitle >
82
+ < Countdown />
81
83
< DialogContent >
82
84
{ ( isApiCalling || isWalletConnecting ) && (
83
85
< div className = "fixed inset-0 flex items-center justify-center z-50 bg-black bg-opacity-50" >
@@ -123,14 +125,14 @@ const DatacapAmountModal = ({
123
125
} }
124
126
>
125
127
< FormControlLabel
126
- value = "directly"
128
+ value = { 'contract' }
127
129
control = { < Radio /> }
128
- label = "Directly"
130
+ label = { 'Contract' }
129
131
/>
130
132
< FormControlLabel
131
- value = { 'contract' }
133
+ value = "directly"
132
134
control = { < Radio /> }
133
- label = { 'Contract' }
135
+ label = "Directly"
134
136
/>
135
137
</ RadioGroup >
136
138
</ FormControl >
Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ const AppInfoCard: React.FC<ComponentProps> = ({
148
148
isDialogOpen : boolean
149
149
} > ( {
150
150
amount : '' ,
151
- allocationType : 'directly ' ,
151
+ allocationType : 'contract ' ,
152
152
unit : AllocationUnit . GIB ,
153
153
isDialogOpen : false ,
154
154
} )
@@ -613,7 +613,7 @@ const AppInfoCard: React.FC<ComponentProps> = ({
613
613
isDialogOpen : false ,
614
614
amount : prev . amount || '0' ,
615
615
unit : prev . unit || AllocationUnit . GIB ,
616
- allocationType : 'directly ' ,
616
+ allocationType : 'contract ' ,
617
617
} ) )
618
618
return
619
619
}
@@ -723,7 +723,7 @@ const AppInfoCard: React.FC<ComponentProps> = ({
723
723
)
724
724
725
725
setAllocationAmountConfig ( ( ) => ( {
726
- allocationType : 'directly ' ,
726
+ allocationType : 'contract ' ,
727
727
amount,
728
728
isDialogOpen : false ,
729
729
unit : unit as AllocationUnit ,
@@ -1036,7 +1036,6 @@ const AppInfoCard: React.FC<ComponentProps> = ({
1036
1036
</ CardContent >
1037
1037
</ div >
1038
1038
) : null }
1039
-
1040
1039
< CardContent >
1041
1040
{ isProgressBarVisible && (
1042
1041
< ProgressBar
You can’t perform that action at this time.
0 commit comments