import{d as C,r as p,eh as L,b as v,a as R,fA as T,gP as h,j as e,T as a,B as o,K as u,N as k,gQ as H,gR as M}from"./index-76d4793e.js";import{o as B}from"./yup-688ec4f6.js";import{T as I}from"./TextArea-f4ef1e8b.js";import{u as W}from"./index.esm-3adfd9f7.js";import{c as E,b as F}from"./index.esm-ad8a7c9f.js";import{L as P}from"./List-4c24b3e8.js";import{A as $}from"./Avatar-ff1026d1.js";import"./TextField-9c64a4a2.js";import"./FormControl-c671c595.js";import"./OutlinedInput-ac933786.js";import"./useFormControl-c8d490e1.js";import"./InputLabel-5ed57f0e.js";import"./Select-338083eb.js";import"./Menu-ed7c6894.js";import"./Grow-84b30c0e.js";import"./useControlled-e03384de.js";import"./createSvgIcon-01ec10fc.js";const q=C(P)(({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=()=>{A()},b=E().shape({comment:F().trim("Comment cannot be empty").required("Please enter a text")}),{control:y,handleSubmit:S,getValues:z,reset:A}=W({resolver:B(b)});z("comment");const _=s=>{const r={tender_id:i,comment:s.comment};n(M({data:r,params:t,hide:j}))};p.useMemo(()=>{n(h({...t,tender:i,search:"",page:1,page_size:10}))},[]);const w=p.useMemo(()=>e.jsx(I,{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(k,{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(_),children:[w,e.jsx(o,{mt:2,textAlign:"end",children:e.jsx(u,{type:"submit",variant:"contained",startIcon:e.jsx(H,{size:16}),size:"medium",color:"secondary",children:"Submit"})})]})})]})]})};export{ie as default};
