fix cta navbar and added an withdrawal button when the wallet didnt find a tos (with a warning)

This commit is contained in:
Sebastian 2021-10-13 09:54:18 -03:00
parent e227fa4e47
commit 021d508337
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
5 changed files with 26 additions and 14 deletions

View File

@ -36,6 +36,7 @@ export enum Pages {
manual_withdraw = '/manual-withdraw', manual_withdraw = '/manual-withdraw',
settings = '/settings', settings = '/settings',
dev = '/dev', dev = '/dev',
cta = '/cta',
backup = '/backup', backup = '/backup',
history = '/history', history = '/history',
transaction = '/transaction/:tid', transaction = '/transaction/:tid',

View File

@ -21,7 +21,10 @@ import { h } from 'preact';
export function ExchangeXmlTos({ doc }: { doc: Document }) { export function ExchangeXmlTos({ doc }: { doc: Document }) {
const termsNode = doc.querySelector('[ids=terms-of-service]') const termsNode = doc.querySelector('[ids=terms-of-service]')
if (!termsNode) { if (!termsNode) {
return <div>not found</div> return <div>
<p>The exchange send us an xml but there is no node with 'ids=terms-of-service'. This is the content:</p>
<pre>{new XMLSerializer().serializeToString(doc)}</pre>
</div>
} }
return <Fragment> return <Fragment>
{Array.from(termsNode.children).map(renderChild)} {Array.from(termsNode.children).map(renderChild)}

View File

@ -214,10 +214,18 @@ export function View({ details, knownExchanges, amount, onWithdraw, onSwitchExch
{i18n.str`Confirm withdrawal`} {i18n.str`Confirm withdrawal`}
</ButtonSuccess> </ButtonSuccess>
} }
{terms.status === 'notfound' && {terms.status === 'notfound' && <Fragment>
<LinkWarning upperCased> <LinkWarning>
{i18n.str`Exchange doesn't have terms of service`} {i18n.str`Exchange doesn't have terms of service`}
</LinkWarning> </LinkWarning>
<ButtonWarning
upperCased
disabled={!details.exchangeInfo.baseUrl}
onClick={onWithdraw}
>
{i18n.str`Withdraw anyway`}
</ButtonWarning>
</Fragment>
} }
</section> </section>
</WalletAction> </WalletAction>

View File

@ -3,7 +3,7 @@ import { ButtonPrimary, ButtonSuccess, PopupBox } from "../components/styled/ind
export interface Props { export interface Props {
url: string; url: string;
onDismiss: (s: boolean) => void; onDismiss: () => void;
} }
export function TalerActionFound({ url, onDismiss }: Props) { export function TalerActionFound({ url, onDismiss }: Props) {
@ -49,7 +49,7 @@ export function TalerActionFound({ url, onDismiss }: Props) {
</section> </section>
<footer> <footer>
<div /> <div />
<ButtonPrimary onClick={() => onDismiss(true)}> Dismiss </ButtonPrimary> <ButtonPrimary onClick={() => onDismiss()}> Dismiss </ButtonPrimary>
</footer> </footer>
</PopupBox>; </PopupBox>;

View File

@ -66,14 +66,9 @@ if (document.readyState === "loading") {
function Application() { function Application() {
const [talerActionUrl, setDismissed] = useTalerActionURL() const [talerActionUrl, setDismissed] = useTalerActionURL()
if (talerActionUrl) { useEffect(() => {
return <div> if (talerActionUrl) route(Pages.cta)
<WalletNavBar /> },[talerActionUrl])
<div style={{ width: 400, height: 290 }}>
<TalerActionFound url={talerActionUrl} onDismiss={setDismissed} />
</div>
</div>
}
return ( return (
<div> <div>
@ -81,11 +76,16 @@ function Application() {
<WalletNavBar /> <WalletNavBar />
<div style={{ width: 400, height: 290 }}> <div style={{ width: 400, height: 290 }}>
<Router history={createHashHistory()}> <Router history={createHashHistory()}>
<Route path={Pages.dev} component={DeveloperPage} />
<Route path={Pages.balance} component={BalancePage} <Route path={Pages.balance} component={BalancePage}
goToWalletManualWithdraw={() => goToWalletPage(Pages.manual_withdraw)} goToWalletManualWithdraw={() => goToWalletPage(Pages.manual_withdraw)}
/> />
<Route path={Pages.settings} component={SettingsPage} /> <Route path={Pages.settings} component={SettingsPage} />
<Route path={Pages.dev} component={DeveloperPage} /> <Route path={Pages.cta} component={() => <TalerActionFound url={talerActionUrl!} onDismiss={() => {
setDismissed(true)
route(Pages.balance)
}} />} />
<Route path={Pages.transaction} <Route path={Pages.transaction}
component={({ tid }: { tid: string }) => goToWalletPage(Pages.transaction.replace(':tid', tid))} component={({ tid }: { tid: string }) => goToWalletPage(Pages.transaction.replace(':tid', tid))}