1import{kR as S,r as g,j as e,bv as A,bw as C,bx as R,by as D,bz as q,fv as k,ap as v,bT as B,fD as M,kS as y,v as W,X as F,as as u,kT as H,fB as I,bA as O,bB as P,av as $,kU as z,i9 as K,kV as Y,aI as b,ig as _}from"./index-CpeGhXo5.js";import{i as G}from"./requestDisplay-DR9biDUM.js";import{M as Q}from"./minus-pU-fxz13.js";function ee({requestId:s,open:l,onOpenChange:a}){const{data:t=[],isFetching:i,isError:n,error:o,refetch:d}=S(s??"",{skip:!l||!s}),m=g.useMemo(()=>[{key:"at",label:"Date/Time",sortable:!1,width:"160px",render:r=>e.jsx("span",{className:"whitespace-nowrap tabular-nums text-slate-500",children:G(r.at)})},{key:"activity",label:"Activity",sortable:!1,render:r=>e.jsx("span",{className:"text-slate-500",children:r.activity})},{key:"from",label:"Old Logs",sortable:!1,render:r=>e.jsx(w,{entry:r,side:"from"})},{key:"to",label:"New Logs",sortable:!1,render:r=>e.jsxs("div",{children:[e.jsx(w,{entry:r,side:"to"}),r.note&&e.jsx("p",{className:"mt-0.5 text-slate-500",children:r.note})]})},{key:"actor",label:"Action By",sortable:!1,render:r=>r.actorName?e.jsxs("span",{className:"text-slate-600 dark:text-slate-300",children:[e.jsx("span",{className:"block",children:r.actorName}),r.actorEmpCode&&e.jsx("span",{className:"block text-slate-400",children:r.actorEmpCode})]}):e.jsx("span",{className:"text-slate-400",children:"System"})},{key:"ipAddress",label:"IP Address",sortable:!1,width:"140px",render:r=>e.jsx("span",{className:"tabular-nums text-slate-500",children:r.ipAddress??"-"})}],[]);return e.jsx(A,{open:l,onOpenChange:a,children:e.jsxs(C,{className:"max-w-5xl w-[calc(100vw-2rem)] p-0 gap-0 overflow-hidden",children:[e.jsxs(R,{className:"px-6 py-4 border-b border-slate-200 dark:border-slate-800 text-left",children:[e.jsx(D,{className:"text-base font-semibold",children:"Activity Logs"}),e.jsx(q,{className:"sr-only",children:"Every change made to this request, who made it and when."})]}),e.jsx("div",{className:"h-[65vh] min-h-[240px] flex flex-col",children:n?e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 py-12 text-center",children:[e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-300",children:k(o,"The activity log could not be loaded.")}),e.jsx(v,{size:"sm",variant:"outline",onClick:()=>d(),children:"Try again"})]}):e.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:e.jsx(B,{rows:t,columns:m,rowKey:r=>r.id,loading:i&&!t.length,storageKey:"hrms-activity-log-v1",initialClientSortKey:null,hideToolbar:!0,fillHeight:!0,emptyTitle:"Nothing yet",empty:"Nothing has happened on this request yet."})})})]})})}function w({entry:s,side:l}){return s.changes.length?e.jsx("ul",{className:"space-y-0.5",children:s.changes.map(a=>e.jsxs("li",{children:[e.jsxs("span",{className:"text-slate-500",children:[a.field,":"]})," ",e.jsx("span",{className:"text-slate-800 dark:text-slate-100 break-words",children:a[l]??"-"})]},a.field))}):e.jsx("span",{className:"text-slate-400",children:"-"})}function te({steps:s,currentLevel:l,isPending:a}){return e.jsx(M,{title:"Approval Chain",children:s.length===0?e.jsx("p",{className:"text-[11px] text-slate-400",children:"No approval chain recorded."}):e.jsx("ol",{className:"pl-2",children:s.map((t,i)=>{const n=y[t.status]??y.pending,o=a&&t.levelNo===l&&t.status==="pending",d=i===s.length-1;return e.jsxs("li",{className:u("relative pl-3.5",!d&&"pb-2.5 border-l border-slate-200 dark:border-slate-700"),"aria-current":o?"step":void 0,children:[e.jsxs("span",{"aria-hidden":!0,className:u("absolute -left-[5px] top-0.5 w-2.5 h-2.5 rounded-full ring-2 ring-white dark:ring-slate-900 flex items-center justify-center",n.dot,o&&"animate-pulse"),children:[t.status==="approved"&&e.jsx(W,{className:"w-1.5 h-1.5 text-white",strokeWidth:4}),t.status==="rejected"&&e.jsx(F,{className:"w-1.5 h-1.5 text-white",strokeWidth:4}),(t.status==="skipped"||t.status==="cancelled")&&e.jsx(Q,{className:"w-1.5 h-1.5 text-white",strokeWidth:4})]}),e.jsxs("div",{className:u("text-[8px] font-bold uppercase tracking-wider leading-none",n.label),children:[o?"Waiting":H[t.status],e.jsxs("span",{className:"text-slate-400 font-medium normal-case tracking-normal",children:[" · Level ",t.levelNo]})]}),e.jsx("div",{className:"text-[11px] font-medium text-slate-800 dark:text-slate-200 mt-0.5 leading-tight",children:t.approverName??(t.status==="pending"?"HR admin":"No approver")}),e.jsxs("div",{className:"text-[9px] text-slate-500",children:[t.label,t.approverDesignation?` · ${t.approverDesignation}`:""]}),t.actedAt&&e.jsxs("div",{className:"text-[9px] text-slate-400 mt-0.5",children:[I(t.actedAt),t.actedAs==="admin"&&t.actedByName?` · by ${t.actedByName} (HR admin)`:""]}),t.comments&&e.jsxs("p",{className:"mt-1 text-[10px] text-slate-600 dar
1k:text-slate-300 bg-slate-50 dark:bg-slate-950 border border-slate-100 dark:border-slate-800 rounded px-1.5 py-1",children:["â",t.comments,"â"]}),t.skipReason&&t.status!=="approved"&&t.status!=="rejected"&&e.jsx("p",{className:u("mt-0.5 text-[9px]",t.status==="pending"?"text-red-600 dark:text-red-400":"text-slate-400"),children:t.skipReason})]},t.id)})})})}function ae({permissions:s,status:l,busy:a,onAction:t}){const i=l==="approved";return e.jsxs("div",{className:"flex items-center gap-2",children:[s.canCancel&&e.jsx(v,{variant:"outline",onClick:()=>t(i?"revoke":"cancel"),disabled:a,className:i?"h-8 text-[11px] font-bold uppercase tracking-wide px-4 border-red-200 text-red-600 hover:bg-red-50":"h-8 text-[11px] font-bold uppercase tracking-wide px-4",children:i?"Revoke":"Cancel"}),s.canReject&&e.jsx(v,{onClick:()=>t("reject"),disabled:a,className:"h-8 text-[11px] bg-red-500 hover:bg-red-600 text-white font-bold uppercase tracking-wide px-5",children:"Reject"}),s.canApprove&&e.jsx(v,{onClick:()=>t("approve"),disabled:a,className:"h-8 text-[11px] bg-[#62a856] hover:bg-[#528d48] text-white font-bold uppercase tracking-wide px-5",children:"Approve"})]})}const U={approve:{title:"Approve this request",confirm:"Approve",placeholder:"Add a note for the employee (optional)",required:!1,button:"bg-emerald-600 hover:bg-emerald-700 text-white"},reject:{title:"Reject this request",confirm:"Reject",placeholder:"Tell the employee why this is being rejected",required:!0,button:"bg-red-600 hover:bg-red-700 text-white"},cancel:{title:"Cancel this request",confirm:"Cancel request",placeholder:"Why is this being cancelled? (optional)",required:!1,button:"bg-slate-800 hover:bg-slate-900 text-white dark:bg-slate-200 dark:text-slate-900"},revoke:{title:"Revoke this approval",confirm:"Revoke",placeholder:"Why is this approval being revoked? The employee sees this.",required:!0,button:"bg-red-600 hover:bg-red-700 text-white"},reverse:{title:"Reverse this adjustment",confirm:"Reverse",placeholder:"Why is this being reversed? (optional)",required:!1,button:"bg-rose-600 hover:bg-rose-700 text-white"}};function V({kind:s,open:l,busy:a,error:t,subject:i,onOpenChange:n,onConfirm:o}){const[d,m]=g.useState(""),r=g.useId(),x=U[s];g.useEffect(()=>{l&&m("")},[l,s]);const j=d.trim(),h=x.required&&!j;return e.jsx(A,{open:l,onOpenChange:p=>!a&&n(p),children:e.jsxs(C,{className:"sm:max-w-[460px]",children:[e.jsxs(R,{children:[e.jsx(D,{className:"text-base font-semibold text-slate-800 dark:text-slate-100",children:x.title}),e.jsx(q,{className:"text-xs",children:i})]}),e.jsxs("form",{onSubmit:p=>{p.preventDefault(),!h&&!a&&o(j)},children:[e.jsxs("label",{htmlFor:r,className:"text-[11px] font-medium text-slate-600 dark:text-slate-300",children:["Comment",x.required&&e.jsx("span",{className:"text-red-500",children:" *"})]}),e.jsx(O,{id:r,autoFocus:!0,value:d,maxLength:1e3,onChange:p=>m(p.target.value),placeholder:x.placeholder,"aria-invalid":!!t||void 0,className:u("mt-1 min-h-[110px] resize-none text-sm",t&&"border-red-400")}),t&&e.jsx("p",{role:"alert",className:"mt-1.5 text-xs text-red-600",children:t}),e.jsxs(P,{className:"mt-4 gap-2",children:[e.jsx(v,{type:"button",variant:"outline",disabled:a,onClick:()=>n(!1),children:"Close"}),e.jsxs(v,{type:"submit",disabled:h||a,className:u("min-w-[110px] gap-1.5",x.button),children:[a&&e.jsx($,{className:"w-3.5 h-3.5 animate-spin"}),x.confirm]})]})]})]})})}function se(s,l){const[a,t]=g.useState(null),[i,n]=g.useState(null),[o,{isLoading:d}]=z(),[m,{isLoading:r}]=K(),[x,{isLoading:j}]=Y(),h=s.employee?.id,p=d||r,E=async c=>{if(a){n(null);try{const f=a==="approve"||a==="reject"?await o({id:s.id,action:a,note:c||void 0,employeeId:h}).unwrap():await m({id:s.id,note:c||void 0,employeeId:h}).unwrap();t(null);const N=a==="revoke"?"Approval revoked":a==="cancel"?"Request cancelled":f.status==="pending"?"Approved â sent to the next approver":a==="approve"?"Request approved":"Request rejected";b.success(N),f.effectStatus==="failed"&&b.error("The decision was saved, but applying it failed. An HR admin can retry it from this request."),l?.(s.id)}catch(f){const N=_(f);n(N.note??Object.values(N)[0]??k(f,"The request could not be updated."))}}},T=async()=>{try{const c=await x({id:s.id,employeeId:h}).unwrap();c.effectStatus==="applied"?b.success("Applied successfully"):b.error(c.effectError??"It still could not be applied.")}catch(c){b.error(k(c,"Retry failed."))}},L=a?e.jsx(V,{kind:a,open:!0,busy:p,error:i,subject:`${s.employee?.name??"Employee"} · ${s.title}`,onOpenChange:c=>{c||(t(null),n(null))},onConfirm:E}):null;return{openDialog:t,busy:p,retrying:j,retryEffect:T,dialogElement:L}}export{te as A,V as D,ae as R,ee as a,se as u};
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.