fix(precedent-edit): translate appeal_subtype enum values to Hebrew
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 34s
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 34s
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.
This commit is contained in:
@@ -35,3 +35,17 @@ export function practiceAreaShort(value: string | null | undefined): string {
|
|||||||
const match = PRACTICE_AREAS.find((p) => p.value === value);
|
const match = PRACTICE_AREAS.find((p) => p.value === value);
|
||||||
return match ? match.short : 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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import {
|
|||||||
type SourceType,
|
type SourceType,
|
||||||
} from "@/lib/api/precedent-library";
|
} from "@/lib/api/precedent-library";
|
||||||
import {
|
import {
|
||||||
PRACTICE_AREAS, PRECEDENT_LEVELS, SOURCE_TYPES,
|
PRACTICE_AREAS, PRECEDENT_LEVELS, SOURCE_TYPES, appealSubtypeLabel,
|
||||||
} from "./practice-area";
|
} from "./practice-area";
|
||||||
import { ExtractedHalachotSection } from "./extracted-halachot";
|
import { ExtractedHalachotSection } from "./extracted-halachot";
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ export function PrecedentEditSheet({ caseLawId, onOpenChange }: Props) {
|
|||||||
court: record.court || "",
|
court: record.court || "",
|
||||||
decision_date: record.date ? record.date.slice(0, 10) : "",
|
decision_date: record.date ? record.date.slice(0, 10) : "",
|
||||||
practice_area: (record.practice_area || "") as PracticeArea,
|
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,
|
source_type: (record.source_type || "") as SourceType,
|
||||||
precedent_level: record.precedent_level || "",
|
precedent_level: record.precedent_level || "",
|
||||||
is_binding: record.is_binding ?? true,
|
is_binding: record.is_binding ?? true,
|
||||||
|
|||||||
Reference in New Issue
Block a user