aboutsummaryrefslogtreecommitdiff
path: root/packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2021-11-03 17:30:11 -0300
committerSebastian <sebasjm@gmail.com>2021-11-03 17:35:29 -0300
commita82b5a6992fda61d6eaa0bb079e284805a394777 (patch)
tree857168ae8c28d93253ec319708ae0818bd76c30f /packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx
parent9fb6536fbc91adaf7a8a80860fcef5e1f80bfb3b (diff)
downloadwallet-core-a82b5a6992fda61d6eaa0bb079e284805a394777.tar.xz
feedback from meeting and editing policy
Diffstat (limited to 'packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx')
-rw-r--r--packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx37
1 files changed, 28 insertions, 9 deletions
diff --git a/packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx b/packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx
index 2c7f54c5b..52046b216 100644
--- a/packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx
+++ b/packages/anastasis-webui/src/pages/home/AttributeEntryScreen.tsx
@@ -7,6 +7,7 @@ import { AnastasisClientFrame, withProcessLabel } from "./index";
import { TextInput } from "../../components/fields/TextInput";
import { DateInput } from "../../components/fields/DateInput";
import { NumberInput } from "../../components/fields/NumberInput";
+import { isAfter, parse } from "date-fns";
export function AttributeEntryScreen(): VNode {
const reducer = useAnastasisContext()
@@ -46,15 +47,14 @@ export function AttributeEntryScreen(): VNode {
identity_attributes: attrs,
})}
>
- <div class="columns">
- <div class="column is-half">
+ <div class="columns" style={{ maxWidth: 'unset' }}>
+ <div class="column is-one-third">
{fieldList}
</div>
- <div class="column is-half" >
+ <div class="column is-two-third" >
<p>This personal information will help to locate your secret.</p>
- <h1><b>This stay private</b></h1>
- <p>The information you have entered here:
- </p>
+ <h1 class="title">This stays private</h1>
+ <p>The information you have entered here:</p>
<ul>
<li>
<span class="icon is-right">
@@ -111,15 +111,17 @@ function AttributeEntryField(props: AttributeEntryFieldProps): VNode {
bind={[props.value, props.setValue]}
/>
}
- <span>
+ <div class="block">
+ This stays private
<span class="icon is-right">
<i class="mdi mdi-eye-off" />
</span>
- This stay private
- </span>
+ </div>
</div>
);
}
+const YEAR_REGEX = /^[0-9]+-[0-9]+-[0-9]+$/
+
function checkIfValid(value: string, spec: UserAttributeSpec): string | undefined {
const pattern = spec['validation-regex']
@@ -136,5 +138,22 @@ function checkIfValid(value: string, spec: UserAttributeSpec): string | undefine
if (!optional && !value) {
return 'This value is required'
}
+ if ("date" === spec.type) {
+ if (!YEAR_REGEX.test(value)) {
+ return "The date doesn't follow the format"
+ }
+
+ try {
+ const v = parse(value, 'yyyy-MM-dd', new Date());
+ if (Number.isNaN(v.getTime())) {
+ return "Some numeric values seems out of range for a date"
+ }
+ if ("birthdate" === spec.name && isAfter(v, new Date())) {
+ return "A birthdate cannot be in the future"
+ }
+ } catch (e) {
+ return "Could not parse the date"
+ }
+ }
return undefined
}