1/*! For license information please see 1376.9ec3e8d8.chunk.js.LICENSE.txt */ 2"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[1376],{1360(e,t,s){s.d(t,{A:()=>a});const a=(0,s(7784).A)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},1376(e,t,s){s.r(t),s.d(t,{default:()=>F});var a=s(9379),l=s(5043),c=s(9970),r=s(1140),n=s(3390),d=s(2264),i=s(9938),o=s(5949),h=s(4370),m=s(5598),x=s(7719),u=s(4459),p=s(2024),j=s(1360),g=s(8646),N=s(2054),f=s(7784);const y=(0,f.A)("list",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]),b=(0,f.A)("calendar-days",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]),v=(0,f.A)("grid-3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);var w=s(9463),A=s(8326),D=s(8006),k=s(6533),M=s(2313),C=s(9855),S=s(614),_=s(8693),E=s(6328),z=s(579);const F=()=>{const[e,t]=(0,l.useState)([]),[s,f]=(0,l.useState)([]),[F,L]=(0,l.useState)(!0),[R,B]=(0,l.useState)(!1),[J,T]=(0,l.useState)(null),[Y,I]=(0,l.useState)(!1),[U,W]=(0,l.useState)("list"),[$,Z]=(0,l.useState)(new Date),[q,V]=(0,l.useState)({course_id:"",date:"",module:"",day:"",tutor:"Dr. Gaurav Mehta",location:"",hands_on_materials:"",clinical_mentoring:"No",batch:"",status:"scheduled"}),P=(0,l.useMemo)(()=>{const t=[];for(let s=0;s<e.length;s++)for(let a=s+1;a<e.length;a++){const l=e[s],c=e[a];l.date===c.date&&"cancelled"!==l.status&&"cancelled"!==c.status&&(l.tutor&&c.tutor&&l.tutor.toLowerCase()===c.tutor.toLowerCase()?t.push({a:l,b:c,reason:"Same tutor"}):l.location&&c.location&&l.location.toLowerCase()===c.location.toLowerCase()&&t.push({a:l,b:c,reason:"Same location"}))}return t},[e]),O=(0,l.useMemo)(()=>{const t={};return e.forEach(e=>{const s=e.date;t[s]||(t[s]=[]),t[s].push(e)}),t},[e]),G=(0,l.useMemo)(()=>{const e=new Set;return P.forEach(t=>e.add(t.a.date)),e},[P]),H=async()=>{try{const e=localStorage.getItem("elevate360_token"),s={Authorization:"Bearer ".concat(e)},a=await fetch("".concat("https://plant4growthuk-production-a1cd.up.railway.app","/api/course-schedule/admin/all"),{headers:s}),l=await a.json();t(l.schedules||[]);const c=await fetch("".concat("https://plant4growthuk-production-a1cd.up.railway.app","/api/courses/"),{headers:s}),r=await c.json();f(r||[])}catch(e){console.error("Failed to fetch data:",e),E.oR.error("Failed to load schedule data")}finally{L(!1)}};(0,l.useEffect)(()=>{H()},[]);const K=()=>{V({course_id:"",date:"",module:"",day:"",tutor:"Dr. Gaurav Mehta",location:"",hands_on_materials:"",clinical_mentoring:"No",batch:"",status:"scheduled"}),T(null)},Q=()=>{K(),B(!0)},X=e=>{T(e),V({course_id:e.course_id||"",date:e.date||"",module:e.module||"",day:e.day||"",tutor:e.tutor||"Dr. Gaurav Mehta",location:e.location||"",hands_on_materials:e.hands_on_materials||"",clinical_mentoring:e.clinical_mentoring||"No",batch:e.batch||"",status:e.status||"scheduled"}),B(!0)},ee=e=>{switch(e){case"upcoming":return(0,z.jsx)(o.E,{className:"bg-blue-100 text-blue-700",children:"Upcoming"});case"scheduled":return(0,z.jsx)(o.E,{className:"bg-amber-100 text-amber-700",children:"Scheduled"});case"completed":return(0,z.jsx)(o.E,{className:"bg-emerald-100 text-emerald-700",children:"Completed"});case"cancelled":return(0,z.jsx)(o.E,{className:"bg-red-100 text-red-700",children:"Cancelled"});default:return(0,z.jsx)(o.E,{className:"bg-slate-100 text-slate-700",children:e})}},te=e=>{const t=e.getFullYear(),s=e.getMonth(),a=new Date(t,s,1);return{daysInMonth:new Date(t,s+1,0).getDate(),startingDay:a.getDay(),year:t,month:s}},se=e=>{const t=e.getDay(),s=e.getDate()-t,a=new Date(e);a.setDate(s);const l=[];for(let c=0;c<7;c++){const e=new Date(a);e.setDate(a.getDate()+c),l.push(e)}return l},ae=e=>e.toISOString().split("T")[0],le=e=>{const t=new Date($);"month"===U?t.setMonth(t.getMonth()+e):"week"===U?t.setDate(t.getDate()+7*e):"year"===U&&t.setFullYear(t.getFullYear()+e),Z(t)},ce=e=>{const t=ae(e);return O[t]||[]},re=e=>{const t=ae(e);return G.has(t)},ne=function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const s=ce(e),a=re(e),l=ae(e)===ae(new Date),c=e.getDate();return(0,z.jsxs)("div",{className:"min-h-[100px] border border-slate-200 p-1 ".concat(t?"bg-white":"bg-slate-50 opacity-50"," ").concat(l?"ring-2 ring-[#41EAD4] ring-inset":""," ").concat(a?"bg-red-50":""),children:[(0,z.jsxs)("div",{className:"text-xs font-medium mb-1 ".concat(l?"text-[#41EAD4]":"text-slate-600"),children:[c,a&&(0,z.jsx)(x.A,{className:"w-3 h-3 text-red-500
2inline ml-1",title:"Overlap detected"})]}),(0,z.jsxs)("div",{className:"space-y-1 max-h-[80px] overflow-y-auto",children:[s.slice(0,3).map((e,t)=>{var s;return(0,z.jsx)("div",{onClick:()=>X(e),className:"text-[10px] px-1 py-0.5 rounded truncate cursor-pointer hover:opacity-80 ".concat("completed"===e.status?"bg-emerald-100 text-emerald-700":"cancelled"===e.status?"bg-red-100 text-red-700":"upcoming"===e.status?"bg-blue-100 text-blue-700":"bg-amber-100 text-amber-700"),title:"".concat(e.course_title||"Course"," - ").concat(e.module),children:(null===(s=e.course_title)||void 0===s?void 0:s.substring(0,15))||e.module},e.schedule_id||t)}),s.length>3&&(0,z.jsxs)("div",{className:"text-[10px] text-slate-500 px-1",children:["+",s.length-3," more"]})]})]},ae(e))};return F?(0,z.jsx)(c.NI,{children:(0,z.jsx)("div",{className:"flex items-center justify-center h-64",children:(0,z.jsx)(p.A,{className:"w-8 h-8 animate-spin text-[#41EAD4]"})})}):(0,z.jsx)(c.NI,{children:(0,z.jsxs)("div",{className:"space-y-6","data-testid":"admin-course-schedule",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h1",{className:"text-2xl font-bold text-[#0D1B2A]",children:"Course Schedule"}),(0,z.jsx)("p",{className:"text-slate-500",children:"Manage training sessions and schedule"})]}),(0,z.jsxs)(n.$,{onClick:Q,className:"bg-[#41EAD4] hover:bg-[#35c4b0] text-[#0D1B2A]","data-testid":"add-schedule-btn",children:[(0,z.jsx)(j.A,{className:"w-4 h-4 mr-2"}),"Add Session"]})]}),(0,z.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[(0,z.jsx)(r.Zp,{className:"border-slate-100",children:(0,z.jsx)(r.Wu,{className:"pt-6",children:(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("p",{className:"text-sm text-slate-500",children:"Total Sessions"}),(0,z.jsx)("p",{className:"text-2xl font-bold text-[#0D1B2A]",children:e.length})]}),(0,z.jsx)(g.A,{className:"w-8 h-8 text-[#41EAD4]"})]})})}),(0,z.jsx)(r.Zp,{className:"border-slate-100",children:(0,z.jsx)(r.Wu,{className:"pt-6",children:(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("p",{className:"text-sm text-slate-500",children:"Upcoming"}),(0,z.jsx)("p",{className:"text-2xl font-bold text-blue-600",children:e.filter(e=>"upcoming"===e.status).length})]}),(0,z.jsx)("div",{className:"w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center",children:(0,z.jsx)(g.A,{className:"w-4 h-4 text-blue-600"})})]})})}),(0,z.jsx)(r.Zp,{className:"border-slate-100",children:(0,z.jsx)(r.Wu,{className:"pt-6",children:(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("p",{className:"text-sm text-slate-500",children:"Scheduled"}),(0,z.jsx)("p",{className:"text-2xl font-bold text-amber-600",children:e.filter(e=>"scheduled"===e.status).length})]}),(0,z.jsx)("div",{className:"w-8 h-8 bg-amber-100 rounded-full flex items-center justify-center",children:(0,z.jsx)(g.A,{className:"w-4 h-4 text-amber-600"})})]})})}),(0,z.jsx)(r.Zp,{className:"border-slate-100",children:(0,z.jsx)(r.Wu,{className:"pt-6",children:(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("p",{className:"text-sm text-slate-500",children:"Completed"}),(0,z.jsx)("p",{className:"text-2xl font-bold text-emerald-600",children:e.filter(e=>"completed"===e.status).length})]}),(0,z.jsx)("div",{className:"w-8 h-8 bg-emerald-100 rounded-full flex items-center justify-center",children:(0,z.jsx)(N.A,{className:"w-4 h-4 text-emerald-600"})})]})})}),(0,z.jsx)(r.Zp,{className:"border-slate-100 ".concat(P.length>0?"border-red-300 bg-red-50":""),children:(0,z.jsx)(r.Wu,{className:"pt-6",children:(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("p",{className:"text-sm text-slate-500",children:"Overlaps"}),(0,z.jsx)("p",{className:"text-2xl font-bold ".concat(P.length>0?"text-red-600":"text-slate-400"),children:P.length})]}),(0,z.jsx)("div",{className:"w-8 h-8 ".concat(P.length>0?"bg-red-100":"bg-slate-100"," rounded-full flex items-center justify-center"),children:(0,z.jsx)(x.A,{className:"w-4 h-4 ".concat(P.length>0?"text-red-600":"text-slate-400")})})]})})})]}),P.length>0&&(0,z.jsx)(r.Zp,{className:"border-red-300 bg-red-50",children:(0,z.jsx)(r.Wu,{className:"pt-4 pb-4",children:(0,z.jsxs)("div",{className:"flex items-start gap-3",children:[(0,z.jsx)(x.A,{className:"w-5 h-5 text-red-600 mt-0.5"}),(0,z.jsxs)("div",{children:[(0,z.jsx)("h3",{className:"font-semibold text-red-800 mb
2-2",children:"Schedule Conflicts Detected"}),(0,z.jsxs)("div",{className:"space-y-2",children:[P.slice(0,5).map((e,t)=>(0,z.jsxs)("div",{className:"text-sm text-red-700 flex items-center gap-2",children:[(0,z.jsxs)("span",{className:"font-medium",children:[new Date(e.a.date).toLocaleDateString("en-GB",{day:"2-digit",month:"short"}),":"]}),(0,z.jsxs)("span",{children:['"',e.a.course_title||e.a.module,'" and "',e.b.course_title||e.b.module,'"']}),(0,z.jsx)(o.E,{className:"bg-red-200 text-red-800 text-[10px]",children:e.reason})]},t)),P.length>5&&(0,z.jsxs)("p",{className:"text-sm text-red-600",children:["...and ",P.length-5," more conflicts"]})]})]})]})})}),(0,z.jsx)(r.Zp,{className:"border-slate-100",children:(0,z.jsx)(r.Wu,{className:"pt-4 pb-4",children:(0,z.jsxs)("div",{className:"flex flex-col md:flex-row items-center justify-between gap-4",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2 bg-slate-100 p-1 rounded-lg",children:[(0,z.jsxs)(n.$,{variant:"list"===U?"default":"ghost",size:"sm",onClick:()=>W("list"),className:"list"===U?"bg-white shadow-sm":"",children:[(0,z.jsx)(y,{className:"w-4 h-4 mr-1"}),"List"]}),(0,z.jsxs)(n.$,{variant:"week"===U?"default":"ghost",size:"sm",onClick:()=>W("week"),className:"week"===U?"bg-white shadow-sm":"",children:[(0,z.jsx)(b,{className:"w-4 h-4 mr-1"}),"Week"]}),(0,z.jsxs)(n.$,{variant:"month"===U?"default":"ghost",size:"sm",onClick:()=>W("month"),className:"month"===U?"bg-white shadow-sm":"",children:[(0,z.jsx)(v,{className:"w-4 h-4 mr-1"}),"Month"]}),(0,z.jsxs)(n.$,{variant:"year"===U?"default":"ghost",size:"sm",onClick:()=>W("year"),className:"year"===U?"bg-white shadow-sm":"",children:[(0,z.jsx)(g.A,{className:"w-4 h-4 mr-1"}),"Year"]})]}),"list"!==U&&(0,z.jsxs)("div",{className:"flex items-center gap-3",children:[(0,z.jsx)(n.$,{variant:"outline",size:"sm",onClick:()=>le(-1),children:(0,z.jsx)(w.A,{className:"w-4 h-4"})}),(0,z.jsx)("span",{className:"text-sm font-medium text-[#0D1B2A] min-w-[180px] text-center",children:(()=>{const e={month:"long",year:"numeric"};if("month"===U)return $.toLocaleDateString("en-US",e);if("week"===U){const e=se($),t=e[0],s=e[6];return"".concat(t.toLocaleDateString("en-US",{month:"short",day:"numeric"})," - ").concat(s.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}))}return"year"===U?$.getFullYear().toString():""})()}),(0,z.jsx)(n.$,{variant:"outline",size:"sm",onClick:()=>le(1),children:(0,z.jsx)(A.A,{className:"w-4 h-4"})}),(0,z.jsx)(n.$,{variant:"outline",size:"sm",onClick:()=>{Z(new Date)},children:"Today"})]})]})})}),"month"===U&&(()=>{const{daysInMonth:e,startingDay:t,year:s,month:a}=te($),l=[],c=new Date(s,a,0).getDate();for(let n=t-1;n>=0;n--){const e=new Date(s,a-1,c-n);l.push(ne(e,!1))}for(let n=1;n<=e;n++){const e=new Date(s,a,n);l.push(ne(e,!0))}const r=42-l.length;for(let n=1;n<=r;n++){const e=new Date(s,a+1,n);l.push(ne(e,!1))}return(0,z.jsxs)("div",{className:"bg-white rounded-lg border border-slate-200",children:[(0,z.jsx)("div",{className:"grid grid-cols-7 border-b border-slate-200",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(e=>(0,z.jsx)("div",{className:"p-2 text-center text-xs font-semibold text-slate-600 bg-slate-50",children:e},e))}),(0,z.jsx)("div",{className:"grid grid-cols-7",children:l})]})})(),"week"===U&&(()=>{const e=se($),t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return(0,z.jsx)("div",{className:"bg-white rounded-lg border border-slate-200",children:(0,z.jsx)("div",{className:"grid grid-cols-7",children:e.map((e,s)=>{const a=ce(e),l=re(e),c=ae(e)===ae(new Date);return(0,z.jsxs)("div",{className:"min-h-[300px] border-r border-slate-200 last:border-r-0 ".concat(c?"bg-[#41EAD4]/5":""," ").concat(l?"bg-red-50":""),children:[(0,z.jsxs)("div",{className:"p-2 text-center border-b border-slate-200 ".concat(c?"bg-[#41EAD4]/10":"bg-slate-50"),children:[(0,z.jsx)("div",{className:"text-xs text-slate-500",children:t[s]}),(0,z.jsx)("div",{className:"text-lg font-semibold ".concat(c?"text-[#41EAD4]":"text-[#0D1B2A]"),children:e.getDate()}),l&&(0,z.jsx)(x.A,{className:"w-4 h-4 text-red-500 mx-auto"})]}),(0,z.jsx)("div",{className:"p-2 space-y-2",children:a.map((e,t)=>(0,z.jsxs)("div",{onClick:()=>X(e),className:"p-2 rounded text-xs cursor-pointer hover:shadow-md transition-shadow ".concat("completed"===e.status?"bg-emerald-100 text-emerald-700 border-l-2 border-emerald-500":"cancelled"===e.status?"bg-red-100 text-red-700 border-l-2 border-red-500":"upcoming"===e.status?"bg-blue-100 text-blue-700 border-l-2 border-blue-500":"bg-amber-100 text-amber-700 border-l-2 border-amber-500"),
2children:[(0,z.jsx)("div",{className:"font-medium truncate",children:e.course_title||"Course"}),(0,z.jsxs)("div",{className:"text-[10px] opacity-75",children:[e.module," - ",e.day]}),(0,z.jsxs)("div",{className:"text-[10px] opacity-75 flex items-center gap-1 mt-1",children:[(0,z.jsx)(u.A,{className:"w-2 h-2"})," ",e.tutor]})]},e.schedule_id||t))})]},s)})})})})(),"year"===U&&(()=>{const t=(e=>{const t=e.getFullYear();return Array.from({length:12},(e,s)=>new Date(t,s,1))})($),s=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return(0,z.jsx)("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-4",children:t.map((t,a)=>{const{daysInMonth:l,startingDay:c}=te(t),n=e.filter(e=>{const s=new Date(e.date);return s.getMonth()===a&&s.getFullYear()===t.getFullYear()}),d=P.filter(e=>{const s=new Date(e.a.date);return s.getMonth()===a&&s.getFullYear()===t.getFullYear()});return(0,z.jsx)(r.Zp,{className:"border-slate-200 cursor-pointer hover:shadow-md transition-shadow ".concat(d.length>0?"border-red-300 bg-red-50/50":""),onClick:()=>{Z(t),W("month")},children:(0,z.jsxs)(r.Wu,{className:"p-3",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,z.jsx)("span",{className:"font-semibold text-[#0D1B2A]",children:s[a]}),(0,z.jsxs)("div",{className:"flex items-center gap-1",children:[n.length>0&&(0,z.jsx)(o.E,{className:"bg-[#41EAD4]/20 text-[#0D1B2A] text-[10px]",children:n.length}),d.length>0&&(0,z.jsx)(x.A,{className:"w-3 h-3 text-red-500",title:"".concat(d.length," overlap(s)")})]})]}),(0,z.jsxs)("div",{className:"grid grid-cols-7 gap-0.5 text-[8px]",children:[["S","M","T","W","T","F","S"].map((e,t)=>(0,z.jsx)("div",{className:"text-center text-slate-400",children:e},t)),Array(c).fill(null).map((e,t)=>(0,z.jsx)("div",{},"empty-".concat(t))),Array.from({length:l},(e,s)=>{const l=new Date(t.getFullYear(),a,s+1),c=ce(l).length>0,r=re(l),n=ae(l)===ae(new Date);return(0,z.jsx)("div",{className:"text-center py-0.5 rounded ".concat(r?"bg-red-400 text-white":c?"bg-[#41EAD4] text-white":n?"ring-1 ring-[#41EAD4]":""),children:s+1},s+1)})]})]})},a)})})})(),"list"===U&&(0,z.jsxs)(r.Zp,{className:"border-slate-100",children:[(0,z.jsx)(r.aR,{className:"pb-3",children:(0,z.jsxs)(r.ZB,{className:"text-lg flex items-center gap-2",children:[(0,z.jsx)(g.A,{className:"w-5 h-5 text-[#41EAD4]"}),"All Sessions"]})}),(0,z.jsx)(r.Wu,{className:"p-0",children:0===e.length?(0,z.jsxs)("div",{className:"text-center py-12",children:[(0,z.jsx)(g.A,{className:"w-12 h-12 text-slate-300 mx-auto mb-4"}),(0,z.jsx)("p",{className:"text-slate-500 mb-4",children:"No schedule entries yet"}),(0,z.jsxs)(n.$,{onClick:Q,variant:"outline",children:[(0,z.jsx)(j.A,{className:"w-4 h-4 mr-2"}),"Add First Session"]})]}):(0,z.jsx)("div",{className:"overflow-x-auto",children:(0,z.jsxs)("table",{className:"w-full","data-testid":"schedule-table",children:[(0,z.jsx)("thead",{children:(0,z.jsxs)("tr",{className:"bg-slate-50 border-y border-slate-200",children:[(0,z.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-600 uppercase",children:"Date"}),(0,z.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-600 uppercase",children:"Course"}),(0,z.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-600 uppercase",children:"Module"}),(0,z.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-600 uppercase",children:"Day"}),(0,z.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-600 uppercase",children:"Tutor"}),(0,z.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-600 uppercase",children:"Location"}),(0,z.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-600 uppercase",children:"Materials"}),(0,z.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-600 uppercase",children:"Mentoring"}),(0,z.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-600 uppercase",children:"Batch"}),(0,z.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-600 uppercase",children:"Status"}),(0,z.jsx)("th",{className:"px-4 py-3 text-left text-xs font-semibold text-slate-600 uppercase",children:"Actions"})]})}),(0,z.jsx)("tbody",{className:"divide-y divide-slate-100",children:e.map(e=>(0,z.jsxs)("tr",{className:"hover:bg-slate-50",children:[(0,z.jsx)("td",{className:"px-4 py-3",children:(0,z.jsx)("span",{className:"text-sm font-medium text-[#0D1B2A]",children:new Date(e.date).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"})})}),(0,z.jsx)("td",{className:"px-4 py-3",children:(0,z.jsx)("span",{className:"text-sm text-slate-600",children:e.course_title||"N/A"})}),(0,z.jsx)("td",{className:"px-4 py-3",children:(0,z.jsx)("span",{className:"text-sm font-medium text-[#0D1B2A]",children:e.module})}),(0,z.jsx)("td",{className:"px-4 py-3",children:(0,z.jsx)("span",{className:"text-sm text-slate-600",children:e.day})}),(0,z.jsx)("td",{className:"px-4 py-3",children:(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)("div",{className:"w-6 h-6 bg-[#0D1B2A] rounded-full flex items-center justify-center",children:(0,z.jsx)(u.A,{className:"w-3 h-3 text-[#41EAD4]"})}),(0,z.jsx)("span",{className:"text-sm text-slate-600",children:e.tutor})]})}),(0,z.jsx)("td",{className:"px-4 py-3",children:(0,z.jsxs)("div",{className:"flex items-center gap-1",children:[(0,z.jsx)(D.A,{className:"w-3 h-3 text-slate-400"}),(0,z.jsx)("span",{className:"text-sm text-slate-600",children:e.location})]})}),(0,z.jsx)("td",{className:"px-4 py-3",children:(0,z.jsx)("span",{className:"text-sm text-slate-600",children:e.hands_on_materials||"N/A"})}),(0,z.jsx)("td",{className:"px-4 py-3",children:(0,z.jsx)("span",{className:"text-sm ".concat("Yes"===e.clinical_mentoring?"text-emerald-600 font-medium":"text-slate-500"),children:e.clinical_mentoring})}),(0,z.jsx)("td",{className:"px-4 py-3",children:(0,z.jsx)("span",{className:"text-sm text-slate-600",children:e.batch})}),(0,z.jsx)("td",{className:"px-4 py-3",children:ee(e.status)}),(0,z.jsx)("td",{className:"px-4 py-3",children:(0,z.jsxs)("div",{className:"flex items-center gap-1",children:[(0,z.jsx)(n.$,{variant:"ghost",size:"sm",onClick:()=>X(e),className:"h-8 w-8 p-0 text-slate-500 hover:text-[#0D1B2A]",title:"Edit",children:(0,z.jsx)(k.A,{className:"w-4 h-4"})}),(0,z.jsx)(n.$,{variant:"ghost",size:"sm",onClick:()=>(e=>{const t=new Date(e.date);t.setDate(t.getDate()+7);const s=parseInt(e.module.replace(/\D/g,""))||1,a=parseInt(e.day.replace(/\D/g,""))||1;V({course_id:e.course_id,date:t.toISOString().split("T")[0],module:"Module ".concat(s+1),day:"Day ".concat(a+1),tutor:e.tutor,location:e.location,hands_on_materials:e.hands_on_materials,clinical_mentoring:e.clinical_mentoring,batch:e.batch,status:"scheduled"}),T(null),B(!0)})(e),className:"h-8 w-8 p-0 text-slate-500 hover:text-blue-600",title:"Duplicate & Add Next",children:(0,z.jsx)(M.A,{className:"w-4 h-4"})}),(0,z.jsx)(n.$,{variant:"ghost",size:"sm",onClick:()=>(async e=>{if(window.confirm("Are you sure you want to delete this schedule entry?"))try{const t=localStorage.getItem("elevate360_token");(await fetch("".concat("https://plant4growthuk-production-a1cd.up.railway.app","/api/course-schedule/admin/").concat(e),{method:"DELETE",headers:{Authorization:"Bearer ".concat(t)}})).ok?(E.oR.success("Schedule deleted"),H()):E.oR.error("Failed to delete schedule")}catch(t){console.error("Delete error:",t),E.oR.error("Failed to delete schedule")}})(e.schedule_id),className:"h-8 w-8 p-0 text-slate-500 hover:text-red-600",title:"Delete",children:(0,z.jsx)(C.A,{className:"w-4 h-4"})})]})})]},e.schedule_id))})]})})})]}),(0,z.jsx)(m.lG,{open:R,onOpenChange:B,children:(0,z.jsxs)(m.Cf,{className:"max-w-2xl",children:[(0,z.jsx)(m.c7,{children:(0,z.jsx)(m.L3,{children:J?"Edit Schedule Entry":"Add New Schedule Entry"})}),(0,z.jsxs)("div",{className:"grid grid-cols-2 gap-4 py-4",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(i.J,{children:"Course *"}),(0,z.jsxs)(h.l6,{value:q.course_id,onValueChange:e=>V((0,a.A)((0,a.A)({},q),{},{course_id:e})),children:[(0,z.jsx)(h.bq,{children:(0,z.jsx)(h.yv,{placeholder:"Select course"})}),(0,z.jsx)(h.gC,{children:s.map(e=>(0,z.jsx)(h.eb,{value:e.course_id,children:e.title},e.course_id))})]})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(i.J,{children:"Date *"}),(0,z.jsx)(d.p,{type:"date",value:q.date,onChange:e=>V((0,a.A)((0,a.A)({},q),{},{date:e.target.value}))})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(i.J,{children:"Module *"}),(0,z.jsx)(d.p,{placeholder:"e.g., Module 1",value:q.module,onChange:e=>V((0,a.A)((0,a.A)({},q),{},{module:e.target.value}))})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(i.J,{children:"Day"}),(0,z.jsx)(d.p,{placeholder:"e.g., Day 1",value:q.day,onChange:e=>V((0,a.A)((0,a.A)({},q),{},{day:e.target.value}))})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(i.J,{children:"Tutor"}),(0,z.jsx)(d.p,{placeholder:"e.g., Dr. Gaurav Mehta",value:q.tutor,onChange:e=>V((0,a.A)((0,a.A)({},q),{},{tutor:e.target.value}))})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(i.J,{children:"Location"}),(0,z.jsx)(d.p,{placeholder:"e.g., London Training Centre",value:q.location,onChange:e=>V((0,a.A)((0,a.A)({},q),{},{location:e.target.value}))})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(i.J,{children:"Hands-on Materials"}),(0,z.jsx)(d.p,{placeholder:"e.g., Implant Kit, Models",value:q.hands_on_materials,onChange:e=>V((0,a.A)((0,a.A)({},q),{},{hands_on_materials:e.target.value}))})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(i.J,{children:"Clinical Mentoring"}),(0,z.jsxs)(h.l6,{value:q.clinical_mentoring,onValueChange:e=>V((0,a.A)((0,a.A)({},q),{},{clinical_mentoring:e})),children:[(0,z.jsx)(h.bq,{children:(0,z.jsx)(h.yv,{})}),(0,z.jsxs)(h.gC,{children:[(0,z.jsx)(h.eb,{value:"Yes",children:"Yes"}),(0,z.jsx)(h.eb,{value:"No",children:"No"})]})]})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(i.J,{children:"Batch"}),(0,z.jsx)(d.p,{placeholder:"e.g., Batch 2026-01",value:q.batch,onChange:e=>V((0,a.A)((0,a.A)({},q),{},{batch:e.target.value}))})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(i.J,{children:"Status"}),(0,z.jsxs)(h.l6,{value:q.status,onValueChange:e=>V((0,a.A)((0,a.A)({},q),{},{status:e})),children:[(0,z.jsx)(h.bq,{children:(0,z.jsx)(h.yv,{})}),(0,z.jsxs)(h.gC,{children:[(0,z.jsx)(h.eb,{value:"upcoming",children:"Upcoming"}),(0,z.jsx)(h.eb,{value:"scheduled",children:"Scheduled"}),(0,z.jsx)(h.eb,{value:"completed",children:"Completed"}),(0,z.jsx)(h.eb,{value:"cancelled",children:"Cancelled"})]})]})]})]}),(0,z.jsxs)(m.Es,{children:[(0,z.jsxs)(n.$,{variant:"outline",onClick:()=>B(!1),children:[(0,z.jsx)(S.A,{className:"w-4 h-4 mr-2"}),"Cancel"]}),(0,z.jsxs)(n.$,{onClick:async()=>
2{if(q.course_id&&q.date&&q.module){I(!0);try{const e=localStorage.getItem("elevate360_token"),t={Authorization:"Bearer ".concat(e),"Content-Type":"application/json"};let s;if(s=J?await fetch("".concat("https://plant4growthuk-production-a1cd.up.railway.app","/api/course-schedule/admin/").concat(J.schedule_id),{method:"PUT",headers:t,body:JSON.stringify(q)}):await fetch("".concat("https://plant4growthuk-production-a1cd.up.railway.app","/api/course-schedule/admin/create"),{method:"POST",headers:t,body:JSON.stringify(q)}),s.ok)E.oR.success(J?"Schedule updated!":"Schedule created!"),B(!1),K(),H();else{const e=await s.json();E.oR.error(e.detail||"Failed to save schedule")}}catch(e){console.error("Save error:",e),E.oR.error("Failed to save schedule")}finally{I(!1)}}else E.oR.error("Please fill in Course, Date, and Module")},disabled:Y,className:"bg-[#41EAD4] hover:bg-[#35c4b0] text-[#0D1B2A]",children:[Y?(0,z.jsx)(p.A,{className:"w-4 h-4 mr-2 animate-spin"}):(0,z.jsx)(_.A,{className:"w-4 h-4 mr-2"}),J?"Update":"Create"]})]})]})})]})})}},2054(e,t,s){s.d(t,{A:()=>a});const a=(0,s(7784).A)("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},2313(e,t,s){s.d(t,{A:()=>a});const a=(0,s(7784).A)("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},4370(e,t,s){s.d(t,{TR:()=>k,bq:()=>v,eb:()=>M,gC:()=>D,l6:()=>f,mi:()=>C,s3:()=>y,yv:()=>b});var a=s(9379),l=s(3986),c=s(5043),r=s(962),n=s(6210),d=s(2382),i=s(5711),o=s(9766),h=s(579);const m=["className","children"],x=["className"],u=["className"],p=["className","children","position"],j=["className"],g=["className","children"],N=["className"],f=r.bL,y=r.YJ,b=r.WT,v=c.forwardRef((e,t)=>{let{className:s,children:c}=e,n=(0,l.A)(e,m);return(0,h.jsxs)(r.l9,(0,a.A)((0,a.A)({ref:t,className:(0,o.cn)("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s)},n),{},{children:[c,(0,h.jsx)(r.In,{asChild:!0,children:(0,h.jsx)(d.A,{className:"h-4 w-4 opacity-50"})})]}))});v.displayName=r.l9.displayName;const w=c.forwardRef((e,t)=>{let{className:s}=e,c=(0,l.A)(e,x);return(0,h.jsx)(r.PP,(0,a.A)((0,a.A)({ref:t,className:(0,o.cn)("flex cursor-default items-center justify-center py-1",s)},c),{},{children:(0,h.jsx)(i.A,{className:"h-4 w-4"})}))});w.displayName=r.PP.displayName;const A=c.forwardRef((e,t)=>{let{className:s}=e,c=(0,l.A)(e,u);return(0,h.jsx)(r.wn,(0,a.A)((0,a.A)({ref:t,className:(0,o.cn)("flex cursor-default items-center justify-center py-1",s)},c),{},{children:(0,h.jsx)(d.A,{className:"h-4 w-4"})}))});A.displayName=r.wn.displayName;const D=c.forwardRef((e,t)=>{let{className:s,children:c,position:n="popper"}=e,d=(0,l.A)(e,p);return(0,h.jsx)(r.ZL,{children:(0,h.jsxs)(r.UC,(0,a.A)((0,a.A)({ref:t,className:(0,o.cn)("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]","popper"===n&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:n},d),{},{children:[(0,h.jsx)(w,{}),(0,h.jsx)(r.LM,{className:(0,o.cn)("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:c}),(0,h.jsx)(A,{})]}))})});D.displayName=r.UC.displayName;
2const k=c.forwardRef((e,t)=>{let{className:s}=e,c=(0,l.A)(e,j);return(0,h.jsx)(r.JU,(0,a.A)({ref:t,className:(0,o.cn)("px-2 py-1.5 text-sm font-semibold",s)},c))});k.displayName=r.JU.displayName;const M=c.forwardRef((e,t)=>{let{className:s,children:c}=e,d=(0,l.A)(e,g);return(0,h.jsxs)(r.q7,(0,a.A)((0,a.A)({ref:t,className:(0,o.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s)},d),{},{children:[(0,h.jsx)("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,h.jsx)(r.VF,{children:(0,h.jsx)(n.A,{className:"h-4 w-4"})})}),(0,h.jsx)(r.p4,{children:c})]}))});M.displayName=r.q7.displayName;const C=c.forwardRef((e,t)=>{let{className:s}=e,c=(0,l.A)(e,N);return(0,h.jsx)(r.wv,(0,a.A)({ref:t,className:(0,o.cn)("-mx-1 my-1 h-px bg-muted",s)},c))});C.displayName=r.wv.displayName},5131(e,t,s){s.d(t,{b:()=>h});var a=s(9379),l=s(5043),c=s(3986),r=(s(7950),s(6851)),n=s(579);const d=["asChild"];var i=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const s=(0,r.TL)("Primitive.".concat(t)),i=l.forwardRef((e,l)=>{const{asChild:r}=e,i=(0,c.A)(e,d),o=r?s:t;return"undefined"!==typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,n.jsx)(o,(0,a.A)((0,a.A)({},i),{},{ref:l}))});return i.displayName="Primitive.".concat(t),(0,a.A)((0,a.A)({},e),{},{[t]:i})},{});var o=l.forwardRef((e,t)=>(0,n.jsx)(i.label,(0,a.A)((0,a.A)({},e),{},{ref:t,onMouseDown:t=>{var s;t.target.closest("button, input, select, textarea")||(null===(s=e.onMouseDown)||void 0===s||s.call(e,t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}})));o.displayName="Label";var h=o},5598(e,t,s){s.d(t,{Cf:()=>f,Es:()=>b,L3:()=>v,c7:()=>y,lG:()=>j,rr:()=>w});var a=s(9379),l=s(3986),c=s(5043),r=s(7427),n=s(614),d=s(9766),i=s(579);const o=["className"],h=["className","children"],m=["className"],x=["className"],u=["className"],p=["className"],j=r.bL,g=(r.l9,r.ZL),N=(r.bm,c.forwardRef((e,t)=>{let{className:s}=e,c=(0,l.A)(e,o);return(0,i.jsx)(r.hJ,(0,a.A)({ref:t,className:(0,d.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s)},c))}));N.displayName=r.hJ.displayName;const f=c.forwardRef((e,t)=>{let{className:s,children:c}=e,o=(0,l.A)(e,h);return(0,i.jsxs)(g,{children:[(0,i.jsx)(N,{}),(0,i.jsxs)(r.UC,(0,a.A)((0,a.A)({ref:t,className:(0,d.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s)},o),{},{children:[c,(0,i.jsxs)(r.bm,{className:"absolute right-4 top-4 roun
2ded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,i.jsx)(n.A,{className:"h-4 w-4"}),(0,i.jsx)("span",{className:"sr-only",children:"Close"})]})]}))]})});f.displayName=r.UC.displayName;const y=e=>{let{className:t}=e,s=(0,l.A)(e,m);return(0,i.jsx)("div",(0,a.A)({className:(0,d.cn)("flex flex-col space-y-1.5 text-center sm:text-left",t)},s))};y.displayName="DialogHeader";const b=e=>{let{className:t}=e,s=(0,l.A)(e,x);return(0,i.jsx)("div",(0,a.A)({className:(0,d.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t)},s))};b.displayName="DialogFooter";const v=c.forwardRef((e,t)=>{let{className:s}=e,c=(0,l.A)(e,u);return(0,i.jsx)(r.hE,(0,a.A)({ref:t,className:(0,d.cn)("text-lg font-semibold leading-none tracking-tight",s)},c))});v.displayName=r.hE.displayName;const w=c.forwardRef((e,t)=>{let{className:s}=e,c=(0,l.A)(e,p);return(0,i.jsx)(r.VY,(0,a.A)({ref:t,className:(0,d.cn)("text-sm text-muted-foreground",s)},c))});w.displayName=r.VY.displayName},6533(e,t,s){s.d(t,{A:()=>a});const a=(0,s(7784).A)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]])},7719(e,t,s){s.d(t,{A:()=>a});const a=(0,s(7784).A)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},8006(e,t,s){s.d(t,{A:()=>a});const a=(0,s(7784).A)("map-pin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]])},8693(e,t,s){s.d(t,{A:()=>a});const a=(0,s(7784).A)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]])},9855(e,t,s){s.d(t,{A:()=>a});const a=(0,s(7784).A)("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},9938(e,t,s){s.d(t,{J:()=>m});var a=s(9379),l=s(3986),c=s(5043),r=s(5131),n=s(917),d=s(9766),i=s(579);const o=["className"],h=(0,n.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),m=c.forwardRef((e,t)=>{let{className:s}=e,c=(0,l.A)(e,o);return(0,i.jsx)(r.b,(0,a.A)({ref:t,className:(0,d.cn)(h(),s)},c))});m.displayName=r.b.displayName}}]); 3//# sourceMappingURL=1376.9ec3e8d8.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.