PageSourceSearch

https://mydancehall.com/static/js/3679.0a5543a6.chunk.js

js mydancehall.com collected 2026-10-08 06:05:37 UTC 27,236 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkclient=self.webpackChunkclient||[]).push([[3679],{53679:(e,a,t)=>{t.d(a,{A:()=>ee});var i=t(89379),l=t(65043),r=t(26553),s=t(8918),n=t(47419),o=t(11645),d=t(64325),c=t(95206),m=t(42261),y=t(89073),u=t(43801),h=t(22019),f=t(1118),g=t(34318),p=t.n(g),x=t(65447),A=t(30119),v=t(75337),b=t(76191),k=t(79722),j=t(15444),w=t(76399),S=t(60647),H=t(487),T=t(96603),C=t(6051),D=t(91686),z=t(91006),B=t(99472),E=t(62751),M=t(61966),I=t(81210),Y=t(95240),F=t(86178),R=t.n(F),P=t(70579);const{TextArea:Z}=j.A,W="https://server.mydancehall.com",N=e=>{let{teacherEmail:a}=e;const[t]=u.A.useForm(),[i,r]=(0,l.useState)(!1),[s,f]=(0,l.useState)([]),[g,p]=(0,l.useState)([]),[x,b]=(0,l.useState)(!1),[j,F]=(0,l.useState)("allday"),[N,O]=(0,l.useState)({}),[V,U]=(0,l.useState)(!1),[q,_]=(0,l.useState)(null),L="undefined"!==typeof window&&window.innerWidth<768,G={allday:{start:"00:00",end:"23:59",label:"All Day"}},K=async()=>{r(!0);try{const e=await k.A.get("".concat(W,"/api/teacher/day-breaks"),{params:{email:a}});e.data.success&&(f(e.data.dayBreaks||[]),O(e.data.timeBlocks||G))}catch(e){console.error("Error fetching day breaks:",e),h.Ay.error("Failed to load day breaks")}finally{r(!1)}};(0,l.useEffect)(()=>{a&&K()},[a]);const J=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{const s=await t.validateFields();let n,o;var i,l;if("custom"===j)n=s.startTime.format("HH:mm"),o=s.endTime.format("HH:mm");else n=(null===(i=N[j])||void 0===i?void 0:i.start)||G[j].start,o=(null===(l=N[j])||void 0===l?void 0:l.end)||G[j].end;r(!0);const d=await k.A.post("".concat(W,"/api/teacher/day-breaks"),{email:a,date:s.date.format("YYYY-MM-DD"),timeBlock:j,startTime:n,endTime:o,reason:s.reason,cancelBookings:e});d.data.success&&(h.Ay.success(d.data.message||"Day break created successfully"),t.resetFields(),F("allday"),b(!1),p([]),K())}catch(o){var s,n;console.error("Error creating day break:",o),h.Ay.error((null===(s=o.response)||void 0===s||null===(n=s.data)||void 0===n?void 0:n.error)||"Failed to create day break")}finally{r(!1)}},Q=[{title:"Date",dataIndex:"date",key:"date",render:e=>R()(e,"YYYY-MM-DD").format("MMM DD, YYYY"),sorter:(e,a)=>R()(e.date).unix()-R()(a.date).unix()},{title:"Time",key:"time",render:e=>"custom"===e.timeBlock?(0,P.jsxs)(w.A,{color:"purple",children:["Custom: ",e.start||e.startTime," - ",e.end||e.endTime]}):(0,P.jsx)(w.A,{color:"blue",children:"All Day"})},{title:"Reason",dataIndex:"reason",key:"reason",ellipsis:!0},{title:"Action",key:"action",render:e=>(0,P.jsx)(S.A,{title:"Delete this day break?",description:"This action cannot be undone.",onConfirm:()=>(async e=>{_(e);try{(await k.A.delete("".concat(W,"/api/teacher/day-breaks/").concat(e),{params:{email:a}})).data.success&&(h.Ay.success("Day break deleted successfully"),K())}catch(t){console.error("Error deleting day break:",t),h.Ay.error("Failed to delete day break")}finally{_(null)}})(e._id),okText:"Yes",cancelText:"No",children:(0,P.jsx)(c.Ay,{type:"text",danger:!0,icon:(0,P.jsx)(M.A,{}),loading:q===e._id,size:"small",children:"Delete"})})}];return(0,P.jsxs)("div",{children:[(0,P.jsx)(y.A,{title:(0,P.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[(0,P.jsx)(I.A,{style:{marginRight:8,color:"#3F51B5"}}),(0,P.jsx)("span",{children:"Add Date-Specific Break"})]}),style:{marginBottom:24},children:(0,P.jsxs)(u.A,{form:t,layout:"vertical",onFinish:()=>J(!1),children:[(0,P.jsxs)(n.A,{gutter:16,children:[(0,P.jsx)(o.A,{xs:24,md:8,children:(0,P.jsx)(u.A.Item,{name:"date",label:"Select Date",rules:[{required:!0,message:"Please select a date"}],children:(0,P.jsx)(H.A,{style:{width:"100%"},disabledDate:e=>e&&e<R()().startOf("day"),format:"MMMM DD, YYYY",size:L?"default":"large"})})}),(0,P.jsx)(o.A,{xs:24,md:16,children:(0,P.jsxs)(u.A.Item,{label:"Break Duration",children:[(0,P.jsx)(T.Ay.Group,{value:j,onChange:e=>F(e.target.value),style:{width:"100%"},children:(0,P.jsxs)(C.A,{direction:"vertical",children:[(0,P.jsx)(T.Ay,{value:"allday",children:"All Day"}),(0,P.jsx)(T.Ay,{value:"custom",children:"Custom Time"})]})}),(0,P.jsx)("div",{style:{marginTop:8,fontSize:12,color:"#666"},children:"* Breaks are set in your timezone"})]})})]}),"custom"===j&&(0,P.jsxs)(n.A,{gutter:16,children:[(0,P.jsx)(o.A,{xs:12,md:8,children:(0,P.jsx)(u.A.Item,{name:"startTime",label:"Start Time",rules:[{required:"custom"===j,message:"Required"}],children:(0,P.jsx)(d.A,{format:"h:mm A",style:{width:"100%"},minuteStep:30,size:L?"default":"large"})})}),(0,P.jsx)(o.A,{xs:12,md:8,children:(0,P.jsx)(u.A.Item,{name:"endTime",label:"End Time",rules:[{required:"custom"===j,message:"Required"},e=>{let{getFieldValue:a}=e;return{validator:(e,t)=>
1t&&a("startTime")?t.isAfter(a("startTime"))?Promise.resolve():Promise.reject(new Error("End time must be after start time")):Promise.resolve()}}],children:(0,P.jsx)(d.A,{format:"h:mm A",style:{width:"100%"},minuteStep:30,size:L?"default":"large"})})})]}),(0,P.jsx)(u.A.Item,{name:"reason",label:"Reason (optional)",children:(0,P.jsx)(Z,{rows:2,placeholder:"e.g., Holiday, Personal commitment, Medical appointment",maxLength:500,showCount:!0})}),(0,P.jsx)(u.A.Item,{children:(0,P.jsx)(c.Ay,{type:"primary",htmlType:"submit",loading:i,icon:(0,P.jsx)(v.A,{}),style:{backgroundColor:"#3F51B5",borderColor:"#3F51B5"},children:"Add Break"})})]})}),(0,P.jsx)(y.A,{title:(0,P.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[(0,P.jsx)(A.A,{style:{marginRight:8,color:"#3F51B5"}}),(0,P.jsx)("span",{children:"Your Date-Specific Breaks"})]}),children:i?(0,P.jsx)("div",{style:{textAlign:"center",padding:40},children:(0,P.jsx)(D.A,{size:"large"})}):s.length>0?(0,P.jsx)(z.A,{dataSource:s.filter(e=>R()(e.date).isAfter(R()().subtract(1,"day"))),columns:Q,rowKey:"_id",pagination:{pageSize:10},scroll:{x:"max-content"}}):(0,P.jsx)(B.A,{description:"No date-specific breaks scheduled",image:B.A.PRESENTED_IMAGE_SIMPLE})}),(0,P.jsxs)(E.A,{title:(0,P.jsxs)("div",{children:[(0,P.jsx)(Y.A,{style:{color:"#ff4d4f",marginRight:8}}),"Booking Conflicts Found"]}),open:x,onCancel:()=>{b(!1),p([])},footer:[(0,P.jsx)(c.Ay,{onClick:()=>b(!1),children:"Cancel"},"cancel"),(0,P.jsx)(c.Ay,{onClick:()=>{b(!1),h.Ay.info("Please adjust your break time")},children:"Adjust Break Time"},"adjust"),(0,P.jsx)(c.Ay,{type:"primary",danger:!0,onClick:()=>J(!0),loading:i,children:"Cancel Bookings & Create Break"},"proceed")],width:700,children:[(0,P.jsx)(m.A,{message:"".concat(g.length," booking conflict").concat(g.length>1?"s":""," found"),description:"The following bookings will be cancelled and students will be notified:",type:"warning",showIcon:!0,style:{marginBottom:16}}),(0,P.jsx)("div",{style:{maxHeight:400,overflowY:"auto"},children:g.map((e,a)=>(0,P.jsxs)("div",{style:{padding:12,background:"#f5f5f5",borderRadius:8,marginBottom:8},children:[(0,P.jsxs)("div",{style:{fontWeight:500},children:[e.studentName," - ",e.classTime]}),(0,P.jsx)("div",{style:{fontSize:12,color:"#666"},children:e.studentEmail})]},a))})]})]})},{Option:O}=r.A,{TabPane:V}=s.A,U="https://server.mydancehall.com",q="#3F51B5",_=[{value:0,label:"Sunday",short:"S"},{value:1,label:"Monday",short:"M"},{value:2,label:"Tuesday",short:"T"},{value:3,label:"Wednesday",short:"W"},{value:4,label:"Thursday",short:"T"},{value:5,label:"Friday",short:"F"},{value:6,label:"Saturday",short:"S"}],L={"Asia/Kolkata":"India","Asia/Calcutta":"India","Asia/Mumbai":"India","Asia/Delhi":"India","Asia/Chennai":"India","Asia/Tokyo":"Japan","Asia/Singapore":"Singapore","Asia/Dubai":"UAE","Europe/London":"UK","Europe/Paris":"France","Europe/Berlin":"Germany","America/New_York":"USA (Eastern)","America/Chicago":"USA (Central)","America/Denver":"USA (Mountain)","America/Los_Angeles":"USA (Pacific)","Australia/Sydney":"Australia (Sydney)","Australia/Melbourne":"Australia (Melbourne)","Pacific/Auckland":"New Zealand"},G="undefined"!==typeof window&&window.innerWidth<768,K=e=>{let{value:a=[],onChange:t}=e;const r=a.filter(e=>!1!==e.recurring),[s,m]=(0,l.useState)(r);(0,l.useEffect)(()=>{const e=a.filter(e=>!1!==e.recurring);JSON.stringify(e)!==JSON.stringify(s)&&m(e)},[a]);const y=e=>{if(m(e),t){const i=a.filter(e=>!1===e.recurring);t([...e,...i])}},u=(e,a,t)=>{const l=[...s];l[e]=(0,i.A)((0,i.A)({},l[e]),{},{[a]:t}),y(l)};return(0,P.jsxs)("div",{style:{marginTop:G?16:24,padding:G?12:16,backgroundColor:"#fafafa",borderRadius:8,border:"1px solid #f0f0f0"},children:[(0,P.jsxs)("div",{style:{display:"flex",alignItems:"center",marginBottom:12},children:[(0,P.jsx)(A.A,{style:{marginRight:8,color:q}}),(0,P.jsx)("h3",{style:{margin:0,fontSize:G?16:18},children:"Manage Breaks"})]}),(0,P.jsx)("p",{style:{color:"#666",marginBottom:16},children:"Add short breaks, or any time you're unavailable during your available hours - check the preview to see how it will look for students."}),s.map((e,a)=>{var t;return(0,P.jsxs)("div",{style:{backgroundColor:"white",padding:G?12:16,borderRadius:8,border:"1px solid #e8e8e8",marginBottom:16},children:[(0,P.jsxs)(n.A,{gutter:[8,8],align:"middle",style:{marginBottom:12},children:[(0,P.jsx)(o.A,{xs:10,sm:8,md:6,children:(0,P.jsx)(d.A,{value:e.start?p()(e.start,"HH:mm"):null,onChange:e=>u(a,"start",e?e.format("HH:mm"):null),format:"HH",placeholder:"Start",size:G?"small":"default",style:{width:"100%"},showNow:!1})}),(0,P.jsx)(o.A,{xs:4,sm:2,md:2,style:{textAlign:"center"},children:(0,P.jsx)("span",{style:{color:"#d9d9d9"},children:"to"})}),(0,P.jsx)(o.A,{xs:10,sm:8,md:6,children:(0,P.jsx)(d.A,{value:e.end?p()(e.end,"HH:mm"):null,onChange:e=>u(a,"end",e?e.format("HH:mm"):null),format:"HH",placeholder:"End",size:G?"small":"default",style:{width:"100%"},showNow:!1})}),(0,P.jsx)(o.A,{xs:24,sm:6,md:4,style:{textAlign:G?"left":"right"},children:(0,P.jsx)(c.Ay,{type:"text",danger:!0,onClick:()=>(e=>{y(s.filter((a,t)=>t!==e))})(a),size:G?"small":"default",style:{fontSize:G?16:18,padding:G?"4px":"8px"},children:"\ud83d\uddd1\ufe0f "})})]}),(0,P.jsxs)("div",{style:{marginBottom:8},children:[(0,P.jsx)("span",{style:{fontSize:12,color:"#666"},children:"Days:"}),(0,P.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:4},children:[(0,P.jsx)("div",{style:{display:"flex",gap:G?4:6,flex:1},children:_.map(t=>{var i;const l=null===(i=e.days)||void 0===i?void 0:i.includes(t.value);return(0,P.jsx)(c.Ay,{size:G?"small":"default",type:l?"primary":"default",onClick:()=>((e,a)=>{const t=s[e].days||[];let i;i=t.includes(a)?t.filter(e=>e!==a):[...t,a],u(e,"days",i)})(a,t.value),style:{minWidth:G?28:32,height:G?28:32,padding:0,fontSize:G?11:12,backgroundColor:l?q:"#f5f5f5",borderColor:l?q:"#d9d9d9",color:l?"#fff":"#666"},children:t.short},t.value)})}),(0,P.jsxs)("div",{style:{marginLeft:G?8:12},children:[(0,P.jsx)(c.Ay,{type:"link",size:"small",onClick:()=>{u(a,"days",[0,1,2,3,4,5,6])},style:{padding:"0 4px",fontSize:G?10:11,color:q},children:"Select All"}),(0,P.jsx)("span",{style:{color:"#d9d9d9"},children:"|"}),(0,P.jsx)(c.Ay,{type:"link",size:"small",onClick:()=>{u(a,"days",[])},style:{padding:"0 4px",fontSize:G?10:11,color:q},children:"Clear All"})]})]})]}),(0,P.jsxs)("div",{style:{marginTop:8,fontSize:11,color:"#666"},children:["Active on: ",(null===(t=e.days)||void 0===t?void 0:t.length)>0?e.days.map(e=>{var a;return null===(a=_.find(a=>a.value===e))||void 0===a?void 0:a.label}).join(", "):"No days selected"]})]},a)}),(0,P.jsx)(c.Ay,{type:"dashed",onClick:()=>{y([...s,{start:null,end:null,days:[],recurring:!0}])},icon:(0,P.jsx)(v.A,{}),style:{width:"100%",marginTop:8,borderColor:q,color:q},size:G?"default":"large",children:"Add Break"})]})},J=e=>{let{availability:a,breaks:t=[],timeZone:i}=e;const[r,s]=(0,l.useState)(p()().startOf("week"));let d;try{d=(()=>{console.log("\ud83d\udd0d SCHEDULE PREVIEW DEBUG:"),console.log("Raw availability received:",a),console.log("Raw breaks re
1ceived:",t),console.log("TimeZone received:",i);const e=[],l=Array.isArray(a)?a:[];console.log("Safe availability array:",l);const s=l.filter((e,a)=>{const t=e&&"object"===typeof e&&"number"===typeof e.dayOfWeek&&e.start&&e.end;return t?console.log("\u2705 Valid slot at index ".concat(a,":"),e):console.log("\u274c Filtering out invalid slot at index ".concat(a,":"),e),t});console.log("Valid availability after filtering:",s);for(let a=0;a<7;a++){const i=r.clone().add(a,"days"),l=i.day();console.log("\n--- Processing day ".concat(l," (").concat(i.format("ddd"),") ---"));const o=s.find(e=>e.dayOfWeek===l);if(console.log("Day ".concat(l," availability:"),o),o&&o.start&&o.end){let a,r;console.log("\u2705 Processing availability for ".concat(i.format("ddd")));try{if(p().isMoment(o.start)?(a=o.start.clone(),console.log("Start time (moment):",a.format("HH:mm"))):(a=p()(o.start,"HH:mm"),console.log("Start time (parsed):",a.format("HH:mm"))),p().isMoment(o.end)?(r=o.end.clone(),console.log("End time (moment):",r.format("HH:mm"))):(r=p()(o.end,"HH:mm"),console.log("End time (parsed):",r.format("HH:mm"))),!a.isValid()||!r.isValid())throw new Error("Invalid time format for day ".concat(l))}catch(n){console.error("\u274c Error parsing times for day ".concat(l,":"),n),e.push({date:i,dayName:i.format("ddd"),allTimePeriods:[]});continue}const s=(Array.isArray(t)?t:[]).filter(e=>{const a=e&&e.start&&e.end&&(e.days&&Array.isArray(e.days)||"number"===typeof e.dayOfWeek||!1===e.recurring&&e.date);return console.log("Break validation:",{breakItem:e,isValid:a}),a}).filter(e=>!1!==e.recurring?e.days&&Array.isArray(e.days)?e.days.includes(l):e.dayOfWeek===l:!(!1!==e.recurring||!e.date)&&p()(e.date).format("YYYY-MM-DD")===i.format("YYYY-MM-DD"));console.log("Breaks for day ".concat(l,":"),s);const d=[];let c=a.clone();for(;c.isBefore(r);){const e=c.clone().add(60,"minutes"),a=s.find(a=>{if(!a.start||!a.end)return!1;try{const t=p()(a.start,"HH:mm"),i=p()(a.end,"HH:mm");return!(!t.isValid()||!i.isValid())&&c.isBefore(i)&&e.isAfter(t)}catch(n){return console.error("Error checking break conflict:",n),!1}});if(a)try{const e=p()(a.start,"HH:mm"),t=p()(a.end,"HH:mm");d.some(a=>"break"===a.type&&a.start===e.format("HH:mm")&&a.end===t.format("HH:mm"))||(d.push({start:e.format("HH:mm"),end:t.format("HH:mm"),type:"break",sortTime:e.format("HHmm"),isDateSpecific:!1===a.recurring,reason:a.reason||""}),console.log("Added break period:",e.format("HH:mm"),"-",t.format("HH:mm"))),c=t.clone()}catch(n){console.error("Error processing break:",n),c.add(60,"minutes")}else d.push({start:c.format("HH:mm"),end:e.format("HH:mm"),type:"available",sortTime:c.format("HHmm")}),console.log("Added available slot:",c.format("HH:mm"),"-",e.format("HH:mm")),c.add(60,"minutes")}d.sort((e,a)=>e.sortTime.localeCompare(a.sortTime)),e.push({date:i,dayName:i.format("ddd"),allTimePeriods:d})}else console.log("\u274c No valid availability for ".concat(i.format("ddd"))),e.push({date:i,dayName:i.format("ddd"),allTimePeriods:[]})}return console.log("Final week schedule:",e),e})()}catch(u){console.error("\u274c Critical error generating week schedule:",u),d=Array.from({length:7},(e,a)=>({date:r.clone().add(a,"days"),dayName:r.clone().add(a,"days").format("ddd"),allTimePeriods:[]}))}return(0,P.jsxs)("div",{className:"schedule-preview",children:[(0,P.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16,flexDirection:G?"column":"row",gap:G?12:0},children:[(0,P.jsxs)("h4",{style:{margin:0,fontSize:G?16:18},children:[(0,P.jsx)(b.A,{style:{marginRight:8,color:q}}),"Student View Preview"]}),(0,P.jsxs)("div",{children:[(0,P.jsx)(c.Ay,{size:G?"small":"default",onClick:()=>s(r.clone().subtract(1,"week")),children:"\u2190 Previous Week"}),(0,P.jsx)(c.Ay,{size:G?"small":"default",onClick:()=>s(r.clone().add(1,"week")),style:{marginLeft:8},children:"Next Week \u2192"})]})]}),(0,P.jsx)(m.A,{message:"Week of ".concat(r.format("MMM DD, YYYY")," - ").concat(r.clone().add(6,"days").format("MMM DD, YYYY")),type:"info",style:{marginBottom:16}}),(0,P.jsx)(n.A,{gutter:[G?4:8,8],children:d.map((e,a)=>(0,P.jsx)(o.A,{xs:12,sm:8,md:24/7,style:{minHeight:G?150:200},children:(0,P.jsx)(y.A,{size:"small",title:(0,P.jsxs)("div",{style:{textAlign:"center"},children:[(0,P.jsx)("div",{style:{fontSize:G?11:12},children:e.dayName}),(0,P.jsx)("div",{style:{fontSize:G?9:10,fontWeight:"normal",color:"#666"},children:e.date.format("MM/DD")})]}),style:{height:"100%"},bodyStyle:{padding:G?8:12},children:e.allTimePeriods.length>0?(0,P.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:G?2:4},children:e.allTimePeriods.map((e,a)=>(0,P.jsxs)("div",{style:{backgroundColor:"available"===e.type?"#f6ffed":"#fff2e8",border:"available"===e.type?"1px solid #b7eb8f":"1px solid #ffbb96",borderRadius:4,padding:G?"2px 4px":"4px 8px",fontSize:G?9:11,textAlign:"center",color:"available"===e.type?"#389e0d":"#d4380d"},children:["break"===e.type?e.isDateSpecific?"Day Break: ":"Break: ":"",e.start," - ",e.end]},a))}):(0,P.jsx)("div",{style:{textAlign:"center",color:"#999",fontSize:G?9:11,padding:G?"16px 0":"20px 0"},children:"Not available"})})},a))}),(0,P.jsxs)("div",{style:{marginTop:16,fontSize:G?10:12,color:"#666"},children:[(0,P.jsxs)("div",{children:["\ud83d\udfe2 Available time slots \u2022 \ud83d\udfe0 Breaks \u2022 Times shown in your timezone (",i,")"]}),(0,P.jsx)("div",{children:"Students will see these times converted to their local timezone"})]})]})};let Q=null;const X=()=>
1{if(Q)return Q;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;return Q=e,e}catch(e){return Q="UTC","UTC"}},$=e=>{let{teacherId:a,onSaveSuccess:t}=e;const{user:g,isAuthenticated:A,getAccessTokenSilently:b}=(0,x.WB)(),[j]=u.A.useForm(),[w,S]=(0,l.useState)(!1),[H,T]=(0,l.useState)(null),[C,D]=(0,l.useState)([]),[z,B]=(0,l.useState)("availability"),[E,M]=(0,l.useState)(X()),[I,Y]=(0,l.useState)(null),[F,R]=(0,l.useState)(!1),[Z,W]=(0,l.useState)({}),Q=(0,l.useCallback)(async()=>{if(H)try{const e=await b({audience:"https://tokenverification"}),a=(await k.A.get("".concat(U,"/api/teacher/").concat(H,"/availability"),{headers:{Authorization:"Bearer ".concat(e)}})).data,t={timeZone:a.timeZone||X(),weeklySchedule:[],breaks:a.breaks||[]};if(a.weeklySchedule&&Array.isArray(a.weeklySchedule)){const e=a.weeklySchedule.map(e=>({dayOfWeek:e.dayOfWeek,start:e.timeRanges&&e.timeRanges[0]?p()(e.timeRanges[0].start,"HH:mm"):null,end:e.timeRanges&&e.timeRanges[0]?p()(e.timeRanges[0].end,"HH:mm"):null}));t.weeklySchedule=e;const i={timeZone:a.timeZone,visibilityDays:a.visibilityDays||30,weeklySchedule:e};j.setFieldsValue(i),W(i)}return a.breaks&&Array.isArray(a.breaks)&&D(a.breaks),Y(t),M(t.timeZone),t}catch(e){return console.error("\u274c Error fetching availability:",e),null}},[H,b]),$=()=>{const e=j.getFieldsValue();W(e)},ee={weeklySchedule:Z.weeklySchedule&&Z.weeklySchedule.length>0?Z.weeklySchedule:(null===I||void 0===I?void 0:I.weeklySchedule)||[],breaks:C,timeZone:Z.timeZone||(null===I||void 0===I?void 0:I.timeZone)||E},ae=p().tz.names().map(e=>{const a=p().tz(e).format("Z"),t=L[e]||e.split("/")[0],i=e.split("/").pop().replace("_"," ");return{value:e,label:L[e]?"".concat(L[e]," - ").concat(i," (GMT").concat(a,")"):"".concat(e.replace("_"," ")," (GMT").concat(a,")"),searchTerms:"".concat(t," ").concat(i," ").concat(e," GMT").concat(a)}});return(0,l.useEffect)(()=>{H||j.setFieldsValue({visibilityDays:30,timeZone:X()})},[]),(0,l.useEffect)(()=>{if(H)return;a?T(a):(async()=>{if(A&&null!==g&&void 0!==g&&g.email)try{const e=await b({audience:"https://tokenverification"}),a=await k.A.get("".concat(U,"/api/user"),{headers:{Authorization:"Bearer ".concat(e)}});a.data&&a.data._id&&T(a.data._id)}catch(e){console.error("Error fetching user ID:",e)}})()},[A,null===g||void 0===g?void 0:g.email,a,b,H]),(0,l.useEffect)(()=>{(async()=>{if(H&&!F)try{const e=await b({audience:"https://tokenverification"}),a=(await k.A.get("".concat(U,"/api/teacher/").concat(H,"/availability"),{headers:{Authorization:"Bearer ".concat(e)}})).data,t={timeZone:a.timeZone||X(),weeklySchedule:[],breaks:a.breaks||[]},i=X(),l=(a.timeZone,{timeZone:a.timeZone||i,visibilityDays:a.visibilityDays||30});if(a.weeklySchedule&&Array.isArray(a.weeklySchedule)){const e=a.weeklySchedule.map(e=>({dayOfWeek:e.dayOfWeek,start:e.timeRanges&&e.timeRanges[0]?p()(e.timeRanges[0].start,"HH:mm"):null,end:e.timeRanges&&e.timeRanges[0]?p()(e.timeRanges[0].end,"HH:mm"):null}));l.weeklySchedule=e,t.weeklySchedule=e}a.breaks&&Array.isArray(a.breaks)&&(D(a.breaks),l.breaks=a.breaks),Y(t),M(t.timeZone),R(!0),j.setFieldsValue(l)}catch(e){console.error("Error fetching availability:",e),j.setFieldsValue({timeZone:X(),visibilityDays:30,weeklySchedule:[]}),D([]),Y({weeklySchedule:[],breaks:[],timeZone:X()}),R(!0)}})()},[H,b,F]),(0,P.jsxs)(y.A,{title:"Set Your Weekly Availability",style:{marginBottom:"20px",borderRadius:G?8:12},bodyStyle:{padding:G?12:24},children:[!G&&(0,P.jsx)(m.A,{message:"Availability Tip",description:(0,P.jsxs)("div",{children:[(0,P.jsx)("div",{children:"More availability increases your chances of getting bookings. Students can see your available time slots when booking lessons."}),(0,P.jsxs)("div",{style:{marginTop:8},children:[(0,P.jsx)("strong",{children:"Note:"})," All times you set here will be automatically converted to each student's local time zone when they view your schedule. You only need to select times convenient for you in your own time zone."]})]}),type:"info",showIcon:!0,style:{marginBottom:"20px"}}),(0,P.jsxs)(s.A,{defaultActiveKey:"availability",size:G?"small":"default",children:[(0,P.jsx)(V,{tab:"Weekly Availability",children:(0,P.jsxs)(u.A,{form:j,layout:"vertical",onFinish:async e=>{if(!H)return console.error("User ID not available, cannot save"),void h.Ay.error("Unable to save: User ID not available. Please try again later.");try{var a;S(!0);const l=(null===(a=e.weeklySchedule)||void 0===a?void 0:a.map(e=>({dayOfWeek:e.dayOfWeek,timeRanges:[{start:e.start?e.start.format("HH:mm"):"",end:e.end?e.end.format("HH:mm"):""}]})))||[],r={timeZone:e.timeZone,visibilityDays:e.visibilityDays||30,weeklySchedule:l,breaks:C||[]},s=await b({audience:"https://tokenverification"}),n=await k.A.post("".concat(U,"/api/teacher/").concat(H,"/availability"),r,{headers:{Authorization:"Bearer ".concat(s)}});console.log("\u2705 Save successful! API Response:",n.data),console.log("\ud83d\udd04 Refreshing data after save..."),await Q(),setTimeout(()=>{const e=j.getFieldsValue();W((0,i.A)({},e)),console.log("\ud83d\udd25 Force updated currentFormValues:",e)},100),t&&"function"===typeof t?t(n.data):h.Ay.success("Availability saved successfully")}catch(l){console.error("\u274c Error saving availability:",l),h.Ay.error("Failed to save availability: ".concat(l.message))}finally{S(!1)}},onValuesChange:$,onFieldsChange:$,children:[(0,P.jsxs)(n.A,{gutter:G?8:16,children:[(0,P.jsx)(o.A,{span:G?24:12,style:{marginBottom:G?16:0},children:(0,P.jsx)(u.A.Item,{name:"timeZone",label:"Time Zone",rules:[{required:!0,message:"Please select your time zone"}],children:(0,P.jsx)(r.A,{showSearch:!0,optionFilterProp:"searchTerms",filterOption:(e,a)=>a.searchTerms.toLowerCase().includes(e.toLowerCase()),size:G?"default":"large",onChange:e=>M(e),children:ae.map(e=>(0,P.jsx)(O,{value:e.value,searchTerms:e.searchTerms,children:e.label},e.value))})})}),(0,P.jsx)(o.A,{span:G?24:12,children:(0,P.jsx)(u.A.Item,{name:"visibilityDays",label:(0,P.jsx)("span",{style:{display:G?"block":"inl
1ine",lineHeight:G?"1.4":"1.5"},children:G?(0,P.jsxs)(P.Fragment,{children:["Show your availability to",(0,P.jsx)("br",{}),"students up to"]}):"Show your availability to students up to"}),rules:[{required:!0,message:"Please specify visibility days"}],children:(0,P.jsx)(f.A,{min:1,max:90,defaultValue:30,addonAfter:"days",style:{width:"100%"},size:G?"default":"large"})})})]}),(0,P.jsx)("h3",{style:{fontSize:G?"16px":"18px",marginTop:G?16:24},children:"Weekly Schedule"}),(0,P.jsx)("p",{style:{fontSize:G?"14px":"16px"},children:"Set your recurring weekly availability. These time slots will repeat every week."}),(0,P.jsx)(u.A.List,{name:"weeklySchedule",children:(e,a)=>{let{add:t,remove:l}=a;return(0,P.jsxs)(P.Fragment,{children:[e.map(e=>(0,P.jsxs)(n.A,{gutter:G?4:8,align:"middle",style:{marginBottom:8},children:[(0,P.jsx)(o.A,{span:G?24:6,style:{marginBottom:G?8:0},children:(0,P.jsx)(u.A.Item,(0,i.A)((0,i.A)({},e),{},{name:[e.name,"dayOfWeek"],rules:[{required:!0,message:"Please select a day"}],children:(0,P.jsx)(r.A,{placeholder:"Day",size:"default",dropdownStyle:{borderColor:q},children:_.map(e=>(0,P.jsx)(O,{value:e.value,children:e.label},e.value))})}))}),(0,P.jsx)(o.A,{span:G?11:8,children:(0,P.jsx)(u.A.Item,(0,i.A)((0,i.A)({},e),{},{name:[e.name,"start"],rules:[{required:!0,message:"Start time required"}],children:(0,P.jsx)(d.A,{format:"HH",minuteStep:60,placeholder:"Start time",size:"default",style:{width:"100%"},showNow:!1})}))}),(0,P.jsx)(o.A,{span:G?11:8,children:(0,P.jsx)(u.A.Item,(0,i.A)((0,i.A)({},e),{},{name:[e.name,"end"],rules:[{required:!0,message:"End time required"}],children:(0,P.jsx)(d.A,{format:"HH",minuteStep:60,placeholder:"End time",size:"default",style:{width:"100%"},showNow:!1})}))}),(0,P.jsx)(o.A,{span:2,children:(0,P.jsx)(c.Ay,{type:"text",danger:!0,onClick:()=>l(e.name),style:{fontSize:G?16:18,padding:G?"4px":"8px"},children:"\ud83d\uddd1\ufe0f"})})]},e.key)),(0,P.jsx)(u.A.Item,{children:(0,P.jsx)(c.Ay,{type:"dashed",onClick:()=>t(),icon:(0,P.jsx)(v.A,{}),style:{width:"100%",borderColor:q,color:q},size:G?"default":"large",children:"Add Availability"})})]})}}),(0,P.jsx)(u.A.Item,{children:(0,P.jsx)(c.Ay,{type:"primary",htmlType:"submit",loading:w,size:G?"default":"large",style:{width:G?"100%":"auto",marginTop:G?"16px":"24px",backgroundColor:q,borderColor:q},onClick:e=>{e.preventDefault(),j.submit()},children:"Save Availability"})})]})},"availability"),(0,P.jsx)(V,{tab:"Manage Breaks",children:(0,P.jsxs)(s.A,{defaultActiveKey:"recurring",size:"small",children:[(0,P.jsx)(V,{tab:"Recurring Breaks",children:(0,P.jsxs)(y.A,{bordered:!1,children:[(0,P.jsx)(K,{value:C,onChange:D}),(0,P.jsx)("div",{style:{marginTop:16},children:(0,P.jsx)(c.Ay,{type:"primary",onClick:async()=>{try{var e;S(!0);const a=j.getFieldsValue(),t={timeZone:a.timeZone,visibilityDays:a.visibilityDays||30,weeklySchedule:(null===(e=a.weeklySchedule)||void 0===e?void 0:e.map(e=>({dayOfWeek:e.dayOfWeek,timeRanges:[{start:e.start?e.start.format("HH:mm"):"",end:e.end?e.end.format("HH:mm"):""}]})))||[],breaks:C||[]},i=await b({audience:"https://tokenverification"});(await k.A.post("".concat(U,"/api/teacher/").concat(H,"/availability"),t,{headers:{Authorization:"Bearer ".concat(i)}})).data&&(h.Ay.success("Breaks saved successfully"),await Q())}catch(a){console.error("Error saving breaks:",a),h.Ay.error("Failed to save breaks")}finally{S(!1)}},loading:w,style:{backgroundColor:q,borderColor:q},children:"Save Recurring Breaks"})})]})},"recurring"),(0,P.jsx)(V,{tab:"Date-Specific Breaks",children:(0,P.jsx)(N,{teacherEmail:null===g||void 0===g?void 0:g.email})},"specific")]})},"breaks"),(0,P.jsx)(V,{tab:"Weekly Preview",children:(0,P.jsx)(J,{availability:ee.weeklySchedule,breaks:ee.breaks,timeZone:ee.timeZone})},"preview")]})]})};$.defaultProps={teacherId:null};const ee=$}}]);
2//# sourceMappingURL=3679.0a5543a6.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.