diff --git a/src/components/earn/EarnPage.tsx b/src/components/earn/EarnPage.tsx index 7cf0df47..0b7ca8e6 100644 --- a/src/components/earn/EarnPage.tsx +++ b/src/components/earn/EarnPage.tsx @@ -35,7 +35,7 @@ import { FidelityBondCard } from './FidelityBondCard' import { MoveToJarDialog } from './MoveToJarDialog' import { OfferCard } from './OfferCard' import { RenewBondDialog } from './RenewBondDialog' -import { EarnReportSheet } from './report/EarnReportSheet' +import { EarnReportDialog } from './report/EarnReportDialog' // In order to prevent state mismatch, the 'maker stop' response is delayed shortly. // Even though the API response suggests that the maker has started or stopped immediately, it seems that this is not always the case. @@ -376,7 +376,7 @@ export const EarnPage = ({ walletFileName }: EarnPageProps) => { )} {/* Earn Report Sheet */} - + ) } diff --git a/src/components/earn/report/EarnReportSheet.tsx b/src/components/earn/report/EarnReportDialog.tsx similarity index 96% rename from src/components/earn/report/EarnReportSheet.tsx rename to src/components/earn/report/EarnReportDialog.tsx index 2157cbe8..b710931f 100644 --- a/src/components/earn/report/EarnReportSheet.tsx +++ b/src/components/earn/report/EarnReportDialog.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useMemo, useState } from 'react' +import { useCallback, useEffect, useMemo, useState, type ComponentProps } from 'react' import { createColumnHelper, flexRender, @@ -25,14 +25,11 @@ import { SortIcon } from '@/components/ui/jam/SortIcon' import { TablePagination } from '@/components/ui/jam/TablePagination' import { Spinner } from '@/components/ui/spinner' import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table' -import { pseudoRandomFloat, pseudoRandomInteger } from '@/lib/utils' +import { BITCOIN_GENESIS_DATE, pseudoRandomFloat, pseudoRandomInteger } from '@/lib/utils' import { jamSettingsStore } from '@/store/jamSettingsStore' -import type { AmountSats, Milliseconds } from '@/types/global' +import type { AmountSats, Milliseconds, WithRequiredProperty } from '@/types/global' import { EarnReportChart } from './EarnReportChart' -// Bitcoin genesis block date - used as the default 'since' for all-time sums -const BITCOIN_GENESIS_DATE = new Date('2009-01-03T18:15:05Z') - const sumEarned = (entries: EarnReportEntry[], since: Date): AmountSats => { return entries.filter((entry) => entry.timestamp >= since).reduce((sum, entry) => sum + (entry.earnedAmount ?? 0), 0) } @@ -62,12 +59,12 @@ const columnHelper = createColumnHelper() type EarnReportColumnMeta = { align?: string; numeric?: boolean } | undefined -interface EarnReportSheetProps { - open: boolean - onOpenChange: (open: boolean) => void -} +type EarnReportDialogProps = WithRequiredProperty< + Omit, 'children'>, + 'open' | 'onOpenChange' +> -export const EarnReportSheet = ({ open, onOpenChange }: EarnReportSheetProps) => { +export const EarnReportDialog = ({ open, onOpenChange }: EarnReportDialogProps) => { const { t } = useTranslation() const { data: entries, isLoading, refetch, isRefetching } = useQueryYieldgenReport({ enabled: open }) const isDeveloperMode = useStore(jamSettingsStore, (state) => state.state.developerMode) diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 4d8888ea..af826f13 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -135,6 +135,9 @@ export const tryBtcToSat = (value: string): number | undefined => { export const SEGWIT_ACTIVATION_BLOCK = 481_824 // https://github.com/bitcoin/bitcoin/blob/v25.0/src/kernel/chainparams.cpp#L86 +// if applicable, the genesis date can be used as minimum `since` timestamp +export const BITCOIN_GENESIS_DATE = new Date('2009-01-03T18:15:05Z') + export const DUMMY_SEED_PHRASE: SeedPhrase = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'.split(' ')