merchant-backoffice

ZZZ: Inactive/Deprecated
Log | Files | Refs | Submodules | README

commit 0535297f2fa46dbc14bca5bbf604d4ba4b5f5501
parent 0fe10f061578b48e40dcf615eff8cfcf69cf330a
Author: ms <ms@taler.net>
Date:   Tue, 25 Jan 2022 09:36:14 +0100

offer 'sign-out' button upon errors

Diffstat:
Mpackages/bank/src/pages/home/index.tsx | 120+++++++++++++++++++++++++++++++++++++++++--------------------------------------
1 file changed, 62 insertions(+), 58 deletions(-)

diff --git a/packages/bank/src/pages/home/index.tsx b/packages/bank/src/pages/home/index.tsx @@ -571,7 +571,7 @@ function Account(Props: any): VNode { console.log("account error", error); switch(error.status) { case 404: { - return <p>Username was not found</p> + return <p>Username or account label not found</p> } case 401: { return <p>Wrong credentials given</p> @@ -619,8 +619,8 @@ function Account(Props: any): VNode { <p>Your balance is {data.balance.amount}.</p> <div> <span>{i18n`Last transactions:`}</span> { txsPages } - <button onClick={() => setTxPageNumber(txPageNumber + 1)}>{i18n`Load more`}</button> - <button onClick={() => setTxPageNumber(0)}>{i18n`Reset`}</button> + <button onClick={() => setTxPageNumber(txPageNumber + 1)}>{i18n`Load more transactions`}</button> + <button onClick={() => setTxPageNumber(0)}>{i18n`Reset transactions`}</button> </div> {Props.children} </Fragment>); @@ -729,69 +729,73 @@ export function BankHome(): VNode { */ if (pageState.isLoggedIn) { if (typeof backendState === "undefined") { - pageStateSetter((prevState) => ({ ...prevState, hasError: true })); - return <p>{i18n`Page has a problem: logged in but backend state is lost.`}</p>; + pageStateSetter((prevState) => ({ + ...prevState, + hasError: true, + error: i18n`Page has a problem: logged in but backend state is lost.` + })); + return <p>Error: waiting for details...</p>; } return ( <SWRWithCredentials username={backendState.username} password={backendState.password} backendUrl={backendState.url}> - - <Account - withdrawalOutcome={pageState.withdrawalOutcome} - talerWithdrawUri={pageState.talerWithdrawUri} - accountLabel={backendState.username}> - - { /* The user is logged in: offer to log out. */ } - <button onClick={() => { - setTxPageNumber(0); + <Fragment> + <Account + withdrawalOutcome={pageState.withdrawalOutcome} + talerWithdrawUri={pageState.talerWithdrawUri} + accountLabel={backendState.username}> + + { /** + * No withdrawal is happening: offer to start one. + */ + !pageState.withdrawalInProgress && <button onClick={() => { + createWithdrawalCall( + "EUR:5", + backendState, + pageStateSetter + )}}>{i18n`Charge Taler wallet`}</button> + } + + { /** + * Withdrawal reached a persisten state: offer to + * return back to the pristine profile page. + */ + pageState.withdrawalOutcome && <button onClick={() => { + pageStateSetter((prevState) => { + const { withdrawalOutcome, withdrawalId, ...rest } = prevState; + return {...rest, withdrawalInProgress: false};})}}>{i18n`Close`}</button> + } + + { /** + * The withdrawal QR code is rendered: offer to confirm + * or abort the operation. + */ + pageState.talerWithdrawUri && <div><button onClick={() => { + confirmWithdrawalCall( + backendState, + pageState.withdrawalId, + pageStateSetter);}}>{i18n`Confirm withdrawal`}</button> + <button onClick={() => { + abortWithdrawalCall( + backendState, + pageState.withdrawalId, + pageStateSetter);}}>{i18n`Abort withdrawal`}</button> + </div>} + </Account> + { /* The user is logged in: offer to log out. */ } + <button onClick={() => { + setTxPageNumber(0); pageStateSetter((prevState) => { const { - talerWithdrawUri, - withdrawalOutcome, - withdrawalId, ...rest } = prevState; - return {...rest, isLoggedIn: false, withdrawalInProgress: false}; - }) - }}>Sign out</button> - - { /** - * No withdrawal is happening: offer to start one. - */ - !pageState.withdrawalInProgress && <button onClick={() => { - createWithdrawalCall( - "EUR:5", - backendState, - pageStateSetter - )}}>{i18n`Charge Taler wallet`}</button> - } - - { /** - * Withdrawal reached a persisten state: offer to - * return back to the pristine profile page. - */ - pageState.withdrawalOutcome && <button onClick={() => { - pageStateSetter((prevState) => { - const { withdrawalOutcome, withdrawalId, ...rest } = prevState; - return {...rest, withdrawalInProgress: false};})}}>{i18n`Close`}</button> - } - - { /** - * The withdrawal QR code is rendered: offer to confirm - * or abort the operation. - */ - pageState.talerWithdrawUri && <div><button onClick={() => { - confirmWithdrawalCall( - backendState, - pageState.withdrawalId, - pageStateSetter);}}>{i18n`Confirm withdrawal`}</button> - <button onClick={() => { - abortWithdrawalCall( - backendState, - pageState.withdrawalId, - pageStateSetter);}}>{i18n`Abort withdrawal`}</button> - </div>} - </Account> + talerWithdrawUri, + withdrawalOutcome, + withdrawalId, ...rest } = prevState; + return {...rest, isLoggedIn: false, withdrawalInProgress: false}; + }) + }}>Sign out</button> + </Fragment> </SWRWithCredentials> ); }