PageSourceSearch

https://smadar.ai/assets/CaregiverOnboarding-DBSMU-GG.js

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

1import{b as T,u as U,d as W,e as a,j as e,k as L,C as f,h as g,B as l,i as D,l as J,X,s as o}from"./index-BoPK12rZ.js";import{I as j}from"./input-B7jnFymG.js";import{L as v}from"./label-CCd9oABz.js";import{S as Y}from"./switch-BKo3y5a4.js";import{A as z}from"./arrow-right-Blw5VId1.js";const G=[{value:"spouse",emoji:"👨‍👩‍👧",label:"בן/בת זוג",en:"Spouse"},{value:"parent",emoji:"👨‍👩‍👦",label:"הורה",en:"Parent"},{value:"child",emoji:"👧",label:"ילד/ה",en:"Child"},{value:"sibling",emoji:"👫",label:"אח/אחות",en:"Sibling"},{value:"friend",emoji:"👥",label:"חבר/ה קרוב/ה",en:"Close Friend"},{value:"other",emoji:"🤝",label:"אחר",en:"Other"}],te=()=>{const{t:s,language:N}=T(),b=U(),{toast:C}=W(),w=N==="he",[n,c]=a.useState("code"),[d,P]=a.useState(""),[i,r]=a.useState("idle"),[h,A]=a.useState(""),[y,E]=a.useState(null),[K,O]=a.useState(null),[m,F]=a.useState(""),[u,B]=a.useState(""),[S,R]=a.useState(""),[k,$]=a.useState(!1),[_,I]=a.useState(!1),H=async()=>{if(!(d.length<4)){r("checking");try{const{data:t,error:p}=await o.rpc("lookup_invitation_code",{_code:d.toUpperCase()});if(p)throw p;if(t){const x=t;r("found"),E(x.id),O(x.patient_id),A(x.patient_name||s("המטופל/ת","the patient"))}else r("not_found")}catch(t){console.error("Code check error:",t),r("not_found")}}},q=async()=>{I(!0);try{const{data:{session:t}}=await o.auth.getSession();if(!(t!=null&&t.user))throw new Error("Not authenticated");await o.from("profiles").update({full_name:u,role_type:"caregiver",relationship_to_patient:m,phone:S}).eq("id",t.user.id),y&&await o.rpc("accept_invitation",{_share_id:y,_relationship:m}),k&&await o.from("patients").insert({user_id:t.user.id,first_name:u,language:N}),C({title:s("ההתחברות הצליחה!","Connected successfully!"),description:s(`מחובר/ת ל${h}`,`Connected to ${h}`)}),b("/caregiver",{replace:!0})}catch(t){console.error("Caregiver onboarding error:",t),C({title:s("שגיאה","Error"),description:t.message,variant:"destructive"})}finally{I(!1)}};return e.jsx("div",{className:"min-h-screen bg-background flex flex-col items-center justify-center px-4",dir:w?"rtl":"ltr",children:e.jsxs("div",{className:"max-w-md w-full space-y-6",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("div",{className:"text-4xl",children:"🫂"}),e.jsx("h1",{className:"text-2xl font-bold",children:s("הצטרפות כמלווה","Join as Caregiver")}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:[n==="code"&&s("הכנס/י את הקוד שקיבלת מהמטופל/ת","Enter the code you received from the patient"),n==="relationship"&&s("מה הקשר שלך למטופל/ת?","What's your relationship to the patient?"),n==="info"&&s("כמה פרטים אחרונים","A few final details")]})]}),e.jsx("div",{className:"flex justify-center gap-2",children:["code","relationship","info"].map((t,p)=>e.jsx("div",{className:L("w-3 h-3 rounded-full transition-all",t===n?"bg-primary scale-125":["code","relationship","info"].indexOf(n)>p?"bg-primary/50":"bg-muted")},t))}),n==="code"&&e.jsx(f,{children:e.jsxs(g,{className:"pt-6 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:s("קוד הזמנה","Invitation Code")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{value:d,onChange:t=>{P(t.target.value.toUpperCase()),r("idle")},placeholder:"ABC123",dir:"ltr",className:"text-center text-xl tracking-widest font-mono",maxLength:8}),e.jsx(l,{onClick:H,disabled:d.length<4||i==="checking",children:i==="checking"?e.jsx(D,{className:"h-4 w-4 animate-spin"}):s("בדוק","Check")})]}),i==="found"&&e.jsxs("div",{className:"flex items-center gap-2 text-green-600 bg-green-50 dark:bg-green-950/30 p-3 rounded-lg",children:[e.jsx(J,{className:"h-5 w-5"}),e.jsx("span",{className:"text-sm font-medium",children:s(`מצאנו את ${h}! רוצה להתחבר?`,`Found ${h}! Want to connect?`)})]}),i==="not_found"&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive bg-destructive/10 p-3 rounded-lg",children:[e.jsx(X,{className:"h-5 w-5"}),e.jsx("span",{className:"text-sm",children:s("הקוד לא נמצא. בדוק/י שהמטופל/ת שלחה את הקוד הנכון","Code not found. Check with the patient.")})]})]}),e.jsx(l,{className:"w-full bg-gradient-brand",disabled:i!=="found",onClick:()=>c("relationship"),children:s("כן, בואו נתחבר!","Yes, let's connect!")}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:s("אין לך קוד? בקש/י מהמטופל/ת ללחוץ על ׳הזמן מלווה׳ בהגדרות","Don't have a code? Ask the patient to click 'Invite Caregiver' in Settings")})]})}),n==="relationship"&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[G.map(t=>e.jsx(f,{className:L("cursor-pointer transition-all border-2",m===t.value?"border-primary bg-primary/5 shadow-md":"border-border hover:border-primary/40"),onClick:()=>F(t.value),children:e.jsxs(g,{className:"flex flex-col items-center justify-center p-4 text-center",children:[e.jsx("span",{className:"text-2xl mb-1",children:t.emoji}),e.jsx("span",{className:"text-sm font-medium",children:w?t.label:t.en})]})},t.value)),e.jsx("div",{className:"col-span-2",children:e.jsx(l,{className:"w-full bg-gradient-brand",disabled:!m,onClick:()=>c("info"),children:s("המשיכו","Continue")})})]}),n==="info"&&e.jsx(f,{children:e.jsxs(g,{className:"pt-6 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:s("שם פרטי","First Name")}
1),e.jsx(j,{value:u,onChange:t=>B(t.target.value),placeholder:s("שם פרטי","First name"),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:s("טלפון","Phone")}),e.jsx(j,{value:S,onChange:t=>R(t.target.value),placeholder:"050-1234567",dir:"ltr",type:"tel"})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("גם לנהל את הבריאות שלי","Also manage my own health")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("תיק אישי נפרד","Separate personal file")})]}),e.jsx(Y,{checked:k,onCheckedChange:$})]}),e.jsx(l,{className:"w-full bg-gradient-brand h-12 text-lg",disabled:_||!u,onClick:q,children:_?s("שומר...","Saving..."):s("סיום הרשמה","Complete")})]})}),e.jsxs(l,{variant:"ghost",className:"w-full gap-2",onClick:()=>{n==="relationship"?c("code"):n==="info"?c("relationship"):b(-1)},children:[e.jsx(z,{className:"h-4 w-4"}),s("חזרה","Back")]})]})})};export{te 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.