import{d as C,r as p,ek as L,b as v,a as T,fD as R,gS as h,j as e,T as a,B as o,J as u,M as k,gT as M,gU as H}from"./index-d2b25495.js";import{o as B}from"./yup-267e586f.js";import{T as I}from"./TextArea-7e39a6e1.js";import{u as W}from"./index.esm-ce3c2c20.js";import{c as D,b as E}from"./index.esm-3043d6d4.js";import{L as F}from"./List-863f013e.js";import{A as $}from"./Avatar-9337c33f.js";import"./TextField-e155d2be.js";import"./FormControl-73683015.js";import"./OutlinedInput-86f3ec98.js";import"./useFormControl-2b068664.js";import"./InputLabel-bb6ab40e.js";import"./Select-ef36a2b2.js";import"./Menu-337a466b.js";import"./Grow-8719411b.js";import"./useControlled-8d737f13.js";import"./createSvgIcon-e39ae511.js";const q=C(F)(({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}}=T(s=>R(s)),j=()=>{_()},b=D().shape({comment:E().trim("Comment cannot be empty").required("Please enter a text")}),{control:y,handleSubmit:S,getValues:z,reset:_}=W({resolver:B(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(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(w),children:[A,e.jsx(o,{mt:2,textAlign:"end",children:e.jsx(u,{type:"submit",variant:"contained",startIcon:e.jsx(M,{size:16}),size:"medium",color:"secondary",children:"Submit"})})]})})]})]})};export{ie as default};
