PageSourceSearch

https://crm-publicity-hound.vercel.app/_next/static/chunks/pages/dashboard/appointments-7a9afe552192735b.js

js crm-publicity-hound.vercel.app collected 2026-10-03 06:41:38 UTC 28,268 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3965],{45937:(e,s,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/dashboard/appointments",function(){return t(73680)}])},73680:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>S});var a=t(37876),r=t(14232),n=t(89099),l=t(94246),i=t(56282),d=t(62125),c=t(28567),o=t(32764),m=t(78769),x=t(31452),u=t(98999),h=t(69673);t(34572);var p=t(96668),g=t(54254),f=t(1481),b=t(3244),j=t(63393),y=t(78620),w=t(68974),v=t(74550),N=t(28022),k=t(47043),A=t(35765),C=t(49539);function S(){let e=(0,n.useRouter)(),{user:s,loading:t,hasPermission:S}=(0,l.A)(),[_,D]=(0,r.useState)([]),[E,T]=(0,r.useState)(!0),[z,P]=(0,r.useState)(null),[$,U]=(0,r.useState)(""),[O,F]=(0,r.useState)("all"),[R,I]=(0,r.useState)("all"),[L,M]=(0,r.useState)(1),[B,Z]=(0,r.useState)(1),[Y,q]=(0,r.useState)(!1),[G,J]=(0,r.useState)(null),[X,K]=(0,r.useState)(!1),[V,W]=(0,r.useState)(new Set),[H,Q]=(0,r.useState)(!1),[ee,es]=(0,r.useState)(!1),[et,ea]=(0,r.useState)(""),[er,en]=(0,r.useState)(!1),[el,ei]=(0,r.useState)({type:"success",title:"",message:""}),[ed,ec]=(0,r.useState)(!1),[eo,em]=(0,r.useState)({title:"",message:"",onConfirm:null,type:"danger",confirmText:"Confirm",cancelText:"Cancel"}),ex=S("canManageAppointments"),eu=S("canCreateAppointments"),eh=S("canDeleteAppointments"),ep=(0,r.useCallback)(function(e){for(var s=arguments.length,t=Array(s>1?s-1:0),a=1;a<s;a++)t[a-1]=arguments[a];t.length},[]),eg=(0,r.useCallback)(async()=>{try{var e,s;T(!0),P(null),ep("Fetching appointments",{page:L,search:$||"-",status:O,type:R});let t=new URLSearchParams({page:L.toString(),limit:"10"});$&&t.append("search",$),"all"!==O&&t.append("status",O),"all"!==R&&t.append("type",R);let a=await fetch("/api/appointments?".concat(t)),r=await a.json();if(!a.ok)throw ep("Fetch failed",a.status,null==r?void 0:r.error),Error(r.error||"Failed to fetch appointments");let n=r.appointments||[];D(n),Z((null==(e=r.pagination)?void 0:e.totalPages)||1),ep("Loaded",n.length,"items, totalPages",null==(s=r.pagination)?void 0:s.totalPages)}catch(e){console.error("[Appointments] Error fetching:",e),P(e.message)}finally{T(!1)}},[L,$,O,R,ep]);(0,r.useEffect)(()=>{!t&&s&&eg()},[t,s,eg]);let ef=async()=>{if(!eh)return void P("You don't have permission to delete appointments");if(!G)return;let e="booking"===G.source,s=e?"/api/bookings/".concat(G._id):"/api/appointments/".concat(G._id);try{K(!0),ep("Deleting single",e?"booking":"appointment",G._id);let t=await fetch(s,{method:"DELETE",credentials:"include"}),a=await t.json();if(!t.ok)throw ep("Delete failed",t.status,null==a?void 0:a.error),Error(a.error||(e?"Failed to delete booking":"Failed to delete appointment"));ep("Deleted successfully",G._id),await eg(),q(!1),J(null)}catch(e){console.error("[Appointments] Error deleting:",e),P(e.message)}finally{K(!1)}},eb=e=>{switch(e){case"completed":return"success";case"confirmed":return"primary";case"scheduled":default:return"secondary";case"rescheduled":return"warning";case"cancelled":case"no_show":return"danger"}},ej=e=>{switch(e){case"consultation":case"meeting":return"primary";case"follow_up":case"call":return"success";case"presentation":return"warning";default:return"secondary"}},ey=e=>{switch(e){case"completed":case"confirmed":return(0,a.jsx)(p.A,{className:"h-4 w-4"});case"scheduled":default:return(0,a.jsx)(g.A,{className:"h-4 w-4"});case"rescheduled":return(0,a.jsx)(f.A,{className:"h-4 w-4"});case"cancelled":case"no_show":return(0,a.jsx)(b.A,{className:"h-4 w-4"})}},ew=e=>e?new Date(e).toLocaleString():"Not set",ev=(e,s)=>!!e&&"scheduled"===s&&new Date(e)>new Date,eN=(e,s)=>!!e&&"scheduled"===s&&new Date(e)<new Date,ek=e=>{let s=new Set(V);s.has(e)?s.delete(e):s.add(e),W(s)},eA=async()=>{Q(!0),ec(!1),P(null);let e=Array.from(V),s=e.filter(e=>{let s=_.find(s=>s._id===e);return s&&!s.source}),t=e.filter(e=>{let s=_.find(s=>s._id===e);return(null==s?void 0:s.source)==="booking"});ep("Bulk delete: appointments",s.length,"bookings",t.length);try{let e=0,r=0;if(s.length>0){var a;let t=await fetch("/api/appointments/bulk",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({appointmentIds:s}),credentials:"include"}),r=await t.json();if(!t.ok)throw ep("Bulk delete appointments failed",t.status,null==r?void 0:r.error),Error(r.error||"Failed to delete appointments");e=null!=(a=r.deletedCount)?a:s.length,ep("Deleted appointments",e)}for(let e of t){let s=await fetch("/api/bookings/".concat(e),{method:"DELETE",credentials:"include"}),t=await s.json();if(!s.ok)throw ep("Delete booking failed",e,null==t?void 0:t.error),Error(t.error||"Failed to delete booking ".concat(e));r+=1}t.length&&ep("Deleted bookings",r);let n=e+r;ei({type:"success",title:"Deleted",message:"Successfully deleted ".concat(n," item(s)").concat(e&&r?" (".concat(e," appointments, ").concat(r," bookings)"):"",".")}),en(!0),W(new Set),await eg()}catch(e){console.error("[Appointments] Error bulk deleting:",e),P(e.message)}finally{Q(!1)}},eC=async()=>{let e=Array.from(V).filter(e=>{let s=_.find(s=>
1s._id===e);return s&&!s.source});if(0===e.length){P("Status update applies only to appointments. Select one or more appointments (not bookings)."),ec(!1);return}es(!0),ec(!1),P(null),ep("Bulk status update",et,"for",e.length,"appointments");try{var s,t;let a=await fetch("/api/appointments/bulk",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({appointmentIds:e,status:et}),credentials:"include"}),r=await a.json();if(!a.ok)throw ep("Bulk status failed",a.status,null==r?void 0:r.error),Error(r.error||"Failed to update appointment statuses");ep("Bulk status updated",null!=(s=r.updatedCount)?s:e.length),ei({type:"success",title:"Status Updated",message:r.message||"Updated ".concat(null!=(t=r.updatedCount)?t:e.length," appointment(s).")}),en(!0),W(new Set),ea(""),await eg()}catch(e){console.error("[Appointments] Error bulk status update:",e),P(e.message)}finally{es(!1)}};return t?(0,a.jsx)(i.A,{children:(0,a.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,a.jsx)("div",{className:"animate-spin rounded-full h-32 w-32 border-b-2 border-blue-600"})})}):s?ex?(0,a.jsx)(i.A,{children:(0,a.jsxs)("div",{className:"py-6",children:[(0,a.jsxs)("div",{className:"relative overflow-hidden rounded-2xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm mb-6 sm:mb-8",children:[(0,a.jsx)("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-gray-50/50 to-transparent dark:via-gray-700/20"}),(0,a.jsx)("div",{className:"relative p-4 sm:p-6",children:(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)(y.A,{className:"h-6 w-6 sm:h-8 sm:w-8 text-blue-600 flex-shrink-0"}),(0,a.jsx)("h1",{className:"text-xl sm:text-2xl lg:text-3xl font-bold text-gray-900 dark:text-white truncate",children:"Appointments"})]}),(0,a.jsx)("p",{className:"mt-1 sm:mt-2 text-sm sm:text-base text-gray-600 dark:text-gray-400",children:"Manage your meetings and appointments"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[(0,a.jsxs)(d.$,{variant:"outline",size:"sm",onClick:()=>{ep("Refresh requested"),eg()},className:"flex items-center gap-2",title:"Refresh list",children:[(0,a.jsx)(w.A,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Refresh"})]}),eu&&(0,a.jsxs)(d.$,{onClick:()=>e.push("/dashboard/appointments/create"),className:"flex items-center gap-2 w-full sm:w-auto",children:[(0,a.jsx)(v.A,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:"Add Appointment"}),(0,a.jsx)("span",{className:"sm:hidden",children:"Add"})]})]})]})})]}),z&&(0,a.jsx)(m.F,{variant:"danger",className:"mb-4 sm:mb-6",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-medium",children:"Error"}),(0,a.jsx)("p",{className:"text-sm break-words",children:z})]})}),V.size>0&&(0,a.jsx)(c.Zp,{className:"mb-4 sm:mb-6",children:(0,a.jsx)("div",{className:"p-4",children:(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row items-center justify-between gap-3",children:[(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsxs)("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[V.size," item",1!==V.size?"s":""," selected"]})}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2 w-full sm:w-auto",children:[ex&&(0,a.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,a.jsxs)("select",{value:et,onChange:e=>ea(e.target.value),className:"px-3 py-2 border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-gray-900 dark:focus:ring-white focus:border-transparent text-sm min-w-[140px]",title:"Applies to appointments only",children:[(0,a.jsx)("option",{value:"",children:"Select Status (appointments only)"}),(0,a.jsx)("option",{value:"scheduled",children:"Scheduled"}),(0,a.jsx)("option",{value:"confirmed",children:"Confirmed"}),(0,a.jsx)("option",{value:"completed",children:"Completed"}),(0,a.jsx)("option",{value:"cancelled",children:"Cancelled"}),(0,a.jsx)("option",{value:"rescheduled",children:"Rescheduled"}),(0,a.jsx)("option",{value:"no_show",children:"No Show"})]}),(0,a.jsxs)(d.$,{variant:"outline",size:"sm",onClick:()=>ex?et?0===V.size?void P("Please select at least one appointment"):void(em({title:"Update Appointment Status",message:"Are you sure you want to update ".concat(V.size,' appointment(s) to "').concat({scheduled:"Scheduled",confirmed:"Confirmed",completed:"Completed",cancelled:"Cancelled",rescheduled:"Rescheduled",no_show:"No Show"}[et],'" status?'),onConfirm:eC,type:"warning",confirmText:"Update",cancelText:"Cancel"}),ec(!0)):void P("Please select a status before applying the update"):void P("You don't have permission to update appointment statuses"),loading:ee,disabled:!et,className:"text-sm flex items-center gap-2",children:[(0,a.jsx)(p.A,{className:"w-4 h-4"}
1),"Update Status"]})]}),(0,a.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,a.jsx)(d.$,{variant:"outline",size:"sm",onClick:()=>{W(new Set)},className:"text-sm",children:"Clear"}),eh&&(0,a.jsxs)(d.$,{variant:"danger",size:"sm",onClick:()=>eh?0===V.size?void P("Please select at least one appointment"):void(em({title:"Delete selected",message:"Are you sure you want to delete ".concat(V.size," item(s)? This applies to both appointments and bookings and cannot be undone."),onConfirm:eA,type:"danger",confirmText:"Delete",cancelText:"Cancel"}),ec(!0)):void P("You don't have permission to delete appointments"),loading:H,className:"text-sm flex items-center gap-2",children:[(0,a.jsx)(N.A,{className:"w-4 h-4"}),"Delete Selected"]})]})]})]})})}),(0,a.jsx)(c.Zp,{className:"mb-4 sm:mb-6",children:(0,a.jsx)("div",{className:"p-4 sm:p-6",children:(0,a.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[(0,a.jsxs)("div",{className:"relative sm:col-span-2 lg:col-span-1",children:[(0,a.jsx)(k.A,{className:"absolute left-4 top-1/2 transform -translate-y-1/2 h-5 w-5 text-gray-400"}),(0,a.jsx)("input",{type:"text",placeholder:"Search appointments...",value:$,onChange:e=>U(e.target.value),className:"w-full pl-12 pr-4 py-3 border border-gray-200 dark:border-gray-600 rounded-xl bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-gray-900 dark:focus:ring-white focus:border-transparent h-12"})]}),(0,a.jsxs)("select",{value:O,onChange:e=>F(e.target.value),className:"px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-xl bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-gray-900 dark:focus:ring-white focus:border-transparent min-w-[140px] w-full",children:[(0,a.jsx)("option",{value:"all",children:"All Status"}),(0,a.jsx)("option",{value:"scheduled",children:"Scheduled"}),(0,a.jsx)("option",{value:"confirmed",children:"Confirmed"}),(0,a.jsx)("option",{value:"completed",children:"Completed"}),(0,a.jsx)("option",{value:"cancelled",children:"Cancelled"}),(0,a.jsx)("option",{value:"rescheduled",children:"Rescheduled"}),(0,a.jsx)("option",{value:"no_show",children:"No Show"})]}),(0,a.jsxs)("select",{value:R,onChange:e=>I(e.target.value),className:"px-4 py-3 border border-gray-200 dark:border-gray-600 rounded-xl bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-gray-900 dark:focus:ring-white focus:border-transparent min-w-[140px] w-full",children:[(0,a.jsx)("option",{value:"all",children:"All Types"}),(0,a.jsx)("option",{value:"consultation",children:"Consultation"}),(0,a.jsx)("option",{value:"follow_up",children:"Follow Up"}),(0,a.jsx)("option",{value:"presentation",children:"Presentation"}),(0,a.jsx)("option",{value:"demo",children:"Demo"}),(0,a.jsx)("option",{value:"meeting",children:"Meeting"}),(0,a.jsx)("option",{value:"call",children:"Call"}),(0,a.jsx)("option",{value:"other",children:"Other"})]})]})})}),E?(0,a.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,a.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"})}):0===_.length?(0,a.jsx)(c.Zp,{children:(0,a.jsxs)("div",{className:"p-12 text-center",children:[(0,a.jsx)(y.A,{className:"h-16 w-16 mx-auto mb-4 text-gray-400"}),(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"No appointments found"}),(0,a.jsx)("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:$||"all"!==O||"all"!==R?"Try adjusting your filters to see more appointments.":"Get started by scheduling your first appointment."}),eu&&(0,a.jsxs)(d.$,{onClick:()=>e.push("/dashboard/appointments/create"),className:"flex items-center gap-2 mx-auto",children:[(0,a.jsx)(v.A,{className:"h-4 w-4"}),"Add Appointment"]})]})}):(0,a.jsxs)(c.Zp,{children:[(0,a.jsx)("div",{className:"hidden md:block overflow-x-auto rounded-xl ",children:(0,a.jsxs)("table",{className:"w-full",children:[(0,a.jsx)("thead",{className:"bg-gray-50 dark:bg-gray-800",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider w-12",children:(0,a.jsx)("input",{type:"checkbox",checked:_.length>0&&_.every(e=>
1V.has(e._id)),onChange:()=>{let e=_.map(e=>e._id);0!==e.length&&(V.size===e.length?(W(new Set),ep("Selection cleared")):(W(new Set(e)),ep("Selected all",e.length,"items")))},className:"w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500",title:"Select all on this page"})}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Appointment"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Contact"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Scheduled"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Status"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Assigned To"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"Actions"})]})}),(0,a.jsx)("tbody",{className:"bg-white  dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700",children:_.map(s=>{var t,r,n,l,i,c;return(0,a.jsxs)("tr",{className:"hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors duration-200",children:[(0,a.jsx)("td",{className:"py-4 whitespace-nowrap",children:(0,a.jsx)("input",{type:"checkbox",checked:V.has(s._id),onChange:()=>ek(s._id),className:"w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500","aria-label":"booking"===s.source?"Select booking":"Select appointment"})}),(0,a.jsx)("td",{className:"py-4 whitespace-nowrap",children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"flex-shrink-0 h-10 w-10",children:(0,a.jsx)("div",{className:"h-10 w-10 rounded-lg bg-blue-100 dark:bg-blue-900 flex items-center justify-center",children:(0,a.jsx)(y.A,{className:"h-5 w-5 text-blue-600 dark:text-blue-400"})})}),(0,a.jsxs)("div",{className:"ml-4",children:[(0,a.jsx)("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:s.type.replace("_"," ")}),(0,a.jsx)("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:(0,a.jsx)(o.E,{variant:ej(s.type),children:s.type.replace("_"," ")})})]})]})}),(0,a.jsxs)("td",{className:"py-4 whitespace-nowrap",children:[(0,a.jsx)("div",{className:"text-sm text-gray-900 dark:text-white",children:(null==(t=s.leadId)?void 0:t.name)||(null==(r=s.clientId)?void 0:r.companyName)||"N/A"}),(0,a.jsx)("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:(null==(n=s.leadId)?void 0:n.email)||(null==(l=s.clientId)?void 0:l.contactPerson)||"N/A"})]}),(0,a.jsxs)("td",{className:"py-4 whitespace-nowrap",children:[(0,a.jsx)("div",{className:"text-sm text-gray-900 dark:text-white",children:ew(s.scheduledDate)}),(0,a.jsxs)("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:[s.duration," minutes"]}),eN(s.scheduledDate,s.status)&&(0,a.jsx)("div",{className:"text-xs text-red-600 font-medium",children:"Overdue"}),ev(s.scheduledDate,s.status)&&(0,a.jsx)("div",{className:"text-xs text-green-600 font-medium",children:"Upcoming"})]}),(0,a.jsx)("td",{className:"py-4 whitespace-nowrap",children:(0,a.jsxs)(o.E,{variant:eb(s.status),className:"flex items-center gap-1",children:[ey(s.status),s.status.replace("_"," ")]})}),(0,a.jsxs)("td",{className:"py-4 whitespace-nowrap",children:[(0,a.jsx)("div",{className:"text-sm text-gray-900 dark:text-white",children:(null==(i=s.assignedTo)?void 0:i.name)||"Unassigned"}),(0,a.jsx)("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:(null==(c=s.assignedTo)?void 0:c.email)||""})]}),(0,a.jsx)("td",{className:"py-4 whitespace-nowrap text-sm font-medium",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(d.$,{onClick:()=>e.push("booking"===s.source?"/dashboard/appointments/view/".concat(s._id,"?source=booking"):"/dashboard/appointments/view/".concat(s._id)),variant:"ghost",size:"sm",children:(0,a.jsx)(A.A,{className:"h-4 w-4"})}),eu&&!s.source&&(0,a.jsx)(d.$,{onClick:()=>e.push("/dashboard/appointments/edit/".concat(s._id)),variant:"ghost",size:"sm",children:(0,a.jsx)(C.A,{className:"h-4 w-4"})}),eh&&(0,a.jsx)(d.$,{onClick:()=>{J(s),q(!0)},variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"booking"===s.source?"Delete booking":"Delete appointment",children:(0,a.jsx)(N.A,{className:"h-4 w-4"})})]})})]},s._id)})})]})}),(0,a.jsx)("div",{className:"md:hidden space-y-4",children:_.map(s=>{var t,r,n;return(0,a.jsxs)("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between mb-3",children:[(0,a.jsx)("input",{type:"checkbox",checked:V.has(s._id),onChange:()=>ek(s._id),className:"w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500 flex-shrink-0 mt-1 mr-2","aria-label":"booking"===s.source?"Select booking":"Select appointment"}),(0,a.jsxs)("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"h-10 w-10 rounded-lg bg-blue-100 dar
1k:bg-blue-900 flex items-center justify-center flex-shrink-0",children:(0,a.jsx)(y.A,{className:"h-5 w-5 text-blue-600 dark:text-blue-400"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("h3",{className:"font-medium text-gray-900 dark:text-white truncate",children:s.type.replace("_"," ")}),(0,a.jsx)(o.E,{variant:ej(s.type),className:"text-xs",children:s.type.replace("_"," ")})]})]}),(0,a.jsxs)(o.E,{variant:eb(s.status),className:"flex items-center gap-1 flex-shrink-0",children:[ey(s.status),(0,a.jsx)("span",{className:"hidden xs:inline",children:s.status.replace("_"," ")})]})]}),(0,a.jsxs)("div",{className:"space-y-2 text-sm text-gray-600 dark:text-gray-400 mb-4",children:[(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)("span",{className:"font-medium flex-shrink-0",children:"Contact:"}),(0,a.jsx)("span",{className:"break-words",children:(null==(t=s.leadId)?void 0:t.name)||(null==(r=s.clientId)?void 0:r.companyName)||"N/A"})]}),(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)("span",{className:"font-medium flex-shrink-0",children:"Scheduled:"}),(0,a.jsx)("span",{className:"break-words",children:ew(s.scheduledDate)})]}),(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)("span",{className:"font-medium flex-shrink-0",children:"Duration:"}),(0,a.jsxs)("span",{children:[s.duration," minutes"]})]}),(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)("span",{className:"font-medium flex-shrink-0",children:"Assigned to:"}),(0,a.jsx)("span",{className:"break-words",children:(null==(n=s.assignedTo)?void 0:n.name)||"Unassigned"})]}),eN(s.scheduledDate,s.status)&&(0,a.jsx)("div",{className:"text-red-600 font-medium",children:"Overdue"}),ev(s.scheduledDate,s.status)&&(0,a.jsx)("div",{className:"text-green-600 font-medium",children:"Upcoming"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(d.$,{onClick:()=>e.push("booking"===s.source?"/dashboard/appointments/view/".concat(s._id,"?source=booking"):"/dashboard/appointments/view/".concat(s._id)),variant:"ghost",size:"sm",className:"flex-1",children:[(0,a.jsx)(A.A,{className:"h-4 w-4 mr-2"}),"View"]}),eu&&!s.source&&(0,a.jsxs)(d.$,{onClick:()=>e.push("/dashboard/appointments/edit/".concat(s._id)),variant:"ghost",size:"sm",className:"flex-1",children:[(0,a.jsx)(C.A,{className:"h-4 w-4 mr-2"}),"Edit"]}),eh&&(0,a.jsx)(d.$,{onClick:()=>{J(s),q(!0)},variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:"booking"===s.source?"Delete booking":"Delete appointment",children:(0,a.jsx)(N.A,{className:"h-4 w-4"})})]})]},s._id)})}),B>1&&(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-center gap-4 pt-6 border-t border-gray-200 dark:border-gray-700 px-4 sm:px-6",children:[(0,a.jsxs)("div",{className:"text-sm text-gray-600 dark:text-gray-400 text-center sm:text-left",children:["Page ",L," of ",B]}),(0,a.jsxs)("div",{className:"flex gap-2 justify-center sm:justify-end",children:[(0,a.jsx)(d.$,{onClick:()=>M(e=>Math.max(1,e-1)),disabled:1===L,variant:"outline",size:"sm",className:"px-3 py-2 rounded-lg flex-1 sm:flex-none",children:"Previous"}),(0,a.jsx)(d.$,{onClick:()=>M(e=>Math.min(B,e+1)),disabled:L===B,variant:"outline",size:"sm",className:"px-3 py-2 rounded-lg flex-1 sm:flex-none",children:"Next"})]})]})]}),(0,a.jsx)(u.A,{isOpen:er,onClose:()=>en(!1),type:el.type,title:el.title,message:el.message}),(0,a.jsx)(h.A,{isOpen:ed,onClose:()=>{ec(!1)},onConfirm:()=>{eo.onConfirm&&eo.onConfirm()},title:eo.title,message:eo.message,type:eo.type,confirmText:eo.confirmText,cancelText:eo.cancelText,loading:H||ee}),Y&&(0,a.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:(0,a.jsx)(c.Zp,{className:"w-full max-w-md",children:(0,a.jsxs)("div",{className:"p-4 sm:p-6",children:[(0,a.jsxs)("div",{className:"flex items-start gap-3 mb-4",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)(j.A,{className:"h-6 w-6 text-red-600"})}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:(null==G?void 0:G.source)==="booking"?"Delete booking":"Delete appointment"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400 break-words",children:"This action cannot be undone."})]})]}),(0,a.jsxs)("p",{className:"text-gray-700 dark:text-gray-300 mb-6 break-words",children:["Are you sure you want to delete this ",(null==G?void 0:G.source)==="booking"?"booking":"appointment","? All associated data will be permanently removed."]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-3",children:[(0,a.jsx)(d.$,{variant:"danger",onClick:ef,disabled:X,className:"flex-1",children:X?"Deleting...":"Delete"}),(0,a.jsx)(d.$,{variant:"ghost",onClick:()=>{q(!1),J(null)},className:"flex-1",children:"Cancel"})]})]})})})]})}):(0,a.jsx)(i.A,{children:(0,a.jsx)("div",{className:"space-y-6 mt-2 mb-2",children:(0,a.jsx)(x.A,{title:"Access Denied",message:"You don't have permission to access the appointments section.",requiredRoles:"Admin, Manager, Project Manager, or Operative",redirectPath:"/dashboard",redirectText:"Back to Dashboard"})})}):(0,a.jsx)(i.A,{children:(0,a.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)(j.A,{className:"h-16 w-16 mx-auto mb-4 text-yellow-600"}),(0,a.jsx)("h2",{className:"text-2xl font-bold mb-2 text-gray-900",children:"Authentication Required"}),(0,a.jsx)("p",{className:"mb-6 text-gray-600",children:"Please login to view this page."}),(0,a.jsx)("button",{onClick:()=>
1e.push("/auth/login"),className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700",children:"Go to Login"})]})})})}},98999:(e,s,t)=>{"use strict";t.d(s,{A:()=>d});var a=t(37876);t(14232);var r=t(96668),n=t(3244),l=t(63393),i=t(986);function d(e){let{isOpen:s,onClose:t,title:d,message:c,type:o="success"}=e;return s?(0,a.jsx)("div",{className:"fixed inset-0 bg-black/50 dark:bg-black/70 z-50 flex justify-center items-center backdrop-blur-sm",onClick:t,children:(0,a.jsxs)("div",{className:"w-[90%] max-w-md transform transition-all duration-300 scale-100 ".concat((()=>{switch(o){case"success":return"bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-800";case"error":return"bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800";case"warning":return"bg-yellow-50 dark:bg-yellow-900/20 border-yellow-200 dark:border-yellow-800";default:return"bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-800"}})()," rounded-xl shadow-xl border overflow-hidden"),onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("div",{className:"px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(()=>{switch(o){case"success":return(0,a.jsx)(r.A,{className:"h-6 w-6 text-green-600 dark:text-green-400"});case"error":return(0,a.jsx)(n.A,{className:"h-6 w-6 text-red-600 dark:text-red-400"});case"warning":return(0,a.jsx)(l.A,{className:"h-6 w-6 text-yellow-600 dark:text-yellow-400"});default:return(0,a.jsx)(i.A,{className:"h-6 w-6 text-blue-600 dark:text-blue-400"})}})(),(0,a.jsx)("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:d||("success"===o?"Success":"error"===o?"Error":"warning"===o?"Warning":"Information")})]})}),(0,a.jsx)("div",{className:"px-6 py-4",children:(0,a.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:c})}),(0,a.jsx)("div",{className:"px-6 py-4 bg-gray-50 dark:bg-gray-800/50 flex justify-end",children:(0,a.jsx)("button",{onClick:t,className:"px-4 py-2 text-sm font-medium text-white rounded-lg transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 ".concat((()=>{switch(o){case"success":return"bg-green-600 hover:bg-green-700 dark:bg-green-700 dark:hover:bg-green-800 focus:ring-green-500";case"error":return"bg-red-600 hover:bg-red-700 dark:bg-red-700 dark:hover:bg-red-800 focus:ring-red-500";case"warning":return"bg-yellow-600 hover:bg-yellow-700 dark:bg-yellow-700 dark:hover:bg-yellow-800 focus:ring-yellow-500";default:return"bg-blue-600 hover:bg-blue-700 dark:bg-blue-700 dark:hover:bg-blue-800 focus:ring-blue-500"}})()),children:"OK"})})]})}):null}}},e=>{e.O(0,[4938,7725,7804,7421,9588,3455,6282,636,6593,8792],()=>e(e.s=45937)),_N_E=e.O()}]);

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.