import{j as e,b as D,a as q,u as M}from"./query-PJ0ZdjbV.js";import{f as Hs,a as p,O as Bs,k as Ys,u as Zs}from"./vendor-CWhr2lg4.js";import{a2 as Is,b0 as ke,T as ys,bz as ws,bf as Xs,ap as Le,p as y,a4 as x,B as b,d as K,h as O,ar as Js,a as ea,e as Ne,f as be,P as Ue,s as se,t as ae,v as te,w as ne,x as N,aa as Me,ab as ze,ac as He,ad as Be,ae as Ye,q as c,I as F,r as le,at as je,af as Ze,av as De,ax as qe,ay as Fe,az as Ve,a$ as Pe,aA as Ae,Q as Xe,V as Je,W as es,X as ss,Y as as,Z as ts,_ as ns,$ as is,a0 as ls,ag as rs,ah as cs,ai as ds,aj as L,ak as os,y as us,c3 as Ts}from"./index-BSPIaiZU.js";import{L as sa}from"./layout-dashboard-pgzECxsO.js";import{M as vs}from"./message-square-warning-DksdPLDU.js";import{F as aa}from"./folder-open-BwrzuZcM.js";import{G as $s}from"./gavel-BRZt127W.js";import{F as Ss}from"./file-chart-column-increasing-DonUpE5r.js";import{C as Cs}from"./chart-column-DbfNf7gS.js";import{B as ge}from"./badge-C34iUAiA.js";import{P as Ee}from"./page-header-D8tSLbK0.js";import{T as ta}from"./trending-up-Cognoqa9.js";import{S as Qs}from"./shield-alert-1Mds4K4N.js";import{A as Ps}from"./arrow-right-Bmt6JCm_.js";import{u as Re,a as Ce,t as Ie,o as Te,b as ve,s as w,e as Ge,c as _e,l as na}from"./date-range-picker-BB0TgAn8.js";import{u as ms}from"./use-data-table-state-CKRg6qY2.js";import{D as xs}from"./data-table-D_-xOEqd.js";import{E as we}from"./employee-select-DtUobKxP.js";import{A as re}from"./async-select-BUbwdJEZ.js";import{u as hs}from"./system-admin.api-BT5u-_A_.js";import{w as Ds,a as ia,i as We}from"./date-validation-D9gNvaP9.js";import{E as ps}from"./ellipsis-DaNBIBaV.js";import{C as la}from"./circle-check-Dgh1V3VA.js";import{R as ra}from"./rotate-ccw-u1EtXcFp.js";import{S as Ks}from"./status-badge-DPaiL_rL.js";import{M as ca}from"./message-square-CrQ4L-TW.js";import{C as da}from"./calendar-check-BOVhup94.js";import{S as oa}from"./square-check-big-BcV2kv-K.js";import"./ui-aO-W1bxx.js";import"./chevron-left-DLFf1YD2.js";import"./core-hr.api-MChaGqvv.js";/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ua=Is("CircleArrowUp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const fs=Is("FileWarning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),ma=[{heading:"Overview",items:[{to:"/grievance",label:"Dashboard",description:"Grievance overview",icon:sa,permission:["grievance","dashboard","read"]}]},{heading:"Grievances",items:[{to:"/grievance/grievances",label:"Grievances",description:"Complaints & issues",icon:vs,permission:["grievance","grievance","read"]},{to:"/grievance/categories",label:"Categories",description:"Grievance categories",icon:aa,permission:["grievance","grievance_category","read"]}]},{heading:"Discipline",items:[{to:"/grievance/show-causes",label:"Show Cause Notices",description:"Issue & track notices",icon:fs,permission:["grievance","show_cause","read"]},{to:"/grievance/disciplinary-cases",label:"Disciplinary Cases",description:"Investigations & hearings",icon:$s,permission:["grievance","disciplinary_case","read"]},{to:"/grievance/warning-letters",label:"Warning Letters",description:"Verbal & written warnings",icon:ys,permission:["grievance","warning_letter","read"]}]},{heading:"Configuration",items:[{to:"/grievance/settings",label:"Settings",description:"Module config",icon:ws,permission:["grievance","settings","read"]}]},{heading:"Insights",items:[{to:"/grievance/reports",label:"Reports",description:"Grievance reports",icon:Ss,permission:["grievance","report","read"]},{to:"/grievance/analytics",label:"Analytics",description:"Trends & insights",icon:Cs,permission:["grievance","analytics","read"]}]}];function xa({item:t,isActive:a}){const s=t.icon;return e.jsxs(Ys,{to:t.to,end:t.to==="/grievance",className:Le("group relative flex items-center gap-3 rounded-lg px-3 py-2.5 transition-all duration-150",a?"bg-primary-subtle/70":"hover:bg-slate-50"),children:[a&&e.jsx("span",{className:"absolute left-0 top-2.5 bottom-2.5 w-[3px] rounded-r-full bg-primary"}),e.jsx("div",{className:Le("flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition-colors duration-150",a?"bg-primary/10 text-primary":"bg-slate-100 text-slate-400 group-hover:bg-slate-200/70 group-hover:text-slate-500"),children:e.jsx(s,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:Le("block text-[13px] truncate leading-tight",a?"font-medium text-primary":"font-medium text-slate-700 group-hover:text-slate-900"),children:t.label}),e.jsx("span",{className:Le("block text-[11px] truncate leading-tight mt-0.5",a?"text-primary/60":"text-slate-400"),children:t.description})]})]})}function At(){const t=Hs(),a=p.useRef(null),{hasPermission:s}=ke();p.useEffect(()=>{var m;(m=a.current)==null||m.scrollTo(0,0)},[t.pathname]);const o=p.useMemo(()=>ma.map(m=>({...m,items:m.items.filter(h=>s(h.permission[0],h.permission[1],h.permission[2]))})).filter(m=>m.items.length>0),[s]);return e.jsxs("div",{className:"-m-6 flex h-[calc(100%+48px)]",children:[e.jsxs("aside",{className:"w-[260px] shrink-0 border-r border-slate-200/60 bg-white flex flex-col",children:[e.jsxs("div",{className:"shrink-0 px-5 pt-6 pb-4 border-b border-slate-100",children:[e.jsx("h1",{className:"text-[15px] font-semibold text-slate-900 tracking-tight",children:"Grievance & Disciplinary"}),e.jsx("p",{className:"mt-0.5 text-[11px] text-slate-400",children:"Complaints, investigations & discipline"})]}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-3 py-3 scrollbar-thin",children:o.map((m,h)=>e.jsxs("div",{className:Le(h>0&&"mt-6"),children:[e.jsx("p",{className:"mb-2 px-3 text-[11px] font-semibold uppercase tracking-[0.08em] text-slate-400",children:m.heading}),e.jsx("div",{className:"space-y-0.5",children:m.items.map(k=>{const S=k.to==="/grievance"?t.pathname==="/grievance":Xs(t.pathname,k.to);return e.jsx(xa,{item:k,isActive:S},k.to)})})]},m.heading))})]}),e.jsx("main",{ref:a,className:"flex-1 min-w-0 overflow-y-auto bg-background scrollbar-thin",children:e.jsx("div",{className:"px-8 py-6 w-full",children:e.jsx(Bs,{})})})]})}const f="/grievance",u={settings:["grievance","settings"],categories:["grievance","categories"],grievances:["grievance","grievances"],grievance:t=>["grievance","grievances",t],notes:t=>["grievance","notes",t],documents:t=>["grievance","documents",t],showCauses:["grievance","show-causes"],showCause:t=>["grievance","show-causes",t],disciplinaryCases:["grievance","disciplinary-cases"],disciplinaryCase:t=>["grievance","disciplinary-cases",t],warningLetters:["grievance","warning-letters"],warningLetter:t=>["grievance","warning-letters",t],dashboard:["grievance","dashboard"],reports:["grievance","reports"],analytics:["grievance","analytics"]};function ha(){return M({queryKey:u.settings,queryFn:()=>y.get(`${f}/settings/`).then(t=>t.data)})}function pa(){const t=D();return q({mutationFn:a=>y.patch(`${f}/settings/`,a).then(s=>s.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.settings}),x.success("Grievance settings updated")},onError:()=>x.error("Failed to update grievance settings")})}function ks(t){return M({queryKey:[...u.categories,t],queryFn:()=>y.get(`${f}/categories/`,{params:t}).then(a=>a.data)})}function ga(){const t=D();return q({mutationFn:a=>y.post(`${f}/categories/`,a).then(s=>s.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.categories}),x.success("Category created")},onError:()=>x.error("Failed to create category")})}function ja(){const t=D();return q({mutationFn:({id:a,...s})=>y.patch(`${f}/categories/${a}/`,s).then(o=>o.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.categories}),x.success("Category updated")},onError:()=>x.error("Failed to update category")})}function va(){const t=D();return q({mutationFn:a=>y.delete(`${f}/categories/${a}/`),onSuccess:()=>{t.invalidateQueries({queryKey:u.categories}),x.success("Category deleted")},onError:()=>x.error("Failed to delete category")})}function qs(t){return M({queryKey:[...u.grievances,t],queryFn:()=>y.get(`${f}/grievances/`,{params:t}).then(a=>a.data)})}function Gt(t){return M({queryKey:u.grievance(t),queryFn:()=>y.get(`${f}/grievances/${t}/`).then(a=>a.data),enabled:!!t})}function ya(){const t=D();return q({mutationFn:a=>y.post(`${f}/grievances/`,a).then(s=>s.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.grievances}),t.invalidateQueries({queryKey:u.dashboard}),x.success("Grievance created")},onError:()=>x.error("Failed to create grievance")})}function fa(){const t=D();return q({mutationFn:({id:a,...s})=>y.patch(`${f}/grievances/${a}/`,s).then(o=>o.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.grievances}),t.invalidateQueries({queryKey:u.dashboard}),x.success("Grievance updated")},onError:()=>x.error("Failed to update grievance")})}function _a(){const t=D();return q({mutationFn:a=>y.delete(`${f}/grievances/${a}/`),onSuccess:()=>{t.invalidateQueries({queryKey:u.grievances}),t.invalidateQueries({queryKey:u.dashboard}),x.success("Grievance deleted")},onError:()=>x.error("Failed to delete grievance")})}function Na(){const t=D();return q({mutationFn:({id:a,remarks:s})=>y.post(`${f}/grievances/${a}/escalate/`,{remarks:s}).then(o=>o.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.grievances}),t.invalidateQueries({queryKey:u.dashboard}),x.success("Grievance escalated")},onError:()=>x.error("Failed to escalate grievance")})}function ba(){const t=D();return q({mutationFn:({id:a,resolution_summary:s})=>y.post(`${f}/grievances/${a}/resolve/`,{resolution_summary:s}).then(o=>o.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.grievances}),t.invalidateQueries({queryKey:u.dashboard}),x.success("Grievance resolved")},onError:()=>x.error("Failed to resolve grievance")})}function wa(){const t=D();return q({mutationFn:({id:a,reason:s})=>y.post(`${f}/grievances/${a}/reopen/`,{reason:s}).then(o=>o.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.grievances}),t.invalidateQueries({queryKey:u.dashboard}),x.success("Grievance reopened")},onError:()=>x.error("Failed to reopen grievance")})}function Et(t,a){return M({queryKey:[...u.notes(t),a],queryFn:()=>y.get(`${f}/notes/`,{params:{grievance:t,...a}}).then(s=>s.data),enabled:!!t})}function Rt(){const t=D();return q({mutationFn:({grievanceId:a,...s})=>y.post(`${f}/notes/`,{...s,grievance:a}).then(o=>o.data),onSuccess:(a,s)=>{t.invalidateQueries({queryKey:u.notes(s.grievanceId)}),x.success("Note added")},onError:()=>x.error("Failed to add note")})}function It(){const t=D();return q({mutationFn:({noteId:a})=>y.delete(`${f}/notes/${a}/`),onSuccess:(a,s)=>{t.invalidateQueries({queryKey:u.notes(s.grievanceId)}),x.success("Note deleted")},onError:()=>x.error("Failed to delete note")})}function Tt(t,a){return M({queryKey:[...u.documents(t),a],queryFn:()=>y.get(`${f}/documents/`,{params:{grievance:t,...a}}).then(s=>s.data),enabled:!!t})}function $t(){const t=D();return q({mutationFn:({grievanceId:a,...s})=>y.post(`${f}/documents/`,{...s,grievance:a}).then(o=>o.data),onSuccess:(a,s)=>{t.invalidateQueries({queryKey:u.documents(s.grievanceId)}),x.success("Document uploaded")},onError:()=>x.error("Failed to upload document")})}function Qt(){const t=D();return q({mutationFn:({documentId:a})=>y.delete(`${f}/documents/${a}/`),onSuccess:(a,s)=>{t.invalidateQueries({queryKey:u.documents(s.grievanceId)}),x.success("Document deleted")},onError:()=>x.error("Failed to delete document")})}function Fs(t){return M({queryKey:[...u.showCauses,t],queryFn:()=>y.get(`${f}/show-causes/`,{params:t}).then(a=>a.data)})}function Kt(t){return M({queryKey:u.showCause(t),queryFn:()=>y.get(`${f}/show-causes/${t}/`).then(a=>a.data),enabled:!!t})}function Sa(){const t=D();return q({mutationFn:a=>y.post(`${f}/show-causes/`,a).then(s=>s.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.showCauses}),t.invalidateQueries({queryKey:u.dashboard}),x.success("Show cause notice created")},onError:()=>x.error("Failed to create show cause notice")})}function Ca(){const t=D();return q({mutationFn:({id:a,...s})=>y.patch(`${f}/show-causes/${a}/`,s).then(o=>o.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.showCauses}),x.success("Show cause notice updated")},onError:()=>x.error("Failed to update show cause notice")})}function ka(){const t=D();return q({mutationFn:a=>y.delete(`${f}/show-causes/${a}/`),onSuccess:()=>{t.invalidateQueries({queryKey:u.showCauses}),t.invalidateQueries({queryKey:u.dashboard}),x.success("Show cause notice deleted")},onError:()=>x.error("Failed to delete show cause notice")})}function Da(){const t=D();return q({mutationFn:({id:a,employee_response:s})=>y.post(`${f}/show-causes/${a}/respond/`,{employee_response:s}).then(o=>o.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.showCauses}),t.invalidateQueries({queryKey:u.dashboard}),x.success("Response submitted")},onError:()=>x.error("Failed to submit response")})}function Os(t){return M({queryKey:[...u.disciplinaryCases,t],queryFn:()=>y.get(`${f}/disciplinary-cases/`,{params:t}).then(a=>a.data)})}function Ot(t){return M({queryKey:u.disciplinaryCase(t),queryFn:()=>y.get(`${f}/disciplinary-cases/${t}/`).then(a=>a.data),enabled:!!t})}function qa(){const t=D();return q({mutationFn:a=>y.post(`${f}/disciplinary-cases/`,a).then(s=>s.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.disciplinaryCases}),t.invalidateQueries({queryKey:u.dashboard}),x.success("Disciplinary case created")},onError:()=>x.error("Failed to create disciplinary case")})}function Fa(){const t=D();return q({mutationFn:({id:a,...s})=>y.patch(`${f}/disciplinary-cases/${a}/`,s).then(o=>o.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.disciplinaryCases}),x.success("Disciplinary case updated")},onError:()=>x.error("Failed to update disciplinary case")})}function Va(){const t=D();return q({mutationFn:a=>y.delete(`${f}/disciplinary-cases/${a}/`),onSuccess:()=>{t.invalidateQueries({queryKey:u.disciplinaryCases}),t.invalidateQueries({queryKey:u.dashboard}),x.success("Disciplinary case deleted")},onError:()=>x.error("Failed to delete disciplinary case")})}function Pa(){const t=D();return q({mutationFn:({id:a,hearing_date:s,hearing_notes:o})=>y.post(`${f}/disciplinary-cases/${a}/schedule_hearing/`,{hearing_date:s,hearing_notes:o}).then(m=>m.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.disciplinaryCases}),x.success("Hearing scheduled")},onError:()=>x.error("Failed to schedule hearing")})}function Aa(){const t=D();return q({mutationFn:({id:a,decision:s,decision_remarks:o,appeal_allowed:m,appeal_deadline:h})=>y.post(`${f}/disciplinary-cases/${a}/record_decision/`,{decision:s,decision_remarks:o,appeal_allowed:m,appeal_deadline:h}).then(k=>k.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.disciplinaryCases}),t.invalidateQueries({queryKey:u.dashboard}),x.success("Decision recorded")},onError:()=>x.error("Failed to record decision")})}function Ga(t){return M({queryKey:[...u.warningLetters,t],queryFn:()=>y.get(`${f}/warning-letters/`,{params:t}).then(a=>a.data)})}function Lt(t){return M({queryKey:u.warningLetter(t),queryFn:()=>y.get(`${f}/warning-letters/${t}/`).then(a=>a.data),enabled:!!t})}function Ea(){const t=D();return q({mutationFn:a=>y.post(`${f}/warning-letters/`,a).then(s=>s.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.warningLetters}),t.invalidateQueries({queryKey:u.dashboard}),x.success("Warning letter created")},onError:()=>x.error("Failed to create warning letter")})}function Ra(){const t=D();return q({mutationFn:({id:a,...s})=>y.patch(`${f}/warning-letters/${a}/`,s).then(o=>o.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.warningLetters}),x.success("Warning letter updated")},onError:()=>x.error("Failed to update warning letter")})}function Ia(){const t=D();return q({mutationFn:a=>y.delete(`${f}/warning-letters/${a}/`),onSuccess:()=>{t.invalidateQueries({queryKey:u.warningLetters}),t.invalidateQueries({queryKey:u.dashboard}),x.success("Warning letter deleted")},onError:()=>x.error("Failed to delete warning letter")})}function Ta(){const t=D();return q({mutationFn:a=>y.post(`${f}/warning-letters/${a}/acknowledge/`).then(s=>s.data),onSuccess:()=>{t.invalidateQueries({queryKey:u.warningLetters}),x.success("Warning acknowledged")},onError:()=>x.error("Failed to acknowledge warning")})}function $a(){return M({queryKey:u.dashboard,queryFn:()=>y.get(`${f}/dashboard/`).then(t=>t.data)})}function Wt(t){return M({queryKey:[...u.reports,t],queryFn:()=>y.get(`${f}/reports/`,{params:t}).then(a=>a.data)})}function Ut(t){return M({queryKey:[...u.analytics,t],queryFn:()=>y.get(`${f}/analytics/`,{params:t}).then(a=>a.data)})}const Qa={draft:"secondary",submitted:"default",under_review:"warning",investigating:"warning",resolved:"success",closed:"success",reopened:"destructive",escalated:"destructive"},Ka={issued:"default",response_received:"warning",under_review:"warning",closed:"success",escalated_to_inquiry:"destructive"};function Mt(){const t=Zs(),{data:a,isLoading:s}=$a();return e.jsxs("div",{children:[e.jsx(Ee,{title:"Grievance Dashboard",description:"Overview of grievances, disciplinary actions, and case resolutions across your organization.",actions:e.jsxs(b,{size:"sm",onClick:()=>t("/grievance/grievances"),children:[e.jsx(vs,{className:"mr-1.5 h-3.5 w-3.5"})," View Grievances"]})}),e.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[e.jsx(K,{children:e.jsx(O,{className:"pt-5 pb-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(vs,{className:"h-4.5 w-4.5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Open Grievances"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:s?"...":(a==null?void 0:a.open_grievances)??0})]})]})})}),e.jsx(K,{children:e.jsx(O,{className:"pt-5 pb-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-amber-500/10",children:e.jsx(Js,{className:"h-4.5 w-4.5 text-amber-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Under Investigation"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:s?"...":(a==null?void 0:a.under_investigation)??0})]})]})})}),e.jsx(K,{children:e.jsx(O,{className:"pt-5 pb-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-emerald-500/10",children:e.jsx(ta,{className:"h-4.5 w-4.5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Resolution Rate"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:s?"...":`${(a==null?void 0:a.resolution_rate)??0}%`})]})]})})}),e.jsx(K,{children:e.jsx(O,{className:"pt-5 pb-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-red-500/10",children:e.jsx(ea,{className:"h-4.5 w-4.5 text-red-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Avg Resolution Days"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:s?"...":(a==null?void 0:a.avg_resolution_days)??0})]})]})})})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[e.jsx(K,{children:e.jsx(O,{className:"pt-5 pb-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-violet-500/10",children:e.jsx(fs,{className:"h-4.5 w-4.5 text-violet-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Pending Show Causes"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:s?"...":(a==null?void 0:a.pending_show_causes)??0})]})]})})}),e.jsx(K,{children:e.jsx(O,{className:"pt-5 pb-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-orange-500/10",children:e.jsx($s,{className:"h-4.5 w-4.5 text-orange-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Active Cases"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:s?"...":(a==null?void 0:a.active_disciplinary_cases)??0})]})]})})}),e.jsx(K,{children:e.jsx(O,{className:"pt-5 pb-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-yellow-500/10",children:e.jsx(ys,{className:"h-4.5 w-4.5 text-yellow-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Active Warnings"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:s?"...":(a==null?void 0:a.active_warnings)??0})]})]})})}),e.jsx(K,{children:e.jsx(O,{className:"pt-5 pb-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-red-500/10",children:e.jsx(Qs,{className:"h-4.5 w-4.5 text-red-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Overdue Grievances"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:s?"...":(a==null?void 0:a.overdue_grievances)??0})]})]})})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs(K,{children:[e.jsx(Ne,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-[14px]",children:"Recent Grievances"}),e.jsxs(b,{variant:"ghost",size:"sm",className:"h-7 text-[12px] gap-1",onClick:()=>t("/grievance/grievances"),children:["View all ",e.jsx(Ps,{className:"h-3 w-3"})]})]})}),e.jsx(O,{children:s?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(o=>e.jsx("div",{className:"h-14 rounded-lg skeleton-shimmer"},o))}):((a==null?void 0:a.recent_grievances)??[]).length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(vs,{className:"h-8 w-8 text-slate-300 mb-2"}),e.jsx("p",{className:"text-[13px] text-slate-500",children:"No recent grievances"})]}):e.jsx("ul",{className:"space-y-2",children:((a==null?void 0:a.recent_grievances)??[]).slice(0,5).map(o=>e.jsxs("li",{className:"flex items-center justify-between rounded-lg border border-slate-100 px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-800 truncate",children:o.subject}),e.jsxs("p",{className:"text-[11px] text-slate-400 mt-0.5",children:[o.grievance_number," · ",o.employee_name??"Anonymous"]})]}),e.jsx(ge,{variant:Qa[o.status],className:"ml-2 text-[11px]",children:o.status.replace(/_/g," ")})]},o.id))})})]}),e.jsxs(K,{children:[e.jsx(Ne,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-[14px]",children:"Recent Show Cause Notices"}),e.jsxs(b,{variant:"ghost",size:"sm",className:"h-7 text-[12px] gap-1",onClick:()=>t("/grievance/show-causes"),children:["View all ",e.jsx(Ps,{className:"h-3 w-3"})]})]})}),e.jsx(O,{children:s?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(o=>e.jsx("div",{className:"h-14 rounded-lg skeleton-shimmer"},o))}):((a==null?void 0:a.recent_show_causes)??[]).length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(fs,{className:"h-8 w-8 text-slate-300 mb-2"}),e.jsx("p",{className:"text-[13px] text-slate-500",children:"No recent show cause notices"})]}):e.jsx("ul",{className:"space-y-2",children:((a==null?void 0:a.recent_show_causes)??[]).slice(0,5).map(o=>e.jsxs("li",{className:"flex items-center justify-between rounded-lg border border-slate-100 px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-800 truncate",children:o.subject}),e.jsxs("p",{className:"text-[11px] text-slate-400 mt-0.5",children:[o.notice_number," · ",o.employee_name]})]}),e.jsx(ge,{variant:Ka[o.status],className:"ml-2 text-[11px]",children:o.status.replace(/_/g," ")})]},o.id))})})]})]})]})}const Oa={draft:"secondary",submitted:"default",under_review:"warning",investigating:"warning",resolved:"success",closed:"success",reopened:"destructive",escalated:"destructive"},La={low:"secondary",medium:"default",high:"warning",critical:"destructive"},Wa=[{value:"low",label:"Low"},{value:"normal",label:"Normal"},{value:"high",label:"High"},{value:"urgent",label:"Urgent"}],As=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"critical",label:"Critical"}],Ua=Ds(Te({employee:w().min(1,"Employee is required"),company:w().min(1,"Company is required"),category:w().min(1,"Category is required"),subject:w().min(1,"Subject is required"),description:w().min(1,"Description is required"),is_anonymous:ve(),severity:Ge(["low","medium","high","critical"]),priority:Ge(["low","normal","high","urgent"]),status:Ge(["draft","submitted","under_review","investigating","resolved","closed","reopened","escalated"]),assigned_to:w().optional(),filed_date:We("Filed date is required"),target_resolution_date:ia(),is_confidential:ve()}),"filed_date","target_resolution_date");function zt(){const[t,a]=p.useState(!1),[s,o]=p.useState(null),[m,h]=p.useState(null),[k,S]=p.useState(""),[V,z]=p.useState(""),[P,I]=p.useState(null),[R,H]=p.useState(null),[T,B]=p.useState(null),[A,$]=p.useState(""),{hasPermission:Y,requirePermission:ce}=ke(),de=Y("grievance","grievance","create"),G=Y("grievance","grievance","update"),oe=Y("grievance","grievance","delete"),W=Y("grievance","grievance","approve"),{pagination:Z,setPagination:Q,sorting:ue,setSorting:ie,globalFilter:J,setGlobalFilter:ee,queryParams:me}=ms(),xe={...me,...k&&{status:k},...V&&{severity:V}},{data:j,isLoading:he}=qs(xe),pe=ya(),X=fa(),v=_a(),_=Na(),r=ba(),E=wa(),g=Re({resolver:Ie(Ua),defaultValues:{severity:"medium",priority:"normal",status:"draft",is_anonymous:!1,is_confidential:!1}}),[ye,l]=p.useState(""),{data:d}=hs({search:ye||void 0}),U=g.watch("company"),[$e,C]=p.useState(""),{data:Qe}=ks({search:$e||void 0,...U?{company:U}:{}});function _s(){ce("grievance","grievance","create")&&(o(null),g.reset({employee:"",company:"",category:"",subject:"",description:"",severity:"medium",priority:"normal",status:"draft",is_anonymous:!1,is_confidential:!1,filed_date:new Date().toISOString().split("T")[0]}),a(!0))}function Ke(n){ce("grievance","grievance","update")&&(o(n),g.reset({employee:n.employee,company:n.company,category:n.category,subject:n.subject,description:n.description,is_anonymous:n.is_anonymous,severity:n.severity,priority:n.priority,status:n.status,assigned_to:n.assigned_to??"",filed_date:n.filed_date,target_resolution_date:n.target_resolution_date??"",is_confidential:n.is_confidential}),a(!0))}function gs(n){const Se={...n,assigned_to:n.assigned_to||null,target_resolution_date:n.target_resolution_date||null,escalation_level:(s==null?void 0:s.escalation_level)??0,resolved_date:(s==null?void 0:s.resolved_date)??null,resolution_summary:(s==null?void 0:s.resolution_summary)??"",satisfaction_rating:(s==null?void 0:s.satisfaction_rating)??null,satisfaction_feedback:(s==null?void 0:s.satisfaction_feedback)??""};s?X.mutate({id:s.id,...Se},{onSuccess:()=>{a(!1),g.reset()}}):pe.mutate(Se,{onSuccess:()=>{a(!1),g.reset()}})}function Ns(n){S(n==="__all__"?"":n),Q(Se=>({...Se,pageIndex:0}))}function Oe(n){z(n==="__all__"?"":n),Q(Se=>({...Se,pageIndex:0}))}const js=[{key:"subject",header:"Grievance",render:n=>e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-900",children:n.subject}),e.jsxs("p",{className:"text-[12px] text-slate-400 mt-0.5",children:[n.grievance_number," · ",n.is_anonymous?"Anonymous":n.employee_name??"--"]})]})},{key:"category_name",header:"Category",className:"w-32",render:n=>e.jsx("span",{className:"text-[12px] text-slate-600",children:n.category_name??"--"})},{key:"severity",header:"Severity",className:"w-24",render:n=>e.jsx(ge,{variant:La[n.severity],className:"text-[11px] capitalize",children:n.severity})},{key:"priority",header:"Priority",className:"w-24",render:n=>e.jsx(ge,{variant:"outline",className:"text-[11px] capitalize",children:n.priority})},{key:"status",header:"Status",className:"w-32",render:n=>e.jsx(ge,{variant:Oa[n.status],className:"text-[11px]",children:n.status.replace(/_/g," ")})},{key:"filed_date",header:"Filed",className:"w-28",render:n=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(n.filed_date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"actions",header:"",className:"w-10",render:n=>e.jsxs(rs,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(b,{variant:"ghost",size:"icon-sm",children:[e.jsx(ps,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(ds,{align:"end",className:"w-44",children:[G&&e.jsx(L,{className:"gap-2 text-[13px]",onClick:()=>Ke(n),children:"Edit"}),W&&(n.status==="submitted"||n.status==="under_review"||n.status==="investigating")&&e.jsxs(L,{className:"gap-2 text-[13px]",onClick:()=>{I(n),$("")},children:[e.jsx(ua,{className:"h-3.5 w-3.5 text-slate-400"}),"Escalate"]}),W&&(n.status==="under_review"||n.status==="investigating")&&e.jsxs(L,{className:"gap-2 text-[13px]",onClick:()=>{H(n),$("")},children:[e.jsx(la,{className:"h-3.5 w-3.5 text-slate-400"}),"Resolve"]}),W&&(n.status==="resolved"||n.status==="closed")&&e.jsxs(L,{className:"gap-2 text-[13px]",onClick:()=>{B(n),$("")},children:[e.jsx(ra,{className:"h-3.5 w-3.5 text-slate-400"}),"Reopen"]}),oe&&e.jsxs(e.Fragment,{children:[e.jsx(os,{}),e.jsxs(L,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>h(n),children:[e.jsx(us,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(Ee,{title:"Grievances",description:"File and manage employee grievances and complaints.",actions:de&&e.jsxs(b,{size:"sm",onClick:_s,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," New Grievance"]})}),e.jsx(xs,{actions:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(se,{value:k,onValueChange:Ns,children:[e.jsx(ae,{className:"w-[140px] h-9",children:e.jsx(te,{placeholder:"All statuses"})}),e.jsxs(ne,{children:[e.jsx(N,{value:"__all__",children:"All Statuses"}),e.jsx(N,{value:"draft",children:"Draft"}),e.jsx(N,{value:"submitted",children:"Submitted"}),e.jsx(N,{value:"under_review",children:"Under Review"}),e.jsx(N,{value:"investigating",children:"Investigating"}),e.jsx(N,{value:"resolved",children:"Resolved"}),e.jsx(N,{value:"closed",children:"Closed"}),e.jsx(N,{value:"reopened",children:"Reopened"}),e.jsx(N,{value:"escalated",children:"Escalated"})]})]}),e.jsxs(se,{value:V,onValueChange:Oe,children:[e.jsx(ae,{className:"w-[140px] h-9",children:e.jsx(te,{placeholder:"All severities"})}),e.jsxs(ne,{children:[e.jsx(N,{value:"__all__",children:"All Severities"}),As.map(n=>e.jsx(N,{value:n.value,children:n.label},n.value))]})]})]}),columns:js,data:(j==null?void 0:j.results)??[],isLoading:he,rowKey:n=>n.id,searchKeys:["subject","grievance_number"],searchPlaceholder:"Search grievances...",emptyMessage:"No grievances found",emptyDescription:"Create your first grievance to get started.",totalCount:(j==null?void 0:j.count)??0,pagination:Z,onPaginationChange:Q,sorting:ue,onSortingChange:ie,globalFilter:J,onGlobalFilterChange:ee}),e.jsx(Me,{open:t,onOpenChange:a,children:e.jsxs(ze,{size:"lg",children:[e.jsxs(He,{children:[e.jsx(Be,{children:s?"Edit Grievance":"New Grievance"}),e.jsx(Ye,{children:s?"Update grievance details.":"File a new employee grievance."})]}),e.jsxs("form",{onSubmit:g.handleSubmit(gs),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Subject *"}),e.jsx(F,{className:"mt-1.5",...g.register("subject"),placeholder:"Brief description of the grievance"}),g.formState.errors.subject&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:g.formState.errors.subject.message})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Description *"}),e.jsx(le,{className:"mt-1.5",...g.register("description"),rows:4,placeholder:"Detailed description of the grievance..."}),g.formState.errors.description&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:g.formState.errors.description.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Employee ID *"}),e.jsx(we,{className:"mt-1.5",value:g.watch("employee")??"",onValueChange:n=>g.setValue("employee",n,{shouldValidate:!0}),placeholder:"Select employee"}),g.formState.errors.employee&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:g.formState.errors.employee.message})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Company *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(re,{value:g.watch("company")??null,onValueChange:n=>{g.setValue("company",n,{shouldValidate:!0}),g.setValue("category","",{shouldValidate:!0})},onSearch:l,options:((d==null?void 0:d.results)??[]).map(n=>({value:n.id,label:n.name,hint:n.code})),placeholder:"Select company",searchPlaceholder:"Search companies..."})}),g.formState.errors.company&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:g.formState.errors.company.message})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Category *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(re,{value:g.watch("category")??null,onValueChange:n=>g.setValue("category",n,{shouldValidate:!0}),onSearch:C,disabled:!U,selectedLabel:s==null?void 0:s.category_name,options:((Qe==null?void 0:Qe.results)??[]).map(n=>({value:n.id,label:n.name,hint:n.code})),placeholder:U?"Select category":"Select a company first",searchPlaceholder:"Search categories..."})}),g.formState.errors.category&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:g.formState.errors.category.message})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Filed Date *"}),e.jsx(F,{className:"mt-1.5",type:"date",...g.register("filed_date"),max:g.watch("target_resolution_date")||void 0})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Severity *"}),e.jsxs(se,{value:g.watch("severity"),onValueChange:n=>g.setValue("severity",n),children:[e.jsx(ae,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(te,{})}),e.jsx(ne,{children:As.map(n=>e.jsx(N,{value:n.value,children:n.label},n.value))})]})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Priority *"}),e.jsxs(se,{value:g.watch("priority"),onValueChange:n=>g.setValue("priority",n),children:[e.jsx(ae,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(te,{})}),e.jsx(ne,{children:Wa.map(n=>e.jsx(N,{value:n.value,children:n.label},n.value))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Assigned To"}),e.jsx(we,{className:"mt-1.5",value:g.watch("assigned_to")??"",onValueChange:n=>g.setValue("assigned_to",n,{shouldValidate:!0}),placeholder:"Select employee"})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Target Resolution Date"}),e.jsx(F,{className:"mt-1.5",type:"date",...g.register("target_resolution_date"),min:g.watch("filed_date")||void 0})]})]}),e.jsxs("div",{className:"flex items-center gap-6 pt-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{name:"is_anonymous",control:g.control,render:({field:n})=>e.jsx(je,{checked:n.value,onCheckedChange:n.onChange})}),e.jsx(c,{className:"text-[13px] text-slate-600",children:"Anonymous"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{name:"is_confidential",control:g.control,render:({field:n})=>e.jsx(je,{checked:n.value,onCheckedChange:n.onChange})}),e.jsx(c,{className:"text-[13px] text-slate-600",children:"Confidential"})]})]})]}),e.jsxs(Ze,{children:[e.jsx(b,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(b,{onClick:g.handleSubmit(gs),disabled:pe.isPending||X.isPending,children:pe.isPending||X.isPending?"Saving...":s?"Update":"Create"})]})]})}),e.jsx(De,{open:!!P,onOpenChange:n=>!n&&I(null),children:e.jsxs(qe,{children:[e.jsxs(Fe,{children:[e.jsx(Ve,{children:"Escalate Grievance"}),e.jsxs(Pe,{children:["Escalate ",e.jsx("span",{className:"font-medium text-slate-700",children:P==null?void 0:P.subject})," to the next level."]})]}),e.jsxs("div",{className:"py-4",children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Remarks"}),e.jsx(le,{className:"mt-1.5",rows:3,value:A,onChange:n=>$(n.target.value),placeholder:"Reason for escalation..."})]}),e.jsxs(Ae,{children:[e.jsx(b,{variant:"outline",onClick:()=>I(null),children:"Cancel"}),e.jsx(b,{disabled:_.isPending,onClick:()=>{P&&_.mutate({id:P.id,remarks:A}),I(null)},children:_.isPending?"Escalating...":"Escalate"})]})]})}),e.jsx(De,{open:!!R,onOpenChange:n=>!n&&H(null),children:e.jsxs(qe,{children:[e.jsxs(Fe,{children:[e.jsx(Ve,{children:"Resolve Grievance"}),e.jsxs(Pe,{children:["Mark ",e.jsx("span",{className:"font-medium text-slate-700",children:R==null?void 0:R.subject})," as resolved."]})]}),e.jsxs("div",{className:"py-4",children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Resolution Summary *"}),e.jsx(le,{className:"mt-1.5",rows:3,value:A,onChange:n=>$(n.target.value),placeholder:"Describe how the grievance was resolved..."})]}),e.jsxs(Ae,{children:[e.jsx(b,{variant:"outline",onClick:()=>H(null),children:"Cancel"}),e.jsx(b,{disabled:r.isPending||!A.trim(),onClick:()=>{R&&r.mutate({id:R.id,resolution_summary:A}),H(null)},children:r.isPending?"Resolving...":"Resolve"})]})]})}),e.jsx(De,{open:!!T,onOpenChange:n=>!n&&B(null),children:e.jsxs(qe,{children:[e.jsxs(Fe,{children:[e.jsx(Ve,{children:"Reopen Grievance"}),e.jsxs(Pe,{children:["Reopen ",e.jsx("span",{className:"font-medium text-slate-700",children:T==null?void 0:T.subject}),"."]})]}),e.jsxs("div",{className:"py-4",children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Reason *"}),e.jsx(le,{className:"mt-1.5",rows:3,value:A,onChange:n=>$(n.target.value),placeholder:"Reason for reopening..."})]}),e.jsxs(Ae,{children:[e.jsx(b,{variant:"outline",onClick:()=>B(null),children:"Cancel"}),e.jsx(b,{disabled:E.isPending||!A.trim(),onClick:()=>{T&&E.mutate({id:T.id,reason:A}),B(null)},children:E.isPending?"Reopening...":"Reopen"})]})]})}),e.jsx(Xe,{open:!!m,onOpenChange:n=>!n&&h(null),children:e.jsxs(Je,{children:[e.jsx(es,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(ss,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(as,{children:"Delete Grievance"}),e.jsxs(ts,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium text-slate-700",children:m==null?void 0:m.subject}),"? This action cannot be undone."]})]})]})}),e.jsxs(ns,{children:[e.jsx(is,{onClick:()=>h(null),children:"Cancel"}),e.jsx(ls,{variant:"destructive",onClick:()=>{m&&v.mutate(m.id),h(null)},children:"Delete"})]})]})})]})}const Ma={low:"secondary",medium:"default",high:"warning",critical:"destructive"},Gs=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"critical",label:"Critical"}],za=Te({company:w().min(1,"Company is required"),name:w().min(1,"Name is required"),code:w().min(1,"Code is required"),description:w().optional(),parent:w().optional(),severity_level:Ge(["low","medium","high","critical"]),default_assignee:w().optional(),sla_days:_e.number().int().positive().optional().or(na("")),is_active:ve()});function Ht(){const[t,a]=p.useState(!1),[s,o]=p.useState(null),[m,h]=p.useState(null),[k,S]=p.useState(""),{hasPermission:V,requirePermission:z}=ke(),P=V("grievance","grievance_category","create"),I=V("grievance","grievance_category","update"),R=V("grievance","grievance_category","delete"),{pagination:H,setPagination:T,sorting:B,setSorting:A,globalFilter:$,setGlobalFilter:Y,queryParams:ce}=ms(),de={...ce,...k&&{severity_level:k}},{data:G,isLoading:oe}=ks(de),W=ga(),Z=ja(),Q=va(),[ue,ie]=p.useState(""),{data:J}=hs({search:ue||void 0}),[ee,me]=p.useState(""),{data:xe}=ks({search:ee||void 0}),j=Re({resolver:Ie(za),defaultValues:{severity_level:"medium",is_active:!0}});function he(){z("grievance","grievance_category","create")&&(o(null),j.reset({company:"",name:"",code:"",description:"",severity_level:"medium",is_active:!0}),a(!0))}function pe(r){z("grievance","grievance_category","update")&&(o(r),j.reset({company:r.company,name:r.name,code:r.code,description:r.description,parent:r.parent??"",severity_level:r.severity_level,default_assignee:r.default_assignee??"",sla_days:r.sla_days??void 0,is_active:r.is_active}),a(!0))}function X(r){const E={...r,description:r.description??"",parent:r.parent||null,default_assignee:r.default_assignee||null,sla_days:r.sla_days?Number(r.sla_days):null};s?Z.mutate({id:s.id,...E},{onSuccess:()=>{a(!1),j.reset()}}):W.mutate(E,{onSuccess:()=>{a(!1),j.reset()}})}function v(r){S(r==="__all__"?"":r),T(E=>({...E,pageIndex:0}))}const _=[{key:"name",header:"Category",render:r=>e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-900",children:r.name}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:r.code})]})},{key:"parent_name",header:"Parent",className:"w-32",render:r=>e.jsx("span",{className:"text-[12px] text-slate-600",children:r.parent_name??"--"})},{key:"severity_level",header:"Severity",className:"w-24",render:r=>e.jsx(ge,{variant:Ma[r.severity_level],className:"text-[11px] capitalize",children:r.severity_level})},{key:"sla_days",header:"SLA",className:"w-20",render:r=>e.jsx("span",{className:"text-[12px] text-slate-600",children:r.sla_days?`${r.sla_days}d`:"--"})},{key:"is_active",header:"Active",className:"w-20",render:r=>e.jsx(Ks,{status:r.is_active?"active":"inactive"})},{key:"actions",header:"",className:"w-10",render:r=>e.jsxs(rs,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(b,{variant:"ghost",size:"icon-sm",children:[e.jsx(ps,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(ds,{align:"end",className:"w-44",children:[I&&e.jsx(L,{className:"gap-2 text-[13px]",onClick:()=>pe(r),children:"Edit"}),R&&e.jsxs(e.Fragment,{children:[e.jsx(os,{}),e.jsxs(L,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>h(r),children:[e.jsx(us,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(Ee,{title:"Grievance Categories",description:"Manage categories for classifying grievances.",actions:P&&e.jsxs(b,{size:"sm",onClick:he,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," New Category"]})}),e.jsx(xs,{actions:e.jsx("div",{className:"flex gap-2",children:e.jsxs(se,{value:k,onValueChange:v,children:[e.jsx(ae,{className:"w-[140px] h-9",children:e.jsx(te,{placeholder:"All severities"})}),e.jsxs(ne,{children:[e.jsx(N,{value:"__all__",children:"All Severities"}),Gs.map(r=>e.jsx(N,{value:r.value,children:r.label},r.value))]})]})}),columns:_,data:(G==null?void 0:G.results)??[],isLoading:oe,rowKey:r=>r.id,searchKeys:["name","code"],searchPlaceholder:"Search categories...",emptyMessage:"No categories found",emptyDescription:"Create your first grievance category to get started.",totalCount:(G==null?void 0:G.count)??0,pagination:H,onPaginationChange:T,sorting:B,onSortingChange:A,globalFilter:$,onGlobalFilterChange:Y}),e.jsx(Me,{open:t,onOpenChange:a,children:e.jsxs(ze,{children:[e.jsxs(He,{children:[e.jsx(Be,{children:s?"Edit Category":"New Category"}),e.jsx(Ye,{children:s?"Update category details.":"Create a new grievance category."})]}),e.jsxs("form",{onSubmit:j.handleSubmit(X),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Category Name *"}),e.jsx(F,{className:"mt-1.5",...j.register("name"),placeholder:"e.g. Workplace Harassment"}),j.formState.errors.name&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:j.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Code *"}),e.jsx(F,{className:"mt-1.5",...j.register("code"),placeholder:"e.g. GRV-HAR"}),j.formState.errors.code&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:j.formState.errors.code.message})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Company *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(re,{value:j.watch("company")??null,onValueChange:r=>j.setValue("company",r,{shouldValidate:!0}),onSearch:ie,options:((J==null?void 0:J.results)??[]).map(r=>({value:r.id,label:r.name,hint:r.code})),placeholder:"Select company",searchPlaceholder:"Search companies..."})}),j.formState.errors.company&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:j.formState.errors.company.message})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Description"}),e.jsx(le,{className:"mt-1.5",...j.register("description"),rows:3,placeholder:"Category description..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Severity Level *"}),e.jsxs(se,{value:j.watch("severity_level"),onValueChange:r=>j.setValue("severity_level",r),children:[e.jsx(ae,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(te,{})}),e.jsx(ne,{children:Gs.map(r=>e.jsx(N,{value:r.value,children:r.label},r.value))})]})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"SLA Days"}),e.jsx(F,{className:"mt-1.5",type:"number",...j.register("sla_days"),placeholder:"e.g. 14"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Parent Category"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(re,{value:j.watch("parent")||null,onValueChange:r=>j.setValue("parent",r,{shouldValidate:!0}),onSearch:me,selectedLabel:s==null?void 0:s.parent_name,options:((xe==null?void 0:xe.results)??[]).filter(r=>r.id!==(s==null?void 0:s.id)).map(r=>({value:r.id,label:r.name,hint:r.code})),placeholder:"Select parent (optional)",searchPlaceholder:"Search categories..."})})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Default Assignee"}),e.jsx(we,{className:"mt-1.5",value:j.watch("default_assignee")??"",onValueChange:r=>j.setValue("default_assignee",r,{shouldValidate:!0}),placeholder:"Select employee"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx(je,{checked:j.watch("is_active"),onCheckedChange:r=>j.setValue("is_active",r)}),e.jsx(c,{className:"text-[13px] text-slate-600",children:"Active"})]})]}),e.jsxs(Ze,{children:[e.jsx(b,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(b,{onClick:j.handleSubmit(X),disabled:W.isPending||Z.isPending,children:W.isPending||Z.isPending?"Saving...":s?"Update":"Create"})]})]})}),e.jsx(Xe,{open:!!m,onOpenChange:r=>!r&&h(null),children:e.jsxs(Je,{children:[e.jsx(es,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(ss,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(as,{children:"Delete Category"}),e.jsxs(ts,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium text-slate-700",children:m==null?void 0:m.name}),"? This action cannot be undone."]})]})]})}),e.jsxs(ns,{children:[e.jsx(is,{onClick:()=>h(null),children:"Cancel"}),e.jsx(ls,{variant:"destructive",onClick:()=>{m&&Q.mutate(m.id),h(null)},children:"Delete"})]})]})})]})}const Ha={issued:"default",response_received:"warning",under_review:"warning",closed:"success",escalated_to_inquiry:"destructive"},Ba=Ds(Te({employee:w().min(1,"Employee is required"),company:w().min(1,"Company is required"),grievance:w().optional(),subject:w().min(1,"Subject is required"),description:w().min(1,"Description is required"),allegations:w().min(1,"Allegations are required"),issued_by:w().min(1,"Issuer is required"),issued_date:We("Issued date is required"),response_due_date:We("Response due date is required")}),"issued_date","response_due_date");function Bt(){const[t,a]=p.useState(!1),[s,o]=p.useState(null),[m,h]=p.useState(null),[k,S]=p.useState(""),[V,z]=p.useState(null),[P,I]=p.useState(""),{hasPermission:R,requirePermission:H}=ke(),T=R("grievance","show_cause","create"),B=R("grievance","show_cause","update"),A=R("grievance","show_cause","delete"),{pagination:$,setPagination:Y,sorting:ce,setSorting:de,globalFilter:G,setGlobalFilter:oe,queryParams:W}=ms(),Z={...W,...k&&{status:k}},{data:Q,isLoading:ue}=Fs(Z),ie=Sa(),J=Ca(),ee=ka(),me=Da(),[xe,j]=p.useState(""),{data:he}=hs({search:xe||void 0}),[pe,X]=p.useState(""),{data:v}=qs({search:pe||void 0}),_=Re({resolver:Ie(Ba)});function r(){H("grievance","show_cause","create")&&(o(null),_.reset({employee:"",company:"",subject:"",description:"",allegations:"",issued_by:"",issued_date:new Date().toISOString().split("T")[0],response_due_date:""}),a(!0))}function E(d){H("grievance","show_cause","update")&&(o(d),_.reset({employee:d.employee,company:d.company,grievance:d.grievance??"",subject:d.subject,description:d.description,allegations:d.allegations,issued_by:d.issued_by,issued_date:d.issued_date,response_due_date:d.response_due_date}),a(!0))}function g(d){const U={...d,grievance:d.grievance||null,employee_response:(s==null?void 0:s.employee_response)??"",response_date:(s==null?void 0:s.response_date)??null,status:(s==null?void 0:s.status)??"issued",outcome:(s==null?void 0:s.outcome)??null,outcome_remarks:(s==null?void 0:s.outcome_remarks)??""};s?J.mutate({id:s.id,...U},{onSuccess:()=>{a(!1),_.reset()}}):ie.mutate(U,{onSuccess:()=>{a(!1),_.reset()}})}function ye(d){S(d==="__all__"?"":d),Y(U=>({...U,pageIndex:0}))}const l=[{key:"subject",header:"Show Cause Notice",render:d=>e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-900",children:d.subject}),e.jsxs("p",{className:"text-[12px] text-slate-400 mt-0.5",children:[d.notice_number," · ",d.employee_name??"--"]})]})},{key:"issued_by_name",header:"Issued By",className:"w-32",render:d=>e.jsx("span",{className:"text-[12px] text-slate-600",children:d.issued_by_name??"--"})},{key:"issued_date",header:"Issued",className:"w-28",render:d=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(d.issued_date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"response_due_date",header:"Response Due",className:"w-28",render:d=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(d.response_due_date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"status",header:"Status",className:"w-36",render:d=>e.jsx(ge,{variant:Ha[d.status],className:"text-[11px]",children:d.status.replace(/_/g," ")})},{key:"outcome",header:"Outcome",className:"w-28",render:d=>{var U;return e.jsx("span",{className:"text-[12px] text-slate-600 capitalize",children:((U=d.outcome)==null?void 0:U.replace(/_/g," "))??"--"})}},{key:"actions",header:"",className:"w-10",render:d=>e.jsxs(rs,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(b,{variant:"ghost",size:"icon-sm",children:[e.jsx(ps,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(ds,{align:"end",className:"w-44",children:[B&&e.jsx(L,{className:"gap-2 text-[13px]",onClick:()=>E(d),children:"Edit"}),B&&d.status==="issued"&&e.jsxs(L,{className:"gap-2 text-[13px]",onClick:()=>{z(d),I("")},children:[e.jsx(ca,{className:"h-3.5 w-3.5 text-slate-400"}),"Submit Response"]}),A&&e.jsxs(e.Fragment,{children:[e.jsx(os,{}),e.jsxs(L,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>h(d),children:[e.jsx(us,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(Ee,{title:"Show Cause Notices",description:"Issue and track show cause notices for disciplinary matters.",actions:T&&e.jsxs(b,{size:"sm",onClick:r,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," New Show Cause"]})}),e.jsx(xs,{actions:e.jsx("div",{className:"flex gap-2",children:e.jsxs(se,{value:k,onValueChange:ye,children:[e.jsx(ae,{className:"w-[160px] h-9",children:e.jsx(te,{placeholder:"All statuses"})}),e.jsxs(ne,{children:[e.jsx(N,{value:"__all__",children:"All Statuses"}),e.jsx(N,{value:"issued",children:"Issued"}),e.jsx(N,{value:"response_received",children:"Response Received"}),e.jsx(N,{value:"under_review",children:"Under Review"}),e.jsx(N,{value:"closed",children:"Closed"}),e.jsx(N,{value:"escalated_to_inquiry",children:"Escalated to Inquiry"})]})]})}),columns:l,data:(Q==null?void 0:Q.results)??[],isLoading:ue,rowKey:d=>d.id,searchKeys:["subject","notice_number","employee_name"],searchPlaceholder:"Search show causes...",emptyMessage:"No show cause notices found",emptyDescription:"Issue your first show cause notice to get started.",totalCount:(Q==null?void 0:Q.count)??0,pagination:$,onPaginationChange:Y,sorting:ce,onSortingChange:de,globalFilter:G,onGlobalFilterChange:oe}),e.jsx(Me,{open:t,onOpenChange:a,children:e.jsxs(ze,{size:"lg",children:[e.jsxs(He,{children:[e.jsx(Be,{children:s?"Edit Show Cause":"New Show Cause Notice"}),e.jsx(Ye,{children:s?"Update show cause notice details.":"Issue a new show cause notice."})]}),e.jsxs("form",{onSubmit:_.handleSubmit(g),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Subject *"}),e.jsx(F,{className:"mt-1.5",..._.register("subject"),placeholder:"Subject of the show cause notice"}),_.formState.errors.subject&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:_.formState.errors.subject.message})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Description *"}),e.jsx(le,{className:"mt-1.5",..._.register("description"),rows:3,placeholder:"Detailed description..."}),_.formState.errors.description&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:_.formState.errors.description.message})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Allegations *"}),e.jsx(le,{className:"mt-1.5",..._.register("allegations"),rows:3,placeholder:"Specific allegations against the employee..."}),_.formState.errors.allegations&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:_.formState.errors.allegations.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Employee *"}),e.jsx(we,{className:"mt-1.5",value:_.watch("employee")??"",onValueChange:d=>_.setValue("employee",d,{shouldValidate:!0}),placeholder:"Select employee"})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Company *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(re,{value:_.watch("company")??null,onValueChange:d=>_.setValue("company",d,{shouldValidate:!0}),onSearch:j,options:((he==null?void 0:he.results)??[]).map(d=>({value:d.id,label:d.name,hint:d.code})),placeholder:"Select company",searchPlaceholder:"Search companies..."})}),_.formState.errors.company&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:_.formState.errors.company.message})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Issued By *"}),e.jsx(we,{className:"mt-1.5",value:_.watch("issued_by")??"",onValueChange:d=>_.setValue("issued_by",d,{shouldValidate:!0}),placeholder:"Select employee"})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Related Grievance"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(re,{value:_.watch("grievance")||null,onValueChange:d=>_.setValue("grievance",d,{shouldValidate:!0}),onSearch:X,options:((v==null?void 0:v.results)??[]).map(d=>({value:d.id,label:d.grievance_number,hint:d.subject})),placeholder:"Select grievance (optional)",searchPlaceholder:"Search grievances..."})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Issued Date *"}),e.jsx(F,{className:"mt-1.5",type:"date",..._.register("issued_date"),max:_.watch("response_due_date")||void 0})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Response Due Date *"}),e.jsx(F,{className:"mt-1.5",type:"date",..._.register("response_due_date"),min:_.watch("issued_date")||void 0})]})]})]}),e.jsxs(Ze,{children:[e.jsx(b,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(b,{onClick:_.handleSubmit(g),disabled:ie.isPending||J.isPending,children:ie.isPending||J.isPending?"Saving...":s?"Update":"Create"})]})]})}),e.jsx(De,{open:!!V,onOpenChange:d=>!d&&z(null),children:e.jsxs(qe,{children:[e.jsxs(Fe,{children:[e.jsx(Ve,{children:"Submit Response"}),e.jsxs(Pe,{children:["Submit the employee response to ",e.jsx("span",{className:"font-medium text-slate-700",children:V==null?void 0:V.subject}),"."]})]}),e.jsxs("div",{className:"py-4",children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Employee Response *"}),e.jsx(le,{className:"mt-1.5",rows:4,value:P,onChange:d=>I(d.target.value),placeholder:"Employee's response to the show cause notice..."})]}),e.jsxs(Ae,{children:[e.jsx(b,{variant:"outline",onClick:()=>z(null),children:"Cancel"}),e.jsx(b,{disabled:me.isPending||!P.trim(),onClick:()=>{V&&me.mutate({id:V.id,employee_response:P}),z(null)},children:me.isPending?"Submitting...":"Submit Response"})]})]})}),e.jsx(Xe,{open:!!m,onOpenChange:d=>!d&&h(null),children:e.jsxs(Je,{children:[e.jsx(es,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(ss,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(as,{children:"Delete Show Cause"}),e.jsxs(ts,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium text-slate-700",children:m==null?void 0:m.subject}),"? This action cannot be undone."]})]})]})}),e.jsxs(ns,{children:[e.jsx(is,{onClick:()=>h(null),children:"Cancel"}),e.jsx(ls,{variant:"destructive",onClick:()=>{m&&ee.mutate(m.id),h(null)},children:"Delete"})]})]})})]})}const Ya={initiated:"default",investigation:"warning",hearing_scheduled:"warning",hearing_completed:"default",decision_pending:"secondary",closed:"success"},Es=[{value:"misconduct",label:"Misconduct"},{value:"gross_misconduct",label:"Gross Misconduct"},{value:"policy_violation",label:"Policy Violation"},{value:"performance",label:"Performance"},{value:"harassment",label:"Harassment"},{value:"fraud",label:"Fraud"},{value:"insubordination",label:"Insubordination"},{value:"other",label:"Other"}],Za=[{value:"exonerated",label:"Exonerated"},{value:"warning",label:"Warning"},{value:"final_warning",label:"Final Warning"},{value:"suspension",label:"Suspension"},{value:"demotion",label:"Demotion"},{value:"termination",label:"Termination"},{value:"other",label:"Other"}],Xa=Te({employee:w().min(1,"Employee is required"),company:w().min(1,"Company is required"),grievance:w().optional(),show_cause:w().optional(),case_type:Ge(["misconduct","gross_misconduct","policy_violation","performance","harassment","fraud","insubordination","other"]),subject:w().min(1,"Subject is required"),description:w().min(1,"Description is required"),initiated_by:w().min(1,"Initiator is required"),initiated_date:We("Date is required")});function Yt(){const[t,a]=p.useState(!1),[s,o]=p.useState(null),[m,h]=p.useState(null),[k,S]=p.useState(""),[V,z]=p.useState(""),[P,I]=p.useState(null),[R,H]=p.useState(""),[T,B]=p.useState(""),[A,$]=p.useState(null),[Y,ce]=p.useState("warning"),[de,G]=p.useState(""),[oe,W]=p.useState(!0),[Z,Q]=p.useState(""),{hasPermission:ue,requirePermission:ie}=ke(),J=ue("grievance","disciplinary_case","create"),ee=ue("grievance","disciplinary_case","update"),me=ue("grievance","disciplinary_case","delete"),{pagination:xe,setPagination:j,sorting:he,setSorting:pe,globalFilter:X,setGlobalFilter:v,queryParams:_}=ms(),r={..._,...k&&{status:k},...V&&{case_type:V}},{data:E,isLoading:g}=Os(r),ye=qa(),l=Fa(),d=Va(),U=Pa(),$e=Aa(),C=Re({resolver:Ie(Xa),defaultValues:{case_type:"misconduct"}}),[Qe,_s]=p.useState(""),{data:Ke}=hs({search:Qe||void 0}),[gs,Ns]=p.useState(""),{data:Oe}=qs({search:gs||void 0}),js=C.watch("grievance"),[n,Se]=p.useState(""),{data:bs}=Fs({search:n||void 0,...js?{grievance:js}:{}});function Ls(){ie("grievance","disciplinary_case","create")&&(o(null),C.reset({employee:"",company:"",subject:"",description:"",case_type:"misconduct",initiated_by:"",initiated_date:new Date().toISOString().split("T")[0]}),a(!0))}function Ws(i){ie("grievance","disciplinary_case","update")&&(o(i),C.reset({employee:i.employee,company:i.company,grievance:i.grievance??"",show_cause:i.show_cause??"",case_type:i.case_type,subject:i.subject,description:i.description,initiated_by:i.initiated_by,initiated_date:i.initiated_date}),a(!0))}function Vs(i){const fe={...i,grievance:i.grievance||null,show_cause:i.show_cause||null,committee_members:(s==null?void 0:s.committee_members)??[],hearing_date:(s==null?void 0:s.hearing_date)??null,hearing_notes:(s==null?void 0:s.hearing_notes)??"",findings:(s==null?void 0:s.findings)??"",status:(s==null?void 0:s.status)??"initiated",decision:(s==null?void 0:s.decision)??null,decision_date:(s==null?void 0:s.decision_date)??null,decision_remarks:(s==null?void 0:s.decision_remarks)??"",appeal_allowed:(s==null?void 0:s.appeal_allowed)??!0,appeal_deadline:(s==null?void 0:s.appeal_deadline)??null};s?l.mutate({id:s.id,...fe},{onSuccess:()=>{a(!1),C.reset()}}):ye.mutate(fe,{onSuccess:()=>{a(!1),C.reset()}})}function Us(i){S(i==="__all__"?"":i),j(fe=>({...fe,pageIndex:0}))}function Ms(i){z(i==="__all__"?"":i),j(fe=>({...fe,pageIndex:0}))}const zs=[{key:"subject",header:"Case",render:i=>e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-900",children:i.subject}),e.jsxs("p",{className:"text-[12px] text-slate-400 mt-0.5",children:[i.case_number," · ",i.employee_name??"--"]})]})},{key:"case_type",header:"Type",className:"w-32",render:i=>e.jsx(ge,{variant:"outline",className:"text-[11px] capitalize",children:i.case_type.replace(/_/g," ")})},{key:"status",header:"Status",className:"w-36",render:i=>e.jsx(ge,{variant:Ya[i.status],className:"text-[11px]",children:i.status.replace(/_/g," ")})},{key:"initiated_date",header:"Initiated",className:"w-28",render:i=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(i.initiated_date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"hearing_date",header:"Hearing",className:"w-28",render:i=>e.jsx("span",{className:"text-[12px] text-slate-400",children:i.hearing_date?new Date(i.hearing_date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):"--"})},{key:"decision",header:"Decision",className:"w-28",render:i=>{var fe;return e.jsx("span",{className:"text-[12px] text-slate-600 capitalize",children:((fe=i.decision)==null?void 0:fe.replace(/_/g," "))??"--"})}},{key:"actions",header:"",className:"w-10",render:i=>e.jsxs(rs,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(b,{variant:"ghost",size:"icon-sm",children:[e.jsx(ps,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(ds,{align:"end",className:"w-48",children:[ee&&e.jsx(L,{className:"gap-2 text-[13px]",onClick:()=>Ws(i),children:"Edit"}),ee&&(i.status==="initiated"||i.status==="investigation")&&e.jsxs(L,{className:"gap-2 text-[13px]",onClick:()=>{I(i),H(""),B("")},children:[e.jsx(da,{className:"h-3.5 w-3.5 text-slate-400"}),"Schedule Hearing"]}),ee&&(i.status==="hearing_completed"||i.status==="decision_pending")&&e.jsxs(L,{className:"gap-2 text-[13px]",onClick:()=>{$(i),ce("warning"),G(""),W(!0),Q("")},children:[e.jsx(Ts,{className:"h-3.5 w-3.5 text-slate-400"}),"Record Decision"]}),me&&e.jsxs(e.Fragment,{children:[e.jsx(os,{}),e.jsxs(L,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>h(i),children:[e.jsx(us,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(Ee,{title:"Disciplinary Cases",description:"Manage disciplinary investigations, hearings, and decisions.",actions:J&&e.jsxs(b,{size:"sm",onClick:Ls,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," New Case"]})}),e.jsx(xs,{actions:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(se,{value:k,onValueChange:Us,children:[e.jsx(ae,{className:"w-[160px] h-9",children:e.jsx(te,{placeholder:"All statuses"})}),e.jsxs(ne,{children:[e.jsx(N,{value:"__all__",children:"All Statuses"}),e.jsx(N,{value:"initiated",children:"Initiated"}),e.jsx(N,{value:"investigation",children:"Investigation"}),e.jsx(N,{value:"hearing_scheduled",children:"Hearing Scheduled"}),e.jsx(N,{value:"hearing_completed",children:"Hearing Completed"}),e.jsx(N,{value:"decision_pending",children:"Decision Pending"}),e.jsx(N,{value:"closed",children:"Closed"})]})]}),e.jsxs(se,{value:V,onValueChange:Ms,children:[e.jsx(ae,{className:"w-[160px] h-9",children:e.jsx(te,{placeholder:"All types"})}),e.jsxs(ne,{children:[e.jsx(N,{value:"__all__",children:"All Types"}),Es.map(i=>e.jsx(N,{value:i.value,children:i.label},i.value))]})]})]}),columns:zs,data:(E==null?void 0:E.results)??[],isLoading:g,rowKey:i=>i.id,searchKeys:["subject","case_number","employee_name"],searchPlaceholder:"Search cases...",emptyMessage:"No disciplinary cases found",emptyDescription:"Create your first disciplinary case to get started.",totalCount:(E==null?void 0:E.count)??0,pagination:xe,onPaginationChange:j,sorting:he,onSortingChange:pe,globalFilter:X,onGlobalFilterChange:v}),e.jsx(Me,{open:t,onOpenChange:a,children:e.jsxs(ze,{size:"lg",children:[e.jsxs(He,{children:[e.jsx(Be,{children:s?"Edit Case":"New Disciplinary Case"}),e.jsx(Ye,{children:s?"Update case details.":"Create a new disciplinary case."})]}),e.jsxs("form",{onSubmit:C.handleSubmit(Vs),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Subject *"}),e.jsx(F,{className:"mt-1.5",...C.register("subject"),placeholder:"Brief description of the case"}),C.formState.errors.subject&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:C.formState.errors.subject.message})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Description *"}),e.jsx(le,{className:"mt-1.5",...C.register("description"),rows:4,placeholder:"Detailed description of the case..."}),C.formState.errors.description&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:C.formState.errors.description.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Employee *"}),e.jsx(we,{className:"mt-1.5",value:C.watch("employee")??"",onValueChange:i=>C.setValue("employee",i,{shouldValidate:!0}),placeholder:"Select employee"})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Company *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(re,{value:C.watch("company")??null,onValueChange:i=>C.setValue("company",i,{shouldValidate:!0}),onSearch:_s,options:((Ke==null?void 0:Ke.results)??[]).map(i=>({value:i.id,label:i.name,hint:i.code})),placeholder:"Select company",searchPlaceholder:"Search companies..."})}),C.formState.errors.company&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:C.formState.errors.company.message})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Case Type *"}),e.jsxs(se,{value:C.watch("case_type"),onValueChange:i=>C.setValue("case_type",i),children:[e.jsx(ae,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(te,{})}),e.jsx(ne,{children:Es.map(i=>e.jsx(N,{value:i.value,children:i.label},i.value))})]})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Initiated Date *"}),e.jsx(F,{className:"mt-1.5",type:"date",...C.register("initiated_date")})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Initiated By *"}),e.jsx(we,{className:"mt-1.5",value:C.watch("initiated_by")??"",onValueChange:i=>C.setValue("initiated_by",i,{shouldValidate:!0}),placeholder:"Select employee"})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Related Grievance"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(re,{value:C.watch("grievance")||null,onValueChange:i=>{C.setValue("grievance",i,{shouldValidate:!0}),C.setValue("show_cause","",{shouldValidate:!0})},onSearch:Ns,options:((Oe==null?void 0:Oe.results)??[]).map(i=>({value:i.id,label:i.grievance_number,hint:i.subject})),placeholder:"Select grievance (optional)",searchPlaceholder:"Search grievances..."})})]})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Related Show Cause"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(re,{value:C.watch("show_cause")||null,onValueChange:i=>C.setValue("show_cause",i,{shouldValidate:!0}),onSearch:Se,options:((bs==null?void 0:bs.results)??[]).map(i=>({value:i.id,label:i.notice_number,hint:i.subject})),placeholder:"Select show cause (optional)",searchPlaceholder:"Search show causes..."})})]})]}),e.jsxs(Ze,{children:[e.jsx(b,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(b,{onClick:C.handleSubmit(Vs),disabled:ye.isPending||l.isPending,children:ye.isPending||l.isPending?"Saving...":s?"Update":"Create"})]})]})}),e.jsx(De,{open:!!P,onOpenChange:i=>!i&&I(null),children:e.jsxs(qe,{children:[e.jsxs(Fe,{children:[e.jsx(Ve,{children:"Schedule Hearing"}),e.jsxs(Pe,{children:["Schedule a hearing for ",e.jsx("span",{className:"font-medium text-slate-700",children:P==null?void 0:P.subject}),"."]})]}),e.jsxs("div",{className:"py-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Hearing Date *"}),e.jsx(F,{className:"mt-1.5",type:"date",value:R,onChange:i=>H(i.target.value)})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Notes"}),e.jsx(le,{className:"mt-1.5",rows:3,value:T,onChange:i=>B(i.target.value),placeholder:"Hearing notes and instructions..."})]})]}),e.jsxs(Ae,{children:[e.jsx(b,{variant:"outline",onClick:()=>I(null),children:"Cancel"}),e.jsx(b,{disabled:U.isPending||!R,onClick:()=>{P&&U.mutate({id:P.id,hearing_date:R,hearing_notes:T}),I(null)},children:U.isPending?"Scheduling...":"Schedule"})]})]})}),e.jsx(De,{open:!!A,onOpenChange:i=>!i&&$(null),children:e.jsxs(qe,{children:[e.jsxs(Fe,{children:[e.jsx(Ve,{children:"Record Decision"}),e.jsxs(Pe,{children:["Record the decision for ",e.jsx("span",{className:"font-medium text-slate-700",children:A==null?void 0:A.subject}),"."]})]}),e.jsxs("div",{className:"py-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Decision *"}),e.jsxs(se,{value:Y,onValueChange:i=>ce(i),children:[e.jsx(ae,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(te,{})}),e.jsx(ne,{children:Za.map(i=>e.jsx(N,{value:i.value,children:i.label},i.value))})]})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Remarks *"}),e.jsx(le,{className:"mt-1.5",rows:3,value:de,onChange:i=>G(i.target.value),placeholder:"Decision remarks and reasoning..."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{checked:oe,onCheckedChange:W}),e.jsx(c,{className:"text-[13px] text-slate-600",children:"Allow Appeal"})]}),oe&&e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Appeal Deadline"}),e.jsx(F,{className:"mt-1.5",type:"date",value:Z,onChange:i=>Q(i.target.value)})]})]}),e.jsxs(Ae,{children:[e.jsx(b,{variant:"outline",onClick:()=>$(null),children:"Cancel"}),e.jsx(b,{disabled:$e.isPending||!de.trim(),onClick:()=>{A&&$e.mutate({id:A.id,decision:Y,decision_remarks:de,appeal_allowed:oe,appeal_deadline:Z||void 0}),$(null)},children:$e.isPending?"Recording...":"Record Decision"})]})]})}),e.jsx(Xe,{open:!!m,onOpenChange:i=>!i&&h(null),children:e.jsxs(Je,{children:[e.jsx(es,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(ss,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(as,{children:"Delete Disciplinary Case"}),e.jsxs(ts,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium text-slate-700",children:m==null?void 0:m.subject}),"? This action cannot be undone."]})]})]})}),e.jsxs(ns,{children:[e.jsx(is,{onClick:()=>h(null),children:"Cancel"}),e.jsx(ls,{variant:"destructive",onClick:()=>{m&&d.mutate(m.id),h(null)},children:"Delete"})]})]})})]})}const Ja={verbal:"secondary",written:"warning",final:"destructive"},Rs=[{value:"verbal",label:"Verbal"},{value:"written",label:"Written"},{value:"final",label:"Final"}],et=Ds(Te({employee:w().min(1,"Employee is required"),company:w().min(1,"Company is required"),disciplinary_case:w().optional(),show_cause:w().optional(),warning_type:Ge(["verbal","written","final"]),subject:w().min(1,"Subject is required"),description:w().min(1,"Description is required"),issued_by:w().min(1,"Issuer is required"),issued_date:We("Issued date is required"),valid_until:w().optional(),is_active:ve()}),"issued_date","valid_until");function Zt(){const[t,a]=p.useState(!1),[s,o]=p.useState(null),[m,h]=p.useState(null),[k,S]=p.useState(""),{hasPermission:V,requirePermission:z}=ke(),P=V("grievance","warning_letter","create"),I=V("grievance","warning_letter","update"),R=V("grievance","warning_letter","delete"),{pagination:H,setPagination:T,sorting:B,setSorting:A,globalFilter:$,setGlobalFilter:Y,queryParams:ce}=ms(),de={...ce,...k&&{warning_type:k}},{data:G,isLoading:oe}=Ga(de),W=Ea(),Z=Ra(),Q=Ia(),ue=Ta(),[ie,J]=p.useState(""),{data:ee}=hs({search:ie||void 0}),[me,xe]=p.useState(""),{data:j}=Os({search:me||void 0}),[he,pe]=p.useState(""),{data:X}=Fs({search:he||void 0}),v=Re({resolver:Ie(et),defaultValues:{warning_type:"written",is_active:!0}});function _(){z("grievance","warning_letter","create")&&(o(null),v.reset({employee:"",company:"",subject:"",description:"",warning_type:"written",issued_by:"",issued_date:new Date().toISOString().split("T")[0],is_active:!0}),a(!0))}function r(l){z("grievance","warning_letter","update")&&(o(l),v.reset({employee:l.employee,company:l.company,disciplinary_case:l.disciplinary_case??"",show_cause:l.show_cause??"",warning_type:l.warning_type,subject:l.subject,description:l.description,issued_by:l.issued_by,issued_date:l.issued_date,valid_until:l.valid_until??"",is_active:l.is_active}),a(!0))}function E(l){const d={...l,disciplinary_case:l.disciplinary_case||null,show_cause:l.show_cause||null,valid_until:l.valid_until||null,employee_acknowledged:(s==null?void 0:s.employee_acknowledged)??!1,acknowledged_at:(s==null?void 0:s.acknowledged_at)??null};s?Z.mutate({id:s.id,...d},{onSuccess:()=>{a(!1),v.reset()}}):W.mutate(d,{onSuccess:()=>{a(!1),v.reset()}})}function g(l){S(l==="__all__"?"":l),T(d=>({...d,pageIndex:0}))}const ye=[{key:"subject",header:"Warning Letter",render:l=>e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-900",children:l.subject}),e.jsxs("p",{className:"text-[12px] text-slate-400 mt-0.5",children:[l.letter_number," · ",l.employee_name??"--"]})]})},{key:"warning_type",header:"Type",className:"w-24",render:l=>e.jsx(ge,{variant:Ja[l.warning_type],className:"text-[11px] capitalize",children:l.warning_type})},{key:"issued_by_name",header:"Issued By",className:"w-32",render:l=>e.jsx("span",{className:"text-[12px] text-slate-600",children:l.issued_by_name??"--"})},{key:"issued_date",header:"Issued",className:"w-28",render:l=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(l.issued_date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"valid_until",header:"Valid Until",className:"w-28",render:l=>e.jsx("span",{className:"text-[12px] text-slate-400",children:l.valid_until?new Date(l.valid_until).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):"--"})},{key:"employee_acknowledged",header:"Acknowledged",className:"w-28",render:l=>e.jsx(ge,{variant:l.employee_acknowledged?"success":"secondary",className:"text-[11px]",children:l.employee_acknowledged?"Yes":"No"})},{key:"is_active",header:"Active",className:"w-20",render:l=>e.jsx(Ks,{status:l.is_active?"active":"inactive"})},{key:"actions",header:"",className:"w-10",render:l=>e.jsxs(rs,{children:[e.jsx(cs,{asChild:!0,children:e.jsxs(b,{variant:"ghost",size:"icon-sm",children:[e.jsx(ps,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(ds,{align:"end",className:"w-44",children:[I&&e.jsx(L,{className:"gap-2 text-[13px]",onClick:()=>r(l),children:"Edit"}),I&&!l.employee_acknowledged&&e.jsxs(L,{className:"gap-2 text-[13px]",onClick:()=>ue.mutate(l.id),children:[e.jsx(oa,{className:"h-3.5 w-3.5 text-slate-400"}),"Acknowledge"]}),R&&e.jsxs(e.Fragment,{children:[e.jsx(os,{}),e.jsxs(L,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>h(l),children:[e.jsx(us,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(Ee,{title:"Warning Letters",description:"Issue and track verbal, written, and final warning letters.",actions:P&&e.jsxs(b,{size:"sm",onClick:_,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," New Warning"]})}),e.jsx(xs,{actions:e.jsx("div",{className:"flex gap-2",children:e.jsxs(se,{value:k,onValueChange:g,children:[e.jsx(ae,{className:"w-[140px] h-9",children:e.jsx(te,{placeholder:"All types"})}),e.jsxs(ne,{children:[e.jsx(N,{value:"__all__",children:"All Types"}),Rs.map(l=>e.jsx(N,{value:l.value,children:l.label},l.value))]})]})}),columns:ye,data:(G==null?void 0:G.results)??[],isLoading:oe,rowKey:l=>l.id,searchKeys:["subject","letter_number","employee_name"],searchPlaceholder:"Search warnings...",emptyMessage:"No warning letters found",emptyDescription:"Issue your first warning letter to get started.",totalCount:(G==null?void 0:G.count)??0,pagination:H,onPaginationChange:T,sorting:B,onSortingChange:A,globalFilter:$,onGlobalFilterChange:Y}),e.jsx(Me,{open:t,onOpenChange:a,children:e.jsxs(ze,{size:"lg",children:[e.jsxs(He,{children:[e.jsx(Be,{children:s?"Edit Warning":"New Warning Letter"}),e.jsx(Ye,{children:s?"Update warning letter details.":"Issue a new warning letter."})]}),e.jsxs("form",{onSubmit:v.handleSubmit(E),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Subject *"}),e.jsx(F,{className:"mt-1.5",...v.register("subject"),placeholder:"Subject of the warning"}),v.formState.errors.subject&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:v.formState.errors.subject.message})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Description *"}),e.jsx(le,{className:"mt-1.5",...v.register("description"),rows:4,placeholder:"Detailed description of the warning..."}),v.formState.errors.description&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:v.formState.errors.description.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Employee *"}),e.jsx(we,{className:"mt-1.5",value:v.watch("employee")??"",onValueChange:l=>v.setValue("employee",l,{shouldValidate:!0}),placeholder:"Select employee"})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Company *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(re,{value:v.watch("company")??null,onValueChange:l=>v.setValue("company",l,{shouldValidate:!0}),onSearch:J,options:((ee==null?void 0:ee.results)??[]).map(l=>({value:l.id,label:l.name,hint:l.code})),placeholder:"Select company",searchPlaceholder:"Search companies..."})}),v.formState.errors.company&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:v.formState.errors.company.message})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Warning Type *"}),e.jsxs(se,{value:v.watch("warning_type"),onValueChange:l=>v.setValue("warning_type",l),children:[e.jsx(ae,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(te,{})}),e.jsx(ne,{children:Rs.map(l=>e.jsx(N,{value:l.value,children:l.label},l.value))})]})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Issued By *"}),e.jsx(we,{className:"mt-1.5",value:v.watch("issued_by")??"",onValueChange:l=>v.setValue("issued_by",l,{shouldValidate:!0}),placeholder:"Select employee"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Issued Date *"}),e.jsx(F,{className:"mt-1.5",type:"date",...v.register("issued_date"),max:v.watch("valid_until")||void 0})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Valid Until"}),e.jsx(F,{className:"mt-1.5",type:"date",...v.register("valid_until"),min:v.watch("issued_date")||void 0})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Related Disciplinary Case"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(re,{value:v.watch("disciplinary_case")||null,onValueChange:l=>v.setValue("disciplinary_case",l,{shouldValidate:!0}),onSearch:xe,options:((j==null?void 0:j.results)??[]).map(l=>({value:l.id,label:l.case_number,hint:l.subject})),placeholder:"Select case (optional)",searchPlaceholder:"Search cases..."})})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-[12px] font-medium text-slate-500",children:"Related Show Cause"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(re,{value:v.watch("show_cause")||null,onValueChange:l=>v.setValue("show_cause",l,{shouldValidate:!0}),onSearch:pe,options:((X==null?void 0:X.results)??[]).map(l=>({value:l.id,label:l.notice_number,hint:l.subject})),placeholder:"Select show cause (optional)",searchPlaceholder:"Search show causes..."})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx("input",{type:"checkbox",className:"rounded border-slate-300",checked:v.watch("is_active"),onChange:l=>v.setValue("is_active",l.target.checked)}),e.jsx(c,{className:"text-[13px] text-slate-600",children:"Active"})]})]}),e.jsxs(Ze,{children:[e.jsx(b,{type:"button",variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(b,{onClick:v.handleSubmit(E),disabled:W.isPending||Z.isPending,children:W.isPending||Z.isPending?"Saving...":s?"Update":"Create"})]})]})}),e.jsx(Xe,{open:!!m,onOpenChange:l=>!l&&h(null),children:e.jsxs(Je,{children:[e.jsx(es,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(ss,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(as,{children:"Delete Warning Letter"}),e.jsxs(ts,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium text-slate-700",children:m==null?void 0:m.subject}),"? This action cannot be undone."]})]})]})}),e.jsxs(ns,{children:[e.jsx(is,{onClick:()=>h(null),children:"Cancel"}),e.jsx(ls,{variant:"destructive",onClick:()=>{m&&Q.mutate(m.id),h(null)},children:"Delete"})]})]})})]})}const st=Te({anonymous_allowed:ve(),auto_assign_committee:ve(),resolution_sla_days:_e.number().int().min(1),escalation_enabled:ve(),escalation_after_days:_e.number().int().min(1),max_escalation_levels:_e.number().int().min(1),allow_reopen:ve(),reopen_window_days:_e.number().int().min(1),satisfaction_survey_enabled:ve(),progressive_discipline_enabled:ve(),show_cause_response_days:_e.number().int().min(1),warning_validity_months:_e.number().int().min(1),max_warnings_before_termination:_e.number().int().min(1),inquiry_committee_min_members:_e.number().int().min(1)});function Xt(){const{hasPermission:t}=ke(),a=t("grievance","settings","update"),{data:s,isLoading:o}=ha(),m=pa(),h=Re({resolver:Ie(st),defaultValues:{anonymous_allowed:!0,auto_assign_committee:!1,resolution_sla_days:14,escalation_enabled:!0,escalation_after_days:7,max_escalation_levels:3,allow_reopen:!0,reopen_window_days:30,satisfaction_survey_enabled:!0,progressive_discipline_enabled:!0,show_cause_response_days:7,warning_validity_months:12,max_warnings_before_termination:3,inquiry_committee_min_members:3}});p.useEffect(()=>{s&&h.reset({anonymous_allowed:s.anonymous_allowed,auto_assign_committee:s.auto_assign_committee,resolution_sla_days:s.resolution_sla_days,escalation_enabled:s.escalation_enabled,escalation_after_days:s.escalation_after_days,max_escalation_levels:s.max_escalation_levels,allow_reopen:s.allow_reopen,reopen_window_days:s.reopen_window_days,satisfaction_survey_enabled:s.satisfaction_survey_enabled,progressive_discipline_enabled:s.progressive_discipline_enabled,show_cause_response_days:s.show_cause_response_days,warning_validity_months:s.warning_validity_months,max_warnings_before_termination:s.max_warnings_before_termination,inquiry_committee_min_members:s.inquiry_committee_min_members})},[s,h]);function k(S){m.mutate({company:(s==null?void 0:s.company)??"",...S})}return o?e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsxs("h2",{className:"text-[16px] font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(ws,{className:"h-5 w-5 text-primary"})," Grievance Settings"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Configure grievance & disciplinary module settings"})]})}),e.jsx("div",{className:"space-y-4",children:[1,2,3,4,5].map(S=>e.jsx("div",{className:"h-32 rounded-lg skeleton-shimmer"},S))})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-[16px] font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(ws,{className:"h-5 w-5 text-primary"})," Grievance Settings"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Configure grievance & disciplinary module settings"})]}),a&&e.jsx(b,{size:"sm",disabled:!h.formState.isDirty||m.isPending,onClick:h.handleSubmit(k),children:m.isPending?"Saving...":"Save Changes"})]}),e.jsxs("form",{onSubmit:h.handleSubmit(k),className:"space-y-4",children:[e.jsxs(K,{children:[e.jsx(Ne,{children:e.jsxs(be,{className:"text-[14px] font-semibold flex items-center gap-2",children:[e.jsx(Qs,{className:"h-4 w-4 text-slate-400"})," General Grievance"]})}),e.jsxs(O,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[13px] font-medium text-slate-700",children:"Anonymous Grievances"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Allow employees to file anonymous grievances"})]}),e.jsx(Ce,{name:"anonymous_allowed",control:h.control,render:({field:S})=>e.jsx(je,{checked:S.value,onCheckedChange:S.onChange})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[13px] font-medium text-slate-700",children:"Auto-assign Committee"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Automatically assign investigation committee"})]}),e.jsx(Ce,{name:"auto_assign_committee",control:h.control,render:({field:S})=>e.jsx(je,{checked:S.value,onCheckedChange:S.onChange})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[13px] font-medium text-slate-700",children:"Satisfaction Survey"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Enable satisfaction survey after resolution"})]}),e.jsx(Ce,{name:"satisfaction_survey_enabled",control:h.control,render:({field:S})=>e.jsx(je,{checked:S.value,onCheckedChange:S.onChange})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[13px] font-medium text-slate-700",children:"Resolution SLA Days"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Default number of days to resolve a grievance"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(F,{className:"w-20 text-center",type:"number",min:1,...h.register("resolution_sla_days")}),e.jsx("span",{className:"text-[12px] text-slate-400",children:"days"})]})]})]})]}),e.jsxs(K,{children:[e.jsx(Ne,{children:e.jsxs(be,{className:"text-[14px] font-semibold flex items-center gap-2",children:[e.jsx(ys,{className:"h-4 w-4 text-slate-400"})," Escalation"]})}),e.jsxs(O,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[13px] font-medium text-slate-700",children:"Escalation Enabled"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Allow automatic escalation of unresolved grievances"})]}),e.jsx(Ce,{name:"escalation_enabled",control:h.control,render:({field:S})=>e.jsx(je,{checked:S.value,onCheckedChange:S.onChange})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[13px] font-medium text-slate-700",children:"Escalate After Days"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Days of inactivity before automatic escalation"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(F,{className:"w-20 text-center",type:"number",min:1,...h.register("escalation_after_days")}),e.jsx("span",{className:"text-[12px] text-slate-400",children:"days"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[13px] font-medium text-slate-700",children:"Max Escalation Levels"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Maximum levels a grievance can be escalated through"})]}),e.jsx(F,{className:"w-20 text-center",type:"number",min:1,...h.register("max_escalation_levels")})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[13px] font-medium text-slate-700",children:"Allow Reopen"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Allow reopening resolved grievances"})]}),e.jsx(Ce,{name:"allow_reopen",control:h.control,render:({field:S})=>e.jsx(je,{checked:S.value,onCheckedChange:S.onChange})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[13px] font-medium text-slate-700",children:"Reopen Window"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Days after resolution during which reopen is allowed"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(F,{className:"w-20 text-center",type:"number",min:1,...h.register("reopen_window_days")}),e.jsx("span",{className:"text-[12px] text-slate-400",children:"days"})]})]})]})]}),e.jsxs(K,{children:[e.jsx(Ne,{children:e.jsxs(be,{className:"text-[14px] font-semibold flex items-center gap-2",children:[e.jsx(Ts,{className:"h-4 w-4 text-slate-400"})," Discipline"]})}),e.jsxs(O,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[13px] font-medium text-slate-700",children:"Progressive Discipline"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Enable progressive discipline workflow"})]}),e.jsx(Ce,{name:"progressive_discipline_enabled",control:h.control,render:({field:S})=>e.jsx(je,{checked:S.value,onCheckedChange:S.onChange})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[13px] font-medium text-slate-700",children:"Inquiry Committee Min Members"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Minimum members required for an inquiry committee"})]}),e.jsx(F,{className:"w-20 text-center",type:"number",min:1,...h.register("inquiry_committee_min_members")})]})]})]}),e.jsxs(K,{children:[e.jsx(Ne,{children:e.jsxs(be,{className:"text-[14px] font-semibold flex items-center gap-2",children:[e.jsx(fs,{className:"h-4 w-4 text-slate-400"})," Show Cause"]})}),e.jsx(O,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[13px] font-medium text-slate-700",children:"Response Days"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Default days for employee to respond to show cause"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(F,{className:"w-20 text-center",type:"number",min:1,...h.register("show_cause_response_days")}),e.jsx("span",{className:"text-[12px] text-slate-400",children:"days"})]})]})})]}),e.jsxs(K,{children:[e.jsx(Ne,{children:e.jsxs(be,{className:"text-[14px] font-semibold flex items-center gap-2",children:[e.jsx(ys,{className:"h-4 w-4 text-slate-400"})," Warnings"]})}),e.jsxs(O,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[13px] font-medium text-slate-700",children:"Warning Validity"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Default validity period for warning letters"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(F,{className:"w-20 text-center",type:"number",min:1,...h.register("warning_validity_months")}),e.jsx("span",{className:"text-[12px] text-slate-400",children:"months"})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-[13px] font-medium text-slate-700",children:"Max Warnings Before Termination"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Maximum warnings before termination is recommended"})]}),e.jsx(F,{className:"w-20 text-center",type:"number",min:1,...h.register("max_warnings_before_termination")})]})]})]})]})]})}function Jt(){return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsxs("h2",{className:"text-[16px] font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(Ss,{className:"h-5 w-5 text-primary"})," Grievance Reports"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"View grievance and disciplinary reports"})]})}),e.jsxs(K,{children:[e.jsx(Ne,{children:e.jsx(be,{className:"text-[14px] font-semibold",children:"Report Center"})}),e.jsx(O,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ss,{className:"h-10 w-10 text-slate-300 mb-3"}),e.jsx("p",{className:"text-[14px] font-medium text-slate-600",children:"Coming Soon"}),e.jsx("p",{className:"text-[13px] text-slate-400 mt-1 max-w-sm",children:"Generate grievance resolution reports, disciplinary case summaries, and department-level compliance metrics."})]})})]})]})}function en(){return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsxs("h2",{className:"text-[16px] font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(Cs,{className:"h-5 w-5 text-primary"})," Grievance Analytics"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Explore grievance trends and disciplinary analytics"})]})}),e.jsxs(K,{children:[e.jsx(Ne,{children:e.jsx(be,{className:"text-[14px] font-semibold",children:"Analytics Dashboard"})}),e.jsx(O,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Cs,{className:"h-10 w-10 text-slate-300 mb-3"}),e.jsx("p",{className:"text-[14px] font-medium text-slate-600",children:"Coming Soon"}),e.jsx("p",{className:"text-[13px] text-slate-400 mt-1 max-w-sm",children:"Analyze grievance trends, resolution timelines, category distribution, and disciplinary action effectiveness."})]})})]})]})}export{Yt as DisciplinaryCasesPage,en as GrievanceAnalyticsPage,Ht as GrievanceCategoriesPage,Mt as GrievanceDashboardPage,At as GrievanceLayout,Jt as GrievanceReportsPage,Xt as GrievanceSettingsPage,zt as GrievancesPage,Bt as ShowCausesPage,Zt as WarningLettersPage,Ta as useAcknowledgeWarning,qa as useCreateDisciplinaryCase,ya as useCreateGrievance,ga as useCreateGrievanceCategory,Rt as useCreateGrievanceNote,Sa as useCreateShowCause,Ea as useCreateWarningLetter,Va as useDeleteDisciplinaryCase,_a as useDeleteGrievance,va as useDeleteGrievanceCategory,Qt as useDeleteGrievanceDocument,It as useDeleteGrievanceNote,ka as useDeleteShowCause,Ia as useDeleteWarningLetter,Ot as useDisciplinaryCaseDetail,Os as useDisciplinaryCases,Na as useEscalateGrievance,Ut as useGrievanceAnalytics,ks as useGrievanceCategories,$a as useGrievanceDashboard,Gt as useGrievanceDetail,Tt as useGrievanceDocuments,Et as useGrievanceNotes,Wt as useGrievanceReports,ha as useGrievanceSettings,qs as useGrievances,Aa as useRecordDecision,wa as useReopenGrievance,ba as useResolveGrievance,Da as useRespondShowCause,Pa as useScheduleHearing,Kt as useShowCauseDetail,Fs as useShowCauses,Fa as useUpdateDisciplinaryCase,fa as useUpdateGrievance,ja as useUpdateGrievanceCategory,pa as useUpdateGrievanceSettings,Ca as useUpdateShowCause,Ra as useUpdateWarningLetter,$t as useUploadGrievanceDocument,Lt as useWarningLetterDetail,Ga as useWarningLetters};
