fix(vehicles): serialize booleans as 1/0 in multipart payload

The vehicle form uploads as multipart/form-data for the image, and the
FormData builder stringified every value, turning has_insurance=false into
the literal "false". Laravel's boolean rule rejects "true"/"false" strings,
producing "The has insurance field must be true or false." Serialize
booleans as "1"/"0" so they validate; null values remain skipped (nullable).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
ERP-System 2026-06-08 13:45:04 +04:00
parent 11d920ba6a
commit f9aac2db37

View File

@ -20,6 +20,10 @@ function buildVehicleFormData(payload: Record<string, any>): FormData {
if (value == null) continue if (value == null) continue
if (value instanceof File) { if (value instanceof File) {
fd.append(key, value) fd.append(key, value)
} else if (typeof value === "boolean") {
// Laravel's `boolean` rule rejects the strings "true"/"false";
// serialize as "1"/"0" so multipart payloads validate correctly.
fd.append(key, value ? "1" : "0")
} else { } else {
fd.append(key, String(value)) fd.append(key, String(value))
} }