1import{r as x,j as e,k as j,S as A,aP as B,B as v,ct as L,cu as P,cv as R,q as k,a_ as E,F as p,aF as _,bu as G,dI as H,u as U,ap as q}from"./elements-DVh2jUIM.js";import{M as b}from"./MobileField-CqNLiG0-.js";import{M as V}from"./MobileTable-3_DrS7X0.js";import{A as W}from"./authorization-CE7gncHO.js";import{x as N,j as $,G as z,T as s,L as y}from"./index-DeQvL4I7.js";import{a as K,u as J}from"./board-communications-DsBZ8KLR.js";import{u as Q}from"./user-securities-BKbGEnXf.js";import"./useAuthorization-D7B2eQha.js";import"./grids-DXrfAsUA.js";import"./startOfDay-AazlW55I.js";const me={title:"Communications",showPropertySelector:!0,showAi:!0,customContentId:["Communications","Homeowner_v2"]},X=7097;function de(){const o=N(),{isLoggedIn:i}=$(),t=z(),l=(t==null?void 0:t.isBoardMember)||!1,c=x.useMemo(()=>[{value:"30",display:s("board.communications.dateOptions.last30Days")},{value:"60",display:s("board.communications.dateOptions.last60Days")},{value:"90",display:s("board.communications.dateOptions.last90Days")},{value:"365",display:s("board.communications.dateOptions.last12Months")},{value:"730",display:s("board.communications.dateOptions.last24Months")},{value:"1095",display:s("board.communications.dateOptions.last36Months")},{value:"3650",display:e.jsxs(e.Fragment,{children:[s("board.communications.dateOptions.allTime"),e.jsx("br",{}),e.jsx("span",{className:"text-sm italic",children:s("board.communications.dateOptions.loadTimes")})]})}],[]),[r,f]=x.useState(c[0]),{startDate:w,endDate:D}=x.useMemo(()=>{const a=new Date;a.setDate(a.getDate()+7);const n=new Date;return n.setDate(n.getDate()-parseInt(r.value)),{startDate:n,endDate:a}},[r.value]),{data:d=[],isFetching:M}=K({associationId:(t==null?void 0:t.id)||0,startDate:w,endDate:D}),{data:u,isLoading:S}=J({associationId:(t==null?void 0:t.id)||0}),{data:g=[],isLoading:F}=Q({associationId:t==null?void 0:t.id,apiVersion:"v2",isLoggedIn:i}),I=[{field:"createdAt",headerName:s("board.communications.created"),valueFormatter:a=>j(a.value,{format:"numeric"}),filter:"agDateColumnFilter",filterValueGetter:({data:a})=>a?new Date(a.createdAt).getTime():void 0,floatingFilter:!0,filterParams:{filterOptions:["greaterThan","lessThan","inRange"],maxNumConditions:1},flex:1},{field:"messageName",headerName:s("board.communications.name"),filter:"agTextColumnFilter",floatingFilter:!0,flex:1},{field:"inSiteAnnouncement.message",headerName:s("board.communications.announcementMessage"),filter:"agTextColumnFilter",floatingFilter:!0,flex:2},{field:"id",headerName:s("board.communications.types"),cellRenderer:({data:a})=>a?e.jsx(C,{communication:a}
1):null,sortable:!1,suppressHeaderMenuButton:!0,flex:1}],T=x.useMemo(()=>{const a=g.find(({id:n})=>n===X);return a?a.create:!1},[g]),h=!!(l&&T&&u&&(u.canSendEmails||u.canSendInSiteAnnouncements||u.canSendPushNotifications));return M||S||F?e.jsx("div",{className:"flex justify-center items-center h-full",children:e.jsx(A,{})}):e.jsx(W,{controller:"Homeowner_v2",action:"Communications",children:e.jsxs("div",{className:"w-full bg-base-fill rounded-xl space-y-4 px-9 pt-9 max-mobile:px-4",children:[e.jsxs("div",{className:"flex justify-between items-center gap-2 flex-wrap",children:[e.jsx(B,{required:!0,options:c,label:"",deriveKey:a=>a.value??"",displaySelected:()=>{var a;return((a=c.find(n=>n===r))==null?void 0:a.display)??""},displayOption:({display:a})=>a,onChange:f,value:c.find(({value:a})=>a===r.value),className:"mobile:w-[215px] max-w-[300px] flex-grow"}),d.length>0&&h&&e.jsx(y,{to:"/new-communication",children:e.jsx(v,{type:"button",variant:"primary",children:s("board.communications.createCommunicationLabel")})})]}),e.jsx(L,{children:e.jsx(P,{className:"flex w-full flex-row border-b",children:e.jsx(R,{as:"button",className:({selected:a})=>k("py-2 px-4 text-center font-bold leading-5 text-input-fg underline-offset-4","focus:outline-none","border-b-2 hover:border-base-link -mb-[1px]",a&&"border-base-link text-base-link"),children:l?s("board.communications.sent"):s("board.communications.received")})})}),d.length===0?e.jsx(Y,{showCreateCommunicationButton:h}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"max-mobile:hidden",children:e.jsx(E,{rowData:d,columnDefs:I,onRowClicked:({data:a})=>o(`/communications/${a==null?void 0:a.id}`)})}),e.jsx("div",{className:"mobile:hidden",children:e.jsx(V,{items:d,renderItem:a=>e.jsx(Z,{communication:a}),getSearchableFields:({messageName:a,createdAt:n,inSiteAnnouncement:m})=>[a,n==null?void 0:n.toLocaleDateString(),m==null?void 0:m.message],sortFn:(a,n)=>{const m=a.createdAt?a.createdAt.getTime():0,O=n.createdAt?n.createdAt.getTime():0;return m-O}})})]})]})})}const Y=({showCreateCommunicationButton:o})=>{const{t:i}=U();return e.jsx("div",{className:"pb-9",children:e.jsxs("div",{className:"flex flex-col items-center gap-5 px-4 py-10 border border-base-border rounded-md",children:[e.jsx(p,{className:"w-6 h-6",icon:q}),e.jsxs("div",{className:"flex flex-col items-center max-mobile:text-center",children:[e.jsx("p",{children:i("board.communications.noCommunicationsHeader")}),o&&e.jsx("p",{className:"text-sm",children:i("board.communications.noCommunicationsBody")})]}),o&&e.jsx(y,{to:"/new-communication",children:e.jsx(v,{type:"button",variant:"primary",children:i("board.communications.createCommunicationLabel")})})]})})},Z=({communication:o})=>{const i=N(),{id:t,messageName:l,createdAt:c,inSiteAnnouncement:r}=o,f=()=>i(`/communications/${t}`);return e.jsxs("div",{className:"p-3 w-full rounded-md border border-base-border flex flex-col gap-2 text-sm",onClick:f,children:[e.jsx(b,{field:s("board.communications.created"),value:j(c,{format:"numeric"})}),e.jsx(b,{field:s("board.communications.name"),value:l}),r&&e.jsx(b,{field:s("board.communications.announcementMessage"),value:r.message}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("p",{className:"font-semibold",children:s("board.communications.types")}),e.jsx(C,{communication:o})]})]})},C=({communication:o})=>{const{email:i,inSiteAnnouncement:t,pushNotification:l}=o;return e.jsxs("div",{className:"flex gap-3 text-base-icon",children:[i&&e.jsx(p,{icon:_}),t&&e.jsx(p,{icon:G}),l&&e.jsx(p,{icon:H})]})};export{de as Component,me 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.