From ec32e26cc041da71ce5e45df465ca59681de4e1a Mon Sep 17 00:00:00 2001 From: Filipe Medeiros Date: Wed, 1 Dec 2021 21:09:28 +0000 Subject: [PATCH] feat: lots of stuff --- components/AddressInput.tsx | 30 ++++++++++++++++++++ components/Balance.tsx | 18 ++++++------ components/BottomMenu.tsx | 2 +- components/RecentTransactions.tsx | 38 ++++++++++++++++++++------ components/XnoInput.tsx | 2 +- lib/hooks/useAccountHistory.ts | 3 +- lib/hooks/useAccountReceivable.ts | 29 +++++++++++++++----- lib/showNotification.ts | 15 ++++++++++ pages/send/index.tsx | 23 +++++++++------- pages/send/{qr.tsx => qrOrAddress.tsx} | 27 ++++++++++++++---- seeds.json | 3 +- 11 files changed, 146 insertions(+), 44 deletions(-) create mode 100644 components/AddressInput.tsx create mode 100644 lib/showNotification.ts rename pages/send/{qr.tsx => qrOrAddress.tsx} (53%) diff --git a/components/AddressInput.tsx b/components/AddressInput.tsx new file mode 100644 index 0000000..854a458 --- /dev/null +++ b/components/AddressInput.tsx @@ -0,0 +1,30 @@ +import { FC } from 'react' + +// delete if not needed +export interface Props { + value: string + onChange: (value: string) => void +} + +const AddressInput: FC = ({ value, onChange }) => { + return ( +
+ + { + console.log(value, validity.patternMismatch) + if (!validity.patternMismatch) onChange(value) + }} + /> +
+ ) +} + +export default AddressInput diff --git a/components/Balance.tsx b/components/Balance.tsx index 7a0a9b0..5e8103c 100644 --- a/components/Balance.tsx +++ b/components/Balance.tsx @@ -41,22 +41,20 @@ const Balance: FC = ({ className }) => { const xnoBalanceDisplay = rawToNanoDisplay(account?.balance ?? '0') return ( -
+
setPreference('showCurrencyDash', nextShowCurrency(showCurrencyDash)) } - className="hover:cursor-pointer active:translate-y-0.5" + className="hover:cursor-pointer" >

- Ӿ + Ӿ {showXnoBalance ? ( account?.balance === null ? ( @@ -76,7 +74,7 @@ const Balance: FC = ({ className }) => {

{showFiatBalance && ( -

+

$ {(Number(xnoBalance) * xnoPrice).toFixed(2)}

)} diff --git a/components/BottomMenu.tsx b/components/BottomMenu.tsx index 73de384..752609a 100644 --- a/components/BottomMenu.tsx +++ b/components/BottomMenu.tsx @@ -117,7 +117,7 @@ const BottomMenu: FC = ({ className }) => {
- + = () => { hasMore, loading: loadingHistory, hasHistory, + revalidate: refetchHistory, } = useAccountHistory() const hasReceivable = @@ -33,11 +36,34 @@ const RecentTransactions: FC = () => { const initialLoading = loadingHistory && accountHistory === undefined + const onIncomingClick = async (receivable: { + hash: string + amount: string + from: string + timestamp: string + }) => { + await receive(receivable.hash, receivable.amount) + onBlockReceived(receivable.hash) + refetchHistory() + + showNotification({ + title: 'received!', + body: `received Ӿ${convert(receivable.amount, { + from: Unit.raw, + to: Unit.Nano, + })} from ${receivable.from}`, + tag: 'received', + }) + } + return ( <> {hasReceivable && (
-
+
setReceivablesExpanded(prev => !prev)} + >

incoming

@@ -46,7 +72,6 @@ const RecentTransactions: FC = () => { {receivableBlocks.length} setReceivablesExpanded(prev => !prev)} className={clsx( 'h-8 transition-transform-child origin-center-child', { @@ -68,10 +93,7 @@ const RecentTransactions: FC = () => { >