merchant-backoffice

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

commit 90ed9dd96bdff1d68476200653de7f653e93454b
parent 112fccd4bad37f88d60dd8360d9607bfb67933fa
Author: ng <�>
Date:   Sun, 25 Sep 2022 15:53:52 +0200

style: 🚨 Add consistent indent style rules

Diffstat:
Mpackages/bank/package.json | 3++-
Mpackages/bank/src/components/Notifications.tsx | 20++++++++++----------
Mpackages/bank/src/components/fields/DateInput.tsx | 2+-
Mpackages/bank/src/components/menu/LangSelector.tsx | 28++++++++++++++--------------
Mpackages/bank/src/components/menu/index.tsx | 4++--
Mpackages/bank/src/hooks/index.ts | 2+-
Mpackages/bank/src/pages/home/index.tsx | 464++++++++++++++++++++++++++++++++++++++++----------------------------------------
7 files changed, 262 insertions(+), 261 deletions(-)

diff --git a/packages/bank/package.json b/packages/bank/package.json @@ -26,7 +26,8 @@ "rules": { "@typescript-eslint/no-explicit-any": [0], "@typescript-eslint/ban-ts-comment": [1], - "quotes": [2, "single", {"allowTemplateLiterals": true,"avoidEscape": false}] + "quotes": [2, "single", {"allowTemplateLiterals": true,"avoidEscape": false}], + "indent": [2,2] } }, "dependencies": { diff --git a/packages/bank/src/components/Notifications.tsx b/packages/bank/src/components/Notifications.tsx @@ -36,16 +36,16 @@ interface Props { function messageStyle(type: MessageType): string { switch (type) { - case 'INFO': - return 'message is-info'; - case 'WARN': - return 'message is-warning'; - case 'ERROR': - return 'message is-danger'; - case 'SUCCESS': - return 'message is-success'; - default: - return 'message'; + case 'INFO': + return 'message is-info'; + case 'WARN': + return 'message is-warning'; + case 'ERROR': + return 'message is-danger'; + case 'SUCCESS': + return 'message is-success'; + default: + return 'message'; } } diff --git a/packages/bank/src/components/fields/DateInput.tsx b/packages/bank/src/components/fields/DateInput.tsx @@ -50,7 +50,7 @@ export function DateInput(props: DateInputProps): VNode { props.onConfirm() } }} - onInput={(e) => { + onInput={(e) => { const text = e.currentTarget.value; setDirty(true); props.bind[1](text); diff --git a/packages/bank/src/components/menu/LangSelector.tsx b/packages/bank/src/components/menu/LangSelector.tsx @@ -53,23 +53,23 @@ export function LangSelectorLikePy(): VNode { <span>{getLangName(lang)}</span> <div style="position: relative; overflow: visible;"> <div - class="nav" - style="position: absolute; background: #0042b2; max-height: 60vh; overflow-y: scroll"> + class="nav" + style="position: absolute; background: #0042b2; max-height: 60vh; overflow-y: scroll"> <br /> {Object.keys(messages) .filter((l) => l !== lang) - .map((l) => ( - <a - key={l} - class="navbtn" - value={l} - onClick={() => { - changeLanguage(l); - setUpdatingLang(false); - }}> - {getLangName(l)} - </a> - ))} + .map((l) => ( + <a + key={l} + class="navbtn" + value={l} + onClick={() => { + changeLanguage(l); + setUpdatingLang(false); + }}> + {getLangName(l)} + </a> + ))} <br /> </div> </div> diff --git a/packages/bank/src/components/menu/index.tsx b/packages/bank/src/components/menu/index.tsx @@ -85,8 +85,8 @@ export function NotificationCard({ n.type === 'ERROR' ? 'message is-danger' : n.type === 'WARN' - ? 'message is-warning' - : 'message is-info' + ? 'message is-warning' + : 'message is-info' } > <div class="message-header"> diff --git a/packages/bank/src/hooks/index.ts b/packages/bank/src/hooks/index.ts @@ -53,7 +53,7 @@ export function useBackendURL( export function useBackendDefaultToken(): [ string | undefined, StateUpdater<string | undefined>, -] { + ] { return useLocalStorage('backend-token'); } diff --git a/packages/bank/src/pages/home/index.tsx b/packages/bank/src/pages/home/index.tsx @@ -131,8 +131,8 @@ interface AccountStateType { ***********/ function maybeDemoContent(content: VNode) { - // @ts-ignore - if (__LIBEUFIN_UI_IS_DEMO__) return content; + // @ts-ignore + if (__LIBEUFIN_UI_IS_DEMO__) return content; } async function fetcher(url: string) { @@ -224,10 +224,10 @@ async function postToBackend( // Backend URL must have been stored _with_ a final slash. const url = new URL(uri, backendState.url) return await fetch(url.href, { - method: 'POST', - headers, - body, - } + method: 'POST', + headers, + body, + } ); } @@ -463,7 +463,7 @@ async function abortWithdrawalCall( // Backend URL must have been stored _with_ a final slash. const url = new URL( `access-api/accounts/${backendState.username}/withdrawals/${withdrawalId}/abort`, - backendState.url + backendState.url ) var res = await fetch(url.href, {method: 'POST', headers}) } catch (error) { @@ -480,15 +480,15 @@ async function abortWithdrawalCall( ...prevState, hasError: true, error: `Withdrawal abortion gave response error (${res.status})`})) - return; + return; } - console.log('Withdrawal operation aborted!'); - pageStateSetter((prevState) => { - const { talerWithdrawUri, withdrawalId, ...rest } = prevState; - return { - ...rest, - withdrawalOutcome: 'Withdrawal aborted!' - }}) + console.log('Withdrawal operation aborted!'); + pageStateSetter((prevState) => { + const { talerWithdrawUri, withdrawalId, ...rest } = prevState; + return { + ...rest, + withdrawalOutcome: 'Withdrawal aborted!' + }}) } @@ -536,7 +536,7 @@ async function confirmWithdrawalCall( // Backend URL must have been stored _with_ a final slash. const url = new URL( `access-api/accounts/${backendState.username}/withdrawals/${withdrawalId}/confirm`, - backendState.url + backendState.url ) var res = await fetch(url.href, { method: 'POST', @@ -556,15 +556,15 @@ async function confirmWithdrawalCall( ...prevState, hasError: true, error: `Withdrawal confirmation gave response error (${res.status})`})) - return; + return; } - console.log('Withdrawal operation confirmed!'); - pageStateSetter((prevState) => { - const { talerWithdrawUri, ...rest } = prevState; - return { - ...rest, - withdrawalOutcome: 'Withdrawal confirmed!' - }}) + console.log('Withdrawal operation confirmed!'); + pageStateSetter((prevState) => { + const { talerWithdrawUri, ...rest } = prevState; + return { + ...rest, + withdrawalOutcome: 'Withdrawal confirmed!' + }}) } @@ -607,7 +607,7 @@ async function createTransactionCall( ...prevState, hasError: true, error: `Transfer creation gave response error: ${responseText} (${res.status})`})) - return; + return; } // status is 200 OK here, tell the user. console.log('Wire transfer created!'); @@ -649,10 +649,10 @@ async function createWithdrawalCall( backendState.url ) var res = await fetch(url.href, { - method: 'POST', - headers, - body: JSON.stringify({amount}), - } + method: 'POST', + headers, + body: JSON.stringify({amount}), + } ); } catch (error) { console.log('Could not POST withdrawal request to the bank', error); @@ -669,7 +669,7 @@ async function createWithdrawalCall( ...prevState, hasError: true, error: `Withdrawal creation gave response error: ${responseText} (${res.status})`})) - return; + return; } console.log('Withdrawal operation created!'); @@ -802,7 +802,7 @@ function ErrorBanner(Props: any): VNode | null { pageStateSetter((prevState: PageStateType) => { delete prevState.error; // delete error message return {...prevState, hasError: false} // delete error state - })}}> + })}}> {i18n`Clear`} </a> </p>); @@ -864,8 +864,8 @@ function BankFrame(Props: any): VNode { } </div> <a href="https://taler.net/"> - <img - src={talerLogo} + <img + src={talerLogo} height="100" width="224" style="margin: 2em 2em" /> @@ -881,7 +881,7 @@ function BankFrame(Props: any): VNode { </div> <section id="main" class="content"> <ErrorBanner pageState={[pageState, pageStateSetter]} /> - {pageState.isLoggedIn ? logOut : null} + {pageState.isLoggedIn ? logOut : null} {Props.children} <hr /> <div> @@ -944,7 +944,7 @@ function PaytoWireTransfer(Props: any): VNode { submitDataSetter((submitData: any) => ({ ...submitData, iban: e.currentTarget.value, - }))}} /><br /><br /> + }))}} /><br /><br /> <input type="text" placeholder="subject" @@ -953,7 +953,7 @@ function PaytoWireTransfer(Props: any): VNode { submitDataSetter((submitData: any) => ({ ...submitData, subject: e.currentTarget.value, - }))}} /><br /><br /> + }))}} /><br /><br /> <input type="text" placeholder="amount" @@ -967,7 +967,7 @@ function PaytoWireTransfer(Props: any): VNode { submitDataSetter((submitData: any) => ({ ...submitData, amount: e.currentTarget.value.replace(',', '.'), - }))}} />&nbsp;<label>{currency}</label><br /><br /> + }))}} />&nbsp;<label>{currency}</label><br /><br /> <input type="submit" value="Send" @@ -1016,7 +1016,7 @@ function PaytoWireTransfer(Props: any): VNode { <p>{i18n`Transfer money via the Payto system:`}<br /><br /> Address pattern: <code style="font-size: 15px"> payto://iban/[receiver-iban]?message=[subject]&amount=[{currency}:X.Y] - </code> + </code> </p> <div name="payto-form"> <input name="address" @@ -1029,23 +1029,23 @@ function PaytoWireTransfer(Props: any): VNode { rawPaytoInputSetter(e.currentTarget.value) }} /> <input class="pure-button pure-button-primary" - type="submit" - value={i18n`Confirm`} + type="submit" + value={i18n`Confirm`} onClick={() => { - // empty string evaluates to false. - if (!rawPaytoInput) { - console.log('Didn\'t get any raw Payto string!'); - return; - } - transactionData = {paytoUri: rawPaytoInput}; - if (typeof transactionData.paytoUri === 'undefined' || + // empty string evaluates to false. + if (!rawPaytoInput) { + console.log('Didn\'t get any raw Payto string!'); + return; + } + transactionData = {paytoUri: rawPaytoInput}; + if (typeof transactionData.paytoUri === 'undefined' || transactionData.paytoUri.length === 0) return; - createTransactionCall( - transactionData, - Props.backendState, - pageStateSetter, - rawPaytoInputSetter); - }} /> + createTransactionCall( + transactionData, + Props.backendState, + pageStateSetter, + rawPaytoInputSetter); + }} /> </div> </div> <p>{goBackRawPayto}</p> @@ -1075,7 +1075,7 @@ function TalerWithdrawalConfirmationQuestion(Props: any): VNode { <label>What is <em>{captchaNumbers.a} + {captchaNumbers.b}</em> ?&nbsp;</label> <input type="text" - required + required onInput={(e): void => { captchaAnswer = e.currentTarget.value; }} /> @@ -1092,7 +1092,7 @@ function TalerWithdrawalConfirmationQuestion(Props: any): VNode { } pageStateSetter((prevState: PageStateType) => ({...prevState, hasError: true, error: 'Answer is wrong.'})) - }} /> + }} /> <input type="submit" value="abort" @@ -1121,12 +1121,12 @@ function QrCodeSection({talerWithdrawUri, abortButton}:{talerWithdrawUri:string, },[]) return <section id="main" class="content"> - <h1 class="nav">{i18n`Withdraw to a Taler Wallet`}</h1> - <p>{i18n`You can use this QR code to withdraw to your mobile wallet:`}</p> - {QR({text: talerWithdrawUri})} - <p>Click <a id="linkqr" href={talerWithdrawUri}>{i18n`this link`}</a> to open your Taler wallet!</p> - <br /> - {abortButton} + <h1 class="nav">{i18n`Withdraw to a Taler Wallet`}</h1> + <p>{i18n`You can use this QR code to withdraw to your mobile wallet:`}</p> + {QR({text: talerWithdrawUri})} + <p>Click <a id="linkqr" href={talerWithdrawUri}>{i18n`this link`}</a> to open your Taler wallet!</p> + <br /> + {abortButton} </section> } @@ -1145,10 +1145,10 @@ function TalerWithdrawalQRCode(Props: any): VNode { backendState } = Props; const i18n = useTranslator(); const abortButton = <a class="pure-button" onClick={() => { - pageStateSetter((prevState: PageStateType) => { - const { withdrawalOutcome, withdrawalId, talerWithdrawUri, ...rest } = prevState; - return { ...rest, withdrawalInProgress: false }; - })}}>{i18n`Abort`}</a> + pageStateSetter((prevState: PageStateType) => { + const { withdrawalOutcome, withdrawalId, talerWithdrawUri, ...rest } = prevState; + return { ...rest, withdrawalInProgress: false }; + })}}>{i18n`Abort`}</a> console.log(`Showing withdraw URI: ${talerWithdrawUri}`); // waiting for the wallet: @@ -1179,13 +1179,13 @@ function TalerWithdrawalQRCode(Props: any): VNode { const { withdrawalOutcome, withdrawalId, - talerWithdrawUri, - ...rest } = prevState; + talerWithdrawUri, + ...rest } = prevState; return { ...rest, - withdrawalInProgress: false, + withdrawalInProgress: false, hasError: true, - error: i18n`This withdrawal was aborted!` + error: i18n`This withdrawal was aborted!` }; }) } @@ -1212,10 +1212,10 @@ function TalerWithdrawal(Props: any): VNode { // const amountRegex = "^[0-9]+(\.[0-9]+)?$"; // currently unused const submitButton = <input - id="select-exchange" - class="pure-button pure-button-primary" - type="submit" - value={i18n`Start withdrawal`} + id="select-exchange" + class="pure-button pure-button-primary" + type="submit" + value={i18n`Start withdrawal`} onClick={() => { submitAmount = validateAmount(submitAmount); /** @@ -1230,33 +1230,33 @@ function TalerWithdrawal(Props: any): VNode { pageStateSetter )}} />; - return (<article> - <div> - <h2>{i18n`Withdraw Money into a Taler wallet`}</h2> - <div id="reserve-form" - class="pure-form" - name="tform"> - {i18n`Amount to withdraw`}:&nbsp; - <select id="reserve-amount" + return (<article> + <div> + <h2>{i18n`Withdraw Money into a Taler wallet`}</h2> + <div id="reserve-form" + class="pure-form" + name="tform"> + {i18n`Amount to withdraw`}:&nbsp; + <select id="reserve-amount" name="withdraw-amount" class="amount" autofocus - onChange={(e): void => { + onChange={(e): void => { submitAmount = e.currentTarget.value; }}> - <option value="5.00">5.00</option> - <option value="10.00">10.00</option> - <option value="15.00">15.00</option> - <option value="20.00">20.00</option> - </select> - <input + <option value="5.00">5.00</option> + <option value="10.00">10.00</option> + <option value="15.00">15.00</option> + <option value="20.00">20.00</option> + </select> + <input type="text" readonly class="currency-indicator" size={currency.length} tabIndex={-1} value={currency} /> &nbsp;{submitButton} - </div> </div> - </article>); + </div> + </article>); } /** @@ -1279,7 +1279,7 @@ function LoginForm(Props: any): VNode { submitDataSetter((submitData: any) => ({ ...submitData, username: e.currentTarget.value, - }))}} /> + }))}} /> <input type="password" value={submitData && submitData.password} @@ -1289,9 +1289,9 @@ function LoginForm(Props: any): VNode { submitDataSetter((submitData: any) => ({ ...submitData, password: e.currentTarget.value, - }))}} /> + }))}} /> <button - autofocus + autofocus type="submit" class="pure-button pure-button-primary" onClick={() => { @@ -1329,36 +1329,36 @@ function RegistrationForm(Props: any): VNode { <Fragment> <h1 class="nav">{i18n`Registration form`}</h1> <aside class="sidebar" id="left" /> - <article> - <div class="register-form"> - <form action="javascript:void(0);" class="pure-form"> - {i18n`Username:`} - <input - type="text" - placeholder="username" - value={submitData && submitData.username} - required - autofocus - onInput={(e): void => { + <article> + <div class="register-form"> + <form action="javascript:void(0);" class="pure-form"> + {i18n`Username:`} + <input + type="text" + placeholder="username" + value={submitData && submitData.username} + required + autofocus + onInput={(e): void => { submitDataSetter((submitData: any) => ({ - ...submitData, - username: e.currentTarget.value, - }))}} /> - <br /> - {i18n`Password:`} - <input - type="password" - placeholder="password" - value={submitData && submitData.password} - required - autofocus - onInput={(e): void => { + ...submitData, + username: e.currentTarget.value, + }))}} /> + <br /> + {i18n`Password:`} + <input + type="password" + placeholder="password" + value={submitData && submitData.password} + required + autofocus + onInput={(e): void => { submitDataSetter((submitData: any) => ({ - ...submitData, - password: e.currentTarget.value, - }))}} /> - <br /> - {/* + ...submitData, + password: e.currentTarget.value, + }))}} /> + <br /> + {/* {i18n`Phone number:`} // FIXME: add input validation (must start with +, otherwise only numbers) <input @@ -1374,53 +1374,53 @@ function RegistrationForm(Props: any): VNode { }))}} /> <br /> */} - <button + <button autofocus - class="pure-button pure-button-primary" - onClick={() => { + class="pure-button pure-button-primary" + onClick={() => { console.log('maybe submitting the registration..'); console.log(submitData); if (typeof submitData === 'undefined') { - console.log(`submit data ${submitData} is undefined`); - return; - } + console.log(`submit data ${submitData} is undefined`); + return; + } if ((typeof submitData.password === 'undefined') || (typeof submitData.username === 'undefined')) { - console.log('username or password is undefined'); - return; - } + console.log('username or password is undefined'); + return; + } if (submitData.password.length === 0 || submitData.username.length === 0) { - console.log('username or password are the empty string'); - return; - } + console.log('username or password are the empty string'); + return; + } console.log('submitting the registration..'); - registrationCall( - {...submitData}, - Props.backendStateSetter, // will store BE URL, if OK. - pageStateSetter - ); - console.log('Clearing the input data'); - /** + registrationCall( + {...submitData}, + Props.backendStateSetter, // will store BE URL, if OK. + pageStateSetter + ); + console.log('Clearing the input data'); + /** * FIXME: clearing the data should be done by setting * it to undefined, instead of the empty strings, just * like done in the login function. Now set to the empty * strings due to a non lively update of the <input> fields * after setting to undefined. */ - submitDataSetter({username: '', password: ''})}}>{i18n`Register`}</button> + submitDataSetter({username: '', password: ''})}}>{i18n`Register`}</button> // FIXME: should use a different color - <button + <button autofocus - class="pure-button pure-button-primary" - onClick={() => { - pageStateSetter((prevState: PageStateType) =>({...prevState, tryRegister: false}))}}> - {i18n`cancel`}</button> - - </form> - </div> - </article> - </Fragment> + class="pure-button pure-button-primary" + onClick={() => { + pageStateSetter((prevState: PageStateType) =>({...prevState, tryRegister: false}))}}> + {i18n`cancel`}</button> + + </form> + </div> + </article> + </Fragment> ) } @@ -1436,15 +1436,15 @@ function Transactions(Props: any): VNode { if (typeof error !== 'undefined') { console.log('transactions not found error', error); switch(error.status) { - case 404: { - return <p>Transactions page {pageNumber} was not found.</p> - } - case 401: { - return <p>Wrong credentials given.</p> - } - default: { - return <p>Transaction page {pageNumber} could not be retrieved.</p> - } + case 404: { + return <p>Transactions page {pageNumber} was not found.</p> + } + case 401: { + return <p>Wrong credentials given.</p> + } + default: { + return <p>Transaction page {pageNumber} could not be retrieved.</p> + } } } if (!data) { @@ -1455,12 +1455,12 @@ function Transactions(Props: any): VNode { return (<div class="results"> <table class="pure-table pure-table-striped"> <thead> - <tr> + <tr> <th>{i18n`Date`}</th> <th>{i18n`Amount`}</th> <th>{i18n`Counterpart`}</th> <th>{i18n`Subject`}</th> - </tr> + </tr> </thead> <tbody> {data.transactions.map((item: any) => { @@ -1523,15 +1523,15 @@ function Account(Props: any): VNode { * message in the case-branch. */ switch(error.status) { - case 404: { - pageStateSetter((prevState: PageStateType) => ({ - ...prevState, - hasError: true, - isLoggedIn: false, - error: i18n`Username or account label '${accountLabel}' not found. Won't login.` - })); - - /** + case 404: { + pageStateSetter((prevState: PageStateType) => ({ + ...prevState, + hasError: true, + isLoggedIn: false, + error: i18n`Username or account label '${accountLabel}' not found. Won't login.` + })); + + /** * 404 should never stick to the cache, because they * taint successful future registrations. How? After * registering, the user gets navigated to this page, @@ -1544,29 +1544,29 @@ function Account(Props: any): VNode { * in the legitimate request after the registration to still * be flagged as 404. Clearing the cache should prevent * this. */ - (cache as any).clear(); - return <p>Profile not found...</p>; - } - case 401: { - pageStateSetter((prevState: PageStateType) => ({ - ...prevState, - hasError: true, - isLoggedIn: false, + (cache as any).clear(); + return <p>Profile not found...</p>; + } + case 401: { + pageStateSetter((prevState: PageStateType) => ({ + ...prevState, + hasError: true, + isLoggedIn: false, error: i18n`Wrong credentials given.` - })); - return <p>Wrong credentials...</p>; - } - default: { - pageStateSetter((prevState: PageStateType) => ({ - ...prevState, - hasError: true, - isLoggedIn: false, + })); + return <p>Wrong credentials...</p>; + } + default: { + pageStateSetter((prevState: PageStateType) => ({ + ...prevState, + hasError: true, + isLoggedIn: false, error: i18n`Account information could not be retrieved.` - })); - return <p>Unknown problem...</p>; - } - } + })); + return <p>Unknown problem...</p>; + } } + } if (!data) return <p>Retrieving the profile page...</p>; /** @@ -1638,18 +1638,18 @@ function Account(Props: any): VNode { <BankFrame> <CurrencyContext.Provider value={balance.currency}> <PaytoWireTransfer backendState={backendState} /> - </CurrencyContext.Provider></BankFrame>); + </CurrencyContext.Provider></BankFrame>); } return (<BankFrame> <div> <h1 class="nav"> - <Translate>Welcome, {accountLabel} ({getIbanFromPayto(data.paytoUri)})!</Translate> + <Translate>Welcome, {accountLabel} ({getIbanFromPayto(data.paytoUri)})!</Translate> </h1> </div> <section id="menu"> <p>{i18n`Bank account balance:`} <br /> - { data.balance.credit_debit_indicator == 'debit' ? (<b>-</b>) : null } - <b>{`${balance.value} ${balance.currency}`}</b></p> + { data.balance.credit_debit_indicator == 'debit' ? (<b>-</b>) : null } + <b>{`${balance.value} ${balance.currency}`}</b></p> </section> <CurrencyContext.Provider value={balance.currency}> {Props.children} @@ -1664,7 +1664,7 @@ function Account(Props: any): VNode { <p><a href="#" onClick={() => pageStateSetter((prevState: PageStateType) => ({...prevState, tryManualTransfer: true})) - }>{i18n`Transfer money manually`}</a></p> + }>{i18n`Transfer money manually`}</a></p> </article> </section> </BankFrame>); @@ -1688,7 +1688,7 @@ function SWRWithCredentials(props: any): VNode { fetch(backendUrl + url || '', { headers }).then( (r) => { if (!r.ok) { - throw {status: r.status, json: r.json()}; + throw {status: r.status, json: r.json()}; } return r.json() } @@ -1707,7 +1707,7 @@ function SWRWithoutCredentials(Props: any): VNode { fetch(baseUrl + url || '').then( (r) => { if (!r.ok) { - throw {status: r.status, json: r.json()}; + throw {status: r.status, json: r.json()}; } return r.json() } @@ -1727,24 +1727,24 @@ function PublicHistories(Props: any): VNode { if (typeof error !== 'undefined') { console.log('account error', error); switch(error.status) { - case 404: - console.log('public accounts: 404', error); - Props.pageStateSetter((prevState: PageStateType) => ({ - ...prevState, - hasError: true, - showPublicHistories: false, - error: i18n`List of public accounts was not found.` - })); - break; - default: - console.log('public accounts: non-404 error', error); - Props.pageStateSetter((prevState: PageStateType) => ({ - ...prevState, - hasError: true, - showPublicHistories: false, + case 404: + console.log('public accounts: 404', error); + Props.pageStateSetter((prevState: PageStateType) => ({ + ...prevState, + hasError: true, + showPublicHistories: false, + error: i18n`List of public accounts was not found.` + })); + break; + default: + console.log('public accounts: non-404 error', error); + Props.pageStateSetter((prevState: PageStateType) => ({ + ...prevState, + hasError: true, + showPublicHistories: false, error: i18n`List of public accounts could not be retrieved.` - })); - break; + })); + break; } } if (!data) return <p>Waiting public accounts list...</p> @@ -1767,7 +1767,7 @@ function PublicHistories(Props: any): VNode { <li class={isSelected ? 'pure-menu-selected pure-menu-item' : 'pure-menu-item pure-menu'}> <a href="#" class="pure-menu-link" - onClick={() => setShowAccount(account.accountLabel)}>{account.accountLabel}</a> + onClick={() => setShowAccount(account.accountLabel)}>{account.accountLabel}</a> </li> ); txs[account.accountLabel] = <Transactions accountLabel={account.accountLabel} pageNumber={0} /> @@ -1829,7 +1829,7 @@ export function BankHome(): VNode { <PageContext.Provider value={[pageState, pageStateSetter]}> <BankFrame> <p>{i18n`Currently, the bank is not accepting new registrations!`}</p> - </BankFrame> + </BankFrame> </PageContext.Provider> ); } @@ -1837,18 +1837,18 @@ export function BankHome(): VNode { if (typeof backendState === 'undefined') { pageStateSetter((prevState) => ({ ...prevState, - hasError: true, - isLoggedIn: false, - error: i18n`Page has a problem: logged in but backend state is lost.` + hasError: true, + isLoggedIn: false, + error: i18n`Page has a problem: logged in but backend state is lost.` })); return <p>Error: waiting for details...</p>; } console.log('Showing the profile page..'); return ( <SWRWithCredentials - username={backendState.username} - password={backendState.password} - backendUrl={backendState.url}> + username={backendState.username} + password={backendState.password} + backendUrl={backendState.url}> <PageContext.Provider value={[pageState, pageStateSetter]}> <Account accountLabel={backendState.username} backendState={backendState} /> </PageContext.Provider> @@ -1864,14 +1864,14 @@ export function BankHome(): VNode { if (__LIBEUFIN_UI_ALLOW_REGISTRATIONS__) { return (<Fragment> <p><Translate>If you are a new customer please&nbsp; - <a href="#" onClick={() => + <a href="#" onClick={() => {pageStateSetter((prevState) => ({...prevState, tryRegister: true}))}}>register!</a> &nbsp;&nbsp;</Translate></p>{ maybeDemoContent(<p><Translate>Registration is fast and free, and it gives you a registration bonus of 100 <Currency /> </Translate></p>) - /*close JS block of optional content*/ } + /*close JS block of optional content*/ } </Fragment>); // close return of registrations allowance. } // close 'then' branch of registrations allowance. } // close helper function. @@ -1880,14 +1880,14 @@ export function BankHome(): VNode { <BankFrame> <h1 class="nav">{i18n`Welcome to the bank!`}</h1> <LoginForm - pageStateSetter={pageStateSetter} - backendStateSetter={backendStateSetter} /> - {regMsg()} - {maybeDemoContent(<p><Translate> + pageStateSetter={pageStateSetter} + backendStateSetter={backendStateSetter} /> + {regMsg()} + {maybeDemoContent(<p><Translate> To view transactions of public accounts, please <a href="#" - onClick={goPublicAccounts(pageStateSetter)}>click here</a>. - </Translate></p> - )} + onClick={goPublicAccounts(pageStateSetter)}>click here</a>. + </Translate></p> + )} </BankFrame> </PageContext.Provider> );