hezarfen_frontend
Clone
https://git.tahinli.com/Hezarfen/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import { For } from "solid-js"; |
| 2 | import { Select } from "@/components/ui/select"; |
| 3 | import { gradeLevelLabel, gradeLevels } from "@/lib/grade-level"; |
| 4 | import { useT } from "@/stores/preferences-context"; |
| 5 | |
| 6 | /** |
| 7 | * A pick on the grade ladder (0 = anaokulu .. 12). `value` null shows the |
| 8 | * placeholder row — the ladder is required on a class, so a form checks it. |
| 9 | */ |
| 10 | export function GradeLevelSelect(props: { |
| 11 | id: string; |
| 12 | value: number | null; |
| 13 | onChange: (level: number | null) => void; |
| 14 | min?: number; |
| 15 | max?: number; |
| 16 | disabled?: boolean; |
| 17 | error?: boolean; |
| 18 | }) { |
| 19 | const t = useT(); |
| 20 | return ( |
| 21 | <Select |
| 22 | id={props.id} |
| 23 | value={props.value === null ? "" : String(props.value)} |
| 24 | disabled={props.disabled} |
| 25 | aria-invalid={props.error || undefined} |
| 26 | onChange={(e) => { |
| 27 | const raw = e.currentTarget.value; |
| 28 | props.onChange(raw === "" ? null : Number(raw)); |
| 29 | }} |
| 30 | > |
| 31 | <option value="">{t("grade.select")}</option> |
| 32 | <For each={gradeLevels(props.min, props.max)}>{(level) => <option value={String(level)}>{gradeLevelLabel(level, t)}</option>}</For> |
| 33 | </Select> |
| 34 | ); |
| 35 | } |