"use client"; import type { Dispatch, FormEvent, SetStateAction } from "react"; import { AyanamsaPreferenceField } from "@/components/ayanamsa-preference-field"; import { ProfileFields } from "@/components/profile-fields"; import { ProfileGenderField } from "@/components/profile-gender-field"; import { resolveAyanamsa } from "@/lib/ayanamsa"; import type { Profile } from "@/lib/home-types"; export type ChartProfileFormProps = { readonly title: string; readonly description: string; readonly value: Profile; readonly onChange: Dispatch>; readonly nameInputId: string; readonly showAyanamsa?: boolean; /** Optional gender (女 / 男 / 不填); saved with the form. */ readonly showGender?: boolean; readonly onSubmit: (event: FormEvent) => void; readonly onCancel?: () => void; readonly cancelLabel?: string; readonly submitLabel: string; readonly submitDisabled: boolean; }; export function ChartProfileForm({ title, description, value, onChange, nameInputId, showAyanamsa = false, showGender = false, onSubmit, onCancel, cancelLabel = "取消", submitLabel, submitDisabled, }: ChartProfileFormProps) { return (
{title}{description}
{showGender ? ( onChange((current) => ({ ...current, gender }))} /> ) : null} {showAyanamsa ? ( onChange((current) => ({ ...current, ayanamsa }))} /> ) : null}
{onCancel ? : null}
); }