PageSourceSearch

https://portal.heritageproperty.com/assets/inspections-C3vrQSTp.js

js heritageproperty.com collected 2026-09-28 05:56:14 UTC 19,413 bytes, 1 lines download raw bytes

1import{r as o,u as T,j as e,k as W,bf as _,B as v,F as P,cw as K,a_ as Q,co as q,aQ as E,n as F,M as X,aP as $,aT as Y,cx as Z}from"./elements-5kxJS_4j.js";import{M as J}from"./ModernPortalPage-ZOfMD2FX.js";import{B as ee}from"./BoardListDetailOutlet-BLfTYBPG.js";import{A as se}from"./authorization-DRCBMAi9.js";import{c as te}from"./clickableCardProps-H_WzBPvj.js";import{M as ae}from"./MobileCardButton-D6bsn729.js";import{u as V,g as ne,a as ie}from"./useMobileRedesignActive-7HkeUmjL.js";import{G as oe}from"./GridSettings-BQybxGtG.js";import{g as re}from"./boardDetailItemIds-CezeTAyo.js";import{x as le,G as ce,j as de,W as pe,a8 as me,a2 as ue,am as xe}from"./index-CtCeyryw.js";import{u as G}from"./useBoardFrustrationEnabled-D-vRo-Pq.js";import{u as fe,a as he,b as ge,c as be,d as we,e as je}from"./board-inspections-B7imZAEA.js";import{u as ye}from"./useAttachmentViewer-BQoPBwhJ.js";import{B as ve,b as Ne}from"./boardDecisionActions-BmpNgjt4.js";import"./useAuthorization-XS6cSJ0I.js";import"./useIsMobile-DE0QDUth.js";import"./useMobileRedesignBoardPages-BgUjR8UU.js";import"./useRedesign-xeayEwR4.js";import"./grids-DGmfp9GI.js";import"./startOfDay-AazlW55I.js";import"./useMutation-jkV-6MpM.js";const B="board-inspections-grid",L=a=>[a.inspectionId??"",a.actionItemId??"",a.stepDescription??"",a.ownerName??"",a.propertyAddress??"",a.description??"",a.followUpDate?new Date(a.followUpDate).toISOString():""].join("|"),Ie=({onSave:a,onCancel:f})=>{const{t:g}=T(),[d,b]=o.useState(""),[c,n]=o.useState(!1),w=async()=>{if(d.trim()){n(!0);try{await a(d.trim())}finally{n(!1)}}};return e.jsxs("div",{className:"flex items-center gap-2 py-1",onClick:t=>t.stopPropagation(),children:[e.jsx(E,{className:"flex-1","data-qa":"inspections-row-reply-input",placeholder:g("board.inspections.replyPlaceholder"),rows:2,value:d,onChange:t=>b(t.target.value),autoFocus:!0}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(v,{variant:"passiveOutline",size:"xs",onClick:f,"data-qa":"inspections-row-reply-cancel",disabled:c,children:g("board.inspections.cancel")}),e.jsx(v,{variant:"primary",size:"xs",onClick:w,"data-qa":"inspections-row-reply-save",disabled:c||!d.trim(),children:g(c?"board.inspections.saving":"board.inspections.save")})]})]})},Se=o.forwardRef(({violations:a,isLoading:f=!1,hasSelectedInspection:g=!1,canAddMessage:d=!1,onFirstDataRendered:b,onView:c,onSaveMessage:n},w)=>{const{t}=T(),{showAttachments:p}=ye(),j=o.useRef(c),y=o.useRef(n),h=o.useRef(d),i=G(),[u,x]=o.useState(null);o.useEffect(()=>{j.current=c},[c]),o.useEffect(()=>{y.current=n},[n]),o.useEffect(()=>{h.current=d},[d]);const S=t(g?"board.inspections.noViolations":"board.inspections.selectInspectionPrompt"),N=o.useCallback(r=>{h.current&&x(L(r))},[]),C=o.useCallback(()=>{x(null)},[]),s=o.useMemo(()=>[{field:"stepDescription",headerName:"Step",rowGroup:!0,enableRowGroup:!0,minWidth:150,filter:"agTextColumnFilter",floatingFilter:!0},{field:"ownerName",headerName:"Owner",autoHeight:!0,minWidth:200,filter:"agTextColumnFilter",floatingFilter:!0,enableRowGroup:!0,cellRenderer:r=>{const{ownerName:m,propertyAddress:R}=r.data??{};return e.jsxs("div",{className:"flex flex-col py-2",children:[e.jsx("span",{className:"font-medium text-base-header",children:m??t("board.inspections.associationName")}),e.jsx("span",{className:"text-sm text-gray-500",children:R??""})]})}},{field:"propertyAddress",headerName:"Property Address",initialHide:!0,minWidth:200,filter:"agTextColumnFilter",floatingFilter:!0,enableRowGroup:!0},{field:"description",headerName:"Description",autoHeight:!0,minWidth:150,filter:"agTextColumnFilter",floatingFilter:!0,wrapText:!0,cellClass:"!leading-snug py-1 text-sm",cellStyle:{lineHeight:"1.3",fontSize:"0.8125rem"},enableRowGroup:!0},{field:"fineAmount",headerName:"Fine",autoHeight:!0,minWidth:130,filter:"agTextColumnFilter",floatingFilter:!0,cellRenderer:r=>{const{followUpDate:m,fineAmount:R}=r.data??{};return e.jsxs("div",{className:"flex flex-col py-2",children:[e.jsx("span",{className:"text-sm text-gray-500",children:t("board.inspections.followUp")}),e.jsx("span",{className:"text-sm text-base-header",children:m?W(m,{format:"numeric"}):"-"}),e.jsx("span",{className:"text-sm text-base-header",children:t("board.inspections.fineLabel",{amount:R!=null?_(R):"$0.00"})})]})}},{field:"lastImageFilename",headerName:"Photo",sortable:!1,autoHeight:!0,minWidth:130,filter:!1,cellRenderer:r=>{const{lastImageFilename:m,actionItemId:R}=r.data??{};return m?e.jsx("button",{type:"button",className:"text-base-link hover:underline text-sm font-medium","data-qa":"inspections-row-view-attachment",onClick:k=>{k.stopPropagation(),R&&p({actionItemId:R,title:t("board.inspections.inspection")})},children:t("board.inspections.viewAttachment")}):e.jsx("span",{className:"text-gray-400 text-sm",children:t("board.inspections.noAttachment")})}},{field:"lastNotePortal",headerName:"Message",autoHeight:!0,minWidth:200,filter:"agTextColumnFilter",floatingFilter:!0,cellRenderer:r=>{const m=r.data;return m?u===L(m)?e.jsx(Ie,{onSave:async k=>{y.current&&(x(null),y.current(m,k))},onCancel:C}):e.jsx("div",{className:`py-2 text-sm ${h.current?"cursor-pointer hover:bg-gray-50":""}`,onDoubleClick:()=>N(m),title:h.current?t("board.inspections.doubleClickToReply"):void 0,children:m.lastNotePortal||e.jsx("span",{className:"text-gray-400 italic",children:"-"})}):null}},{colId:"actions",headerName:"",sortable:!1,resizable:!1,hide:i&&!d,autoHeight:!0,...i?{width:110,minWidth:110}:{width:220,minWidth:220},filter:!1,suppressMenu:!0,cellRenderer:({data:r})=>r?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-2",children:[!i&&e.jsx(v,{variant:"passiveOutline",size:"xs",onClick:m=>{m.stopPropagation(),j.current(r)},"data-qa":"inspections-row-view",children:t("board.inspections.view")}),h.current&&e.jsx(v,{variant:"passiveOutline",size:"xs",onClick:m=>{m.stopPropagation(),N(r)},"data-qa":"inspections-row-reply",startIcon:e.jsx(P,{icon:K,className:"w-3 h-3"}),children:t("board.inspections.edit")})]}):null}],[u,N,C,t,p,d,i]);return e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(P,{icon:q,className:"w-8 h-8 text-primary animate-spin"})}),children:e.jsx(Q,{ref:w,"data-qa":"inspections-table",gridId:B,rowData:a,columnDefs:s,enableClipboard:!0,pagination:!1,getRowId:({data:r})=>L(r),suppressLoadingOverlay:!f,overlayNoRowsTemplate:`<span class="text-gray-500">${S}</span>`,rowGroupPanelShow:"always",suppressRowGroupHidesColumns:!0,onRowClicked:i?({data:r})=>{r&&j.current(r)}:void 0,onFirstDataRendered:b})})}),z=a=>{const f=new Date;return f.setDate(f.getDate()+a),f.toISOString().split("T")[0]},Ce=a=>new Date(a+"T00:00:00Z").toISOString(),Re=({open:a,onClose:f,inspectionId:g,associationId:d,onSuccess:b})=>{const{t:c}=T(),{data:n=[],isLoading:w}=fe(g,d,!0,{enabled:a}
1),t=he(),[p,j]=o.useState(null),[y,h]=o.useState(""),[i,u]=o.useState(""),[x,S]=o.useState(null);o.useEffect(()=>{n.length>0&&!p&&(j(n[0]),u(z(n[0].duration)))},[n,p]);const N=o.useCallback(s=>{j(s),u(z(s.duration))},[]);o.useEffect(()=>{a||(j(null),h(""),u(""),S(null))},[a]);const C=o.useCallback(async()=>{if(!p)return;const s={nextStepId:p.actionStepId,approved:1,associationId:d,...y.trim()&&{note:y.trim()},...i&&{followUpDate:Ce(i)},...x&&{attachments:x}};try{const r=await t.mutateAsync({inspectionId:g,request:s});F({type:"success",message:r.message||c("board.inspections.reviewCompleteSuccess")}),b(),f()}catch(r){console.error("Review complete failed:",r),F({type:"error",message:c("board.inspections.reviewCompleteError")})}},[p,d,y,i,x,g,t,b,f,c]);return e.jsx(X,{open:a,onClose:f,title:c("board.inspections.reviewCompleteTitle"),textAlign:"left",dataQa:"inspection-review-modal",actions:Ne({onSubmit:C,onCancel:f,isPending:t.isPending,submitDisabled:!p,qaPrefix:"inspection-review",t:c}),children:e.jsx("div",{className:"flex flex-col gap-4 min-w-[400px]",children:w?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(P,{icon:q,className:"w-6 h-6 text-primary animate-spin"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{children:e.jsx($,{label:c("board.decisionModal.nextStep"),options:n,value:p??void 0,onChange:N,qaListAttribute:"inspection-next-step",qaOptionValue:s=>s.actionStepId.toString(),deriveKey:s=>s.actionStepId.toString(),displaySelected:s=>s.displayText,displayOption:s=>e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:s.displayText}),s.feeAmount!=null&&s.feeAmount>0&&e.jsx("span",{className:"text-xs text-gray-500",children:c("board.inspections.feeLabel",{amount:`$${s.feeAmount.toFixed(2)}`})})]}),placeholder:c("board.decisionModal.selectStep")})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:c("board.inspections.followUpDate")}),e.jsx("input",{type:"date","data-qa":"inspection-review-follow-up-date",className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-1 focus:ring-primary focus:border-primary",value:i,onChange:s=>u(s.target.value)})]}),e.jsx(E,{label:c("board.decisionModal.noteLabel"),"data-qa":"inspection-review-note",placeholder:c("board.decisionModal.notePlaceholder"),rows:4,value:y,onChange:s=>h(s.target.value)}),e.jsx(ve,{files:x,onChange:S,disabled:t.isPending,qaPrefix:"inspection-review"})]})})})},Ae=()=>{const{t:a}=T(),f=le(),g=ce(),d=(g==null?void 0:g.id)??0,{isMobileRedesignActive:b}=V(),c=o.useRef(null),n=de(l=>l.gridsColumnState),w=o.useMemo(()=>n[B],[n]),{data:t,isLoading:p}=ge(d),{data:j=[],isLoading:y}=be(d),h=o.useMemo(()=>[...j].sort((l,I)=>{const A=l.startDateUtc?new Date(l.startDateUtc).getTime():0;return(I.startDateUtc?new Date(I.startDateUtc).getTime():0)-A}),[j]),[i,u]=o.useState(null),[x,S]=o.useState(!1),[N,C]=o.useState(!1),{data:s=[],isLoading:r}=we((i==null?void 0:i.assocInspectId)??0,d),m=je(),R=o.useCallback(async()=>{if(!(!i||x)){S(!0);try{const{blob:l,filename:I}=await pe.downloadBoardInspectionReport(i.assocInspectId,d),A=()=>{const D=window.URL.createObjectURL(l),M=document.createElement("a");M.href=D,M.download=I,document.body.appendChild(M),M.click(),document.body.removeChild(M),window.URL.revokeObjectURL(D)};try{const D=await me(l);ue({content:D,contentType:l.type,fileName:I},A)}catch{A()}}catch(l){console.error("Failed to download report:",l);const I=l instanceof Error?l.message.includes("403")?"You do not have permission to download this report":l.message.includes("404")?"Inspection not found":"Failed to download report. Please try again.":"Failed to download report. Please try again.";F({type:"error",title:"Error",message:I})}finally{S(!1)}}},[i,d,x]),k=o.useCallback(l=>{const I=re(c.current,s,({actionItemId:D})=>D),A=new URLSearchParams({associationId:d.toString()});i!=null&&i.assocInspectId&&A.append("inspectionId",i.assocInspectId.toString()),f(`/board/inspections/${l.actionItemId}?${A.toString()}`,{state:{itemIds:I}})},[f,d,i,s]),U=o.useCallback(async(l,I)=>{if(i)try{await m.mutateAsync({inspectionId:i.assocInspectId,violationId:l.actionItemId,request:{noteText:I,existingNoteId:l.lastNoteId??
10,associationId:d}}),F({type:"success",message:a("board.inspections.messageSaved")})}catch(A){throw console.error("Failed to save message:",A),F({type:"error",message:a("board.inspections.messageSaveError")}),A}},[i,d,m,a]),H=p||y||r,O=o.useCallback(()=>{!c.current||!w||c.current.applyColumnState({state:w,applyOrder:!0})},[w]);return o.useEffect(()=>{if(p||!w)return;const l=window.setTimeout(()=>{O()},0);return()=>window.clearTimeout(l)},[p,t==null?void 0:t.isAdmin,w,O]),t&&!t.canRead?e.jsx("div",{className:"w-full bg-base-fill rounded-xl px-6 py-6",children:e.jsx("div",{className:"text-center py-12 text-gray-500",children:a("board.inspections.noPermission")})}):e.jsxs("div",{...ne(b,"w-full bg-base-fill rounded-xl px-9 py-6 max-mobile:px-4 space-y-4 relative"),children:[e.jsxs("div",{className:"flex flex-col mobile:flex-row mobile:items-center mobile:justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-col mobile:flex-row mobile:items-center gap-3 mobile:gap-4 flex-wrap",children:[e.jsx("span",{className:"text-base font-medium text-base-header",children:a("board.inspections.chooseInspection")}),e.jsx($,{options:h,value:i??void 0,onChange:u,qaListAttribute:"inspection-select",qaOptionValue:l=>l.assocInspectId.toString(),deriveKey:l=>l.assocInspectId.toString(),displaySelected:l=>l.displayText,displayOption:l=>e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:l.displayText}),l.inspectionType&&e.jsx("span",{className:"text-xs text-gray-500",children:l.inspectionType})]}),label:"",placeholder:a("board.inspections.selectInspection"),className:"w-full mobile:min-w-[400px] mobile:w-auto",buttonClassName:"bg-white"}),i&&(t==null?void 0:t.isAdmin)&&e.jsx(v,{variant:"additive",size:"sm","data-qa":"inspection-review-complete",startIcon:e.jsx(P,{icon:Y,className:"w-4 h-4"}),onClick:()=>C(!0),children:a("board.inspections.reviewComplete")})]}),e.jsxs("div",{className:"flex items-center gap-3 max-mobile:self-end",children:[!b&&e.jsx(v,{variant:"passive",size:"sm",onClick:R,"data-qa":"inspections-print-report",startIcon:e.jsx(P,{icon:x?q:Z,className:`w-4 h-4 ${x?"animate-spin":""}`}),disabled:!i||x,children:e.jsx("span",{className:"max-mobile:hidden",children:a(x?"board.inspections.generatingReport":"board.inspections.printReport")})}),!b&&e.jsx(oe,{gridId:B,getGridRef:()=>c.current})]})]}),e.jsx("div",{className:"max-mobile:hidden",children:e.jsx(Se,{ref:c,violations:s,isLoading:r,hasSelectedInspection:!!i,canAddMessage:(t==null?void 0:t.isAdmin)??!1,onFirstDataRendered:O,onView:k,onSaveMessage:U})}),e.jsx("div",{className:"mobile:hidden",children:e.jsx(De,{violations:s,isLoading:r,hasSelectedInspection:!!i,canAddMessage:(t==null?void 0:t.isAdmin)??!1,onSaveMessage:U,onView:k})}),H&&e.jsx("div",{className:"absolute inset-0 bg-white/50 flex items-center justify-center rounded-xl",children:e.jsx(P,{icon:q,className:"w-8 h-8 text-primary animate-spin"})}),i&&(t==null?void 0:t.isAdmin)&&e.jsx(Re,{open:N,onClose:()=>C(!1),inspectionId:i.assocInspectId,associationId:d,onSuccess:()=>{u(null)}})]})},De=({violations:a,isLoading:f,hasSelectedInspection:g,canAddMessage:d,onSaveMessage:b,onView:c})=>{const{t:n}=T(),{isMobileRedesignActive:w}=V(),t=G(),p=d&&!!b,[j,y]=o.useState(null),[h,i]=o.useState(""),[u,x]=o.useState(!1),S=s=>{y(s),i("")},N=()=>{y(null),i("")},C=async s=>{if(!(!h.trim()||u||!b)){x(!0);try{await b(s,h.trim()),N()}finally{x(!1)}}};return g?a.length===0&&!f?e.jsx("div",{className:"text-center py-8 text-gray-500",children:n("board.inspections.noViolations")}):w?e.jsx("div",{className:"flex flex-col gap-3",children:a.map(s=>e.jsxs("div",{className:`flex flex-col ${ie}`,children:[e.jsx(ae,{onClick:()=>c(s),"data-qa":"inspections-mobile-view","aria-label":`${n("board.inspections.view")} ${s.ownerName??n("board.inspections.unknownOwner")} XN ${s.actionItemId}`,buttonClassName:"p-4 pb-0",children:e.jsxs("div",{className:"flex-1 flex flex-col gap-3 min-w-0",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"font-medium text-base-header",children:s.ownerName??n("board.inspections.unknownOwner")}),e.jsx("span",{className:"text-sm text-gray-500",children:s.propertyAddress??""})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-sm font-medium text-gray-600",children:n("board.inspections.description")}),e.jsx("span",{className:"text-sm text-base-header",children:s.description??"-"})]})]})}),e.jsxs("div",{className:"px-4 pb-4 pt-3 flex justify-between items-end",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-sm text-gray-500",children:n("board.inspections.fine")}),e.jsx("span",{className:"text-sm text-base-header",children:s.fineAmount!=null?`$${s.fineAmount.toFixed(2)}`:"-"})]}),p&&e.jsx(v,{variant:"passiveOutline",size:"xs",onClick:()=>S(s.actionItemId),"data-qa":"inspections-mobile-reply",children:n("board.inspections.edit")})]}),p&&j===s.actionItemId&&e.jsxs("div",{className:"px-4 pb-4 flex flex-col gap-2 pt-2 border-t border-base-border",children:[e.jsx(E,{"data-qa":"inspections-mobile-reply-input",placeholder:n("board.inspections.replyPlaceholder"),rows:3,value:h,onChange:r=>i(r.target.value)}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(v,{variant:"passiveOutline",size:"xs",onClick:N,"data-qa":"inspections-mobile-reply-cancel",disabled:u,children:n("board.inspections.cancel")}),e.jsx(v,{variant:"primary",size:"xs",onClick:()=>C(s),"data-qa":"inspections-mobile-reply-save",disabled:u||!h.trim(),children:n(u?"board.inspections.saving":"board.inspections.save")})]})]})]},s.actionItemId))}):e.jsx("div",{className:"flex flex-col gap-3",children:a.map(s=>e.jsxs("div",{className:`p-4 rounded-md border border-base-border bg-white flex flex-col gap-3 ${t?"cursor-pointer":""}`,...t?te(()=>c(s)):{},children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"font-medium text-base-header",children:s.ownerName??n("board.inspections.unknownOwner")}),e.jsx("span",{className:"text-sm text-gray-500",children:s.propertyAddress??""})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-sm font-medium text-gray-600",children:n("board.inspections.description")}),e.jsx("span",{className:"text-sm text-base-header",children:s.description??"-"})]}),e.jsxs("div",{className:"flex justify-between items-end",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-sm text-gray-500",children:n("board.inspections.fine")}),e.jsx("span",{className:"text-sm text-base-header",children:s.fineAmount!=null?`$${s.fineAmount.toFixed(2)}`:"-"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!t&&e.jsx(v,{variant:"passiveOutline",size:"xs",onClick:()=>c(s),"data-qa":"inspections-mobile-view",children:n("board.inspections.view")}),p&&e.jsx(v,{variant:"passiveOutline",size:"xs",onClick:()=>S(s.actionItemId),"data-qa":"inspections-mobile-reply",children:n("board.inspections.edit")})]})]}),p&&j===s.actionItemId&&e.jsxs("div",{className:"flex flex-col gap-2 pt-2 border-t border-base-border",children:[e.jsx(E,{"data-qa":"inspections-mobile-reply-input",placeholder:n("board.inspections.replyPlaceholder"),rows:3,value:h,onChange:r=>i(r.target.value)}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(v,{variant:"passiveOutline",size:"xs",onClick:N,"data-qa":"inspections-mobile-reply-cancel",disabled:u,children:n("board.inspections.cancel")}),e.jsx(v,{variant:"primary",size:"xs",onClick:()=>C(s),"data-qa":"inspections-mobile-reply-save",disabled:u||!h.trim(),children:n(u?"board.inspections.saving":"board.inspections.save")})]})]})]},s.actionItemId))}):e.jsx("div",{className:"text-center py-8 text-gray-500",children:n("board.inspections.selectInspectionPrompt")})},Ye={title:"Inspections",showPropertySelector:!0,showAi:!0,redesignPage:"inspectionsPage",redesignHandle:{customContentId:["Inspections","Board_v2"]}};function Ze(){const a=xe("inspectionsPage");return e.jsx(se,{controller:"Board_v2",action:"Inspections",children:a?e.jsx(ee,{children:e.jsx(Ae,{})}):e.jsx(J,{action:"Inspections",controller:"Board_v2"})})}export{Ze as Component,Ye as handle};

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.