import{j as e,aH as i,B as C,b7 as D,be as w,a7 as S,p as b,M as R,S as k}from"./vendor-mui-CBBEb17G.js";import{a as d}from"./vendor-react-BBazpZul.js";import{I as p,G as r,D as T,a as F,C as N}from"./CreateLetters-Dfe_B6tw.js";import{aP as h,aX as v,aQ as m,C as A,fB as L,fA as q,a_ as o,al as B,c4 as G}from"./index-DdWwwZXu.js";import{F as E}from"./FileDownload-BKpA-DVT.js";import"./vendor-utils-BveVE6Uf.js";import"./vendor-charts-tGnAgELZ.js";const P=({infomation:t})=>{const{DownloadAttachmentAsync:a}=p(),n=[{title:"عنوان",key:"FileName",dataIndex:"FileName",width:400},{title:"فرمت",key:"ContentType",dataIndex:"ContentType",width:100},{title:"دانلود",key:"Id",dataIndex:"Id",width:100,render:c=>e.jsx(C,{onClick:()=>c&&s(c),children:e.jsx(E,{color:"success"})})}],s=async c=>{const x=t.Attachments.find(j=>j.Id===c),u=x&&x.FileName;await a(c,u||"")};return e.jsxs(r,{container:!0,px:2,rowSpacing:.5,children:[e.jsxs(r,{item:!0,xs:12,children:[e.jsx(i,{children:" شماره درخواست :"}),e.jsx(h,{value:t==null?void 0:t.Id})]}),e.jsxs(r,{item:!0,xs:12,children:[e.jsx(i,{children:" تاریخ زمان ارسال :"}),e.jsx(h,{value:(t==null?void 0:t.CreateDate)&&new Date(t==null?void 0:t.CreateDate).toLocaleDateString("fa-IR-u-nu-latn",{year:"numeric",month:"2-digit",day:"2-digit"})})]}),e.jsxs(r,{item:!0,xs:12,children:[e.jsx(i,{children:' ارسال شده توسط" :'}),e.jsx(h,{value:t==null?void 0:t.EmployeeName})]}),e.jsx(r,{item:!0,xs:12,children:e.jsxs(T,{fullWidth:!0,className:"!mt-5",children:[e.jsx(i,{children:"موضوع :"}),e.jsx("textarea",{className:"description !border-2 !border-[#e7e7e7e7] !border-solid",value:t==null?void 0:t.Title})]})}),e.jsxs(r,{item:!0,xs:12,children:[e.jsx(i,{children:"تاریخ زمان اولین مشاهده نامه :"}),e.jsx(h,{value:(t==null?void 0:t.ReadingDate)&&new Date(t==null?void 0:t.ReadingDate).toLocaleDateString("fa-IR-u-nu-latn",{year:"numeric",month:"2-digit",day:"2-digit"})})]}),e.jsxs(r,{item:!0,xs:12,children:[e.jsx(i,{children:"پیوست نامه :"}),e.jsx(v,{columns:n,data:t==null?void 0:t.Attachments,rowKey:"Id",boxProps:{sx:{height:150}}})]})]})},K=({reqId:t,open:a,onClose:n})=>{const[s,c]=d.useState(null),{GetIncomingRequestByIdAsync:x}=p();return d.useEffect(()=>{t&&x(t).then(u=>{c(u)})},[t]),e.jsx(e.Fragment,{children:s&&e.jsxs(F,{open:a,children:[e.jsx(r,{item:!0,xs:12,mt:1,className:"px-4 align-middle text-left",children:e.jsx(m,{onClick:n,children:e.jsx(A,{})})}),e.jsxs(r,{container:!0,className:"min-h-[87vh]",children:[e.jsx(r,{item:!0,xs:12,md:4,children:e.jsx(P,{infomation:s})}),e.jsx(r,{item:!0,xs:12,md:8,className:"h-full",children:e.jsx(D,{sx:{height:"70vh"},children:e.jsx(w,{children:e.jsx(S,{variant:"body2",children:s!=null&&s.Text?s==null?void 0:s.Text:"متن خالی است"})})})})]})]})})},M=()=>{const[t,a]=d.useState(!1),[n,s]=d.useState(),{GetIncomingRequests:c}=p(),[x,u]=d.useState([]),[j,g]=d.useState(!1),y=[{title:"تاریخ ارسال درخواست",key:"CreateDate",dataIndex:"CreateDate",width:110,render:l=>o(l)},{key:"Title",dataIndex:"Title",width:180,render:l=>o(l),title:"عنوان در خواست"},{title:"تاریخ دریافت درخواست",dataIndex:"ReadingDate",key:"ReadingDate",width:110,render:l=>o(l)}],I=async()=>{g(!0);try{const l=await c();u(l)}finally{g(!1)}};return d.useEffect(()=>{I()},[]),e.jsxs(e.Fragment,{children:[n&&e.jsx(K,{reqId:n,open:t,onClose:()=>a(!1)}),e.jsxs(L,{children:[e.jsx(q,{loading:j,sticky:!0,scroll:{x:600},rowKey:"id",columns:y||[],data:x||[],onDoubleClick:l=>{s(l.Id),a(!0)}}),e.jsx(b,{className:"pagination-box"})]})]})},U=B(R)`
  box-shadow: 0 3px 20px rgb(0 0 0 / 4%);
  background-color: rgb(255, 255, 255);
  padding: 1rem;
  min-height: 100vh;

  .MuiDataGrid-row {
    cursor: pointer !important;
  }
`,H=()=>{const[t,a]=d.useState(!1);return e.jsxs(U,{children:[t&&e.jsx(N,{onClose:()=>a(!1)}),e.jsxs(k,{direction:"row",justifyContent:"start",spacing:1,mb:2,alignItems:"center",children:[e.jsx("span",{children:"درخواست های ارسالی "}),e.jsx(m,{onClick:()=>a(!0),children:e.jsx(G,{})})]}),e.jsx(M,{})]})},J=()=>e.jsx(H,{});export{J as default};
