修正大部分的编译错误。
This commit is contained in:
@@ -11,21 +11,24 @@ export function NewScheme() {
|
||||
const createScheme = useCreateScheme();
|
||||
const navigate = useNavigate();
|
||||
const [schemeType, setSchemeType] = useState<SchemeTypeOption['value']>('q_scheme');
|
||||
const [errors, formAction] = useActionState((prevState, formData) => {
|
||||
try {
|
||||
const name = formData.get('name') as string;
|
||||
if (isNil(name) || isEmpty(name)) {
|
||||
throw { name: 'Name is required' };
|
||||
const [errors, formAction] = useActionState<{ [key: string]: string }, FormData>(
|
||||
(_prevState, formData): { [key: string]: string } => {
|
||||
try {
|
||||
const name = formData.get('name') as string;
|
||||
if (isNil(name) || isEmpty(name)) {
|
||||
throw { name: 'Name is required' };
|
||||
}
|
||||
const description = (formData.get('description') ?? null) as string | null;
|
||||
const schemeType = (formData.get('type') ?? 'q_scheme') as SchemeTypeOption['value'];
|
||||
const newId = createScheme(name, schemeType, description);
|
||||
navigate(`../${newId}`);
|
||||
} catch (error) {
|
||||
return error as { [key: string]: string };
|
||||
}
|
||||
const description = (formData.get('description') ?? null) as string | null;
|
||||
const schemeType = (formData.get('type') ?? 'q_scheme') as SchemeTypeOption['value'];
|
||||
const newId = createScheme(name, schemeType, description);
|
||||
navigate(`../${newId}`);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
return {};
|
||||
}, {});
|
||||
return {} as { [key: string]: string };
|
||||
},
|
||||
{},
|
||||
);
|
||||
|
||||
return (
|
||||
<form action={formAction} className={styles.create_scheme_form_layout}>
|
||||
@@ -37,7 +40,7 @@ export function NewScheme() {
|
||||
options={SchemeTypeOptions}
|
||||
extendClassName={styles.custom_segment}
|
||||
value={schemeType}
|
||||
onChange={setSchemeType}
|
||||
onChange={(v) => setSchemeType(v as SchemeTypeOption['value'])}
|
||||
/>
|
||||
<input type="hidden" name="type" value={schemeType} />
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user