@@ -6,6 +6,7 @@ import { Link } from "react-router-dom";
66import { CheckOutlined , CloseOutlined } from "@ant-design/icons" ;
77import { Card , Col , Row , Switch } from "antd" ;
88import BigNumber from "bignumber.js" ;
9+ import qs from "qs" ;
910
1011import { BlockCountContext } from "api/contexts/BlockCount" ;
1112import { ConfirmationHistoryContext } from "api/contexts/ConfirmationHistory" ;
@@ -39,6 +40,14 @@ const HomePage = () => {
3940 const { availableSupply } = useAvailableSupply ( ) ;
4041 const { fiat } = React . useContext ( PreferencesContext ) ;
4142
43+ // Get the current URL
44+ const currentUrl = window . location . href ;
45+
46+ // Create URLSearchParams object
47+ const urlParams = new URLSearchParams ( new URL ( currentUrl ) . search ) ;
48+
49+ let isFeatureActive = urlParams . get ( "7d" ) ;
50+
4251 const {
4352 marketStatistics,
4453 isInitialLoading : isMarketStatisticsInitialLoading ,
@@ -85,13 +94,12 @@ const HomePage = () => {
8594 . toFixed ( CurrencyDecimal ?. [ fiat ] )
8695 : 0 ;
8796
88-
8997 const btcTransactionFees14d =
90- marketStatistics [ BITCOIN_TOTAL_TRANSACTION_FEES_14D ] && btcCurrentPrice
91- ? new BigNumber ( marketStatistics [ BITCOIN_TOTAL_TRANSACTION_FEES_14D ] )
92- . times ( btcCurrentPrice )
93- . toFixed ( CurrencyDecimal ?. [ fiat ] )
94- : 0 ;
98+ marketStatistics [ BITCOIN_TOTAL_TRANSACTION_FEES_14D ] && btcCurrentPrice
99+ ? new BigNumber ( marketStatistics [ BITCOIN_TOTAL_TRANSACTION_FEES_14D ] )
100+ . times ( btcCurrentPrice )
101+ . toFixed ( CurrencyDecimal ?. [ fiat ] )
102+ : 0 ;
95103
96104 const btcTransactionFeesChange24h = btcTransactionFees24h
97105 ? new BigNumber ( marketStatistics [ BITCOIN_TOTAL_TRANSACTION_FEES_24H ] )
@@ -120,60 +128,45 @@ const HomePage = () => {
120128 . times ( 100 )
121129 . toNumber ( ) ;
122130 }
123-
124- let totalConfirmations48hAgo = 0 ;
125- let confirmationChange24h = 0 ;
126-
127- let totalConfirmations7dAgo = 0 ;
128- let confirmationChange14d = 0 ;
129- if ( marketStatistics [ TOTAL_CONFIRMATIONS_24H ] && marketStatistics [ TOTAL_CONFIRMATIONS_48H ] ) {
130- totalConfirmations48hAgo = new BigNumber ( marketStatistics [ TOTAL_CONFIRMATIONS_48H ] )
131- . minus ( marketStatistics [ TOTAL_CONFIRMATIONS_24H ] )
132- . toNumber ( ) ;
133- confirmationChange24h = new BigNumber ( marketStatistics [ TOTAL_CONFIRMATIONS_24H ] )
134- . minus ( totalConfirmations48hAgo )
135- . dividedBy ( totalConfirmations48hAgo )
136- . times ( 100 )
137- . toNumber ( ) ;
138- }
139-
140- if ( marketStatistics [ TOTAL_CONFIRMATIONS_7D ] && marketStatistics [ TOTAL_CONFIRMATIONS_7D ] ) {
141- totalConfirmations48hAgo = new BigNumber ( marketStatistics [ TOTAL_CONFIRMATIONS_7D ] )
142- . minus ( marketStatistics [ TOTAL_CONFIRMATIONS_7D ] )
143- . toNumber ( ) ;
144- confirmationChange24h = new BigNumber ( marketStatistics [ TOTAL_CONFIRMATIONS_7D ] )
145- . minus ( totalConfirmations7dAgo )
146- . dividedBy ( totalConfirmations7dAgo )
147- . times ( 100 )
148- . toNumber ( ) ;
149- // here
150- let totalConfirmations14dAgo = 0 ;
131+ // Start here
132+ let totalConfirmations14dAgo = 0 ;
151133 let confirmationChange7d = 0 ;
152134
153135 let totalConfirmations7dAgo = 0 ;
154136 let confirmationChange14d = 0 ;
155- if ( marketStatistics [ TOTAL_CONFIRMATIONS_14D ] && marketStatistics [ TOTAL_CONFIRMATIONS_14D ] ) {
156- totalConfirmations48hAgo = new BigNumber ( marketStatistics [ TOTAL_CONFIRMATIONS_14D ] )
137+ if ( marketStatistics [ TOTAL_CONFIRMATIONS_7D ] && marketStatistics [ TOTAL_CONFIRMATIONS_7D ] ) {
138+ totalConfirmations7dAgo = new BigNumber ( marketStatistics [ TOTAL_CONFIRMATIONS_7D ] )
157139 . minus ( marketStatistics [ TOTAL_CONFIRMATIONS_7D ] )
158140 . toNumber ( ) ;
159- confirmationChange24h = new BigNumber ( marketStatistics [ TOTAL_CONFIRMATIONS_7D ] )
141+ confirmationChange14d = new BigNumber ( marketStatistics [ TOTAL_CONFIRMATIONS_14D ] )
160142 . minus ( totalConfirmations14dAgo )
161143 . dividedBy ( totalConfirmations14dAgo )
162144 . times ( 100 )
163145 . toNumber ( ) ;
164146 }
165147
166148 if ( marketStatistics [ TOTAL_CONFIRMATIONS_7D ] && marketStatistics [ TOTAL_CONFIRMATIONS_7D ] ) {
167- totalConfirmations48hAgo = new BigNumber ( marketStatistics [ TOTAL_CONFIRMATIONS_7D ] )
149+ confirmationChange14d = new BigNumber ( marketStatistics [ TOTAL_CONFIRMATIONS_7D ] )
168150 . minus ( marketStatistics [ TOTAL_CONFIRMATIONS_7D ] )
169151 . toNumber ( ) ;
170- confirmationChange24h = new BigNumber ( marketStatistics [ TOTAL_CONFIRMATIONS_7D ] )
152+ confirmationChange7d = new BigNumber ( marketStatistics [ TOTAL_CONFIRMATIONS_7D ] )
171153 . minus ( totalConfirmations7dAgo )
172154 . dividedBy ( totalConfirmations7dAgo )
173155 . times ( 100 )
174156 . toNumber ( ) ;
175157 }
176-
158+ let totalConfirmations48hAgo = 0 ;
159+ let confirmationChange24h = 0 ;
160+ if ( marketStatistics [ TOTAL_CONFIRMATIONS_24H ] && marketStatistics [ TOTAL_CONFIRMATIONS_48H ] ) {
161+ totalConfirmations48hAgo = new BigNumber ( marketStatistics [ TOTAL_CONFIRMATIONS_48H ] )
162+ . minus ( marketStatistics [ TOTAL_CONFIRMATIONS_24H ] )
163+ . toNumber ( ) ;
164+ confirmationChange24h = new BigNumber ( marketStatistics [ TOTAL_CONFIRMATIONS_24H ] )
165+ . minus ( totalConfirmations48hAgo )
166+ . dividedBy ( totalConfirmations48hAgo )
167+ . times ( 100 )
168+ . toNumber ( ) ;
169+ }
177170
178171 React . useEffect ( ( ) => {
179172 setFormattedLedgerSize ( formatBytes ( ledgerSize ) ) ;
@@ -268,14 +261,16 @@ const HomePage = () => {
268261 size = "small"
269262 title = { is24Hours ? t ( "pages.home.last24Hours" ) : t ( "pages.home.last7Days" ) }
270263 extra = {
271- < Switch
272- checkedChildren = { < CheckOutlined /> }
273- unCheckedChildren = { < CloseOutlined /> }
274- onChange = { ( checked : boolean ) => {
275- setIs24Hours ( checked ) ;
276- } }
277- checked = { is24Hours }
278- />
264+ isFeatureActive ? (
265+ < Switch
266+ checkedChildren = { < CheckOutlined /> }
267+ unCheckedChildren = { < CloseOutlined /> }
268+ onChange = { ( checked : boolean ) => {
269+ setIs24Hours ( checked ) ;
270+ } }
271+ checked = { is24Hours }
272+ />
273+ ) : null
279274 }
280275 >
281276 < Row gutter = { 6 } >
@@ -300,7 +295,12 @@ const HomePage = () => {
300295 ! confirmationChange24h
301296 }
302297 title = { t ( "pages.home.confirmedTransactions" ) }
303- suffix = { < StatisticsChange value = { confirmationChange24h } isPercent /> }
298+ suffix = {
299+ < StatisticsChange
300+ value = { is24Hours ? confirmationChange24h : confirmationChange7d }
301+ isPercent
302+ />
303+ }
304304 value = { marketStatistics [ TOTAL_CONFIRMATIONS_24H ] }
305305 />
306306 { isSmallAndLower ? (
0 commit comments