From a82b5a6992fda61d6eaa0bb079e284805a394777 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 3 Nov 2021 17:30:11 -0300 Subject: feedback from meeting and editing policy --- packages/anastasis-webui/package.json | 4 +- .../anastasis-webui/src/components/AsyncButton.tsx | 51 ++++++++ .../src/components/fields/DateInput.tsx | 46 ++++--- .../src/components/menu/NavigationBar.tsx | 2 +- .../src/components/menu/SideBar.tsx | 14 +-- .../src/components/picker/DatePicker.tsx | 12 +- packages/anastasis-webui/src/hooks/async.ts | 77 ++++++++++++ .../pages/home/AttributeEntryScreen.stories.tsx | 4 +- .../src/pages/home/AttributeEntryScreen.tsx | 37 ++++-- .../src/pages/home/AuthenticationEditorScreen.tsx | 4 + .../src/pages/home/BackupFinishedScreen.tsx | 7 +- .../home/ContinentSelectionScreen.stories.tsx | 18 ++- .../src/pages/home/ContinentSelectionScreen.tsx | 36 +++--- .../pages/home/CountrySelectionScreen.stories.tsx | 39 ------ .../src/pages/home/CountrySelectionScreen.tsx | 31 ----- .../src/pages/home/EditPoliciesScreen.stories.tsx | 109 +++++++++++++++++ .../src/pages/home/EditPoliciesScreen.tsx | 133 +++++++++++++++++++++ .../pages/home/ReviewPoliciesScreen.stories.tsx | 8 +- .../src/pages/home/ReviewPoliciesScreen.tsx | 57 +++++++-- .../anastasis-webui/src/pages/home/StartScreen.tsx | 42 +++---- .../home/authMethod/AuthMethodQuestionSetup.tsx | 15 +-- packages/anastasis-webui/src/pages/home/index.tsx | 33 ++--- packages/anastasis-webui/src/scss/main.scss | 2 +- packages/anastasis-webui/src/utils/index.tsx | 97 ++++++++++++--- 24 files changed, 657 insertions(+), 221 deletions(-) create mode 100644 packages/anastasis-webui/src/components/AsyncButton.tsx create mode 100644 packages/anastasis-webui/src/hooks/async.ts delete mode 100644 packages/anastasis-webui/src/pages/home/CountrySelectionScreen.stories.tsx delete mode 100644 packages/anastasis-webui/src/pages/home/CountrySelectionScreen.tsx create mode 100644 packages/anastasis-webui/src/pages/home/EditPoliciesScreen.stories.tsx create mode 100644 packages/anastasis-webui/src/pages/home/EditPoliciesScreen.tsx diff --git a/packages/anastasis-webui/package.json b/packages/anastasis-webui/package.json index b032c563c..3042d8ca1 100644 --- a/packages/anastasis-webui/package.json +++ b/packages/anastasis-webui/package.json @@ -4,9 +4,9 @@ "version": "0.0.0", "license": "MIT", "scripts": { - "build": "preact build", + "build": "preact build --no-sw --no-esm", "serve": "sirv build --port 8080 --cors --single", - "dev": "preact watch", + "dev": "preact watch --no-sw --no-esm", "lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'", "test": "jest ./tests", "build-storybook": "build-storybook", diff --git a/packages/anastasis-webui/src/components/AsyncButton.tsx b/packages/anastasis-webui/src/components/AsyncButton.tsx new file mode 100644 index 000000000..5602715e4 --- /dev/null +++ b/packages/anastasis-webui/src/components/AsyncButton.tsx @@ -0,0 +1,51 @@ +/* + 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 + */ + +/** +* +* @author Sebastian Javier Marchano (sebasjm) +*/ + +import { ComponentChildren, h, VNode } from "preact"; +// import { LoadingModal } from "../modal"; +import { useAsync } from "../hooks/async"; +// import { Translate } from "../../i18n"; + +type Props = { + children: ComponentChildren; + disabled: boolean; + onClick?: () => Promise; + [rest: string]: any; +}; + +export function AsyncButton({ onClick, disabled, children, ...rest }: Props): VNode { + const { isLoading, request } = useAsync(onClick); + + // if (isSlow) { + // return ; + // } + console.log(isLoading) + if (isLoading) { + + return ; + } + + return + + ; +} diff --git a/packages/anastasis-webui/src/components/fields/DateInput.tsx b/packages/anastasis-webui/src/components/fields/DateInput.tsx index 69a05fcf3..c406b85d1 100644 --- a/packages/anastasis-webui/src/components/fields/DateInput.tsx +++ b/packages/anastasis-webui/src/components/fields/DateInput.tsx @@ -1,4 +1,4 @@ -import { format } from "date-fns"; +import { format, isAfter, parse, sub, subYears } from "date-fns"; import { h, VNode } from "preact"; import { useLayoutEffect, useRef, useState } from "preact/hooks"; import { DatePicker } from "../picker/DatePicker"; @@ -19,16 +19,14 @@ export function DateInput(props: DateInputProps): VNode { inputRef.current?.focus(); } }, [props.grabFocus]); - const [opened, setOpened2] = useState(false) - function setOpened(v: boolean): void { - console.log('dale', v) - setOpened2(v) - } + const [opened, setOpened] = useState(false) const value = props.bind[0] || ""; const [dirty, setDirty] = useState(false) const showError = dirty && props.error + const calendar = subYears(new Date(), 30) + return
-
- { setOpened(true) } } - value={value} - ref={inputRef} /> - - - - +
+
+

+ { + const text = e.currentTarget.value + setDirty(true) + props.bind[1](text); + }} + ref={inputRef} /> +

+

+ { setOpened(true) }}> + + +

+
+

Using the format yyyy-mm-dd

{showError &&

{props.error}

} setOpened(false)} dateReceiver={(d) => { setDirty(true) - const v = format(d, 'yyyy/MM/dd') + const v = format(d, 'yyyy-MM-dd') props.bind[1](v); }} /> diff --git a/packages/anastasis-webui/src/components/menu/NavigationBar.tsx b/packages/anastasis-webui/src/components/menu/NavigationBar.tsx index e1bb4c7c0..935951ab9 100644 --- a/packages/anastasis-webui/src/components/menu/NavigationBar.tsx +++ b/packages/anastasis-webui/src/components/menu/NavigationBar.tsx @@ -49,7 +49,7 @@ export function NavigationBar({ onMobileMenu, title }: Props): VNode {
diff --git a/packages/anastasis-webui/src/components/menu/SideBar.tsx b/packages/anastasis-webui/src/components/menu/SideBar.tsx index 35720e0f1..72655662f 100644 --- a/packages/anastasis-webui/src/components/menu/SideBar.tsx +++ b/packages/anastasis-webui/src/components/menu/SideBar.tsx @@ -39,9 +39,9 @@ export function Sidebar({ mobile }: Props): VNode { return (