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.3 KB · 24 lines tsx
Raw Blame History
1'use client';23import { useActionState } from 'react';4import { saveSearchAction } from '@/lib/account/actions';5import { idle } from '@/lib/auth/state';6import { Checkbox, Field, FormMessage, SubmitButton, TextInput } from '@/components/account/form';78export function SaveSearchForm({ initialUrl, initialName }: { initialUrl: string; initialName: string }) {9  const [state, action] = useActionState(saveSearchAction, idle);10  return (11    <form action={action} className="space-y-3" noValidate key={state.ok ? 'reset' : 'form'}>12      <FormMessage state={state} />13      <Field label="Name" name="name" error={state.fieldErrors?.name}>14        <TextInput name="name" required maxLength={80} defaultValue={initialName} placeholder="e.g. PSA 10 Charizards under $5k" />15      </Field>16      <Field label="RareIndex URL" name="url" error={state.fieldErrors?.url} hint="Paste the path of a /search or /explore page with its filters.">17        <TextInput name="url" required defaultValue={initialUrl} placeholder="/search?q=charizard+psa+10&max=5000" className="mono-num text-xs md:text-xs" />18      </Field>19      <Checkbox name="notify" label="Notify me about new matches" description="Re-run daily; new assets or listings go to your inbox." />20      <SubmitButton pendingText="Saving…">Save search</SubmitButton>21    </form>22  );23}24