1import{r as a,d as b,j as e,H as re}from"./app-CCpZZfiU.js";import{I as ne}from"./institute-admin-layout-CA93b1sE.js";import{B as x}from"./button-DzSev-Sf.js";import{b as le,C as oe,c as ce,d as de,a as me}from"./card-DvOEDc1z.js";import{D as V,a as B,b as F,c as L,d as M,e as R}from"./dialog-D2WqbyiI.js";import{D as xe,a as ue,b as pe,c as C,C as he}from"./dropdown-menu-DBbIbdBq.js";import{I as je}from"./input-D6NEnf8k.js";import{L as c}from"./label-8uBxM-YH.js";import{S,a as w,b as E,c as P,d as r}from"./select-Cy8YvxAe.js";import{T as ge}from"./toast-Bhjbg2cV.js";import{S as N}from"./stat-card-BSZeh6JB.js";import{B as fe}from"./badge-BqYRTkMx.js";import{C as ve}from"./circle-play-DzlpnTM4.js";import{C as Ne}from"./clock-B0IaZmLq.js";import{C as H}from"./circle-check-big-B1BJxh8X.js";import{S as ye}from"./search-EZW4lm-E.js";import{E as be}from"./ellipsis-vertical-KDgZYAcA.js";import{E as Ce}from"./eye-BODuEgIX.js";import{T as Se}from"./trash-2-5wVJws-2.js";import{C as we}from"./chevron-left-Dfrtkb2t.js";/* empty css */import"./institute-admin-app-sidebar-layout-DQ4wDlOD.js";import"./nav-main-DSXjyUmT.js";import"./createLucideIcon-3_sU3Fsa.js";import"./sheet-Da3yFtkU.js";import"./index-C6bjBpJ5.js";import"./check-DLr6i1hx.js";import"./index-BIt_Hmsv.js";import"./index-Byu-ws87.js";import"./x-C9SAcLFP.js";import"./index-DNu7356g.js";import"./use-mobile-navigation-Qa6ht353.js";import"./app-logo-icon-B_n3Um1u.js";import"./index-LDA7zf9H.js";import"./users-C3DaYSzO.js";import"./graduation-cap-HH8T1ApP.js";import"./book-open-C-2lRqxY.js";import"./ticket-Ofbl5HXn.js";import"./theme-toggle-ChtjMYRI.js";import"./sun-3mgJ3m-i.js";import"./building-2-CiTGsS4y.js";import"./user-check-BlxoAx6h.js";import"./credit-card-DTZwSHb_.js";import"./file-text-oiLi0dsj.js";import"./school-qbuixWnp.js";import"./video-Bp9qf7wh.js";import"./circle-help-Cq4VoaZ8.js";import"./bell-DP0UGrcH.js";import"./message-square-B5dyVmG9.js";import"./chevron-down-AzpnrCwU.js";import"./index-DPz-BDYJ.js";import"./index-CGiGfTlp.js";import"./circle-x-D9or-THw.js";import"./circle-alert-B4ob51JW.js";import"./arrow-right-DX311mZ_.js";const Ee=[{title:"CRM",href:"#"},{title:"Job Enquiries"}];function Dt({stats:U,filters:D}){const[h,_]=a.useState(U),[J,$]=a.useState([]),[k,q]=a.useState(!1),[j,G]=a.useState(10),[i,K]=a.useState({currentPage:1,lastPage:1,total:0,from:0,to:0}),[g,Q]=a.useState(D.search||""),[f,W]=a.useState(D.status||""),[l,X]=a.useState("id"),[o,I]=a.useState("desc"),[Y,y]=a.useState(!1),[Z,v]=a.useState(!1),[n,T]=a.useState(null),[z,A]=a.useState(""),[ee,u]=a.useState(null),d=a.useCallback(async(t=1)=>{q(!0);try{const s=await b.get("/institute-admin/job-enquiries/data",{params:{page:t,per_page:j,search:g,status:f,sort_by:l,sort_order:o}});$(s.data.data),K({currentPage:s.data.meta.current_page,lastPage:s.data.meta.last_page,total:s.data.meta.total,from:s.data.meta.from,to:s.data.meta.to})}catch(s){console.error("Failed to fetch Job Enquiries:",s)}finally{q(!1)}},[g,f,l,o,j]);a.useEffect(()=>{d(1)},[g,f,l,o,j,d]);const m=t=>{l===t?I(o==="asc"?"desc":"asc"):(X(t),I("desc"))},te=t=>{T(t),y(!0)},se=t=>{T(t),A(t.status),v(!0)},ae=async()=>{if(n)try{const t=await b.put(`/institute-admin/job-enquiries/${n.id}`,{status:z});t.data.type==="success"&&(u({type:"success",message:t.data.message}),v(!1),d(i.currentPage))}catch(t){u({type:"danger",message:t.response?.data?.message||"Failed to update status"})}},ie=async t=>{if(confirm("Are you sure you want to delete this Job Enquiry?"))try{const s=await b.delete(`/institute-admin/job-enquiries/${t.id}`);s.data.type==="success"&&(u({type:"success",message:s.data.message}),d(i.currentPage),_(p=>({...p,total:p.total-1})))}catch(s){u({type:"danger",message:s.response?.data?.message||"Failed to delete Job Enquiry"})}},O=t=>{const s={pending:{variant:"outline",label:"Pending"},contacted:{variant:"secondary",label:"Contacted"},completed:{variant:"default",label:"Completed"},cancelled:{variant:"destructive",label:"Cancelled"}},p=s[t]||s.pending;return e.jsx(fe,{variant:p.variant,children:p.label})};return e.jsxs(ne,{breadcrumbs:Ee,children:[e.jsx(re,{title:"Job Enquiries"}),e.jsxs("div",{className:"flex flex-1 flex-col gap-4 p-4",children:[e.jsx(ge,{toast:ee,onClose:()=>u(null)}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Job Enquiries"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage Job Enquiries from your website"})]})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(N,{title:"Total Requests",value:h?.total||0,description:"All Job Enquiries",icon:ve,paletteIndex:0}),e.jsx(N,{title:"Pending",value:h?.pending||0,description:"Awaiting response",icon:Ne,paletteIndex:1}),e.jsx(N,{title:"Contacted",value:h?.contacted||0,description:"Already contacted",icon:H,paletteIndex:2}),e.jsx(N,{title:"Completed",value:h?.completed||0,description:"Successfully completed",icon:H,paletteIndex:3})]}),e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(ce,{children:"All Job Enquiries"}),e.jsx(de,{children:"A list of all Job Enquiries from your website"})]})}),e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(ye,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(je,{placeholder:"Search requests...",value:g,onChange:t=>Q(t.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(S,{value:f||void 0,onValueChange:t=>W(t||""),children:[e.jsx(w,{className:"w-[140px]",children:e.jsx(E,{placeholder:"All Status"})}),e.jsxs(P,{children:[e.jsx(r,{value:"pending",children:"Pending"}),e.jsx(r,{value:"contacted",children:"Contacted"}),e.jsx(r,{value:"completed",children:"Completed"}),e.jsx(r,{value:"cancelled",children:"Cancelled"})]})]}),e.jsxs(S,{value:j.toString(),onValueChange:t=>G(parseInt(t)),children:[e.jsx(w,{className:"w-[100px]",children:e.jsx(E,{})}),e.jsxs(P,{children:[e.jsx(r,{value:"10",children:"10"}),e.jsx(r,{value:"25",children:"25"}),e.jsx(r,{value:"50",children:"50"}),e.jsx(r,{value:"100",children:"100"})]})]})]})]})]}),e.jsxs(me,{children:[e.jsx("div",{className:"rounded-md border",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"border-b bg-muted/50",children:e.jsxs("tr",{children:[e.jsxs("th",{className:"px-4 py-3 text-left text-sm font-medium cursor-pointer hover:bg-muted/70",onClick:()=>m("id"),children:["ID ",l==="id"&&"?"]}),e.jsxs("th",{className:"px-4 py-3 text-left text-sm font-medium cursor-pointer hover:bg-muted/70",onClick:()=>m("name"),children:["Name ",l==="name"&&"?"]}),e.jsxs("th",{className:"px-4 py-3 text-left text-sm font-medium cursor-pointer hover:bg-muted/70",onClick:()=>m("organization"),children:["Organization ",l==="organization"&&"?"]}),e.jsxs("th",{className:"px-4 py-3 text-left text-sm font-medium cursor-pointer hover:bg-muted/70",onClick:()=>m("email"),children:["Email ",l==="email"&&"?"]}),e.jsx("th",{className:"px-4 py-3 text-left text-sm font-medium",children:"Phone"}),e.jsxs("th",{className:"px-4 py-3 text-left text-sm font-medium cursor-pointer hover:bg-muted/70",onClick:()=>m("status"),children:["Status ",l==="status"&&"?"]}),e.jsxs("th",{className:"px-4 py-3 text-left text-sm font-medium cursor-pointer hover:bg-muted/70",onClick:()=>m("created_at"),children:["Date ",l==="created_at"&&"?"]}),e.jsx("th",{className:"px-4 py-3 text-right text-sm font-medium",children:"Actions"})]})}),e.jsx("tbody",{children:k?e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"Loading..."})}):J.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:"px-4 py-8 text-center text-sm text-muted-foreground",children:"No Job Enquiries found."})}):J.map(t=>e.jsxs("tr",{className:"border-b hover:bg-muted/50",children:[e.jsxs("td",{className:"px-4 py-3 text-sm text-muted-foreground",children:["#",t.id]}),e.jsx("td",{className:"px-4 py-3 text-sm font-medium",children:t.name}),e.jsx("td",{className:"px-4 py-3 text-sm",children:t.organization}),e.jsx("td",{className:"px-4 py-3 text-sm",children:t.email}),e.jsx("td",{className:"px-4 py-3 text-sm",children:t.phone}),e.jsx("td",{className:"px-4 py-3 text-sm",children:O(t.status)}),e.jsx("td",{className:"px-4 py-3 text-sm",children:new Date(t.created_at).toLocaleDateString()}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsxs(xe,{children:[e.jsx(ue,{asChild:!0,children:e.jsx(x,{variant:"ghost",size:"icon",children:e.jsx(be,{className:"h-4 w-4"})})}),e.jsxs(pe,{align:"end",children:[e.jsxs(C,{onClick:()=>te(t),children:[e.jsx(Ce,{className:"mr-2 h-4 w-4"}),"View Details"]}
1),e.jsx(C,{onClick:()=>se(t),children:"Update Status"}),e.jsxs(C,{onClick:()=>ie(t),className:"text-red-600",children:[e.jsx(Se,{className:"mr-2 h-4 w-4"}),"Delete"]})]})]})})]},t.id))})]})})}),!k&&i.total>0&&e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",i.from," to ",i.to," of ",i.total," results"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>d(i.currentPage-1),disabled:i.currentPage===1,children:[e.jsx(we,{className:"h-4 w-4"}),"Previous"]}),e.jsxs("div",{className:"text-sm",children:["Page ",i.currentPage," of ",i.lastPage]}),e.jsxs(x,{variant:"outline",size:"sm",onClick:()=>d(i.currentPage+1),disabled:i.currentPage===i.lastPage,children:["Next",e.jsx(he,{className:"h-4 w-4"})]})]})]})]})]})]}),e.jsx(V,{open:Y,onOpenChange:y,children:e.jsxs(B,{className:"max-w-2xl",children:[e.jsxs(F,{children:[e.jsx(L,{children:"Job Enquiry Details"}),e.jsx(M,{children:"Full details of the Job Enquiry"})]}),n&&e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-sm font-medium",children:"Name"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.name})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-sm font-medium",children:"Email"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.email})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-sm font-medium",children:"Phone"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.phone})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-sm font-medium",children:"Organization"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.organization})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(c,{className:"text-sm font-medium",children:"Role"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.role})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-sm font-medium",children:"Status"}),e.jsx("div",{className:"mt-1",children:O(n.status)})]})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-sm font-medium",children:"Message"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:n.message})]}),e.jsxs("div",{children:[e.jsx(c,{className:"text-sm font-medium",children:"Submitted Date"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:new Date(n.created_at).toLocaleString()})]})]}),e.jsx(R,{children:e.jsx(x,{variant:"outline",onClick:()=>y(!1),children:"Close"})})]})}),e.jsx(V,{open:Z,onOpenChange:v,children:e.jsxs(B,{children:[e.jsxs(F,{children:[e.jsx(L,{children:"Update Status"}),e.jsx(M,{children:"Change the status of this Job Enquiry"})]}),e.jsx("div",{className:"grid gap-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"status",children:"Status"}),e.jsxs(S,{value:z,onValueChange:A,children:[e.jsx(w,{children:e.jsx(E,{placeholder:"Select status"})}),e.jsxs(P,{children:[e.jsx(r,{value:"pending",children:"Pending"}),e.jsx(r,{value:"contacted",children:"Contacted"}),e.jsx(r,{value:"completed",children:"Completed"}),e.jsx(r,{value:"cancelled",children:"Cancelled"})]})]})]})}),e.jsxs(R,{children:[e.jsx(x,{variant:"outline",onClick:()=>v(!1),children:"Cancel"}),e.jsx(x,{onClick:ae,children:"Update Status"})]})]})})]})}export{Dt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.