@@ -5,73 +5,73 @@ import type { Report } from "@/types";
5
5
import { Loader2 } from "lucide-react" ;
6
6
7
7
interface FundingDataWrapperProps {
8
- hypercertId : Partial < Report > [ "hypercertId" ] ;
9
- children : React . ReactNode ;
10
- totalAmount : Partial < Report > [ "totalCost" ] ;
11
- fundedAmount : Partial < Report > [ "fundedSoFar" ] ;
8
+ hypercertId : Partial < Report > [ "hypercertId" ] ;
9
+ children : React . ReactNode ;
10
+ totalAmount : Partial < Report > [ "totalCost" ] ;
11
+ fundedAmount : Partial < Report > [ "fundedSoFar" ] ;
12
12
}
13
13
14
14
const FundingDataWrapper : React . FC < FundingDataWrapperProps > = ( {
15
- hypercertId,
16
- totalAmount,
17
- fundedAmount,
18
- children,
15
+ hypercertId,
16
+ totalAmount,
17
+ fundedAmount,
18
+ children,
19
19
} : FundingDataWrapperProps ) => {
20
- if ( ! hypercertId ) {
21
- return < div > No hypercertId found </ div > ;
22
- }
23
- if ( ! totalAmount ) {
24
- return < div > No total cost found</ div > ;
25
- }
20
+ if ( ! hypercertId ) {
21
+ return < div > No hypercertId found </ div > ;
22
+ }
23
+ if ( ! totalAmount ) {
24
+ return < div > No total cost found</ div > ;
25
+ }
26
26
27
- const { genesisFractionQuery, hypercertClaimQuery } =
28
- useFetchFundingData ( hypercertId ) ;
27
+ const { genesisFractionQuery, hypercertClaimQuery } =
28
+ useFetchFundingData ( hypercertId ) ;
29
29
30
- const { data : genesisFractionResponse , isPending : fractionsPending } =
31
- genesisFractionQuery ;
32
- const { data : hypercertClaimResponse , isPending : claimPending } =
33
- hypercertClaimQuery ;
30
+ const { data : genesisFractionResponse , isPending : fractionsPending } =
31
+ genesisFractionQuery ;
32
+ const { data : hypercertClaimResponse , isPending : claimPending } =
33
+ hypercertClaimQuery ;
34
+ const genesisFraction = genesisFractionResponse ?. data [ 0 ] ;
35
+ const hypercertClaim = hypercertClaimResponse ;
34
36
35
- const genesisFraction = genesisFractionResponse ?. claimTokens [ 0 ] ;
36
- const hypercertClaim = hypercertClaimResponse ?. claim ;
37
+ if ( fractionsPending || claimPending )
38
+ return (
39
+ < section className = "h-20 shadow-md max-w-3xl flex justify-center items-center bg-vd-beige-100 gap-2 rounded-lg ease-in duration-300" >
40
+ < div className = "animate-spin" >
41
+ < Loader2 size = { 18 } />
42
+ </ div >
43
+ Loading funding data...
44
+ </ section >
45
+ ) ;
37
46
38
- if ( fractionsPending || claimPending )
39
- return (
40
- < section className = "h-20 shadow-md max-w-3xl flex justify-center items-center bg-vd-beige-100 gap-2 rounded-lg ease-in duration-300" >
41
- < div className = "animate-spin" >
42
- < Loader2 size = { 18 } />
43
- </ div >
44
- Loading funding data...
45
- </ section >
46
- ) ;
47
+ if ( ! hypercertClaim ) {
48
+ return < div > Missing data for calculations</ div > ;
49
+ }
50
+ console . log ( "hypercertClaim" , hypercertClaim ) ;
47
51
48
- if ( ! hypercertClaim ) {
49
- return < div > Missing data for calculations</ div > ;
50
- }
52
+ const totalUnits = hypercertClaim . units ? Number ( hypercertClaim . units ) : 0 ;
53
+ const pricePerUnit = totalAmount / Number ( totalUnits ) ;
54
+ const percentProgress = ( ( fundedAmount || 0 ) / totalAmount ) * 100 ;
55
+ const minUnitAmount = 1 / pricePerUnit ;
56
+ const dollarAmountNeeded = ( totalAmount - ( fundedAmount || 0 ) ) . toFixed ( 2 ) ;
51
57
52
- const totalUnits = hypercertClaim . totalUnits ;
53
- const pricePerUnit = totalAmount / Number ( totalUnits ) ;
54
- const percentProgress = ( ( fundedAmount || 0 ) / totalAmount ) * 100 ;
55
- const minUnitAmount = 1 / pricePerUnit ;
56
- const dollarAmountNeeded = ( totalAmount - ( fundedAmount || 0 ) ) . toFixed ( 2 ) ;
57
-
58
- return (
59
- < FundingProvider
60
- value = { {
61
- genesisFraction,
62
- hypercertClaim,
63
- pricePerUnit,
64
- totalUnits,
65
- totalAmount,
66
- // unitsRemaining,
67
- percentProgress,
68
- minUnitAmount,
69
- dollarAmountNeeded,
70
- } }
71
- >
72
- { children }
73
- </ FundingProvider >
74
- ) ;
58
+ return (
59
+ < FundingProvider
60
+ value = { {
61
+ genesisFraction,
62
+ hypercertClaim,
63
+ pricePerUnit,
64
+ totalUnits,
65
+ totalAmount,
66
+ // unitsRemaining,
67
+ percentProgress,
68
+ minUnitAmount,
69
+ dollarAmountNeeded,
70
+ } }
71
+ >
72
+ { children }
73
+ </ FundingProvider >
74
+ ) ;
75
75
} ;
76
76
77
77
export default FundingDataWrapper ;
0 commit comments