PageSourceSearch

https://smadar.ai/assets/AppointmentsTab-Bq0y7v7B.js

js smadar.ai collected 2026-10-05 15:05:19 UTC 6,198 bytes, 1 lines download raw bytes

1import{b as k,f as q,d as M,e as f,g,s as m,j as e,B as c,i as N,C as y,h as v}from"./index-BoPK12rZ.js";import{u as L}from"./useMutation-CQ66tvoD.js";import{I as l}from"./input-B7jnFymG.js";import{T}from"./textarea-D9g-r6Bx.js";import{S as D,a as F,b as P,c as E}from"./sheet-cWIgBlZN.js";import{M as K}from"./MvpBottomNav-RUPcAmlh.js";import{C as x}from"./calendar-days-Ghlhkcyw.js";import{P as b}from"./plus-DvgK6Rve.js";import{C as O}from"./clock-DupAsq6s.js";import{M as Q}from"./map-pin-BAbW9TMd.js";import{f as B}from"./format-Mfnei9oz.js";import"./index-BAk_bO_9.js";import"./index-DR_KIw6N.js";import"./index-DuY6vpjC.js";import"./house-CPCAQwMa.js";import"./message-square-CRH2oD2V.js";import"./pill-DyW1TgDo.js";import"./users-DpKGh2ZL.js";import"./en-US-BsB0DKe1.js";const w={doctor_name:"",date:"",time:"",location:"",notes:""},re=()=>{const{t,language:C}=k(),S=C==="he",u=q(),{toast:p}=M(),[A,o]=f.useState(!1),[a,r]=f.useState(w),{data:i}=g({queryKey:["patient-appts"],queryFn:async()=>{const{data:{session:s}}=await m.auth.getSession();if(!(s!=null&&s.user))return null;const{data:n}=await m.from("patients").select("id").eq("user_id",s.user.id).maybeSingle();return n}}),{data:h=[],isLoading:_}=g({queryKey:["appointments",i==null?void 0:i.id],queryFn:async()=>{if(!(i!=null&&i.id))return[];const s=new Date().toISOString().split("T")[0],{data:n,error:j}=await m.from("appointments").select("*").eq("patient_id",i.id).gte("date",s).order("date",{ascending:!0}).order("time",{ascending:!0});if(j)throw j;return n||[]},enabled:!!(i!=null&&i.id)}),d=L({mutationFn:async()=>{if(!(i!=null&&i.id)||!a.doctor_name.trim()||!a.date||!a.time)return;const{error:s}=await m.from("appointments").insert({patient_id:i.id,doctor_name:a.doctor_name.trim(),date:a.date,time:a.time,location:a.location.trim()||null,notes:a.notes.trim()||null});if(s)throw s},onSuccess:()=>{u.invalidateQueries({queryKey:["appointments"]}
1),u.invalidateQueries({queryKey:["home-next-appt"]}),p({title:t("התור נוסף","Appointment added")}),o(!1),r(w)},onError:s=>{p({title:t("שגיאה","Error"),description:s.message,variant:"destructive"})}});return e.jsxs("div",{className:"min-h-screen bg-background pb-24",dir:S?"rtl":"ltr",children:[e.jsxs("div",{className:"sticky top-0 z-10 bg-background/95 backdrop-blur border-b px-4 py-3 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{className:"h-6 w-6 text-primary"}),e.jsx("h1",{className:"text-lg font-bold",children:t("התורים שלי","My Appointments")})]}),e.jsxs(c,{size:"sm",onClick:()=>o(!0),className:"gap-1",children:[e.jsx(b,{className:"h-4 w-4"}),t("הוסף","Add")]})]}),e.jsx("div",{className:"max-w-[430px] mx-auto p-4 space-y-3",children:_?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(N,{className:"h-6 w-6 animate-spin text-primary"})}):h.length===0?e.jsx(y,{children:e.jsxs(v,{className:"p-8 text-center",children:[e.jsx(x,{className:"h-12 w-12 text-muted-foreground/50 mx-auto mb-3"}),e.jsx("p",{className:"font-medium",children:t("אין תורים קרובים","No upcoming appointments")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t("הוסיפו תור חדש","Add a new appointment")}),e.jsxs(c,{className:"mt-4",onClick:()=>o(!0),children:[e.jsx(b,{className:"h-4 w-4 mr-1"}),t("הוסף תור","Add Appointment")]})]})}):h.map(s=>{var n;return e.jsx(y,{className:"overflow-hidden",children:e.jsx(v,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-1 h-full min-h-[60px] rounded-full bg-primary shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold",children:s.doctor_name}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(x,{className:"h-3.5 w-3.5"}),B(new Date(s.date),"dd/MM/yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(O,{className:"h-3.5 w-3.5"}),(n=s.time)==null?void 0:n.slice(0,5)]})]}),s.location&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 flex items-center gap-1",children:[e.jsx(Q,{className:"h-3.5 w-3.5"}),s.location]}),s.notes&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2 bg-muted/50 p-2 rounded",children:s.notes})]})]})})},s.id)})}),e.jsx(D,{open:A,onOpenChange:o,children:e.jsxs(F,{side:"bottom",className:"rounded-t-3xl max-h-[80vh]",children:[e.jsx(P,{children:e.jsx(E,{children:t("הוספת תור","Add Appointment")})}),e.jsxs("div",{className:"space-y-4 mt-4 pb-6",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium",children:[t("שם הרופא/ה","Doctor Name")," *"]}),e.jsx(l,{value:a.doctor_name,onChange:s=>r(n=>({...n,doctor_name:s.target.value})),placeholder:t("ד״ר ישראלי","Dr. Smith"),maxLength:100})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium",children:[t("תאריך","Date")," *"]}),e.jsx(l,{type:"date",value:a.date,onChange:s=>r(n=>({...n,date:s.target.value}))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-sm font-medium",children:[t("שעה","Time")," *"]}),e.jsx(l,{type:"time",value:a.time,onChange:s=>r(n=>({...n,time:s.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:t("מיקום","Location")}),e.jsx(l,{value:a.location,onChange:s=>r(n=>({...n,location:s.target.value})),placeholder:t("בית חולים / מרפאה","Hospital / Clinic"),maxLength:200})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:t("הערות","Notes")}),e.jsx(T,{value:a.notes,onChange:s=>r(n=>({...n,notes:s.target.value})),placeholder:t("הערות נוספות...","Additional notes..."),maxLength:500,rows:2})]}),e.jsx(c,{className:"w-full",onClick:()=>d.mutate(),disabled:!a.doctor_name.trim()||!a.date||!a.time||d.isPending,children:d.isPending?e.jsx(N,{className:"h-4 w-4 animate-spin"}):t("שמור תור","Save Appointment")})]})]})}),e.jsx(K,{})]})};export{re as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.