import{d as C,r as p,eh as L,b as v,a as R,fM as T,gV as h,j as e,T as a,B as o,K as u,N as M,gW as k,gX as H}from"./index-60a3c753.js";import{o as W}from"./yup-92678dde.js";import{T as B}from"./TextArea-b2d5bcf9.js";import{u as I}from"./index.esm-c494934a.js";import{c as E,b as F}from"./index.esm-62d6b2f7.js";import{L as V}from"./List-f567f8e4.js";import{A as $}from"./Avatar-a21f41a5.js";import"./TextField-32b29087.js";import"./FormControl-d13d2693.js";import"./OutlinedInput-3a884178.js";import"./useFormControl-e13b5747.js";import"./InputLabel-71dfc9d4.js";import"./Select-99fc0d84.js";import"./Menu-d1b7e1c3.js";import"./Grow-68442588.js";import"./useControlled-194ef007.js";import"./createSvgIcon-de433e5f.js";const q=C(V)(({theme:i})=>({maxHeight:"300px",marginTop:"15px",overflowY:"auto",padding:"0 8px","&::-webkit-scrollbar":{width:"8px"},"&::-webkit-scrollbar-thumb":{backgroundColor:i.palette.primary.main,borderRadius:"8px"}})),ie=()=>{p.useState("");const{id:i}=L(),n=v(),{comments:{commentsList:l,pageParams:t,commentsCount:g,loading:f}}=R(s=>T(s)),j=()=>{_()},b=E().shape({comment:F().trim("Comment cannot be empty").required("Please enter a text")}),{control:y,handleSubmit:S,getValues:z,reset:_}=I({resolver:W(b)});z("comment");const w=s=>{const r={tender_id:i,comment:s.comment};n(H({data:r,params:t,hide:j}))};p.useMemo(()=>{n(h({...t,tender:i,search:"",page:1,page_size:10}))},[]);const A=p.useMemo(()=>e.jsx(B,{name:"comment",label:"",type:"text",placeholder:"Write comment here...",minRows:3,maxRows:5,containerSx:{display:"grid",gap:1},control:y}),[]);return e.jsxs(e.Fragment,{children:[e.jsxs(a,{component:"h4",children:["Comments (",g,")"]}),e.jsxs(o,{sx:{mt:"28px"},children:[e.jsxs(q,{onScroll:s=>{const{target:r}=s;Math.ceil((r==null?void 0:r.scrollTop)+(r==null?void 0:r.offsetHeight))==(r==null?void 0:r.scrollHeight)&&t.page<t.no_of_pages&&n(h({...t,page:(t==null?void 0:t.page)+1,page_size:10}))},children:[l&&l.map(s=>{var r,c,m,d,x;return e.jsxs(o,{sx:{display:"flex",gap:"12px",mt:"20px"},children:[e.jsx($,{variant:"circular",src:(c=(r=s==null?void 0:s.created_by)==null?void 0:r.fullname)==null?void 0:c.charAt(0),sx:{height:"32px",width:"32px"}}),e.jsxs(o,{width:"100%",children:[e.jsxs(o,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(o,{children:e.jsxs(a,{component:"h5",sx:{mb:"8px",color:"grey.700",fontWeight:500,fontSize:"13px"},children:[(m=s==null?void 0:s.created_by)==null?void 0:m.fullname," ","(",(d=s==null?void 0:s.created_by)==null?void 0:d.username,")"]})}),e.jsx(a,{component:"p",sx:{color:"grey.700",fontSize:"10px",fontWeight:500},children:(x=s==null?void 0:s.created_on)==null?void 0:x.toLocaleString()})]}),e.jsx(a,{component:"p",sx:{color:"grey.600",fontSize:"13px"},children:s.comment})]})]})}),f&&e.jsx(o,{textAlign:"center",mt:"12px",children:e.jsx(u,{size:"small",color:"error",sx:{"& > svg":{"@keyframes spin":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}}},startIcon:e.jsx(M,{size:16,style:{marginRight:"6px",animation:"spin 1.5s linear infinite"}}),children:"Load More"})})]}),e.jsx(o,{sx:{border:"1px solid divider",borderRadius:"5px",mt:"28px"},children:e.jsxs("form",{onSubmit:S(w),children:[A,e.jsx(o,{mt:2,textAlign:"end",children:e.jsx(u,{type:"submit",variant:"contained",startIcon:e.jsx(k,{size:16}),size:"medium",color:"secondary",children:"Submit"})})]})})]})]})};export{ie as default};
