PageSourceSearch

https://sober-path-emr--eseitz8413.replit.app/assets/HouseDetail-vvMWCPJx.js

js sober-path-emr--eseitz8413.replit.app collected 2026-10-03 03:55:31 UTC 19,198 bytes, 1 lines download raw bytes

1import{d as N,j as e}from"./vendor-react-DI1Sy88J.js";import{e as S,c as W,f as ae,g as ie,L as M}from"./vendor-router-DW82M7iN.js";import{f as T,j as A,k as H,h as se,g as B,I as $,e as j,ar as re,L as P,S as ne,Q as de,T as le,N as oe,O as C,ag as ce,B as D}from"./app-marketing-ByOgiMj4.js";import{a2 as me,a9 as ue,U as he,Z as z,T as xe,y as pe,z as J,x as q,v as ge,w as L,V as je,a3 as Y,E as _}from"./app-public-tools-BQrJS2St.js";import{u as ye}from"./useHouseManagerLabel-BEKhMQlJ.js";import{g as ve,R as fe}from"./RobertTreatmentBeds-OnrtM6sC.js";import{u as be}from"./participantTerminology-CfPWcn9W.js";import{r as X}from"./RobertResidentRent-CFw2p3WP.js";import{b1 as Q,D as Ne,X as we,V as ke,f as Ce,c8 as Z,ce as Se,bE as $e,c2 as Te}from"./vendor-misc-B1nzCziw.js";import{a as Be}from"./ChoresPanel-pJsgDgK1.js";import"./vendor-radix-ocehe2sJ.js";import"./vendor-date-DPo7-IdA.js";import"./bridgeHavenPolicy-BY823TNo.js";import"./temporaryAbsence-IGYCVrGd.js";import"./robertRent-GjOOPs8Z.js";import"./index-a2zt1fnL.js";function Fe({houseId:i}){const r=`/api/robert-rent/houses/${i}`,{data:m,error:d,isLoading:w}=S({queryKey:[r],queryFn:()=>X(r),retry:!1}),[f,p]=N.useState(null),[g,b]=N.useState(!1),o=f??m?.schedule??[],u=W({mutationFn:()=>X(r,{schedule:o,previousSchedule:m?.schedule??[]}),onSuccess:()=>{p(null),b(!0),me.invalidateQueries({queryKey:[r]})}});function y(c,h){b(!1),p(o.map((l,v)=>v===c?{...l,...h}:l))}return e.jsxs(T,{"data-testid":"robert-house-rent-schedule",children:[e.jsxs(A,{children:[e.jsx(H,{children:"Room and move-in rate schedule"}),e.jsx(se,{children:"Used only as a suggestion when confirming individual agreements. Existing resident rent is never changed here."})]}),e.jsxs(B,{className:"space-y-4",children:[w&&e.jsx("p",{children:"Loading schedule…"}),d&&e.jsx("p",{role:"alert",className:"text-destructive",children:d.message}),m&&e.jsxs(e.Fragment,{children:[!o.length&&e.jsx("p",{children:"No single/shared rates supplied yet. Leave this unset until the actual rates are known."}),o.map((c,h)=>e.jsxs("fieldset",{className:"grid gap-3 rounded border p-3 sm:grid-cols-2",children:[e.jsxs("legend",{className:"text-sm",children:["Rate ",h+1]}),e.jsxs("label",{className:"text-sm",children:["Room",e.jsxs("select",{className:"block w-full border rounded bg-background p-2",value:c.roomType,onChange:l=>y(h,{roomType:l.target.value}),children:[e.jsx("option",{value:"single",children:"Single"}),e.jsx("option",{value:"shared",children:"Shared"})]})]}),e.jsxs("label",{className:"text-sm",children:["Move-ins starting",e.jsx($,{type:"date",value:c.moveInFrom,onChange:l=>y(h,{moveInFrom:l.target.value})})]}),e.jsxs("label",{className:"text-sm",children:["Amount ($)",e.jsx($,{type:"number",min:"0",step:"0.01",value:Number.isFinite(c.amountCents)?c.amountCents/100:"",onChange:l=>y(h,{amountCents:l.target.value===""?NaN:Math.round(Number(l.target.value)*100)})})]}),e.jsxs("label",{className:"text-sm",children:["Frequency",e.jsxs("select",{className:"block w-full border rounded bg-background p-2",value:c.frequency,onChange:l=>y(h,{frequency:l.target.value}),children:[e.jsx("option",{value:"monthly",children:"Monthly"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"biweekly",children:"Every two weeks"})]})]}),e.jsxs(j,{variant:"outline",onClick:()=>p(o.filter((l,v)=>v!==h)),children:["Remove rate ",h+1]})]},h)),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(j,{variant:"outline",onClick:()=>p([...o,{roomType:"shared",amountCents:NaN,frequency:"monthly",moveInFrom:""}]),children:"Add confirmed rate"}),e.jsx(j,{disabled:f===null||u.isPending,onClick:()=>u.mutate(),children:u.isPending?"Saving…":"Save rate schedule"})]}),u.error&&e.jsx("p",{role:"alert",className:"text-destructive",children:u.error.message}),g&&e.jsx("p",{role:"status",children:"Schedule saved. Existing individual agreements unchanged."})]})]})]})}async function U(i,r){const m=await fetch(i,{credentials:"include",headers:{"Content-Type":"application/json",...r?.headers||{}},...r}),d=await m.json().catch(()=>({}));if(!m.ok)throw new Error(d.error||"Unable to save the house meeting schedule");return d}function Me(){return new Date().toISOString().slice(0,10)}function Pe({houseId:i}){const r=ae(),{toast:m}=re(),d=["robert-house-meeting-schedule",i],[w,f]=N.useState("0"),[p,g]=N.useState(""),[b,o]=N.useState(Me),[u,y]=N.useState(""),[c,h]=N.useState(""),[l,v]=N.useState(""),k=S({queryKey:d,queryFn:()=>U(`/api/robert-black/houses/${i}/meeting-schedule`)}),n=k.data;N.useEffect(()=>{if(!n)return;const a=n.schedule?.versions[n.schedule.versions.length-1];f(String(a?.weekday??n.suggestedDefault.weekday)),g(a?.time??n.suggestedDefault.time??""),v(a?.time??n.suggestedDefault.time??""),o(n.localToday)},[n]);const O=W({mutationFn:()=>U(`/api/robert-black/houses/${i}/meeting-schedule`,{method:"PUT",body:JSON.stringify({effectiveFrom:b,weekday:Number(w),time:p,title:"House Meeting"})}),onSuccess:()=>{r.invalidateQueries({queryKey:d}),m({title:"Recurring meeting confirmed",description:"This house now has its own effective-dated weekly schedule."})},onError:a=>m({title:"Schedule not saved",description:a.message,variant:"destructive"})}),F=W({mutationFn:a=>U(`/api/robert-black/houses/${i}/meeting-overrides/${u}`,{method:"PUT",body:JSON.stringify(a==="cancelled"?{status:a}:{status:a,meetingDate:c,time:l,title:"House Meeting"})}),onSuccess:(a,E)=>{r.invalidateQueries({queryKey:d}
1),m({title:E==="cancelled"?"Meeting cancelled for that week":"Dated meeting adjustment saved",description:"The recurring schedule and prior meeting history were not changed."})},onError:a=>m({title:"Adjustment not saved",description:a.message,variant:"destructive"})});if(k.isLoading)return e.jsx(T,{"data-testid":"robert-meeting-schedule-loading",children:e.jsxs(B,{className:"flex items-center gap-2 py-6 text-muted-foreground",children:[e.jsx(Q,{className:"h-4 w-4 animate-spin"})," Loading house meeting schedule…"]})});if(k.isError||!n)return e.jsx(T,{"data-testid":"robert-meeting-schedule-error",children:e.jsxs(B,{className:"space-y-3 py-6",children:[e.jsx("p",{className:"text-sm text-destructive",children:"The house meeting schedule could not be loaded."}),e.jsx(j,{variant:"outline",onClick:()=>k.refetch(),children:"Try again"})]})});const t=n.schedule?.versions[n.schedule.versions.length-1];return e.jsxs(T,{"data-testid":"robert-house-meeting-schedule",children:[e.jsxs(A,{children:[e.jsxs(H,{className:"flex items-center gap-2",children:[e.jsx(Ne,{className:"h-5 w-5"})," Weekly house meeting"]}),e.jsx(se,{children:"Set and save this house separately. The suggestion shown here does not become a schedule until you confirm it."})]}),e.jsxs(B,{className:"space-y-6",children:[e.jsx("div",{className:"rounded-md border p-3 text-sm",children:t?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(we,{className:"h-4 w-4 text-emerald-600 mt-0.5"}),e.jsxs("span",{children:["Confirmed: ",["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t.weekday]," at ",t.time,", effective ",t.effectiveFrom,"."]})]}):e.jsxs("div",{className:"flex gap-2 text-amber-800",children:[e.jsx(ke,{className:"h-4 w-4 mt-0.5"}),e.jsxs("span",{children:["Unconfirmed. Suggested day: ",n.suggestedDefault.day,n.suggestedDefault.time?` at ${n.suggestedDefault.time}`:"; the meeting time still needs confirmation"," ","(",n.suggestedDefault.timezone,"). No recurring meeting will be generated until staff chooses a time and saves."]})]})}),n.canEdit?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:`meeting-day-${i}`,children:"Weekly day"}),e.jsxs(ne,{value:w,onValueChange:f,children:[e.jsx(de,{id:`meeting-day-${i}`,children:e.jsx(le,{})}),e.jsxs(oe,{children:[e.jsx(C,{value:"0",children:"Sunday"}),e.jsx(C,{value:"1",children:"Monday"}),e.jsx(C,{value:"2",children:"Tuesday"}),e.jsx(C,{value:"3",children:"Wednesday"}),e.jsx(C,{value:"4",children:"Thursday"}),e.jsx(C,{value:"5",children:"Friday"}),e.jsx(C,{value:"6",children:"Saturday"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:`meeting-time-${i}`,children:"Local time"}),e.jsx($,{id:`meeting-time-${i}`,type:"time",value:p,onChange:a=>g(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:`meeting-effective-${i}`,children:"Effective date"}),e.jsx($,{id:`meeting-effective-${i}`,type:"date",value:b,onChange:a=>o(a.target.value)})]})]}),e.jsxs(j,{onClick:()=>O.mutate(),disabled:!p||!b||O.isPending,"data-testid":"confirm-robert-house-meeting",children:[O.isPending&&e.jsx(Q,{className:"mr-2 h-4 w-4 animate-spin"}),"Confirm new schedule version"]}),n.schedule&&e.jsxs("div",{className:"space-y-3 border-t pt-5",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:"One-week adjustment"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Move or cancel one occurrence without changing future weeks."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:`override-week-${i}`,children:"Week starts"}),e.jsx($,{id:`override-week-${i}`,type:"date",value:u,onChange:a=>y(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:`override-date-${i}`,children:"Adjusted date"}),e.jsx($,{id:`override-date-${i}`,type:"date",value:c,onChange:a=>h(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{htmlFor:`override-time-${i}`,children:"Adjusted time"}),e.jsx($,{id:`override-time-${i}
1`,type:"time",value:l,onChange:a=>v(a.target.value)})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(j,{variant:"secondary",disabled:!u||!c||!l||F.isPending,onClick:()=>F.mutate("scheduled"),children:"Save dated adjustment"}),e.jsx(j,{variant:"outline",disabled:!u||F.isPending,onClick:()=>F.mutate("cancelled"),children:"Cancel that week's meeting"})]})]})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"You can view this schedule. An administrator with property-management permission must confirm or adjust it."})]})]})}const ee=i=>fetch(i,{credentials:"include"}).then(r=>r.ok?r.json():null);function Je(){const[,i]=ie("/admin/house/:id"),r=i?.id,m=ye(),{currentUser:d}=ue(),{singular:w,plural:f}=be(),p=ce(d),g=d?.impersonatingOrgId||d?.organizationId,b=je(g),o=z(g),u=S({queryKey:Y.houses,queryFn:()=>_.houses.list(),enabled:!!r}),y=S({queryKey:Y.residents,queryFn:()=>_.residents.list(),enabled:!!r}),c=S({queryKey:["robert-treatment-beds",g],enabled:!!r&&o,queryFn:async()=>{const s=await fetch("/api/robert-treatment-beds",{credentials:"include"});if(!s.ok)throw new Error("Treatment bed availability could not be loaded");return s.json()}}),h=S({queryKey:["/api/gmb/billing/status"],queryFn:()=>ee("/api/gmb/billing/status"),enabled:!!r&&!p}),l=S({queryKey:["/api/gmb/connect/status"],queryFn:()=>ee("/api/gmb/connect/status"),enabled:!!r&&!p}),v=!!h.data?.active,k=!!l.data?.connected,n="/admin/business-development/gmb",O=u.isLoading||y.isLoading||o&&c.isLoading,F=u.isError||y.isError||o&&c.isError,t=(u.data||[]).find(s=>s.id===r)||null,a=(y.data||[]).filter(s=>s.houseId===r&&s.status==="Active");if(O)return e.jsxs("div",{className:"flex items-center justify-center py-12 text-muted-foreground","data-testid":"house-detail-loading",children:[e.jsx(Q,{className:"w-5 h-5 mr-2 animate-spin"}),"Loading property…"]});if(F)return e.jsxs("div",{className:"text-center py-12","data-testid":"house-detail-error",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"Couldn't load this property right now."}),e.jsx(M,{href:"/admin/houses",children:e.jsx(j,{children:"Back to Properties"})})]});if(!t)return e.jsxs("div",{className:"text-center py-12","data-testid":"house-detail-not-found",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"Property not found"}),e.jsx(M,{href:"/admin/houses",children:e.jsx(j,{children:"Back to Properties"})})]});const E=Number(t.totalBeds??t.capacity??0)||0,G=(c.data||[]).filter(s=>s.houseId===t.id),te=G.filter(s=>s.held&&!s.assignedResidentId).length,R=b?Math.max(0,E-(Number(t.reservedBeds)||0)):o?Math.max(0,E-(Number(t.reservedBeds)||0)-te):E,K=!he(g,t),x=ve(a,t.id,g,K),V=R>0?Math.min(100,Math.round(x.totalPeople/R*100)):0,I=Math.max(0,R-x.totalPeople);return e.jsxs("div",{className:"space-y-8","data-testid":"house-detail",children:[e.jsx(M,{href:"/admin/houses",children:e.jsxs(j,{variant:"ghost",className:"mb-4","data-testid":"link-back-to-houses",children:[e.jsx(Ce,{className:"w-4 h-4 mr-2"})," Back to Properties"]})}),e.jsx(Be,{manage:!0,houseId:r,todayOnly:!0,embedded:!0}),e.jsx(T,{className:"bg-gradient-to-br from-primary/10 to-primary/5 border-primary/20",children:e.jsx(B,{className:"pt-6",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-4xl font-bold","data-testid":`text-house-name-${t.id}`,children:t.name}),e.jsx("p",{className:"text-muted-foreground","data-testid":`text-house-address-${t.id}`,children:t.address||"No address on file"}),e.jsxs("div",{className:"flex flex-wrap gap-6 mt-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Total Capacity"}),e.jsxs("p",{className:"text-3xl font-bold text-primary","data-testid":`text-house-capacity-${t.id}`,children:[R," ",R===1?"Bed":"Beds"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Currently Occupied"}),e.jsxs("p",{className:"text-3xl font-bold text-primary","data-testid":`text-house-occupied-${t.id}`,children:[x.totalPeople," ",x.totalPeople===1?w:f]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Available"}),e.jsxs("p",{className:"text-3xl font-bold text-primary","data-testid":`text-house-available-${t.id}`,children:[I," ",I===1?"Bed":"Beds"]})]})]}),b&&K&&e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4 mt-6 border-t border-primary/15 pt-5","data-testid":"house-detail-occupancy-breakdown",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Participants"}),e.jsx("p",{className:"text-xl font-semibold",children:x.participants})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Dependent children"}),e.jsx("p",{className:"text-xl font-semibold",children:x.dependentChildren})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Spouses"}),e.jsx("p",{className:"text-xl font-semibold",children:x.spouses})]}),x.houseManagers>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[m,x.houseManagers===1?"":"s"]}),e.jsx("p",{className:"text-xl font-semibold",children:x.houseManagers})]}),e.jsxs("p",{className:"col-span-2 sm:col-span-4 text-xs text-muted-foreground",children:["Saved accompanying family counts use physical beds; configured capacity does not increase. Open a participant below to update household details.",x.residentsWithUnknownFamilyStatus>0&&e.jsxs("span",{className:"block text-amber-700 mt-1",children:["Household details are unknown for ",x.residentsWithUnknownFamilyStatus," participant record",x.residentsWithUnknownFamilyStatus===1?"":"s","."]})]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"h-3 bg-secondary rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${V}%`}})}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2","data-testid":`text-house-occupancy-pct-${t.id}`,children:["Occupancy: ",V,"%"]})]})]})})}),o&&e.jsx(fe,{houseId:t.id,beds:G,residents:y.data||[],canManage:!!d?.isSuperAdmin||d?.role?.toLowerCase()==="admin",legacyReservedBeds:Number(t.reservedBeds)||0,configuredCapacity:Number(t.capacity)||0}),z(g)&&e.jsx(Pe,{houseId:t.id}),z(g)&&(d?.isSuperAdmin||d?.role==="Admin"||d?.permissions?.manageBilling)&&e.jsx(Fe,{houseId:t.id}),!p&&e.jsxs(T,{className:"border-purple-200 dark:border-purple-800","data-testid":"card-boost-on-google",children:[e.jsx(A,{className:"pb-3",children:e.jsxs(H,{
1className:"text-base flex items-center gap-2",children:[e.jsx(Z,{className:"w-4 h-4 text-purple-500"}),"Boost ",t.name," on Google"]})}),e.jsxs(B,{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[e.jsxs(D,{variant:v?"default":"outline","data-testid":"badge-gmb-active",children:[e.jsx(Se,{className:"w-3 h-3 mr-1"}),v?"GMB add-on active":"GMB add-on inactive"]}),e.jsxs(D,{variant:k?"default":"outline","data-testid":"badge-gmb-connected",children:[e.jsx($e,{className:"w-3 h-3 mr-1"}),k?"Google account connected":"Google not connected"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Open the GMB Rank Optimizer — track your local search rank, auto-publish posts, reply to reviews, and keep your Google Business Profile healthy, all on autopilot."}),e.jsx(M,{href:n,children:e.jsxs(j,{size:"sm","data-testid":"button-open-gmb-optimizer",children:[e.jsx(Z,{className:"w-4 h-4 mr-1"}),v?"Open GMB Rank Optimizer":"See GMB Rank Optimizer (subscribe to use)"]})})]})]}),e.jsxs(T,{children:[e.jsx(A,{children:e.jsxs(H,{children:["Current ",f," (",a.length,")"]})}),e.jsx(B,{children:a.length===0?e.jsxs("p",{className:"text-center py-8 text-muted-foreground","data-testid":"text-no-residents",children:["No ",f.toLowerCase()," currently in this property"]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(xe,{children:[e.jsx(pe,{children:e.jsxs(J,{children:[e.jsx(q,{children:"Name"}),e.jsx(q,{children:"Email"}),e.jsx(q,{children:"Phone"}),e.jsx(q,{children:"Admitted Date"}),e.jsx(q,{children:"Status"}),e.jsx(q,{className:"text-right",children:"Actions"})]})}),e.jsx(ge,{children:a.map(s=>e.jsxs(J,{className:"hover:bg-muted/50","data-testid":`row-resident-${s.id}`,children:[e.jsx(L,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{href:`/admin/resident/${s.id}`,children:e.jsx("span",{className:"text-primary hover:underline cursor-pointer","data-testid":`link-resident-${s.id}`,children:[s.firstName,s.lastName].filter(Boolean).join(" ").trim()||s.email||`Unnamed ${w.toLowerCase()}`})}),s.isHouseManager&&e.jsxs(D,{className:"bg-amber-600 hover:bg-amber-700 text-white text-xs",children:[e.jsx(Te,{className:"w-3 h-3 mr-1"})," ",m]})]})}),e.jsx(L,{className:"text-sm","data-testid":`text-resident-email-${s.id}`,children:s.email||"—"}),e.jsx(L,{className:"text-sm","data-testid":`text-resident-phone-${s.id}`,children:s.phone||"—"}),e.jsx(L,{className:"text-sm","data-testid":`text-resident-admitted-${s.id}`,children:s.admissionDate||"—"}),e.jsx(L,{children:e.jsx(D,{variant:"outline",children:s.status||"Active"})}),e.jsx(L,{className:"text-right",children:e.jsx(M,{href:`/admin/resident/${s.id}`,children:e.jsx(j,{variant:"ghost",size:"sm","data-testid":`button-view-resident-${s.id}`,children:"View Profile"})})})]},s.id))})]})})})]})]})}export{Je 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.