From d81c3c37ab94e71b736a055ead20731ebcf075a7 Mon Sep 17 00:00:00 2001 From: Chaim Date: Thu, 7 May 2026 08:45:03 +0000 Subject: [PATCH] fix(precedent-edit): translate appeal_subtype enum values to Hebrew MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The metadata extractor occasionally stuffs the practice_area enum (``betterment_levy``, ``rishuy_uvniya``, ``compensation_197``) into the free-text ``appeal_subtype`` column. The edit sheet then showed the raw English string in the "תת-סוג" input. When initialising the form, run the value through ``appealSubtypeLabel`` which maps known practice-area enum values to their Hebrew label and returns anything else unchanged. The user can then edit normally; on save the Hebrew sticks, so the next view is also clean. --- web-ui/src/components/precedents/practice-area.ts | 14 ++++++++++++++ .../components/precedents/precedent-edit-sheet.tsx | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/web-ui/src/components/precedents/practice-area.ts b/web-ui/src/components/precedents/practice-area.ts index 69fca60..db96eae 100644 --- a/web-ui/src/components/precedents/practice-area.ts +++ b/web-ui/src/components/precedents/practice-area.ts @@ -35,3 +35,17 @@ export function practiceAreaShort(value: string | null | undefined): string { const match = PRACTICE_AREAS.find((p) => p.value === value); return match ? match.short : value; } + +/** + * Display label for ``appeal_subtype``. The field is free text — the chair + * usually types specific subjects like "תכנית רחביה" or "סופיות ההחלטה" — + * but the LLM extractor sometimes mistakenly stuffs the practice_area + * enum value (``betterment_levy``, ``rishuy_uvniya``, ``compensation_197``) + * in there. When that happens, translate to Hebrew so the UI doesn't + * leak English. Otherwise return the value unchanged. + */ +export function appealSubtypeLabel(value: string | null | undefined): string { + if (!value) return ""; + const enumMatch = PRACTICE_AREAS.find((p) => p.value === value); + return enumMatch ? enumMatch.label : value; +} diff --git a/web-ui/src/components/precedents/precedent-edit-sheet.tsx b/web-ui/src/components/precedents/precedent-edit-sheet.tsx index b39f621..146c13f 100644 --- a/web-ui/src/components/precedents/precedent-edit-sheet.tsx +++ b/web-ui/src/components/precedents/precedent-edit-sheet.tsx @@ -22,7 +22,7 @@ import { type SourceType, } from "@/lib/api/precedent-library"; import { - PRACTICE_AREAS, PRECEDENT_LEVELS, SOURCE_TYPES, + PRACTICE_AREAS, PRECEDENT_LEVELS, SOURCE_TYPES, appealSubtypeLabel, } from "./practice-area"; import { ExtractedHalachotSection } from "./extracted-halachot"; @@ -75,7 +75,7 @@ export function PrecedentEditSheet({ caseLawId, onOpenChange }: Props) { court: record.court || "", decision_date: record.date ? record.date.slice(0, 10) : "", practice_area: (record.practice_area || "") as PracticeArea, - appeal_subtype: record.appeal_subtype || "", + appeal_subtype: appealSubtypeLabel(record.appeal_subtype), source_type: (record.source_type || "") as SourceType, precedent_level: record.precedent_level || "", is_binding: record.is_binding ?? true,