fix-patient-role

This commit is contained in:
João Gustavo 2025-10-24 16:51:17 -03:00
parent a2ca13607e
commit 2527d28f6b

View File

@ -11,6 +11,7 @@ import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label"; import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea"; import { Textarea } from "@/components/ui/textarea";
import { Select, SelectTrigger, SelectContent, SelectItem, SelectValue } from "@/components/ui/select";
import { SimpleThemeToggle } from "@/components/simple-theme-toggle"; import { SimpleThemeToggle } from "@/components/simple-theme-toggle";
import { import {
Table, Table,
@ -20,13 +21,7 @@ import {
TableHeader, TableHeader,
TableRow, TableRow,
} from "@/components/ui/table"; } from "@/components/ui/table";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { Avatar, AvatarImage, AvatarFallback } from "@/components/ui/avatar" import { Avatar, AvatarImage, AvatarFallback } from "@/components/ui/avatar"
import { User, FolderOpen, X, Users, MessageSquare, ClipboardList, Plus, Edit, Trash2, ChevronLeft, ChevronRight, Clock, FileCheck, Upload, Download, Eye, History, Stethoscope, Pill, Activity, Search } from "lucide-react" import { User, FolderOpen, X, Users, MessageSquare, ClipboardList, Plus, Edit, Trash2, ChevronLeft, ChevronRight, Clock, FileCheck, Upload, Download, Eye, History, Stethoscope, Pill, Activity, Search } from "lucide-react"
import { Calendar as CalendarIcon, FileText, Settings } from "lucide-react"; import { Calendar as CalendarIcon, FileText, Settings } from "lucide-react";
@ -2586,19 +2581,19 @@ const ProfissionalPage = () => {
<div className="grid grid-cols-1 gap-4"> <div className="grid grid-cols-1 gap-4">
<div className="space-y-2"> <div className="space-y-2">
<Label htmlFor="patientSelect">Paciente *</Label> <Label htmlFor="patientSelect">Paciente *</Label>
<select <Select
id="patientSelect"
className="input"
value={commPatientId ?? ''} value={commPatientId ?? ''}
onChange={(e) => { onValueChange={(val: string) => {
const val = e.target.value || null; // Radix Select does not allow an Item with empty string as value.
setCommPatientId(val); // Use a sentinel value "__none" for the "-- nenhum --" choice and map it to null here.
if (!val) { const v = val === "__none" ? null : (val || null);
setCommPatientId(v);
if (!v) {
setCommPhoneNumber(''); setCommPhoneNumber('');
return; return;
} }
try { try {
const found = (pacientes || []).find((p: any) => String(p.id ?? p.uuid ?? p.email ?? '') === String(val)); const found = (pacientes || []).find((p: any) => String(p.id ?? p.uuid ?? p.email ?? '') === String(v));
if (found) { if (found) {
setCommPhoneNumber( setCommPhoneNumber(
found.phone_mobile ?? found.celular ?? found.telefone ?? found.phone ?? found.mobile ?? found.phone_number ?? '' found.phone_mobile ?? found.celular ?? found.telefone ?? found.phone ?? found.mobile ?? found.phone_number ?? ''
@ -2612,13 +2607,18 @@ const ProfissionalPage = () => {
} }
}} }}
> >
<option value="">-- nenhum --</option> <SelectTrigger className="w-full">
<SelectValue placeholder="-- nenhum --" />
</SelectTrigger>
<SelectContent>
<SelectItem value="__none">-- nenhum --</SelectItem>
{pacientes && pacientes.map((p:any) => ( {pacientes && pacientes.map((p:any) => (
<option key={String(p.id || p.uuid || p.cpf || p.email)} value={String(p.id ?? p.uuid ?? p.email ?? '')}> <SelectItem key={String(p.id || p.uuid || p.cpf || p.email)} value={String(p.id ?? p.uuid ?? p.email ?? '')}>
{p.full_name ?? p.nome ?? p.name ?? p.email ?? String(p.id ?? p.cpf ?? '')} {p.full_name ?? p.nome ?? p.name ?? p.email ?? String(p.id ?? p.cpf ?? '')}
</option> </SelectItem>
))} ))}
</select> </SelectContent>
</Select>
</div> </div>
<div className="space-y-2"> <div className="space-y-2">