mirror of
https://github.com/joinmarket-webui/jam.git
synced 2026-08-20 13:28:21 +02:00
refactor(v2): use total balance from display context on receive page
This commit is contained in:
parent
f5b9c94841
commit
a0bf3801db
3 changed files with 4 additions and 11 deletions
|
|
@ -25,13 +25,9 @@ export const Receive = ({ walletFileName }: ReceiveProps) => {
|
|||
const [bitcoinAddress, setBitcoinAddress] = useState<string | undefined>()
|
||||
const [copied, setCopied] = useState(false)
|
||||
|
||||
const { jars, currency, isPrivate, toggleCurrencyUnit } = useJamDisplayContext()
|
||||
const { jars, currency, isPrivate, totalBalance, toggleCurrencyUnit } = useJamDisplayContext()
|
||||
const client = useApiClient()
|
||||
|
||||
const totalBalance = useMemo(() => {
|
||||
return jars.reduce((total, jar) => total + (jar.balance || 0), 0)
|
||||
}, [jars])
|
||||
|
||||
const getAddressQuery = useQuery({
|
||||
...getaddressOptions({
|
||||
client,
|
||||
|
|
@ -117,10 +113,7 @@ export const Receive = ({ walletFileName }: ReceiveProps) => {
|
|||
}
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => {
|
||||
setCopied(false)
|
||||
}, 1_500)
|
||||
|
||||
const timer = setTimeout(() => setCopied(false), 1_500)
|
||||
return () => clearTimeout(timer)
|
||||
}, [copied])
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ export function useWalletDisplay(): UseWalletDisplayResult {
|
|||
}
|
||||
})
|
||||
|
||||
const totalBalance = jars.reduce((acc, jar) => acc + jar.balance, 0)
|
||||
const totalBalance = jars.reduce((acc, jar) => acc + (jar.balance || 0), 0)
|
||||
|
||||
return {
|
||||
jars,
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@
|
|||
"feedback_invalid_amount": "Please provide a valid amount.",
|
||||
"button_new_address": "Get new address",
|
||||
"button_download_qr": "Save QR Code to file",
|
||||
"text_getting_address": "Getting new address."
|
||||
"text_getting_address": "Getting new address"
|
||||
},
|
||||
"earn": {
|
||||
"title": "Earn",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue