diff --git a/apps/edr-freight-web/portal/src/pages/accounts/companyProfileForm/schema.ts b/apps/edr-freight-web/portal/src/pages/accounts/companyProfileForm/schema.ts index f84783607..275b8a4fa 100644 --- a/apps/edr-freight-web/portal/src/pages/accounts/companyProfileForm/schema.ts +++ b/apps/edr-freight-web/portal/src/pages/accounts/companyProfileForm/schema.ts @@ -38,7 +38,16 @@ export const onboardingSchema = z.object({ // fields above are read-only confirmations pulled from eTrade). // Region is a closed set; zone/woreda/kebele stay free text until the platform // has an authoritative dataset of Ethiopian zones/woredas/kebeles. - region: z.enum(ETHIOPIAN_REGIONS, { message: "Region is required" }), + // + // Deliberately `.refine` over `z.enum`: the form needs "" as its unselected + // sentinel (default value, and legacy rows whose region isn't in the list). A + // literal union makes "" untypable, which also splits the resolver's + // input/output types and breaks useForm's inference for every other field. + region: z + .string() + .refine((v) => (ETHIOPIAN_REGIONS as readonly string[]).includes(v), { + message: "Region is required", + }), zone: z.string().min(1, "Zone is required"), woreda: z.string().min(1, "Woreda is required"), kebele: z.string().min(1, "Kebele is required"),