source: frontend/src/components/PatientSelector.tsx@ 700e2f9

main
Last change on this file since 700e2f9 was 700e2f9, checked in by 186079 <matej.milevski@…>, 5 days ago

Init

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[700e2f9]1import { type Component, For, Show } from "solid-js";
2import type { Patient } from "@/api/therapist";
3
4interface PatientSelectorProps {
5 patients: Patient[] | undefined;
6 loading: boolean;
7 selectedPatientId: number | null;
8 onPatientChange: (patientId: number | null) => void;
9}
10
11const PatientSelector: Component<PatientSelectorProps> = (props) => (
12 <div class="mb-6">
13 <label
14 for="patient-selector"
15 class="block text-sm font-semibold text-gray-700 mb-2"
16 >
17 Select Patient
18 </label>
19 <Show
20 when={!props.loading}
21 fallback={
22 <div class="flex items-center gap-2 text-gray-500">
23 <div class="animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600" />
24 <span>Loading patients...</span>
25 </div>
26 }
27 >
28 <select
29 id="patient-selector"
30 value={props.selectedPatientId || ""}
31 onChange={(e) => {
32 const value = e.currentTarget.value;
33 props.onPatientChange(value ? Number(value) : null);
34 }}
35 class="w-full md:w-96 px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
36 >
37 <Show when={!props.patients || props.patients.length === 0}>
38 <option value="">No patients assigned</option>
39 </Show>
40 <For each={props.patients}>
41 {(patient) => (
42 <option value={patient.userId}>
43 {patient.firstName} {patient.lastName} ({patient.email})
44 </option>
45 )}
46 </For>
47 </select>
48 </Show>
49 </div>
50);
51
52export default PatientSelector;
Note: See TracBrowser for help on using the repository browser.