Files
legal-ai/web-ui/src/components/precedents/practice-area.ts
Chaim d81c3c37ab
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 34s
fix(precedent-edit): translate appeal_subtype enum values to Hebrew
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.
2026-05-07 08:45:03 +00:00

52 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Practice-area constants for the precedent library.
*
* The chair confined the library to the three appeals committee
* domains — no national-insurance corpus. The DB enforces this
* via a CHECK constraint on case_law.practice_area.
*/
export const PRACTICE_AREAS = [
{ value: "rishuy_uvniya", label: "רישוי ובניה", short: "רישוי" },
{ value: "betterment_levy", label: "היטל השבחה", short: "השבחה" },
{ value: "compensation_197", label: "פיצויים לפי ס' 197", short: "פיצויים" },
] as const;
export const PRECEDENT_LEVELS = [
{ value: "עליון", label: "עליון" },
{ value: "מנהלי", label: "מנהלי" },
{ value: "ועדת_ערר_ארצית", label: "ועדת ערר ארצית" },
{ value: "ועדת_ערר_מחוזית", label: "ועדת ערר מחוזית" },
] as const;
export const SOURCE_TYPES = [
{ value: "court_ruling", label: "פסק דין" },
{ value: "appeals_committee", label: "החלטת ועדת ערר" },
] as const;
export function practiceAreaLabel(value: string | null | undefined): string {
if (!value) return "—";
const match = PRACTICE_AREAS.find((p) => p.value === value);
return match ? match.label : value;
}
export function practiceAreaShort(value: string | null | undefined): string {
if (!value) return "—";
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;
}