confirm personal information fix #7090
This commit is contained in:
parent
ea13e19ece
commit
0ac7433ea7
@ -6,6 +6,7 @@ import { DateInput } from "../../components/fields/DateInput";
|
||||
import { PhoneNumberInput } from "../../components/fields/NumberInput";
|
||||
import { TextInput } from "../../components/fields/TextInput";
|
||||
import { useAnastasisContext } from "../../context/anastasis";
|
||||
import { ConfirmModal } from "./ConfirmModal";
|
||||
import { AnastasisClientFrame, withProcessLabel } from "./index";
|
||||
|
||||
export function AttributeEntryScreen(): VNode {
|
||||
@ -18,6 +19,7 @@ export function AttributeEntryScreen(): VNode {
|
||||
const [attrs, setAttrs] = useState<Record<string, string>>(
|
||||
currentIdentityAttributes,
|
||||
);
|
||||
const [askUserIfSure, setAskUserIfSure] = useState(false);
|
||||
|
||||
if (!reducer) {
|
||||
return <div>no reducer in context</div>;
|
||||
@ -51,12 +53,25 @@ export function AttributeEntryScreen(): VNode {
|
||||
<AnastasisClientFrame
|
||||
title={withProcessLabel(reducer, "Who are you?")}
|
||||
hideNext={hasErrors ? "Complete the form." : undefined}
|
||||
onNext={() =>
|
||||
reducer.transition("enter_user_attributes", {
|
||||
identity_attributes: attrs,
|
||||
})
|
||||
}
|
||||
onNext={async () => setAskUserIfSure(true) }
|
||||
>
|
||||
{askUserIfSure ? (
|
||||
<ConfirmModal
|
||||
active
|
||||
onCancel={() => setAskUserIfSure(false)}
|
||||
description="You can not forget what you had entered"
|
||||
label="I am sure"
|
||||
cancelLabel="Wait, I want to check"
|
||||
onConfirm={() => reducer.transition("enter_user_attributes", {
|
||||
identity_attributes: attrs,
|
||||
})}
|
||||
>
|
||||
You personal information is used to define the location where your
|
||||
secret will be safely stored. If you forget what you have entered or
|
||||
if there is a misspell you will be unable to recover your secret again.
|
||||
</ConfirmModal>
|
||||
) : null}
|
||||
|
||||
<div class="columns" style={{ maxWidth: "unset" }}>
|
||||
<div class="column">{fieldList}</div>
|
||||
<div class="column">
|
||||
|
@ -10,6 +10,7 @@ import {
|
||||
isKnownAuthMethods,
|
||||
KnownAuthMethods,
|
||||
} from "./authMethod";
|
||||
import { ConfirmModal } from "./ConfirmModal";
|
||||
import { AnastasisClientFrame } from "./index";
|
||||
|
||||
const getKeys = Object.keys as <T extends object>(obj: T) => Array<keyof T>;
|
||||
@ -246,60 +247,3 @@ function AuthMethodNotImplemented(props: AuthMethodSetupProps): VNode {
|
||||
);
|
||||
}
|
||||
|
||||
function ConfirmModal({
|
||||
active,
|
||||
description,
|
||||
onCancel,
|
||||
onConfirm,
|
||||
children,
|
||||
danger,
|
||||
disabled,
|
||||
label = "Confirm",
|
||||
}: ConfirmModelProps): VNode {
|
||||
return (
|
||||
<div class={active ? "modal is-active" : "modal"}>
|
||||
<div class="modal-background " onClick={onCancel} />
|
||||
<div class="modal-card" style={{ maxWidth: 700 }}>
|
||||
<header class="modal-card-head">
|
||||
{!description ? null : (
|
||||
<p class="modal-card-title">
|
||||
<b>{description}</b>
|
||||
</p>
|
||||
)}
|
||||
<button class="delete " aria-label="close" onClick={onCancel} />
|
||||
</header>
|
||||
<section class="modal-card-body">{children}</section>
|
||||
<footer class="modal-card-foot">
|
||||
<button class="button" onClick={onCancel}>
|
||||
Dismiss
|
||||
</button>
|
||||
<div class="buttons is-right" style={{ width: "100%" }}>
|
||||
<button
|
||||
class={danger ? "button is-danger " : "button is-info "}
|
||||
disabled={disabled}
|
||||
onClick={onConfirm}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
<button
|
||||
class="modal-close is-large "
|
||||
aria-label="close"
|
||||
onClick={onCancel}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
interface ConfirmModelProps {
|
||||
active?: boolean;
|
||||
description?: string;
|
||||
onCancel?: () => void;
|
||||
onConfirm?: () => void;
|
||||
label?: string;
|
||||
children?: ComponentChildren;
|
||||
danger?: boolean;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
52
packages/anastasis-webui/src/pages/home/ConfirmModal.tsx
Normal file
52
packages/anastasis-webui/src/pages/home/ConfirmModal.tsx
Normal file
@ -0,0 +1,52 @@
|
||||
import { ComponentChildren, h, VNode } from "preact";
|
||||
|
||||
export interface ConfirmModelProps {
|
||||
active?: boolean;
|
||||
description?: string;
|
||||
onCancel?: () => void;
|
||||
onConfirm?: () => void;
|
||||
label?: string;
|
||||
cancelLabel?: string;
|
||||
children?: ComponentChildren;
|
||||
danger?: boolean;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export function ConfirmModal({
|
||||
active, description, onCancel, onConfirm, children, danger, disabled, label = "Confirm", cancelLabel = "Dismiss"
|
||||
}: ConfirmModelProps): VNode {
|
||||
return (
|
||||
<div class={active ? "modal is-active" : "modal"}>
|
||||
<div class="modal-background " onClick={onCancel} />
|
||||
<div class="modal-card" style={{ maxWidth: 700 }}>
|
||||
<header class="modal-card-head">
|
||||
{!description ? null : (
|
||||
<p class="modal-card-title">
|
||||
<b>{description}</b>
|
||||
</p>
|
||||
)}
|
||||
<button class="delete " aria-label="close" onClick={onCancel} />
|
||||
</header>
|
||||
<section class="modal-card-body">{children}</section>
|
||||
<footer class="modal-card-foot">
|
||||
<button class="button" onClick={onCancel}>
|
||||
{cancelLabel}
|
||||
</button>
|
||||
<div class="buttons is-right" style={{ width: "100%" }}>
|
||||
<button
|
||||
class={danger ? "button is-danger " : "button is-info "}
|
||||
disabled={disabled}
|
||||
onClick={onConfirm}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
<button
|
||||
class="modal-close is-large "
|
||||
aria-label="close"
|
||||
onClick={onCancel} />
|
||||
</div>
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue
Block a user