1import{j as e}from"./vendor-editor-YezxlIi6.js";import{r as a,h as s}from"./vendor-react-Bi4a4EiF.js";import{C as r}from"./Card-BmbakBLD.js";import{r as t}from"./index-Dx54j0je.js";import{d as l,r as d,v as i,z as c}from"./index-COu_gDVE.js";import{q as n,a as o,I as m}from"./vendor-ui-32IHAVAn.js";import{I as x}from"./Icon-DVBR0hTE.js";import{c as b,a as u,u as p}from"./vendor-forms-I7v9PsJd.js";import{T as h}from"./Textarea-BJCwUBFE.js";import{u as g}from"./vendor-redux-wb1HQVsL.js";import{M as j}from"./Modal-B7Uw-c3I.js";import{o as f}from"./yup-nnBCiISO.js";import"./vendor-date-DycrGX6G.js";const v=()=>{const a=l.c(1);let s;return a[0]===Symbol.for("react.memo_cache_sentinel")?(s=e.jsx("div",{className:"w-full",children:Array(4).fill().map(y)}),a[0]=s):s=a[0],s};function y(a,s){return e.jsx("div",{className:"mb-4 p-3 border-b border-slate-100 dark:border-slate-700",children:e.jsxs("div",{role:"status",className:"w-full animate-pulse mx-2",children:[e.jsx("div",{className:"h-[10px] bg-gray-200 rounded-full dark:bg-gray-700 w-48 mb-4"}),e.jsx("div",{className:"h-[10px] bg-gray-200 rounded-full dark:bg-gray-700 max-w-[300px] mb-2.5"}),e.jsx("div",{className:"h-[10px] bg-gray-200 rounded-full dark:bg-gray-700 mb-2.5"}),e.jsx("div",{className:"h-[10px] bg-gray-200 rounded-full dark:bg-gray-700 max-w-[280px] mb-2.5"}),e.jsx("div",{className:"h-[10px] bg-gray-200 rounded-full dark:bg-gray-700 max-w-[150px] mb-2.5"}),e.jsx("div",{className:"h-[10px] bg-gray-200 rounded-full dark:bg-gray-700 max-w-[360px]"}),e.jsxs("div",{className:"flex items-center justify-between pt-4 mt-5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"h-[10px] bg-gray-300 rounded-full dark:bg-gray-600 w-24 mb-2.5"}),e.jsx("div",{className:"w-32 h-[10px] bg-gray-200 rounded-full dark:bg-gray-700"})]}),e.jsx("div",{className:"h-[10px] bg-gray-300 rounded-full dark:bg-gray-700 w-12"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 mt-5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"h-[10px] bg-gray-300 rounded-full dark:bg-gray-600 w-24 mb-2.5"}),e.jsx("div",{className:"w-32 h-[10px] bg-gray-200 rounded-full dark:bg-gray-700"})]}),e.jsx("div",{className:"h-[10px] bg-gray-300 rounded-full dark:bg-gray-700 w-12"})]}),e.jsxs("div",{className:"flex items-center justify-between pt-4 mt-5",children:[e.jsxs("div",{children:[e.jsx("div",{className:"h-[10px] bg-gray-300 rounded-full dark:bg-gray-600 w-24 mb-2.5"}),e.jsx("div",{className:"w-32 h-[10px] bg-gray-200 rounded-full dark:bg-gray-700"})]}),e.jsx("div",{className:"h-[10px] bg-gray-300 rounded-full dark:bg-gray-700 w-12"})]})]})},s)}const k=s=>{const r=l.c(47),{activeModal:t,onClose:d,noFade:i,disableBackdrop:c,className:m,children:b,footerContent:u,centered:p,scrollContent:h,themeClass:g,title:j}=s,f=void 0===m?"max-w-xl":m,v=void 0===g?"bg-slate-900 dark:bg-slate-800 dark:border-b dark:border-slate-700":g,y=i?"":"duration-300 ease-out",k=i?"":"opacity-0",N=i?"":"opacity-100",w=i?"":"duration-200 ease-in",C=i?"":"opacity-100",F=i?"":"opacity-0";let S,_;r[0]!==c?(S=!c&&e.jsx("div",{className:"fixed inset-0 bg-slate-900/50 backdrop-filter backdrop-blur-sm"}),r[0]=c,r[1]=S):S=r[1],r[2]!==y||r[3]!==k||r[4]!==N||r[5]!==w||r[6]!==C||r[7]!==F||r[8]!==S?(_=e.jsx(n.Child,{as:a.Fragment,enter:y,enterFrom:k,enterTo:N,leave:w,leaveFrom:C,leaveTo:F,children:S}),r[2]=y,r[3]=k,r[4]=N,r[5]=w,r[6]=C,r[7]=F,r[8]=S,r[9]=_):_=r[9];const T="flex min-h-full justify-center text-center p-6 "+(p?"items-center":"items-start "),M=i?"":"duration-300 ease-out",$=i?"":"opacity-0 scale-95",P=i?"":"opacity-100 scale-100",A=i?"":"duration-200 ease-in",H=i?"":"opacity-100 scale-100",z=i?"":"opacity-0 scale-95",B=`w-full transform overflow-hidden rounded-md\n bg-white dark:bg-slate-800 text-left align-middle shadow-xl transition-alll ${f}`,D=`relative overflow-hidden py-4 px-5 text-white flex justify-between ${v}`;let I,U,E,G;r[10]!==j?(I=e.jsx("h2",{className:"capitalize leading-6 tracking-wider font-medium text-base text-white",children:j}),r[10]=j,r[11]=I):I=r[11],r[12]===Symbol.for("react.memo_cache_sentinel")?(U=e.jsx(x,{icon:"heroicons-outline:x"}),r[12]=U):U=r[12],r[13]!==d?(E=e.jsx("button",{onClick:d,className:"text-[22px]",children:U}),r[13]=d,r[14]=E):E=r[14],r[15]!==D||r[16]!==I||r[17]!==E?(G=e.jsxs("div",{className:D,children:[I,E]}),r[15]=D,r[16]=I,r[17]=E,r[18]=G):G=r[18];const O="px-6 py-8 "+(h?"overflow-y-auto max-h-[400px]":"");let q,V,R,J,K,L,Q;return r[19]!==b||r[20]!==O?(q=e.jsx("div",{className:O,children:b}),r[19]=b,r[20]=O,r[21]=q):q=r[21],r[22]!==u?(V=u&&e.jsx("div",{className:"px-4 py-3 flex justify-end space-x-3 border-t border-slate-100 dar
1k:border-slate-700",children:u}),r[22]=u,r[23]=V):V=r[23],r[24]!==B||r[25]!==G||r[26]!==q||r[27]!==V?(R=e.jsxs(o.Panel,{className:B,children:[G,q,V]}),r[24]=B,r[25]=G,r[26]=q,r[27]=V,r[28]=R):R=r[28],r[29]!==M||r[30]!==$||r[31]!==P||r[32]!==A||r[33]!==H||r[34]!==z||r[35]!==R?(J=e.jsx(n.Child,{as:a.Fragment,enter:M,enterFrom:$,enterTo:P,leave:A,leaveFrom:H,leaveTo:z,children:R}),r[29]=M,r[30]=$,r[31]=P,r[32]=A,r[33]=H,r[34]=z,r[35]=R,r[36]=J):J=r[36],r[37]!==T||r[38]!==J?(K=e.jsx("div",{className:"fixed inset-0 overflow-y-auto",children:e.jsx("div",{className:T,children:J})}),r[37]=T,r[38]=J,r[39]=K):K=r[39],r[40]!==d||r[41]!==_||r[42]!==K?(L=e.jsxs(o,{as:"div",className:"relative z-[99999]",onClose:d,children:[_,K]}),r[40]=d,r[41]=_,r[42]=K,r[43]=L):L=r[43],r[44]!==t||r[45]!==L?(Q=e.jsx(n,{appear:!0,show:t,as:a.Fragment,children:L}),r[44]=t,r[45]=L,r[46]=Q):Q=r[46],Q},N=({isModalOpen:s,setIsModalOpen:r,editFeedbackValue:t,fetchFeedbacks:l})=>{const[c,n]=a.useState(!1),o=b({comments:u().required("Comments is required")}).required(),{register:m,reset:x,formState:{errors:g},handleSubmit:v,setValue:y}=p({resolver:f(o),mode:"all"});a.useEffect(()=>{y("comments",t.comments)},[t,y]);return e.jsx("div",{children:e.jsx(j,{title:"Edit Feedback",labelclassName:"btn-outline-dark",activeModal:s,onClose:()=>{r(!1),x({comments:t.comments})},children:e.jsxs("form",{onSubmit:v(async e=>{try{n(!0);(await d(`https://api.dyzo.ai/employee-feedback/patch/${t?.id}/`,{body:{comments:e.comments}})).status&&(i.success("Feedback updated successfully"),r(!1),l())}catch{i.error("Unable to update feedback")}finally{n(!1)}}),className:"space-y-4",children:[e.jsx(h,{label:"Description",name:"comments",register:m,placeholder:"Description",rows:"10",error:g.comments}),e.jsx("div",{className:"ltr:text-right rtl:text-left",children:e.jsx("button",{type:"submit",className:"btn btn-dark text-center",disabled:c,children:c?"Update...":"Update"})})]})})})},w=()=>{const{userId:l}=s(),[d,n]=a.useState(!1),[o,x]=a.useState([]),[b,u]=a.useState(!1),[j,f]=a.useState(!1),[y,w]=a.useState(null),[C,F]=a.useState({comment:""}),S="https://api.dyzo.ai",_=g(e=>e.auth.user),[T,M]=a.useState(!1),[$,P]=a.useState({}),A=async()=>{n(!0);try{const e=c(),a=await fetch(`${S}/api/feedbacks/${l}/`,{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),s=await a.json();s.status&&x(s.data)}catch(e){}finally{n(!1)}};a.useEffect(()=>{A()},[l]);const H=a.useMemo(()=>[{Header:"Feedback Giver",accessor:"feedback_giver_name",Cell:a=>e.jsx("span",{children:a?.cell?.value})},{Header:"Feedback Receiver",accessor:"feedback_receiver_name",Cell:a=>e.jsx("span",{children:a?.cell?.value})},{Header:"Comments",accessor:"comments",Cell:a=>{const s=a?.cell?.value;return e.jsx("span",{children:s.length>40?`${s.substring(0,40)}...`:s})}},{Header:"Updated At",accessor:"updated_at",Cell:a=>{const s=new Date(a?.cell?.value);return e.jsx("span",{children:J(s)})}},{Header:"Actions",accessor:"actions",Cell:a=>e.jsx("span",{onClick:e=>{e.stopPropagation(),M(!0),P(a.row.original)},children:_._id===a.row.original.feedback_giver&&e.jsx(m,{icon:"heroicons:pencil-square",className:"w-6 h-6 cursor-pointer"})})}],[]),z=a.useMemo(()=>o,[o]),B=t.useTable({columns:H,data:z},t.useGlobalFilter,t.useSortBy),{getTableProps:D,getTableBodyProps:I,headerGroups:U,rows:E,prepareRow:G}=B,{register:O,handleSubmit:q,reset:V,formState:{errors:R}}=p(),J=e=>new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!0}).format(e).replace(/(am|pm)/gi,e=>e.toUpperCase());return e.jsxs(e.Fragment,{children:[e.jsxs(r,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("div",{className:"text-black flex rounded-2 items-center gap-2 pb-6 pt-2",children:[e.jsx(m,{icon:"eva:pie-chart-fill",className:"h-7 w-7"}),e.jsx("p",{className:"text-black font-bold text-lg flex items-center",children:"User Feedbacks"})]}),e.jsxs("button",{onClick:()=>u(!0),className:"btn flex items-center gap-2 mb-4 btn-dark text-center dark:border-2 dark:border-white",children:[e.jsx(m,{icon:"clarity:plus-circle-line",className:"w-4 h-4"})," Add Feedback"]})]}),e.jsx("div",{className:"overflow-x-auto -mx-6",children:e.jsx("div",{className:"inline-block min-w-full align-middle",children:e.jsx("div",{className:"overflow-hidden",children:e.jsxs("table",{className:"min-w-full divide-y divide-slate-100 table-fixed dark:divide-slate-700",...D(),children:[e.jsx("thead",{className:"bg-slate-200 dark:bg-slate-700",children:U.map(a=>e.jsx("tr",{...a.getHeaderGroupProps(),children:a.headers.map(a=>e.jsx("th",{...a.getHeaderProps(a.getSortByToggleProps()),scope:"col",className:"table-th",children:e.jsxs("div",{className:"flex",children:[a.render("Header"),e.jsx("span",{children:a.isSorted?a.isSortedDesc?" ð½":" ð¼":""})]})}))}))}),e.jsx("tbody",{className:"bg-white divide-y divide-slate-100 dar
1k:bg-slate-800 dark:divide-slate-700",...I(),children:d?e.jsx(v,{}):0===E.length?e.jsx("tr",{children:e.jsx("td",{colSpan:"4",className:"text-center py-5",children:"No feedbacks found!"})}):E.map(a=>(G(a),e.jsx("tr",{...a.getRowProps(),className:"cursor-pointer relative",onClick:()=>{return e=a.original,w(e),void f(!0);var e},children:a.cells.map(a=>e.jsx("td",{...a.getCellProps(),className:"table-td",children:a.render("Cell")}))})))})]})})})}),e.jsx(k,{activeModal:b,onClose:()=>u(!1),title:"Add Feedback",children:e.jsxs("form",{onSubmit:async e=>{e.preventDefault(),n(!0);try{const e=`${S}/feedback/`,a=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c()}`},body:JSON.stringify({comments:C.comment,feedback_giver:_._id,feedback_receiver:l})}),s=await a.json();s.status?(i.success("Feedback posted successfully."),A(),u(!1)):i.error(`Failed to post feedback: ${s.message}`)}catch(a){i.error(`Error: ${a.message||"An error occurred"}`)}finally{n(!1),F({comment:""})}},children:[e.jsx(h,{name:"comment",label:"Comments",value:C.comment,onChange:e=>{const{name:a,value:s}=e.target;F(e=>({...e,[a]:s}))},error:R.comments,placeholder:"Enter your feedback comments",register:O}),e.jsx("button",{type:"submit",className:"btn mt-2 mb-4 btn-dark text-center dark:border-2 dark:border-white",children:"Submit"})]})}),y&&e.jsx(k,{activeModal:j,onClose:()=>f(!1),title:"View Feedback",children:e.jsxs("div",{children:[e.jsxs("p",{className:"pb-2",children:[e.jsx("strong",{children:"Feedback Giver:"})," ",y.feedback_giver_name]}),e.jsxs("p",{className:"pb-2",children:[e.jsx("strong",{children:"Feedback Receiver:"})," ",y.feedback_receiver_name]}),e.jsxs("p",{className:"pb-2",children:[e.jsx("strong",{children:"Comments:"})," ",y.comments]}),e.jsxs("p",{className:"pb-2",children:[e.jsx("strong",{children:"Updated At:"})," ",J(new Date(y.updated_at))]})]})})]}),e.jsx(N,{isModalOpen:T,setIsModalOpen:M,editFeedbackValue:$,fetchFeedbacks:A})]})};export{w as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.