import { useState, type FormEvent } from 'react'; import { Link } from 'react-router-dom'; import { Heading } from '../../components/ui/heading'; import { InputControl } from '../../components/ui/input-control'; import { Button } from '../../components/ui/button'; import { DismissibleAlert } from '../../components/ui/dismissible-alert'; import { requestNeutralAccount, type NeutralAccountOutcome } from '../../services/neutralAccountRequest'; // Creating an account on the org-less patient portal: an email and a name, no practice involved. export const NeutralSignupPage = () => { const [email, setEmail] = useState(''); const [firstname, setFirstname] = useState(''); const [lastname, setLastname] = useState(''); // The age-gated features read this from the record, so the account is not made without it. const [birthdate, setBirthdate] = useState(''); const [submitting, setSubmitting] = useState(false); const [outcome, setOutcome] = useState(null); const birthdateInFuture = birthdate !== '' && birthdate > new Date().toISOString().slice(0, 10); const canSubmit = email.trim() !== '' && firstname.trim() !== '' && lastname.trim() !== '' && birthdate !== '' && !birthdateInFuture && !submitting; const onSubmit = async (event: FormEvent) => { event.preventDefault(); if (!canSubmit) return; setSubmitting(true); setOutcome(null); setOutcome(await requestNeutralAccount({ email, firstname, lastname, birthdate })); setSubmitting(false); }; // Never says the account was created: the server answers the same way for an address it already holds. if (outcome?.outcome === 'accepted') { return (
Check your email. If that address can be used, we have sent what you need to sign in. Sign in
); } return (
Create your Akashic account

Your record belongs to you, not to a practice. You can add your practices later.

{outcome?.outcome === 'refused' && {outcome.message}} {outcome?.outcome === 'unreachable' && ( We could not reach Akashic. Check your connection and try again. )} setEmail(value ?? '')} /> setFirstname(value ?? '')} /> setLastname(value ?? '')} /> setBirthdate(value ?? '')} /> {birthdateInFuture &&

Date of birth cannot be in the future.

}
I already have an account
); }; export default NeutralSignupPage;