diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-09-25 19:22:15 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-09-25 19:22:15 +0200 |
commit | 482e00d055f70a178449603c6604f747779d0d5d (patch) | |
tree | ae3c760f42f7fb51834039be89aa94bceb7977c0 /packages | |
parent | 86575541f07cdb7f5c076742ef9385b1ba663dd8 (diff) | |
download | merchant-backoffice-482e00d055f70a178449603c6604f747779d0d5d.tar.gz merchant-backoffice-482e00d055f70a178449603c6604f747779d0d5d.tar.bz2 merchant-backoffice-482e00d055f70a178449603c6604f747779d0d5d.zip |
-hide registration button if registrations are disabled
Diffstat (limited to 'packages')
-rw-r--r-- | packages/bank/src/pages/home/index.tsx | 68 |
1 files changed, 43 insertions, 25 deletions
diff --git a/packages/bank/src/pages/home/index.tsx b/packages/bank/src/pages/home/index.tsx index 3c4f349..90e044f 100644 --- a/packages/bank/src/pages/home/index.tsx +++ b/packages/bank/src/pages/home/index.tsx @@ -133,7 +133,6 @@ interface AccountStateType { ***********/ function maybeDemoContent(content: VNode) { - // @ts-ignore if (__LIBEUFIN_UI_IS_DEMO__) return content; } @@ -865,7 +864,10 @@ function BankFrame(Props: any): VNode { <div style="max-width: 50em; margin-left: 2em;"> <h1> <span class="it"> - <a href="/">__LIBEUFIN_UI_BANK_NAME__</a> + <a href="/">{ + __LIBEUFIN_UI_BANK_NAME__ + } + </a> </span> </h1>{ maybeDemoContent(<p><Translate> @@ -1279,6 +1281,26 @@ function TalerWithdrawal(Props: any): VNode { </article>); } +function RegistrationButton(Props: any): VNode { + const { backendStateSetter, pageStateSetter } = Props; + const i18n = useTranslator(); + if (__LIBEUFIN_UI_ALLOW_REGISTRATIONS__) + { + return (<button + autofocus + class="pure-button pure-button-secondary btn-cancel" + onClick={() => { + pageStateSetter((prevState: PageStateType) => ({ ...prevState, tryRegister: true })) + }}> + {i18n`Register`} + </button>); + } + else + { + return (<span></span>); + } +} + /** * Collect and submit login data. */ @@ -1337,15 +1359,10 @@ function LoginForm(Props: any): VNode { pageStateSetter ); submitDataSetter(undefined); - }}>{i18n`Login`}</button> - <button - autofocus - class="pure-button pure-button-secondary btn-cancel" - onClick={() => { - pageStateSetter((prevState: PageStateType) => ({ ...prevState, tryRegister: true })) - }}> - {i18n`Register`} - </button> + }}>{i18n`Login`} + </button>) + + RegistrationButton(props) + + ( </div> </form>); } @@ -1361,7 +1378,11 @@ function RegistrationForm(Props: any): VNode { // https://stackoverflow.com/questions/36683770/how-to-get-the-value-of-an-input-field-using-reactjs return ( <Fragment> - <h1 class="nav">{i18n`Welcome to ${__LIBEUFIN_UI_BANK_NAME__}!`}</h1> + <h1 class="nav"> + { + i18n`Welcome to ${__LIBEUFIN_UI_BANK_NAME__}!` + } + </h1> <aside class="sidebar" id="left" /> <article> <div class="register-form"> @@ -1801,7 +1822,8 @@ function PublicHistories(Props: any): VNode { break; } } - if (!data) return <p>Waiting public accounts list...</p> + if (!data) + return (<p>Waiting public accounts list...</p>) const txs: any = {}; const accountsBar = []; @@ -1868,7 +1890,7 @@ export function BankHome(): VNode { </SWRWithoutCredentials>); if (pageState.tryRegister) { - console.log('allow registrations?', __LIBEUFIN_UI_ALLOW_REGISTRATIONS__) + console.log('allow registrations?', __LIBEUFIN_UI_ALLOW_REGISTRATIONS__); if (__LIBEUFIN_UI_ALLOW_REGISTRATIONS__) return ( <PageContext.Provider value={[pageState, pageStateSetter]}> @@ -1894,7 +1916,7 @@ export function BankHome(): VNode { isLoggedIn: false, error: i18n`Page has a problem: logged in but backend state is lost.` })); - return <p>Error: waiting for details...</p>; + return (<p>Error: waiting for details...</p>); } console.log('Showing the profile page..'); return ( @@ -1908,22 +1930,18 @@ export function BankHome(): VNode { </SWRWithCredentials> ); } // end of logged-in state. - /** - * Currency only known _after_ a user logs in / registers. Thus not - * mentioning the currency right at the home page (as instead the Python - * bank did.) FIXME: currency needed at startup too. */ - const regMsg = function () { - if (__LIBEUFIN_UI_ALLOW_REGISTRATIONS__) - return <span></span> - } // close helper function. + return ( <PageContext.Provider value={[pageState, pageStateSetter]}> <BankFrame> - <h1 class="nav">{i18n`Welcome to ${__LIBEUFIN_UI_BANK_NAME__}!`}</h1> + <h1 class="nav"> + { + i18n`Welcome to ${__LIBEUFIN_UI_BANK_NAME__}!` + } + </h1> <LoginForm pageStateSetter={pageStateSetter} backendStateSetter={backendStateSetter} /> - {regMsg()} {maybeDemoContent(<p><Translate> To view transactions of public accounts, please <a href="#" onClick={goPublicAccounts(pageStateSetter)}>click here</a>. |