Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

1.3 KB
Raw Blame
import type { FormEvent } from 'react';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Spinner } from '@/components/ui/spinner';
import { FieldRow } from '@/components/DetailPanel';
import type { LoginCopy } from './loginCopy';

export interface LoginEmailFormProps {
  copy: LoginCopy;
  email: string;
  onEmailChange: (value: string) => void;
  loading: boolean;
  onSubmit: (e: FormEvent<HTMLFormElement>) => void;
  error?: string;
}

export default function LoginEmailForm({ copy, email, onEmailChange, loading, onSubmit, error }: LoginEmailFormProps) {
  return (
    <form onSubmit={onSubmit} noValidate className="flex flex-col gap-4">
      <FieldRow label="Email" htmlFor="email" error={error}>
        <Input
          id="email"
          type="email"
          className="h-(--control-h-lg)"
          placeholder="[email protected]"
          value={email}
          onChange={e => onEmailChange(e.target.value)}
          required
          autoComplete="email"
          autoFocus
        />
      </FieldRow>
      <Button type="submit" size="lg" className="mt-2 w-full" disabled={loading}>
        {loading && <Spinner className="size-4" />}
        {loading ? copy.busy : copy.submit}
      </Button>
    </form>
  );
}