refactor(earn-report): rename EarnReportSheet to EarnReportDialog

This commit is contained in:
theborakompanioni 2026-03-09 20:53:21 +01:00
parent dde1db1fb2
commit 2ff1ce1786
No known key found for this signature in database
GPG key ID: E8070AF0053AAC0D
3 changed files with 13 additions and 13 deletions

View file

@ -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 */}
<EarnReportSheet open={showEarnReport} onOpenChange={setShowEarnReport} />
<EarnReportDialog open={showEarnReport} onOpenChange={setShowEarnReport} />
</div>
)
}

View file

@ -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<EarnReportEntry>()
type EarnReportColumnMeta = { align?: string; numeric?: boolean } | undefined
interface EarnReportSheetProps {
open: boolean
onOpenChange: (open: boolean) => void
}
type EarnReportDialogProps = WithRequiredProperty<
Omit<ComponentProps<typeof Dialog>, '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)

View file

@ -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(' ')