SPB Git forge

spb/rareindex

Public
54commits 1branches 0releases
7.1 MBsize
maindefault branch
10 days agolast push
TypeScript 61.9% HTML 37.2% SQL 0.7%
1.1 KB · 30 lines tsx
Raw Blame History
1'use client';23import { useActionState } from 'react';4import { resetAction } from '@/lib/auth/actions';5import { idle } from '@/lib/auth/state';6import { CodeInput, Field, FormMessage, PasswordField, SubmitButton, TextInput } from '@/components/account/form';78export function ResetForm({ token }: { token: string }) {9  const [state, action] = useActionState(resetAction, idle);10  return (11    <form action={action} className="mt-6 space-y-4" noValidate>12      <FormMessage state={state} />13      {token ? (14        <input type="hidden" name="t" value={token} />15      ) : (16        <>17          <Field label="E-mail" name="email" error={state.fieldErrors?.email}>18            <TextInput name="email" type="email" autoComplete="email" required />19          </Field>20          <CodeInput name="code" autoSubmit={false} error={state.fieldErrors?.code} label="Reset code" />21        </>22      )}23      <PasswordField name="password" label="New password" autoComplete="new-password" error={state.fieldErrors?.password} />24      <SubmitButton className="w-full" pendingText="Saving…">25        Set new password26      </SubmitButton>27    </form>28  );29}30