diff --git a/pages/wallet.js b/pages/wallet.js index 0e2c1539..4ad3f1b4 100644 --- a/pages/wallet.js +++ b/pages/wallet.js @@ -14,23 +14,43 @@ import Alert from 'react-bootstrap/Alert' import { CREATE_WITHDRAWL, SEND_TO_LNADDR } from '../fragments/wallet' import { getGetServerSideProps } from '../api/ssrApollo' import { amountSchema, lnAddrSchema, withdrawlSchema } from '../lib/validate' +import Nav from 'react-bootstrap/Nav' import { SSR } from '../lib/constants' import { numWithUnits } from '../lib/format' +import styles from '../components/user-header.module.css' export const getServerSideProps = getGetServerSideProps() export default function Wallet () { - return ( - - - - ) + const router = useRouter() + + if (router.query.type === 'fund') { + return ( + + + + ) + } else if (router.query.type?.includes('withdraw')) { + return ( + + + + ) + } else { + return ( + + + + + + ) + } } function YouHaveSats () { const me = useMe() return ( -

+

you have {me && numWithUnits(me.sats, { abbreviate: false })}

) @@ -38,42 +58,24 @@ function YouHaveSats () { function WalletHistory () { return ( -
- - wallet history - -
+ + wallet history + ) } export function WalletForm () { - const router = useRouter() - - if (!router.query.type) { - return ( -
- - - - - or - - - - -
- ) - } - - if (router.query.type === 'fund') { - return - } else if (router.query.type === 'withdraw') { - return - } else if (router.query.type === 'lnurl-withdraw') { - return - } else { - return - } + return ( +
+ + + + or + + + +
+ ) } export function FundForm () { @@ -98,43 +100,89 @@ export function FundForm () { return ( <> - {me && showAlert && - { - window.localStorage.setItem('hideLnAddrAlert', 'yep') - setShowAlert(false) +
+ {me && showAlert && + { + window.localStorage.setItem('hideLnAddrAlert', 'yep') + setShowAlert(false) + }} + > + You can also fund your account via lightning address with {`${me.name}@stacker.news`} + } +
{ + const { data } = await createInvoice({ variables: { amount: Number(amount) } }) + router.push(`/invoices/${data.createInvoice.id}`) }} > - You can also fund your account via lightning address with {`${me.name}@stacker.news`} - } - { - const { data } = await createInvoice({ variables: { amount: Number(amount) } }) - router.push(`/invoices/${data.createInvoice.id}`) - }} - > - sats} - /> - generate invoice -
+ sats} + /> + generate invoice + +
) } +export function WithdrawalForm () { + const router = useRouter() + + return ( +
+ + + +
+ ) +} + +export function SelectedWithdrawalForm () { + const router = useRouter() + + switch (router.query.type) { + case 'withdraw': + return + case 'lnurl-withdraw': + return + case 'lnaddr-withdraw': + return + } +} + const MAX_FEE_DEFAULT = 10 -export function WithdrawlForm () { +export function InvWithdrawal () { const router = useRouter() const me = useMe() @@ -163,7 +211,6 @@ export function WithdrawlForm () { return ( <> -
withdraw
- or via - - - - - - - ) } @@ -254,7 +293,6 @@ export function LnAddrWithdrawal () { return ( <> -