1"use strict";(self.webpackChunkquickGrowth=self.webpackChunkquickGrowth||[]).push([[5969],{5969(e,t,r){r.r(t),r.d(t,{default:()=>u});var s=r(2555),l=r(5043),a=r(3216),o=r(3976),n=r(5016),i=r(4987),d=r(579);const c=["lead_created","discovery","quote_pending","client_reviewing_quote","contract_pending_signature","retainer_pending","active","waiting_on_client","submitted_for_review","revision_requested","approved","completed","cancelled","refunded","archived"];const u=function(){const e=(0,a.Zp)(),{profile:t}=(0,n.As)(),[r,u]=(0,l.useState)([]),[x,m]=(0,l.useState)(!0),[p,b]=(0,l.useState)(""),[h,g]=(0,l.useState)(""),[v,y]=(0,l.useState)("created_at"),[f,j]=(0,l.useState)("desc"),[_,w]=(0,l.useState)([]),[N,C]=(0,l.useState)([]),[k,S]=(0,l.useState)(null),[A,q]=(0,l.useState)({}),[R,z]=(0,l.useState)(!1),U=(0,l.useCallback)((async()=>{const[e,t]=await Promise.all([o.supabase.from("profiles").select("id, full_name, email").eq("role","sales_rep"),o.supabase.from("profiles").select("id, full_name, email").eq("role","contractor")]);w(e.data||[]),C(t.data||[])}),[]),D=(0,l.useCallback)((async()=>{m(!0);try{let e=o.supabase.from("jobs").select("\n *,\n client:profiles!jobs_client_id_fkey(id, full_name, email),\n sales_rep:profiles!jobs_sales_rep_id_fkey(id, full_name, email),\n contractor:profiles!jobs_contractor_id_fkey(id, full_name, email)\n ").order(v,{ascending:"asc"===f});h&&(e=e.eq("status",h)),p.trim()&&(e=e.ilike("title","%".concat(p.trim(),"%")));const{data:t,error:r}=await e;if(r)throw r;u(t||[])}catch(e){console.error("Error fetching jobs:",e)}finally{m(!1)}}),[h,p,v,f]);(0,l.useEffect)((()=>{D(),U()}),[D,U]);const E=e=>{switch(e){case"urgent":return"text-red-500";case"high":return"text-yellow-400";case"medium":return"text-yellow-500";default:return"text-secondary"}};return(0,d.jsxs)("div",{className:"space-y-6",children:[(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("h1",{className:"text-2xl font-bold text-primary",children:"Jobs Manager"}),(0,d.jsxs)("p",{className:"text-secondary text-sm mt-1",children:[r.length," total job",1!==r.length?"s":""," \u2014 Full admin control"]})]}),(0,d.jsxs)("button",{onClick:()=>e("/dashboard/admin/jobs/create"),className:"px-4 py-2 bg-yellow-500 text-black text-sm font-medium rounded-lg hover:bg-yellow-400 transition-colors flex items-center space-x-2",children:[(0,d.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,d.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),(0,d.jsx)("span",{children:"Create Job"})]})]}),(0,d.jsx)("div",{className:"bg-card border border-theme rounded-xl p-4",children:(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3",children:[(0,d.jsx)("div",{className:"flex-1",children:(0,d.jsx)("input",{type:"text",placeholder:"Search jobs...",value:p,onChange:e=>b(e.target.value),className:"w-full bg-input border border-theme-hover rounded-lg px-4 py-2 text-primary text-sm focus:outline-none focus:border-yellow-500 transition-colors"})}),(0,d.jsxs)("select",{value:h,onChange:e=>g(e.target.value),className:"bg-input border border-theme-hover rounded-lg px-3 py-2 text-primary text-sm focus:outline-none focus:border-yellow-500 transition-colors",children:[(0,d.jsx)("option",{value:"",children:"All Statuses"}),c.map((e=>(0,d.jsx)("option",{value:e,children:e.replace(/_/g," ").replace(/\b\w/g,(e=>e.toUpperCase()))},e)))]}),(0,d.jsxs)("select",{value:"".concat(v,":").concat(f),onChange:e=>{const[t,r]=e.target.value.split(":");y(t),j(r)},className:"bg-input border border-theme-hover rounded-lg px-3 py-2 text-primary text-sm focus:outline-none focus:border-yellow-500 transition-colors",children:[(0,d.jsx)("option",{value:"created_at:desc",children:"Newest First"}),(0,d.jsx)("option",{value:"created_at:asc",children:"Oldest First"}),(0,d.jsx)("option",{value:"title:asc",children:"Title A-Z"}),(0,d.jsx)("option",{value:"updated_at:desc",children:"Recently Updated"})]})]})}),x?(0,d.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,d.jsx)("div",{className:"w-8 h-8 border-2 border-yellow-500 border-t-transparent roun
1ded-full animate-spin"})}):0===r.length?(0,d.jsxs)("div",{className:"bg-card border border-theme rounded-xl p-12 text-center",children:[(0,d.jsx)("p",{className:"text-secondary text-lg font-medium",children:"No jobs found"}),(0,d.jsx)("p",{className:"text-muted text-sm mt-1",children:p||h?"Try adjusting your filters":"No jobs in the system yet"})]}):(0,d.jsx)("div",{className:"space-y-3",children:r.map((l=>(0,d.jsx)("div",{className:"bg-card border border-theme rounded-xl p-4 sm:p-5 hover:border-theme-hover transition-all",children:k===l.id?(0,d.jsxs)("div",{className:"space-y-4",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between",children:[(0,d.jsx)("h3",{className:"text-primary font-semibold",children:l.title}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("button",{onClick:()=>(async e=>{z(!0);try{const s=r.find((t=>t.id===e)),l={status:A.status,sales_rep_id:A.sales_rep_id||null,contractor_id:A.contractor_id||null,priority:A.priority,updated_at:(new Date).toISOStr
1ing()},{error:a}=await o.supabase.from("jobs").update(l).eq("id",e);if(a)throw a;s&&s.status!==A.status&&await o.supabase.from("job_status_history").insert({job_id:e,old_status:s.status,new_status:A.status,changed_by:t.id,notes:"Status changed by admin"}),S(null),await D()}catch(s){console.error("Error updating job:",s)}finally{z(!1)}})(l.id),disabled:R,className:"px-3 py-1.5 bg-yellow-500 text-black text-xs font-medium rounded-lg hover:bg-yellow-400 disabled:opacity-50 transition-colors min-h-[32px]",children:R?"Saving...":"Save"}),(0,d.jsx)("button",{onClick:()=>S(null),className:"px-3 py-1.5 border border-theme-hover text-secondary text-xs rounded-lg hover:text-primary hover:border-theme-hover transition-colors",children:"Cancel"})]})]}),(0,d.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-xs text-muted mb-1",children:"Status Override"}),(0,d.jsx)("select",{value:A.status,onChange:e=>q((t=>(0,s.A)((0,s.A)({},t),{},{status:e.target.value}))),className:"w-full bg-input border border-theme-hover rounded-lg px-3 py-2 text-primary text-sm focus:outline-none focus:border-yellow-500",children:c.map((e=>(0,d.jsx)("option",{value:e,children:e.replace(/_/g," ").replace(/\b\w/g,(e=>e.toUpperCase()))},e)))})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-xs text-muted mb-1",children:"Assign Sales Rep"}),(0,d.jsxs)("select",{value:A.sales_rep_id,onChange:e=>q((t=>(0,s.A)((0,s.A)({},t),{},{sales_rep_id:e.target.value}))),className:"w-full bg-input border border-theme-hover rounded-lg px-3 py-2 text-primary text-sm focus:outline-none focus:border-yellow-500",children:[(0,d.jsx)("option",{value:"",children:"Unassigned"}),_.map((e=>(0,d.jsx)("option",{value:e.id,children:e.full_name||e.email},e.id)))]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-xs text-muted mb-1",children:"Assign Contractor"}),(0,d.jsxs)("select",{value:A.contractor_id,onChange:e=>q((t=>(0,s.A)((0,s.A)({},t),{},{contractor_id:e.target.value}))),className:"w-full bg-input border border-theme-hover rounded-lg px-3 py-2 text-primary text-sm focus:outline-none focus:border-yellow-500",children:[(0,d.jsx)("option",{value:"",children:"Unassigned"}),N.map((e=>(0,d.jsx)("option",{value:e.id,children:e.full_name||e.email},e.id)))]})]}),(0,d.jsxs)("div",{children:[(0,d.jsx)("label",{className:"block text-xs text-muted mb-1",children:"Priority"}),(0,d.jsxs)("select",{value:A.priority,onChange:e=>q((t=>(0,s.A)((0,s.A)({},t),{},{priority:e.target.value}))),className:"w-full bg-input border border-theme-hover rounded-lg px-3 py-2 text-primary text-sm focus:outline-none focus:border-yellow-500",children:[(0,d.jsx)("option",{value:"low",children:"Low"}),(0,d.jsx)("option",{value:"medium",children:"Medium"}),(0,d.jsx)("option",{value:"high",children:"High"}),(0,d.jsx)("option",{value:"urgent",children:"Urgent"})]})]})]})]}):(0,d.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[(0,d.jsxs)("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>e("/dashboard/admin/jobs/".concat(l.id)),children:[(0,d.jsxs)("div",{className:"flex items-center gap-3 mb-2",children:[(0,d.jsx)("h3",{className:"text-primary font-semibold text-base truncate hover:text-yellow-400 transition-colors",children:l.title}),(0,d.jsx)(i.A,{status:l.status}),"archived"===l.status&&(0,d.jsx)("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded-full",children:"Frozen"})]}),(0,d.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted",children:[l.service_type&&(0,d.jsx)("span",{children:l.service_type}),l.priority&&(0,d.jsx)("span",{className:"capitalize ".concat(E(l.priority)),children:l.priority}),l.client&&(0,d.jsxs)("span",{children:["Client: ",l.client.full_name||l.client.email]}),l.sales_rep&&(0,d.jsxs)("span",{children:["Rep: ",l.sales_rep.full_name||l.sales_rep.email]}),l.contractor&&(0,d.jsxs)("span",{children:["Contractor: ",l.contractor.full_name||l.contractor.email]}),(0,d.jsxs)("span",{children:["Created ",new Date(l.created_at).toLocaleDateString()]})]})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[(0,d.jsx)("button",{onClick:()=>(e=>{S(e.id),q({status:e.status,sales_rep_id:e.sales_rep_id||"",contractor_id:e.contractor_id||"",priority:e.priority||"medium"})})(l),className:"px-3 py-1.5 text-xs font-medium text-yellow-400 border border-yellow-500/30 rounded-lg hover:bg-yellow-500/10 transition-colors",children:"Edit"}),(0,d.jsx)("button",{onClick:()=>(async e=>{const r="archived"===e.status?"active":"archived";try{await o.supabase.from("jobs").update({status:r,updated_at:(new Date).toISOString()}).eq("id",e.id),await o.supabase.from("job_status_history").insert({job_id:e.id,old_status:e.status,new_status:r,changed_by:t.id,notes:"archived"===r?"Job frozen by admin":"Job unfrozen by admin"}),await D()}catch(s){console.error("Error toggling freeze:",s)}})(l),className:"px-3 py-1.5 text-xs font-medium border rounded-lg transition-colors ".concat("archived"===l.status?"text-green-400 border-green-500/30 hover:bg-green-500/10":"text-red-400 border-red-500/30 hover:bg-red-500/10"),children:"archived"===l.status?"Unfreeze":"Freeze"}),(0,d.jsx)("button",{onClick:()=>e("/dashboard/admin/jobs/".concat(l.id)),className:"px-3 py-1.5 text-xs font-medium text-secondary border border-theme-hover rounded-lg hover:text-primary hover:border-theme-hover transition-colors",children:"View"})]})]})},l.id)))})]})}},4987(e,t,r){r.d(t,{A:()=>a,M:()=>l});r(5043);var s=r(579);const l={lead_created:{label:"Lead Created",color:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30"},discovery:{label:"Discovery",color:"bg-purple-500/20 text-purple-400 border-purple-500/30"},quote_pending:{label:"Quote Pending",color:"bg-indigo-500/20 text-indigo-400 border-indigo-500/30"},client_reviewing_quote:{label:"Client Reviewing",color:"bg-cyan-500/20 text-cyan-400 border-cyan-500/30"},contract_pending_signature:{label:"Contract Pending",color:"bg-orange-500/20 text-orange-400 border-orange-500/30"}
1,retainer_pending:{label:"Retainer Pending",color:"bg-amber-500/20 text-amber-400 border-amber-500/30"},active:{label:"Active",color:"bg-green-500/20 text-green-400 border-green-500/30"},waiting_on_client:{label:"Waiting on Client",color:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30"},submitted_for_review:{label:"Submitted for Review",color:"bg-teal-500/20 text-teal-400 border-teal-500/30"},revision_requested:{label:"Revision Requested",color:"bg-rose-500/20 text-rose-400 border-rose-500/30"},approved:{label:"Approved",color:"bg-emerald-500/20 text-emerald-400 border-emerald-500/30"},completed:{label:"Completed",color:"bg-green-600/20 text-emerald-400 border-green-600/30"},cancelled:{label:"Cancelled",color:"bg-red-500/20 text-red-400 border-red-500/30"},refunded:{label:"Refunded",color:"bg-muted/20 text-secondary border-theme"},archived:{label:"Archived",color:"bg-muted/10 text-muted border-theme"}};const a=function(e){var t;let{status:r,size:a="sm"}=e;const o=l[r]||{label:r,color:"bg-muted/20 text-secondary border-theme"},n="lg"===a?"px-3 py-1.5 text-sm":"md"===a?"px-2.5 py-1 text-xs":"px-2 py-0.5 text-xs";return(0,s.jsxs)("span",{className:"inline-flex items-center rounded-full border font-medium ".concat(o.color," ").concat(n),children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full mr-1.5 ".concat((null===(t=o.color.split(" ")[1])||void 0===t?void 0:t.replace("text-","bg-"))||"bg-gray-400")}),o.label]})}}}]); 2//# sourceMappingURL=5969.0ae8dd1f.chunk.js.map
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.