merchant-backoffice

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

commit 483d6da704e644f3f4fc741dd7cbd34b4a2423a2
parent 5189b9dc44519bcd60b73bf4483aace5e52e271d
Author: ms <ms@taler.net>
Date:   Sat,  8 Jan 2022 10:11:40 +0100

partially addressing state persistence

Diffstat:
Mpackages/bank/build-bank-translations.sh | 2+-
Mpackages/bank/package.json | 12++++++++----
Mpackages/bank/src/context/translation.ts | 1+
Mpackages/bank/src/i18n/bank.pot | 82++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Mpackages/bank/src/i18n/de.po | 82++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Mpackages/bank/src/i18n/en.po | 96++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Apackages/bank/src/i18n/it.po | 89+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpackages/bank/src/i18n/strings.ts | 90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------
Mpackages/bank/src/pages/home/index.tsx | 37+++++++++++++++++++++++++++----------
9 files changed, 348 insertions(+), 143 deletions(-)

diff --git a/packages/bank/build-bank-translations.sh b/packages/bank/build-bank-translations.sh @@ -6,7 +6,7 @@ function build { POTGEN=node_modules/@gnu-taler/pogen/bin/pogen PACKAGE_NAME=$1 - find \( -name "*.ts" -or -name "*.tsx" \) ! -name "*.d.ts" \ + find src/ \( -type f -name "*.ts" -or -name "*.tsx" \) ! -name "*.d.ts" \ | xargs node $POTGEN \ | msguniq \ | msgmerge src/i18n/poheader - \ diff --git a/packages/bank/package.json b/packages/bank/package.json @@ -37,23 +37,25 @@ }, "devDependencies": { "@babel/core": "^7.13.16", + "@babel/plugin-transform-react-jsx": "^7.12.13", + "@babel/plugin-transform-react-jsx-source": "^7.12.13", + "@babel/preset-env": "^7.16.7", "@creativebulma/bulma-tooltip": "^1.2.0", + "@gnu-taler/pogen": "^0.0.5", "@storybook/addon-a11y": "6.2.9", "@storybook/addon-actions": "6.2.9", "@storybook/addon-essentials": "6.2.9", "@storybook/addon-links": "6.2.9", "@storybook/preact": "6.2.9", "@storybook/preset-scss": "^1.0.3", + "@testing-library/jest-dom": "^5.16.1", "@testing-library/preact": "^2.0.1", "@testing-library/preact-hooks": "^1.1.0", - "@testing-library/jest-dom": "^5.16.1", "@types/enzyme": "^3.10.10", "@types/jest": "^27.0.2", "@typescript-eslint/eslint-plugin": "^5.3.0", "@typescript-eslint/parser": "^5.3.0", - "jest-fetch-mock": "^3.0.3", "bulma": "^0.9.3", - "@gnu-taler/pogen": "^0.0.5", "bulma-checkbox": "^1.1.1", "bulma-radio": "^1.1.1", "enzyme": "^3.11.0", @@ -61,9 +63,11 @@ "eslint": "^8.1.0", "eslint-config-preact": "^1.2.0", "jest": "^27.3.1", + "jest-fetch-mock": "^3.0.3", "jest-preset-preact": "^4.0.5", - "po2json": "^0.4.5", + "jest-watch-typeahead": "^1.0.0", "jssha": "^3.2.0", + "po2json": "^0.4.5", "preact-cli": "3.0.5", "sass": "1.32.13", "sass-loader": "^10", diff --git a/packages/bank/src/context/translation.ts b/packages/bank/src/context/translation.ts @@ -50,6 +50,7 @@ export const TranslationProvider = ({ children, forceLang, }: Props): VNode => { + const [lang, changeLanguage] = useLang(initial); useEffect(() => { if (forceLang) { diff --git a/packages/bank/src/i18n/bank.pot b/packages/bank/src/i18n/bank.pot @@ -1,80 +1,90 @@ -#: /home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:55 +# This file is part of GNU Taler +# (C) 2021 Taler Systems S.A. +# GNU Taler is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3, or (at your option) any later version. +# GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public License along with +# GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: Taler Wallet\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-23 00:00+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/components/picker/DurationPicker.tsx:55 #, c-format msgid "days" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:65 +#: src/components/picker/DurationPicker.tsx:65 #, c-format msgid "hours" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:76 +#: src/components/picker/DurationPicker.tsx:76 #, c-format msgid "minutes" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:87 +#: src/components/picker/DurationPicker.tsx:87 #, c-format msgid "seconds" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:549 +#: src/pages/home/index.tsx:561 #, c-format msgid "Page has a problem:" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:560 +#: src/pages/home/index.tsx:564 +#, c-format +msgid "Go back" +msgstr "" + +#: src/pages/home/index.tsx:576 #, c-format msgid "Page has a problem: logged in but backend state is lost." msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:588 +#: src/pages/home/index.tsx:604 #, c-format msgid "Charge Taler wallet" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:594 +#: src/pages/home/index.tsx:610 #, c-format msgid "Close" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:601 +#: src/pages/home/index.tsx:617 #, c-format msgid "Confirm withdrawal" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:606 +#: src/pages/home/index.tsx:622 #, c-format msgid "Abort withdrawal" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:656 +#: src/pages/home/index.tsx:632 #, c-format -msgid "Sign in" +msgid "Welcome to euFin bank: Taler+IBAN now possible!" msgstr "" -# This file is part of GNU Taler -# (C) 2021 Taler Systems S.A. -# GNU Taler is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 3, or (at your option) any later version. -# GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# You should have received a copy of the GNU General Public License along with -# GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -# -#, fuzzy -msgid "" +#: src/pages/home/index.tsx:673 +#, c-format +msgid "Sign in" msgstr "" -"Project-Id-Version: Taler Wallet\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-11-23 00:00+0100\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" -"Language-Team: LANGUAGE <LL@li.org>\n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" diff --git a/packages/bank/src/i18n/de.po b/packages/bank/src/i18n/de.po @@ -1,79 +1,89 @@ -#: /home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:55 +# This file is part of GNU Taler +# (C) 2021 Taler Systems S.A. +# GNU Taler is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3, or (at your option) any later version. +# GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public License along with +# GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +# +msgid "" +msgstr "" +"Project-Id-Version: Taler Wallet\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-23 00:00+0100\n" +"PO-Revision-Date: 2022-01-08 09:57+0100\n" +"Last-Translator: <translate@taler.net>\n" +"Language-Team: German\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/components/picker/DurationPicker.tsx:55 #, c-format msgid "days" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:65 +#: src/components/picker/DurationPicker.tsx:65 #, c-format msgid "hours" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:76 +#: src/components/picker/DurationPicker.tsx:76 #, c-format msgid "minutes" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:87 +#: src/components/picker/DurationPicker.tsx:87 #, c-format msgid "seconds" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:549 +#: src/pages/home/index.tsx:561 #, c-format msgid "Page has a problem:" -msgstr "Es gibt ein Problem:" +msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:560 +#: src/pages/home/index.tsx:564 +#, c-format +msgid "Go back" +msgstr "" + +#: src/pages/home/index.tsx:576 #, c-format msgid "Page has a problem: logged in but backend state is lost." msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:588 +#: src/pages/home/index.tsx:604 #, c-format msgid "Charge Taler wallet" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:594 +#: src/pages/home/index.tsx:610 #, c-format msgid "Close" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:601 +#: src/pages/home/index.tsx:617 #, c-format msgid "Confirm withdrawal" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:606 +#: src/pages/home/index.tsx:622 #, c-format msgid "Abort withdrawal" msgstr "" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:656 +#: src/pages/home/index.tsx:632 #, c-format -msgid "Sign in" +msgid "Welcome to euFin bank: Taler+IBAN now possible!" msgstr "" -# This file is part of GNU Taler -# (C) 2021 Taler Systems S.A. -# GNU Taler is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 3, or (at your option) any later version. -# GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# You should have received a copy of the GNU General Public License along with -# GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -# -msgid "" +#: src/pages/home/index.tsx:673 +#, c-format +msgid "Sign in" msgstr "" -"Project-Id-Version: Taler Wallet\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-11-23 00:00+0100\n" -"PO-Revision-Date: 2022-01-06 19:44+0100\n" -"Last-Translator: <translations@taler.net>\n" -"Language-Team: German\n" -"Language: de\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" diff --git a/packages/bank/src/i18n/en.po b/packages/bank/src/i18n/en.po @@ -1,79 +1,89 @@ -#: /home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:55 +# This file is part of GNU Taler +# (C) 2021 Taler Systems S.A. +# GNU Taler is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3, or (at your option) any later version. +# GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public License along with +# GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +# +msgid "" +msgstr "" +"Project-Id-Version: Taler Wallet\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-23 00:00+0100\n" +"PO-Revision-Date: 2022-01-08 09:57+0100\n" +"Last-Translator: <translate@taler.net>\n" +"Language-Team: English\n" +"Language: en\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/components/picker/DurationPicker.tsx:55 #, c-format msgid "days" msgstr "days" -#: /home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:65 +#: src/components/picker/DurationPicker.tsx:65 #, c-format msgid "hours" msgstr "hours" -#: /home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:76 +#: src/components/picker/DurationPicker.tsx:76 #, c-format msgid "minutes" msgstr "minutes" -#: /home/job/merchant-backoffice/packages/bank/src/components/picker/DurationPicker.tsx:87 +#: src/components/picker/DurationPicker.tsx:87 #, c-format msgid "seconds" msgstr "seconds" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:549 +#: src/pages/home/index.tsx:561 #, c-format msgid "Page has a problem:" -msgstr "" +msgstr "Page has a problem:" + +#: src/pages/home/index.tsx:564 +#, c-format +msgid "Go back" +msgstr "Go back" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:560 +#: src/pages/home/index.tsx:576 #, c-format msgid "Page has a problem: logged in but backend state is lost." -msgstr "" +msgstr "Page has a problem: logged in but backend state is lost." -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:588 +#: src/pages/home/index.tsx:604 #, c-format msgid "Charge Taler wallet" -msgstr "" +msgstr "Charge Taler wallet" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:594 +#: src/pages/home/index.tsx:610 #, c-format msgid "Close" -msgstr "" +msgstr "Close" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:601 +#: src/pages/home/index.tsx:617 #, c-format msgid "Confirm withdrawal" -msgstr "" +msgstr "Confirm withdrawal" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:606 +#: src/pages/home/index.tsx:622 #, c-format msgid "Abort withdrawal" -msgstr "" +msgstr "Abort withdrawal" -#: /home/job/merchant-backoffice/packages/bank/src/pages/home/index.tsx:656 +#: src/pages/home/index.tsx:632 #, c-format -msgid "Sign in" -msgstr "" +msgid "Welcome to euFin bank: Taler+IBAN now possible!" +msgstr "Welcome to euFin bank: Taler+IBAN now possible!" -# This file is part of GNU Taler -# (C) 2021 Taler Systems S.A. -# GNU Taler is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 3, or (at your option) any later version. -# GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# You should have received a copy of the GNU General Public License along with -# GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> -# -msgid "" -msgstr "" -"Project-Id-Version: Taler Wallet\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-11-23 00:00+0100\n" -"PO-Revision-Date: 2022-01-06 19:43+0100\n" -"Last-Translator: <translations@taler.net>\n" -"Language-Team: English\n" -"Language: en\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" +#: src/pages/home/index.tsx:673 +#, c-format +msgid "Sign in" +msgstr "Sign in" diff --git a/packages/bank/src/i18n/it.po b/packages/bank/src/i18n/it.po @@ -0,0 +1,89 @@ +# This file is part of GNU Taler +# (C) 2021 Taler Systems S.A. +# GNU Taler is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3, or (at your option) any later version. +# GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public License along with +# GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +# +msgid "" +msgstr "" +"Project-Id-Version: Taler Wallet\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-23 00:00+0100\n" +"PO-Revision-Date: 2022-01-08 10:05+0100\n" +"Last-Translator: <translate@taler.net>\n" +"Language-Team: Italian\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/components/picker/DurationPicker.tsx:55 +#, c-format +msgid "days" +msgstr "" + +#: src/components/picker/DurationPicker.tsx:65 +#, c-format +msgid "hours" +msgstr "" + +#: src/components/picker/DurationPicker.tsx:76 +#, c-format +msgid "minutes" +msgstr "" + +#: src/components/picker/DurationPicker.tsx:87 +#, c-format +msgid "seconds" +msgstr "" + +#: src/pages/home/index.tsx:561 +#, c-format +msgid "Page has a problem:" +msgstr "" + +#: src/pages/home/index.tsx:564 +#, c-format +msgid "Go back" +msgstr "" + +#: src/pages/home/index.tsx:576 +#, c-format +msgid "Page has a problem: logged in but backend state is lost." +msgstr "" + +#: src/pages/home/index.tsx:604 +#, c-format +msgid "Charge Taler wallet" +msgstr "" + +#: src/pages/home/index.tsx:610 +#, c-format +msgid "Close" +msgstr "" + +#: src/pages/home/index.tsx:617 +#, c-format +msgid "Confirm withdrawal" +msgstr "" + +#: src/pages/home/index.tsx:622 +#, c-format +msgid "Abort withdrawal" +msgstr "" + +#: src/pages/home/index.tsx:632 +#, c-format +msgid "Welcome to euFin bank: Taler+IBAN now possible!" +msgstr "Benvenuti da banca euFin: prova Taler+IBAN!" + +#: src/pages/home/index.tsx:673 +#, c-format +msgid "Sign in" +msgstr "" diff --git a/packages/bank/src/i18n/strings.ts b/packages/bank/src/i18n/strings.ts @@ -21,6 +21,11 @@ strings['de'] = { "domain": "messages", "locale_data": { "messages": { + "": { + "domain": "messages", + "plural_forms": "nplurals=2; plural=(n != 1);", + "lang": "de" + }, "days": [ "" ], @@ -34,7 +39,10 @@ strings['de'] = { "" ], "Page has a problem:": [ - "Es gibt ein Problem:" + "" + ], + "Go back": [ + "" ], "Page has a problem: logged in but backend state is lost.": [ "" @@ -51,14 +59,12 @@ strings['de'] = { "Abort withdrawal": [ "" ], - "Sign in": [ + "Welcome to euFin bank: Taler+IBAN now possible!": [ "" ], - "": { - "domain": "messages", - "plural_forms": "nplurals=2; plural=(n != 1);", - "lang": "de" - } + "Sign in": [ + "" + ] } } }; @@ -67,6 +73,11 @@ strings['en'] = { "domain": "messages", "locale_data": { "messages": { + "": { + "domain": "messages", + "plural_forms": "nplurals=2; plural=(n != 1);", + "lang": "en" + }, "days": [ "days" ], @@ -80,6 +91,61 @@ strings['en'] = { "seconds" ], "Page has a problem:": [ + "Page has a problem:" + ], + "Go back": [ + "Go back" + ], + "Page has a problem: logged in but backend state is lost.": [ + "Page has a problem: logged in but backend state is lost." + ], + "Charge Taler wallet": [ + "Charge Taler wallet" + ], + "Close": [ + "Close" + ], + "Confirm withdrawal": [ + "Confirm withdrawal" + ], + "Abort withdrawal": [ + "Abort withdrawal" + ], + "Welcome to euFin bank: Taler+IBAN now possible!": [ + "Welcome to euFin bank: Taler+IBAN now possible!" + ], + "Sign in": [ + "Sign in" + ] + } + } +}; + +strings['it'] = { + "domain": "messages", + "locale_data": { + "messages": { + "": { + "domain": "messages", + "plural_forms": "nplurals=2; plural=(n != 1);", + "lang": "it" + }, + "days": [ + "" + ], + "hours": [ + "" + ], + "minutes": [ + "" + ], + "seconds": [ + "" + ], + "Page has a problem:": [ + "" + ], + "Go back": [ "" ], "Page has a problem: logged in but backend state is lost.": [ @@ -97,14 +163,12 @@ strings['en'] = { "Abort withdrawal": [ "" ], + "Welcome to euFin bank: Taler+IBAN now possible!": [ + "Benvenuti da banca euFin: prova Taler+IBAN!" + ], "Sign in": [ "" - ], - "": { - "domain": "messages", - "plural_forms": "nplurals=2; plural=(n != 1);", - "lang": "en" - } + ] } } }; diff --git a/packages/bank/src/pages/home/index.tsx b/packages/bank/src/pages/home/index.tsx @@ -4,6 +4,7 @@ import { useState, useEffect, StateUpdater } from "preact/hooks"; import { Buffer } from "buffer"; import { useTranslator, Translate } from "../../i18n"; import { QR } from "../../components/QR"; +import { useNotNullLocalStorage } from "../../hooks"; /********************************************** * Type definitions for states and API calls. * @@ -107,6 +108,10 @@ function useAccountState( return useState<AccountStateTypeOpt>(); } + +/** + * Wrapper providing defaults. + */ function usePageState( state: PageStateType = { isLoggedIn: false, @@ -114,7 +119,13 @@ function usePageState( withdrawalInProgress: false, } ): [PageStateType, StateUpdater<PageStateType>] { - return useState<PageStateType>(state); + const ret = useNotNullLocalStorage("page-state", JSON.stringify(state)); + const retObj: PageStateType = JSON.parse(ret[0]); + const retSetter: StateUpdater<PageStateType> = function(val) { + const newVal = val instanceof Function ? JSON.stringify(val(retObj)) : JSON.stringify(val) + ret[1](newVal) + } + return [retObj, retSetter]; } /** @@ -478,10 +489,10 @@ function Account(props: any) { if (!data) return <p>Retrieving the profile page...</p>; if (withdrawalOutcome) { - return <div> + return <Fragment> <p>{withdrawalOutcome}</p> {props.children} - </div> + </Fragment> } /** * A Taler withdrawal replaces everything in the page and @@ -493,18 +504,18 @@ function Account(props: any) { * the outcome. */ if (talerWithdrawUri) { - return (<div> + return (<Fragment> <p>Scan the following QR code, and then confirm!</p> <div>{QR({text: talerWithdrawUri})}</div> <a href={talerWithdrawUri}></a> <p>Withdraw address: <pre>{talerWithdrawUri}</pre></p> {props.children} - </div>); + </Fragment>); } - return (<div> + return (<Fragment> <p>Your balance is {data.balance.amount}.</p> {props.children} - </div>); + </Fragment>); } /** @@ -546,7 +557,12 @@ export function BankHome(): VNode { var i18n = useTranslator(); if (pageState.hasError) { - return <p>{i18n`Page has a problem:`} {pageState.error}</p>; + return <Fragment> + <p>{i18n`Page has a problem:`} {pageState.error}</p> + <a onClick={() => { + pageStateSetter((prevState) => ({...prevState, hasError: false})) + }}>{i18n`Go back`}</a> + </Fragment>; } /** @@ -612,7 +628,8 @@ export function BankHome(): VNode { var submitData: CredentialsRequestType; return ( - <div> + <Fragment> + <p>{i18n`Welcome to euFin bank: Taler+IBAN now possible!`}</p> <input type="text" placeholder="username" @@ -654,6 +671,6 @@ export function BankHome(): VNode { pageStateSetter ); }}>{i18n`Sign in`}</button> - </div> + </Fragment> ); }