ekyc

Electronic KYC process with uploading ID document using OAuth 2.1 (experimental)
Log | Files | Refs | README | LICENSE

email_input.tsx (726B)


      1 import { useComputed, useSignal } from "@preact/signals";
      2 import { EMAIL_REGEX } from "#core/domain/constants.ts";
      3 
      4 export default function EmailInput(props: { error: boolean }) {
      5   const error = useSignal(props.error);
      6   const value = useSignal("");
      7 
      8   const invalid = useComputed(() => {
      9     if (error.value) return true;
     10     if (value.value === "") return undefined;
     11     return EMAIL_REGEX.test(value.value) ? "false" : "true";
     12   });
     13 
     14   return (
     15     <label>
     16       Email:
     17       <input
     18         type="email"
     19         name="email"
     20         value={value}
     21         aria-invalid={invalid}
     22         onInput={(e) => {
     23           error.value = false;
     24           value.value = e.currentTarget.value;
     25         }}
     26       />
     27     </label>
     28   );
     29 }