import { Loader2 } from "lucide-react"; import { MAX_PAGES_LIMIT, MIN_PAGES, } from "@/client/features/audit/launch/types"; import type { useLaunchController } from "@/client/features/audit/launch/useLaunchController"; import { getFieldError, getFormError } from "@/client/lib/forms"; type Props = { launchForm: ReturnType["launchForm"]; commitMaxPagesInput: () => number; }; export function LaunchFormCard({ commitMaxPagesInput, launchForm }: Props) { return (

Start New Audit

{ event.preventDefault(); void launchForm.handleSubmit(); }} > {(field) => { const urlError = getFieldError(field.state.meta.errors); return ( ); }} state.isSubmitting}> {(isSubmitting) => ( )}
); } function LaunchOptions({ launchForm, commitMaxPagesInput }: Props) { return (
Max pages {(field) => ( { const next = event.target.value; if (!/^\d*$/.test(next)) return; field.handleChange(next); if (launchForm.state.errorMap.onSubmit) { launchForm.setErrorMap({ onSubmit: undefined }); } }} onBlur={commitMaxPagesInput} /> )}

Enter any value from {MIN_PAGES} to {MAX_PAGES_LIMIT}.

); } function LighthouseOptions({ launchForm }: Pick) { return (
snapshot.values.runLighthouse} > {(runLighthouse) => runLighthouse ? (

We choose a sample of 20 pages to audit, removing pages from duplicate templates.

) : null }
); } function LaunchErrors({ launchForm }: Pick) { return (
{(field) => { const urlError = getFieldError(field.state.meta.errors); return urlError ? (

{urlError}

) : null; }}
state.errorMap.onSubmit}> {(submitError) => { const errorMessage = getFormError(submitError); return errorMessage ? (
{errorMessage}
) : null; }}
); }