fix(housekeeping): address task 14 review round 2

This commit is contained in:
Simo committed 2026-08-30 11:30:17 +02:00
1 parent d09eaa33d6
commit c524b305d7
17 files changed
+614 -130

No files matched your search

@@ -19,7 +19,7 @@ export interface ContentCommandField {
readonly min?: number;
readonly max?: number;
readonly maxLength?: number;
readonly defaultValue?: string | number;
readonly defaultValue?: string | number | boolean;
readonly options?: readonly Readonly<{
value: string | number;
label: string;
@@ -41,8 +41,8 @@ const OMIT_FIELD = Symbol("omit optional Content command field");
function parseField(field: ContentCommandField, formData: FormData): unknown {
const rawValue = formData.get(field.name);
if (rawValue === null && !field.required) return OMIT_FIELD;
if (field.type === "checkbox") return rawValue === "on";
if (rawValue === null && !field.required) return OMIT_FIELD;
if (field.type === "file") return rawValue instanceof File ? rawValue : null;
const raw = String(rawValue ?? "")
.normalize("NFC")
@@ -136,6 +136,7 @@ export function ContentCommandForm({
id={`${commandId}-${field.name}`}
name={field.name}
type="checkbox"
defaultChecked={field.defaultValue === true}
/>{" "}
{field.label}
</>
@@ -145,7 +146,11 @@ export function ContentCommandForm({
<select
id={`${commandId}-${field.name}`}
name={field.name}
defaultValue={field.defaultValue}
defaultValue={
typeof field.defaultValue === "boolean"
? undefined
: field.defaultValue
}
required={field.required}
className="mt-1 block w-full"
>
@@ -182,7 +187,10 @@ export function ContentCommandForm({
: "text"
}
defaultValue={
field.type === "file" ? undefined : field.defaultValue
field.type === "file" ||
typeof field.defaultValue === "boolean"
? undefined
: field.defaultValue
}
required={field.required}
min={field.min}