import { type Component, For, Show, createSignal } from "solid-js"; import type { TherapistInfo } from "@/api/therapist"; import { patientApi } from "@/api/patient"; import { formatDateWithWeekday } from "@/utils"; interface TherapistCardProps { therapist: TherapistInfo; isCurrentTherapist?: boolean; onTherapistChange?: () => void; } const TherapistCard: Component = (props) => { const [isLoading, setIsLoading] = createSignal(false); const [error, setError] = createSignal(""); const handleSetTherapist = async () => { setIsLoading(true); setError(""); try { if (props.isCurrentTherapist) { await patientApi.removeTherapist(); } else { await patientApi.setTherapist(props.therapist.idUser); } props.onTherapistChange?.(); } catch (err) { setError( err instanceof Error ? err.message : "Failed to update therapist", ); } finally { setIsLoading(false); } }; return (
My Therapist

{props.therapist.name} {props.therapist.surname}

{props.therapist.degree}

{props.therapist.officeLocation}
{props.therapist.email}
{props.therapist.phoneNumber}
{props.therapist.yearsExp} years experience

Available Consultations ( {props.therapist.freeConsultationSlots.length || "None"})

0 } fallback={

No available slots at the moment

} >
{(slot) => (
{formatDateWithWeekday(slot)}
)}
{error()}
} >
); }; export default TherapistCard;