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-43bf7a1c.js";import{o as W}from"./yup-3b80ed10.js";import{T as B}from"./TextArea-23730be7.js";import{u as I}from"./index.esm-0548c843.js";import{c as E,b as F}from"./index.esm-f9e0a906.js";import{L as V}from"./List-6fcc4821.js";import{A as $}from"./Avatar-ec89b895.js";import"./TextField-4da97115.js";import"./FormControl-8d011aab.js";import"./OutlinedInput-6bcf3cf8.js";import"./useFormControl-2c5d60c2.js";import"./InputLabel-6c7474f0.js";import"./Select-44fd3147.js";import"./Menu-362130d3.js";import"./Grow-ca573f65.js";import"./useControlled-ab567149.js";import"./createSvgIcon-f118be02.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};
