1import{s as T,r as s,l as _,v as U,j as e,L as g,C as q,a as B,z as i,I as d,T as H,aL as M,B as E,bb as W,p as z,dl as A,a2 as F,W as R}from"./pages-admin-CBNFTGIo.js";import{u as D,s as G}from"./phone-CWLuOqrh.js";function Q(){const{toast:l}=T(),[f,v]=s.useState(""),[c,j]=s.useState(""),[h,p]=s.useState(""),[u,b]=s.useState(""),r=D(""),[y,N]=s.useState(""),[w,P]=s.useState("not_accepting"),[k,S]=s.useState(!1),C=s.useRef(null),{data:t,isLoading:I}=_({queryKey:["/api/therapist/profile"]});s.useEffect(()=>{t&&(v(t.practiceName||""),j(t.bio||""),p(t.headshotUrl||""),b(t.yearsExperience?.toString()||""),r.setFormatted(t.phone||""),N(t.websiteUrl||""),P(t.availabilityStatus||"not_accepting"))},[t]);const o=U({mutationFn:async a=>{const n=new FormData;n.append("file",a);const x=await fetch("/api/therapist/profile/headshot",{method:"POST",body:n,credentials:"include"});if(!x.ok){const L=await x.json().catch(()=>({message:"Upload failed"}));throw new Error(L.message||"Upload failed")}return x.json()},onSuccess:a=>{p(a.headshotUrl),F.invalidateQueries({queryKey:["/api/therapist/profile"]}),l({title:"Headshot uploaded"})},onError:a=>{l({title:"Upload failed",description:a.message,variant:"destructive"})}}),m=U({mutationFn:async()=>{await R("PUT","/api/therapist/profile",{practiceName:f,bio:c,headshotUrl:h||void 0,yearsExperience:u?parseInt(u,10):void 0,phone:G(r.value),websiteUrl:y,availabilityStatus:w})},onSuccess:()=>{F.invalidateQueries({queryKey:["/api/therapist/profile"]}),S(!0),setTimeout(()=>S(!1),2e3),l({title:"Profile saved"})},onError:a=>{l({title:"Save failed",description:a.message,variant:"destructive"})}});return I?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(g,{className:"h-6 w-6 animate-spin text-teal-600"})}):e.jsxs("div",{"data-testid":"health-profile",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900","data-testid":"text-profile-title",children:"Professional Profile"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Manage your therapist profile information."})]}),e.jsx(q,{children:e.jsxs(B,{className:"p-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx(i,{htmlFor:"practiceName",children:"Practice Name"}),e.jsx(d,{id:"practiceName",value:f,onChange:a=>v(a.target.value),placeholder:"Your practice name","data-testid":"input-practice-name"})]}),e.jsxs("div",{children:[e.jsx(i,{htmlFor:"bio",children:"Professional Bio"}),e.jsx(H,{id:"bio",value:c,onChange:a=>j(a.target.value),placeholder:"Describe your practice and approach...",className:"min-h-[120px]",maxLength:2e3,"data-testid":"input-bio"}),e.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:[c.length,"/2000"]})]}),e.jsxs("div",{children:[e.jsx(i,{children:"Headshot / Photo"}),e.jsxs("div",{className:"flex items-start gap-4 mt-1",children:[h&&e.jsxs("div",{className:"relative shrink-0","data-testid":"headshot-preview",children:[e.jsx("img",{src:h,alt:"Headshot preview",className:"h-20 w-20 rounded-full object-cover border border-gray-200","data-testid":"img-headshot"}),e.jsx("button",{type:"button",onClick:()=>p(""),className:"absolute -top-1 -right-1 bg-white rounded-full border border-gray-300 p-0.5 hover:bg-gray-100","data-testid":"button-remove-headshot",children:e.jsx(M,{className:"h-3 w-3 text-gray-500"})})]}),e.jsxs("div",{className:"flex flex-col gap-2 flex-1",children:[e.jsx("input",{ref:C,type:"file",accept:"image/jpeg,image/png,image/gif,image/webp",className:"hidden",onChange:a=>{const n=a.target.files?.[0];n&&o.mutate(n),a.target.value=""},"data-testid":"input-headshot-file"}),e.jsxs(E,{type:"button",variant:"outline",size:"sm",onClick:()=>C.current?.click(),disabled:o.isPending,"data-testid":"button-upload-headshot",children:[o.isPending?e.jsx(g,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(W,{className:"h-4 w-4 mr-1"}),o.isPending?"Uploading...":"Upload Photo"]}),e.jsx("p",{className:"text-xs text-gray-400",children:"JPEG, PNG, GIF, or WebP up to 5MB"})]})]})]}),e.jsxs("div",{children:[e.jsx(i,{htmlFor:"yearsExperience",children:"Years of Experience"}),e.jsx(d,{id:"yearsExperience",type:"number",min:"0",max:"99",value:u,onChange:a=>b(a.target.value),placeholder:"e.g. 10","data-testid":"input-years-experience"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(i,{htmlFor:"phone",children:"Phone"}),e.jsx(d,{id:"phone",value:r.value,onChange:r.onChange,ref:r.ref,placeholder:"(555) 123-4567","data-testid":"input-phone"})]}),e.jsxs("div",{children:[e.jsx(i,{htmlFor:"websiteUrl",children:"Website"}),e.jsx(d,{id:"websiteUrl",value:y,onChange:a=>N(a.target.value),placeholder:"https://practice.com","data-testid":"input-website"})]})]}),e.jsxs("div",{children:[e.jsx(i,{children:"Availability Status"}),e.jsxs("select",{value:w,onChange:a=>P(a.target.value),className:"w-full border rounded-md px-3 py-2 text-sm","data-testid":"select-availability",children:[e.jsx("option",{value:"not_accepting",children:"Not Accepting Clients"}),e.jsx("option",{value:"accepting_clients",children:"Accepting Clients"}),e.jsx("option",{value:"waitlist_only",children:"Waitlist Only"})]})]}),t&&e.jsxs("div",{className:"flex items-center gap-4 pt-2 text-sm text-gray-500",children:[e.jsxs("span",{children:["Verification: ",e.jsx("span",{className:"font-medium capitalize",children:t.verificationStatus})]}),e.jsxs("span",{children:["Onboarding: ",e.jsx("span",{className:"font-medium capitalize",children:t.onboardingStatus.replace(/_/g," ")})]})]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsx(E,{onClick:()=>m.mutate(),disabled:m.isPending,className:"bg-teal-600 hover:bg-teal-700","data-testid":"button-save-profile",children:m.isPending?e.jsx(g,{className:"h-4 w-4 animate-spin"}):k?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"h-4 w-4 mr-1"})," Saved"]}):e.jsxs(e.Fragment,{children:[e.jsx(A,{className:"h-4 w-4 mr-1"})," Save Profile"]})})})]})})]})}export{Q 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.