PageSourceSearch

https://studycafe.se/_next/static/chunks/pages/admin/shifts-25503f394902490f.js

js studycafe.se collected 2026-10-08 03:20:42 UTC 54,205 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6362],{43551:function(e,t,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/shifts",function(){return r(37518)}])},61042:function(e,t,r){"use strict";r.d(t,{k:function(){return s}});var i=r(85893),a=r(99226),n=r(87952),o=r(15861);let s=e=>(0,i.jsxs)(a.Z,{sx:{display:"flex",alignItems:"center"},children:[(0,i.jsx)(n.Z,{alt:e.name||"",sx:{width:"1.875rem",height:"1.875rem",borderRadius:5},src:e.avatarSrc||""}),(0,i.jsxs)(a.Z,{sx:{display:"flex",alignItems:"flex-start",flexDirection:"column",ml:2},children:[(0,i.jsx)(o.Z,{variant:"subtitle1",children:e.name}),(0,i.jsx)(o.Z,{noWrap:!0,variant:"caption",children:e.subText})]})]})},37518:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return eF}});var i,a,n=r(85893),o=r(67294),s=r(99226),l=r(87952),d=r(15861),c=r(26447),p=r(86886),m=r(78462),u=r(46901),h=r(83321),x=r(19294),g=r(98619),b=r(18987),v=r(59334),f=r(93395),y=r(93946),j=r(7631),k=r(55008),Z=r(63730),_=r(13529),P=r(18597),C=r(30381),w=r.n(C),S=r(6882),I=r(81010),T=r(96486),M=r.n(T),D=r(50613),L=r(45013),O=r(90948),F=r(41796),N=r(38333),R=r(18972),W=r(77957),G=r(75503);let H=(0,O.ZP)(e=>(0,n.jsx)(N.Z,{elevation:0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},...e}))(e=>{let{theme:t}=e;return{"& .MuiPaper-root":{borderRadius:6,marginTop:t.spacing(1),minWidth:180,color:"light"===t.palette.mode?"rgb(55, 65, 81)":t.palette.grey[300],boxShadow:"rgb(255, 255, 255) 0px 0px 0px 0px, rgba(0, 0, 0, 0.05) 0px 0px 0px 1px, rgba(0, 0, 0, 0.1) 0px 10px 15px -3px, rgba(0, 0, 0, 0.05) 0px 4px 6px -2px","& .MuiMenu-list":{padding:"4px 0"},"& .MuiMenuItem-root":{"& .MuiSvgIcon-root":{fontSize:18,color:t.palette.text.secondary,marginRight:t.spacing(1.5)},"&:active":{backgroundColor:(0,F.Fq)(t.palette.primary.main,t.palette.action.selectedOpacity)}}}}}),E=e=>{var t;let[r,i]=o.useState(null),a=!!r,s=e=>{i(e.currentTarget)},l=()=>{i(null)};return(0,n.jsxs)("div",{children:[(0,n.jsx)(h.Z,{...e,id:"demo-customized-button","aria-controls":a?"demo-customized-menu":void 0,"aria-haspopup":"true","aria-expanded":a?"true":void 0,disableElevation:!0,onClick:s,endIcon:(0,n.jsx)(G.Z,{}),children:e.title}),(0,n.jsx)(H,{id:"demo-customized-menu",MenuListProps:{"aria-labelledby":"demo-customized-button"},anchorEl:r,open:a,onClose:l,children:null===(t=e.menuItems)||void 0===t?void 0:t.map((e,t)=>(0,n.jsxs)(R.Z,{onClick:e.onClick,disableRipple:!0,children:[(0,n.jsx)(W.Z,{}),e.title]},"menuItem-"+t))})]})};var A=r(41733),Y=r(22120);let U=e=>{let{t}=(0,Y.$G)();return(0,n.jsxs)(p.ZP,{container:!0,columnSpacing:2,sx:{padding:"6px 12px"},children:[(0,n.jsx)(p.ZP,{item:!0,children:(0,n.jsx)(E,{title:"Status",variant:"outlined",menuItems:[{title:"Approve",onClick:()=>console.log("approve selected")}]})}),(0,n.jsx)(p.ZP,{item:!0,children:(0,n.jsx)(h.Z,{disabled:e.disableDelete,onClick:e.onDelete,startIcon:(0,n.jsx)(A.Z,{sx:{color:e.disableDelete?"#e7e6e8":"red"}}),variant:"outlined",children:t("adminPage.shifts.deleteButtonLabel")})})]})};var z=r(23918),B=r(81134),q=r(66242),Q=r(69368),$=r(51049);let X=e=>{let{shifts:t,onDeleteShift:r}=e,{showConfirmation:i}=(0,B.p)(),{t:a}=(0,Y.$G)(),[l,c]=(0,o.useState)([]),p=e=>{c(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},u=async()=>{if(0===l.length)return;let e=await i({message:a("adminPage.shifts.deleteMultipleShiftsConfirmationMessage",{count:l.length}),title:a("adminPage.shifts.deleteShiftConfirmationTitle"),confirmButtonText:a("common.delete")});e&&(await r(l),c([]))};return(0,n.jsx)(q.Z,{children:(0,n.jsxs)(s.Z,{p:3,children:[(0,n.jsxs)(s.Z,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[(0,n.jsx)(d.Z,{variant:"h6",children:a("adminPage.shifts.myShifts")}),l.length>0&&(0,n.jsxs)($.KM,{onClick:u,children:[a("common.delete")," (",l.length,")"]})]}),(0,n.jsx)(m.Z,{children:t.map(e=>(0,n.jsxs)(x.ZP,{divider:!0,children:[(0,n.jsx)(Q.Z,{checked:l.includes(e.id),onChange:()=>p(e.id)}),(0,n.jsx)(v.Z,{primary:e.name,secondary:"".concat(w()(e.startTime).format("YYYY-MM-DD HH:mm")," - ").concat(w()(e.endTime).format("HH:mm"))}),(0,n.jsx)(f.Z,{children:(0,n.jsx)(y.Z,{edge:"end",onClick:()=>r([e.id]),children:(0,n.jsx)(Z.Z,{icon:"mdi:delete"})})})]},e.id))})]})})};var V=r(2734),K=r(98396),J=r(76624),ee=r(44472),et=r(83578),er=r(76229),ei=r(94054),ea=r(50135),en=r(33841),eo=r(18360),es=r(56815),el=r(34386),ed=r(67720),ec=r(9354),ep=r(50591),em=r(25812);r(459);let eu=(0,O.ZP)(s.Z)(e=>{let{theme:t}=e,{settings:r}=(0,z.r)(),i=(0,ep.Z)();return{"& .react-datepicker-popper":{zIndex:20},"& .react-datepicker-wrapper":{width:"100%"},"& .react-datepicker":{color:t.palette.text.primary,borderRadius:t.shape.borderRadius,fontFamily:t.typography.fontFamily,backgroundColor:t.palette.background.paper,boxShadow:t.shadows["bordered"===r.skin?0:7],border:"bordered"===r.skin?"1px solid ".concat(t.palette.divider):"none","& .react-datepicker__header":{padding:0,border:"none",fontWeight:"normal",backgroundColor:t.palette.background.paper,"&:not(.react-datepicker-year-header)":{"& + .react-datepicker__month, & + .react-datepicker__year":{margin:t.spacing(3.2),marginTop:t.spacing(6)}},"&.react-datepicker-year-header":{"& + .react-datepicker__month, & + .react-datepicker__year":{margin:t.spacing(3.2),marginTop:t.spacing(4)}}},"& .react-datepicker__triangle":{display:"none"},"& > .react-datepicker__navigation":{top:18,"&.react-datepicker__navigation--previous":{width:24,height:24,border:"none",..."ltr"===t.direction?{left:15}:{right:15},backgroundImage:"".concat("url('data:image/svg+xml,%3Csvg xmlns=\\'http://www.w3.org/2000/svg\\' style=\\'width:24px;height:24px\\' viewBox=\\'0 0 24 24\\'%3E%3Cpath fill=\\'currentColor\\' d=\\'M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z\\' /%3E%3C/svg%3E')".replace("currentColor",t.palette.text.secondary).replace("#","%23")),"& .react-datepicker__navigation-icon":{display:"none"}},"&.react-datepicker__navigation--next":{width:24,height:24,border:"none",..."ltr"===t.direction?{right:15}:{left:15},backgroundImage:"".concat("url('data:image/svg+xml,%3Csvg xmlns=\\'http://www.w3.org/2000/svg\\' style=\\'width:24px;height:24px\\' viewBox=\\'0 0 24 24\\'%3E%3Cpath fill=\\'currentColor\\' d=\\'M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z\\' /%3E%3C/svg%3E')".replace("currentColor",t.palette.text.secondary).replace("#","%23")),"& .react-datepicker__navigation-icon":{display:"none"}},"&.react-datepicker__navigation--next--with-time":"ltr"===t.direction?{right:127}:{left:127},"&:focus, &:active":{outline:0}},"& .react-datepicker__month-container":{paddingTop:t.spacing(3.2)},"& .react-datepicker__current-month, & .react-datepicker-year-header":{lineHeight:2.1,fontSize:"1rem",fontWeight:"normal",letterSpacing:"0.15px",marginBottom:t.spacing(2),color:t.palette.text.primary},"& .react-datepicker__day-name":{margin:0,lineHeight:1.5,width:"2.25rem",fontSize:"0.75rem",letterSpacing:"0.4px",color:t.palette.text.secondary},"& .react-datepicker__day":{margin:0,width:"2.25rem",borderRadius:"50%",lineHeight:"2.25rem",color:t.palette.text.primary,"&.react-datepicker__day--selected.react-datepicker__day--in-selecting-range.react-datepicker__day--selecting-range-start, &.react-datepicker__day--selected.react-datepicker__day--range-start.react-datepicker__day--in-range, &.react-datepicker__day--range-start":{borderTopLeftRadius:"50%",borderBottomLeftRadius:"50%",color:"".concat(t.palette.common.white," !important"),backgroundColor:"".concat(t.palette.primary.main," !important")},"&.react-datepicker__day--range-end.react-datepicker__day--in-range":{borderTopRightRadius:"50%",borderBottomRightRadius:"50%",color:"".concat(t.palette.common.white," !important"),backgroundColor:"".concat(t.palette.primary.main," !important")},"&:focus, &:active":{outline:0},"&.react-datepicker__day--outside-month, &.react-datepicker__day--disabled:not(.react-datepicker__day--selected)":{color:t.palette.text.disabled,"&:hover":{backgroundColor:"transparent"}},"&.react-datepicker__day--highlighted, &.react-datepicker__day--highlighted:hover":{color:t.palette.success.main,backgroundColor:"".concat(i.successLight.backgroundColor," !important"),"&.react-datepicker__day--selected":{backgroundColor:"".concat(t.palette.primary.main," !important")}}},"& .react-datepicker__day--in-range, & .react-datepicker__day--in-selecting-range":{borderRadius:0,color:t.palette.primary.main,backgroundColor:"".concat((0,em.E)(t.palette.primary.main,.06)," !important")},"& .react-datepicker__day--today":{fontWeight:"normal","&:not(.react-datepicker__day--selected):not(:empty)":{lineHeight:"2.125rem",color:t.palette.primary.main,border:"1px solid ".concat(t.palette.primary.main),"&:hover":{backgroundColor:(0,em.E)(t.palette.primary.main,.04)},"&.react-datepicker__day--keyboard-selected":{backgroundColor:(0,em.E)(t.palette.primary.main,.06),"&:hover":{backgroundColor:(0,em.E)(t.palette.primary.main,.06)}}}},"& .react-datepicker__month-text--today":{fontWeight:"normal","&:not(.react-datepicker__month--selected)":{lineHeight:"2.125rem",color:t.palette.primary.main,border:"1px solid ".concat(t.palette.primary.main),"&:hover":{backgroundColor:(0,em.E)(t.palette.primary.main,.04)}}},"& .react-datepicker__year-text--today":{fontWeight:"normal","&:not(.react-datepicker__year-text--selected)":{lineHeight:"2.125rem",color:t.palette.primary.main,border:"1px solid ".concat(t.palette.primary.main),"&:hover":{backgroundColor:(0,em.E)(t.palette.primary.main,.04)},"&.react-datepicker__year-text--keyboard-selected":{color:t.palette.primary.main,backgroundColor:(0,em.E)(t.palette.primary.main,.06),"&:hover":{color:t.palette.primary.main,backgroundColor:(0,em.E)(t.palette.primary.main,.06)}}}},"& .react-datepicker__day--keyboard-selected":{"&:not(.react-datepicker__day--in-range)":{backgroundColor:"rgba(".concat(t.palette.customColors.main,", 0.06)"),"&:hover":{backgroundColor:"rgba(".concat(t.palette.customColors.main,", 0.06)")}},"&.react-datepicker__day--in-range:not(.react-datepicker__day--range-end)":{backgroundColor:"".concat(i.primaryLight.backgroundColor," !important"),"&:hover":{backgroundColor:"".concat(i.primaryLight.backgroundColor," !important")}}},"& .react-datepicker__month-text--keyboard-selected":{"&:not(.react-datepicker__month--in-range)":{color:t.palette.text.primary,backgroundColor:"rgba(".concat(t.palette.customColors.main,", 0.06)"),"&:hover":{color:t.palette.text.primary,backgroundColor:"rgba(".concat(t.palette.customColors.main,", 0.06)")}}},"& .react-datepicker__year-text--keyboard-selected, & .react-datepicker__quarter-text--keyboard-selected":{color:t.palette.text.primary,backgroundColor:"rgba(".concat(t.palette.customColors.main,", 0.06)"),"&:hover":{color:t.palette.text.primary,backgroundColor:"rgba(".concat(t.palette.customColors.main,", 0.06)")}},"& .react-datepicker__day--selected, & .react-datepicker__month--selected, & .react-datepicker__year-text--selected, & .react-datepicker__quarter--selected":{color:"".concat(t.palette.common.white," !important"),backgroundColor:"".concat(t.palette.primary.main," !important"),"&:hover":{backgroundColor:"".concat(t.palette.primary.dark," !important")}},"& .react-datepicker__header__dropdown":{"& .react-datepicker__month-dropdown-container:not(:last-child)":{marginRight:t.spacing(8)},"& .react-datepicker__month-dropdown-container, & .react-datepicker__year-dropdown-container":{marginBottom:t.spacing(4)},"& .react-datepicker__month-read-view--selected-month, & .react-datepicker__year-read-view--selected-year":{fontSize:"0.875rem",marginRight:t.spacing(1),color:t.palette.text.primary},"& .react-datepicker__month-read-view:hover .react-datepicker__month-read-view--down-arrow, & .react-datepicker__year-read-view:hover .react-datepicker__year-read-view--down-arrow":{borderColor:t.palette.text.secondary},"& .react-datepicker__month-read-view--down-arrow, & .react-datepicker__year-read-view--down-arrow":{top:4,borderColor:t.palette.text.disabled},"& .react-datepicker__month-dropdown, & .react-datepicker__year-dropdown":{paddingTop:t.spacing(2),paddingBottom:t.spacing(2),borderColor:t.palette.divider,borderRadius:t.shape.borderRadius,backgroundColor:t.palette.background.paper,boxShadow:"light"===t.palette.mode?t.shadows[8]:t.shadows[9]},"& .react-datepicker__month-option, & .react-datepicker__year-option":{paddingTop:t.spacing(1),paddingBottom:t.spacing(1),"&:first-of-type, &:last-of-type":{borderRadius:0},"&:hover":{backgroundColor:t.palette.action.hover}},"& .react-datepicker__month-option.react-datepicker__month-option--selected_month":{backgroundColor:(0,em.E)(t.palette.primary.main,.08),"&:hover":{backgroundColor:i.primaryLight.backgroundColor},"& .react-datepicker__month-option--selected":{display:"none"}},"& .react-datepicker__year-option.react-datepicker__year-option--selected_year":{backgroundColor:(0,em.E)(t.palette.primary.main,.08),"&:hover":{backgroundColor:i.primaryLight.backgroundColor},"& .react-datepicker__year-option--selected":{display:"none"}},"& .react-datepicker__year-option":{"& .react-datepicker__navigation--years-upcoming":{width:9,height:9,borderStyle:"solid",borderWidth:"3px 3px 0 0",transform:"rotate(-45deg)",borderTopColor:t.palette.text.disabled,borderRightColor:t.palette.text.disabled,margin:"".concat(t.spacing(2.75)," auto ").concat(t.spacing(0))},"&:hover .react-datepicker__navigation--years-upcoming":{borderTopColor:t.palette.text.secondary,borderRightColor:t.palette.text.secondary},"& .react-datepicker__navigation--years-previous":{width:9,height:9,borderStyle:"solid",borderWidth:"0 0 3px 3px",transform:"rotate(-45deg)",borderLeftColor:t.palette.text.disabled,borderBottomColor:t.palette.text.disabled,margin:"".concat(t.spacing(0)," auto ").concat(t.spacing(2.75))},"&:hover .react-datepicker__navigation--years-previous":{borderLeftColor:t.palette.text.secondary,borderBottomColor:t.palette.text.secondary}}},"& .react-datepicker__week-number":{margin:0,fontWeight:600,width:"2.25rem",lineHeight:"2.25rem",color:t.palette.text.primary},"& .react-datepicker__month-text, & .react-datepicker__year-text, & .react-datepicker__quarter-text":{margin:0,alignItems:"center",lineHeight:"2.25rem",display:"inline-flex",justifyContent:"center",borderRadius:t.shape.borderRadius,"&:focus, &:active":{outline:0}},"& .react-datepicker__year--container":{paddingTop:t.spacing(3.2)},"& .react-datepicker__year-wrapper":{maxWidth:205,justifyContent:"center"},"& .react-datepicker__input-time-container":{display:"flex",alignItems:"center",..."rtl"===t.direction?{flexDirection:"row-reverse"}:{}},"& .react-datepicker__today-button":{borderTop:0,borderRadius:"1rem",margin:t.spacing(0,4,4),color:t.palette.common.white,backgroundColor:t.palette.primary.main},"&:not(.react-datepicker--time-only)":{"& .react-datepicker__time-container":{borderLeftColor:t.palette.divider,[t.breakpoints.down("sm")]:{width:"5.5rem"},[t.breakpoints.up("sm")]:{width:"7rem"}},".react-datepicker-time__header":{paddingTop:t.spacing(3.2)}},"&.react-datepicker--time-only":{width:"7rem",padding:t.spacing(1.2,0),"& .react-datepicker__time-container":{width:"calc(7rem - 2px)"}},"& .react-datepicker__time-container":{padding:t.spacing(1.2,0),"& .react-datepicker-time__header":{fontSize:"1rem",lineHeight:1.31,fontWeight:"normal",letterSpacing:"0.15px",marginBottom:t.spacing(3),color:t.palette.text.primary},"& .react-datepicker__time":{background:t.palette.background.paper,"& .react-datepicker__time-box .react-datepicker__time-list-item--disabled":{pointerEvents:"none",color:t.palette.text.disabled,"&.react-datepicker__time-list-item--selected":{fontWeight:"normal",backgroundColor:t.palette.action.disabledBackgroun
1d}}},"& .react-datepicker__time-list-item":{lineHeight:1.75,height:"auto !important",marginLeft:t.spacing(3.2),marginRight:t.spacing(1.2),color:t.palette.text.primary,borderRadius:t.shape.borderRadius,"&:focus, &:active":{outline:0},"&:hover":{backgroundColor:"".concat(t.palette.action.hover," !important")},"&.react-datepicker__time-list-item--selected:not(.react-datepicker__time-list-item--disabled)":{fontWeight:"600 !important",color:"".concat(t.palette.common.white," !important"),backgroundColor:"".concat(t.palette.primary.main," !important")}},"& .react-datepicker__time-box":{width:"100%"},"& .react-datepicker__time-list":{"&::-webkit-scrollbar":{width:8},"&::-webkit-scrollbar-track":{background:t.palette.background.paper},"&::-webkit-scrollbar-thumb":{borderRadius:10,background:"#aaa"},"&::-webkit-scrollbar-thumb:hover":{background:"#999"}}},"& .react-datepicker__day:hover, & .react-datepicker__month-text:hover, & .react-datepicker__quarter-text:hover, & .react-datepicker__year-text:hover":{backgroundColor:t.palette.action.hover}},"& .react-datepicker__close-icon":{paddingRight:t.spacing(4),..."rtl"===t.direction?{right:0,left:"auto"}:{},"&:after":{width:"unset",height:"unset",fontSize:"1.5rem",color:t.palette.text.primary,backgroundColor:"transparent !important"}}}});var eh=r(87536),ex=r(9198),eg=r.n(ex),eb=r(61042),ev=r(50480),ef=r(33454),ey=r(96420);let ej=e=>{let{startTime:t,endTime:r,onRecurrentShiftsChange:i}=e,{t:a}=(0,Y.$G)(),[l,c]=(0,o.useState)(!1),[m,u]=(0,o.useState)(1),[h,x]=(0,o.useState)([]),g=[{value:1,label:a("common.weekdays.monday")},{value:2,label:a("common.weekdays.tuesday")},{value:3,label:a("common.weekdays.wednesday")},{value:4,label:a("common.weekdays.thursday")},{value:5,label:a("common.weekdays.friday")},{value:6,label:a("common.weekdays.saturday")},{value:0,label:a("common.weekdays.sunday")}],b=(e,t)=>{let r=t||[];x(r),f(r,m)},v=e=>{let t=parseInt(e.target.value);t>0&&(u(t),f(h||[],t))},f=(e,a)=>{if(!t||!r||!e.length)return;let n=[],o=w()(r).diff(w()(t),"minutes");n.push({start:t,end:r});for(let r=1;r<a;r++)e.forEach(e=>{let i=w()(t).add(r,"weeks").day(e);n.push({start:i.toDate(),end:w()(i).add(o,"minutes").toDate()})});n.sort((e,t)=>e.start.getTime()-t.start.getTime()),i(n)};return l?(0,n.jsx)(s.Z,{sx:{mt:2},children:(0,n.jsxs)(p.ZP,{container:!0,spacing:3,children:[(0,n.jsx)(p.ZP,{item:!0,xs:12,children:(0,n.jsx)(ev.Z,{control:(0,n.jsx)(Q.Z,{checked:l,onChange:e=>c(e.target.checked)}),label:a("adminPage.shifts.recurrentShift")})}),(0,n.jsxs)(p.ZP,{item:!0,xs:12,children:[(0,n.jsx)(d.Z,{variant:"subtitle2",sx:{mb:2},children:a("adminPage.shifts.selectWeekdays")}),(0,n.jsx)(ef.Z,{value:h,onChange:b,"aria-label":"weekdays",children:g.map(e=>(0,n.jsx)(ey.Z,{value:e.value,"aria-label":e.label,children:e.label},e.value))})]}),(0,n.jsx)(p.ZP,{item:!0,xs:12,md:6,children:(0,n.jsx)(ea.Z,{fullWidth:!0,type:"number",label:a("adminPage.shifts.numberOfWeeks"),value:m,onChange:v,inputProps:{min:1}})})]})}):(0,n.jsx)(ev.Z,{control:(0,n.jsx)(Q.Z,{checked:l,onChange:e=>c(e.target.checked)}),label:a("adminPage.shifts.recurrentShift")})};var ek=r(37042),eZ=r(4543),e_=r(47533),eP=r(16310),eC=r(86501);let ew=(0,O.ZP)(s.Z)(e=>{let{theme:t}=e,r=(0,ep.Z)();return{[t.breakpoints.down("md")]:{"& .MuiStepper-horizontal:not(.MuiStepper-alternativeLabel)":{flexDirection:"column",alignItems:"flex-start"}},"& .MuiStep-root":{"& .step-label":{display:"flex",alignItems:"center",justifyContent:"center"},"& .step-number":{fontWeight:"bold",fontSize:"2.125rem",marginRight:t.spacing(2.5),color:t.palette.text.primary},"& .step-title":{fontWeight:600,fontSize:"0.875rem",color:t.palette.text.primary},"& .step-subtitle":{fontSize:"0.75rem",color:t.palette.text.secondary},"& .MuiStepLabel-root.Mui-disabled":{"& .step-number":{color:t.palette.text.disabled}},"& .Mui-error":{"& .MuiStepLabel-labelContainer, & .step-number, & .step-title, & .step-subtitle":{color:t.palette.error.main}}},"& .MuiStepConnector-root":{"& .MuiStepConnector-line":{borderWidth:3,borderRadius:3},"&.Mui-active, &.Mui-completed":{"& .MuiStepConnector-line":{borderColor:t.palette.primary.main}},"&.Mui-disabled .MuiStepConnector-line":{borderColor:r.primaryLight.backgroundColor}},"& .MuiStepper-alternativeLabel":{"& .MuiStepConnector-root":{top:10},"& .MuiStepLabel-labelContainer":{display:"flex",alignItems:"center",flexDirection:"column","& > * + *":{marginTop:t.spacing(1)}}},"& .MuiStepper-vertical":{"& .MuiStep-root":{"& .step-label":{justifyContent:"flex-start"},"& .MuiStepContent-root":{borderWidth:3,marginLeft:t.spacing(2.25),borderColor:t.palette.primary.main},"& .button-wrapper":{marginTop:t.spacing(4)},"&.active + .MuiStepConnector-root .MuiStepConnector-line":{borderColor:t.palette.primary.main}},"& .MuiStepConnector-root":{marginLeft:t.spacing(2.25),"& .MuiStepConnector-line":{borderRadius:0}}}}});(i=a||(a={}))[i.MainForm=0]="MainForm",i[i.UserSelect=1]="UserSelect",i[i.Confirmation=2]="Confirmation";let eS={description:"",startTime:(0,ek.default)((0,eZ.default)(new Date,0),16).toISOString(),endTime:(0,ek.default)((0,eZ.default)(new Date,0),20).toISOString(),teacherId:void 0,autoApprovalMaxLimit:15,visibleToGroupIds:[],visibleToUserIds:[],participantGroupIds:[],participantUserIds:[]},eI=e=>[{title:e("adminPage.shifts.steps.shiftDetails"),subtitle:e("adminPage.shifts.steps.shiftDetailsSubtitle")},{title:e("adminPage.shifts.steps.usersAndGroups"),subtitle:e("adminPage.shifts.steps.usersAndGroupsSubtitle")},{title:e("adminPage.shifts.steps.confirmation"),subtitle:e("adminPage.shifts.steps.confirmationSubtitle")}],eT=e=>{let t=(0,j.m)(),{t:r}=(0,Y.$G)(),i=(0,V.Z)(),l=(0,K.Z)(i.breakpoints.up("md"),{defaultMatches:!0}),[c,p]=(0,o.useState)([]),[m,u]=(0,o.useState)([]),[h,x]=(0,o.useState)([]),[g,b]=(0,o.useState)([]),[v,f]=(0,o.useState)(0),y=eP.Ry().shape({name:eP.Z_().required(r("common.required")),description:eP.Z_(),type:eP.Rx().required(r("adminPage.shifts.typeRequired")),startTime:eP.Z_().nullable().required(r("common.required")),endTime:eP.Z_().nullable().required(r("common.required")),teacherId:eP.Rx().required(r("adminPage.shifts.teacherRequired")),autoApprovalMaxLimit:eP.Rx().when("type",{is:e=>e!==k.IF.OneOnOne,then:e=>e.required(r("adminPage.shifts.autoApprovalMaxLimitRequired")),otherwise:e=>e.notRequired()}),visibleToGroupIds:eP.IX(),visibleToUserIds:eP.IX(),participantGroupIds:eP.IX(),participantUserIds:eP.IX()}),{control:Z,handleSubmit:_,watch:P,reset:C,setValue:S,formState:{errors:I}}=(0,eh.cI)({defaultValues:eS,resolver:(0,e_.X)(y),mode:"onChange"}),T=P("type"),D=P("teacherId");(0,o.useEffect)(()=>{S("participantUserIds",void 0),S("participantGroupIds",void 0),S("visibleToGroupIds",void 0),S("visibleToUserIds",void 0)},[T]);let L=e=>{p(e)},O=()=>
1{C(eS),f(a.MainForm),e.handleDialogClose()},F=e=>{switch(e){case"autoApprovalMaxLimit":return{visible:T!==k.IF.OneOnOne&&void 0!==T,label:r("adminPage.shifts.autoApprovalMaxLimit")};case"visibleTo":return{visible:T===k.IF.Seminar||T===k.IF.QueuePass,required:T===k.IF.Seminar||T===k.IF.QueuePass};case"participantUserIds":case"participantGroupIds":return{visible:T===k.IF.OneOnOne||T===k.IF.OneToMany,required:T===k.IF.OneOnOne||T===k.IF.OneToMany};default:return{required:!1,visible:!0,label:""}}},N=async i=>{try{if(c.length>0){for(let e of c)await t.shift.save({...i,startTime:e.start.toISOString(),endTime:e.end.toISOString()});eC.ZP.success(r("adminPage.shifts.multipleShiftsAdded",{count:c.length}),{duration:5e3})}else{if(!i.startTime||!i.endTime){eC.ZP.error(r("adminPage.shifts.toastErrorMessages.timeRequired"));return}await t.shift.save({...i,startTime:w()(i.startTime).toISOString(),endTime:w()(i.endTime).toISOString()}),eC.ZP.success(r("adminPage.shifts.shiftAdded",{from:w()(i.startTime).format("MMMM Do YYYY, HH:mm"),to:w()(i.endTime).format("HH:mm")}),{duration:5e3})}O(),e.onSubmitted()}catch(e){var a;(null===(a=e.error)||void 0===a?void 0:a.message)==="overlapping-shift"?eC.ZP.error(r("adminPage.shifts.toastErrorMessages.overlappingShift")):eC.ZP.error(r("adminPage.shifts.toastErrorMessages.errorAddingShifts"))}},R=async()=>{let e=await t.user.search({Roles:[k.i4.Teacher]});u(M().orderBy(e.data,e=>e.firstName))},W=async()=>{let e=await t.user.search({Roles:[k.i4.Student]});b(M().orderBy(e.data,e=>e.firstName))},G=e=>{switch(e){case a.MainForm:return(0,n.jsx)(eM,{watch:P,control:Z,errors:I,teachers:m,onRecurrentShiftsChange:L,getFieldProps:F,onPreviousStep:O,onNextStep:()=>{f(a.UserSelect)}});case a.UserSelect:return(0,n.jsx)(eD,{watch:P,control:Z,errors:I,getFieldProps:F,watchedType:T,selectedTeacherId:D,onGroupChange:e=>{x(e)},onPreviousStep:()=>{f(a.MainForm)},onNextStep:()=>{f(a.Confirmation)}});case a.Confirmation:return(0,n.jsx)(eL,{watch:P,teachers:m,groups:h,students:g,recurrentShifts:c,onNextStep:()=>{_(N)()},onPreviousStep:()=>{f(a.UserSelect)}})}};return(0,o.useEffect)(()=>{e.isBookingDialogOpen&&e.selectedDay&&(R(),W(),S("startTime",(0,ek.default)((0,eZ.default)(e.selectedDay,0),16).toISOString()),S("endTime",(0,ek.default)((0,eZ.default)(e.selectedDay,0),20).toISOString()))},[e.isBookingDialogOpen,e.selectedDay]),(0,n.jsx)(ec.o,{open:e.isBookingDialogOpen,onClose:e.handleDialogClose,title:r("adminPage.shifts.addNewShiftDialogTitle"),containerStyles:{minHeight:l?"390px":void 0,minWidth:l?"600px":void 0},children:(0,n.jsx)(s.Z,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:(0,n.jsx)("form",{onSubmit:_(N),noValidate:!0,children:(0,n.jsx)(ew,{children:(0,n.jsx)(J.Z,{activeStep:v,orientation:"vertical",children:eI(r).map((e,t)=>(0,n.jsxs)(ee.Z,{active:v===t,children:[(0,n.jsx)(et.Z,{children:(0,n.jsx)("div",{className:"step-label",children:(0,n.jsxs)("div",{children:[(0,n.jsx)(d.Z,{className:"step-title",children:e.title}
1),(0,n.jsx)(d.Z,{className:"step-subtitle",children:e.subtitle})]})})}),(0,n.jsx)(eu,{sx:{padding:"15px 0"},children:(0,n.jsx)(er.Z,{sx:{padding:"8px"},children:G(t)})})]},t))})})})})})};function eM(e){let{t}=(0,Y.$G)(),r=e.watch("type"),i=e.watch("teacherId"),a=e.watch("name"),o=e.watch("startTime"),s=e.watch("endTime");return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(p.ZP,{container:!0,columnSpacing:2,rowGap:5,direction:"row",children:[(0,n.jsx)(p.ZP,{item:!0,xs:12,children:(0,n.jsx)(ei.Z,{fullWidth:!0,error:!!e.errors.name,children:(0,n.jsx)(eh.Qr,{name:"name",control:e.control,render:r=>{var i;let{field:a}=r;return(0,n.jsx)(ea.Z,{...a,label:t("common.name"),error:!!e.errors.name,helperText:null===(i=e.errors.name)||void 0===i?void 0:i.message})}})})}),(0,n.jsx)(p.ZP,{item:!0,xs:12,children:(0,n.jsx)(ei.Z,{fullWidth:!0,children:(0,n.jsx)(eh.Qr,{name:"description",control:e.control,render:e=>{let{field:r}=e;return(0,n.jsx)(ea.Z,{...r,label:t("common.description"),multiline:!0,rows:2})}})})}),(0,n.jsx)(p.ZP,{item:!0,xs:12,md:6,children:(0,n.jsx)(ei.Z,{fullWidth:!0,children:(0,n.jsx)(eh.Qr,{name:"type",control:e.control,render:e=>{let{field:r}=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(en.Z,{id:"shift-type-label",children:t("adminPage.shifts.shiftType")}),(0,n.jsxs)(eo.Z,{...r,labelId:"shift-type-label",label:t("adminPage.shifts.shiftType"),children:[(0,n.jsx)(R.Z,{value:k.IF.QueuePass,children:t("adminPage.shifts.types.queuePass")}),(0,n.jsx)(R.Z,{value:k.IF.OneOnOne,children:t("adminPage.shifts.types.oneOnOne")}),(0,n.jsx)(R.Z,{value:k.IF.Seminar,children:t("adminPage.shifts.types.seminar")})]})]})}})})}),(0,n.jsx)(p.ZP,{item:!0,xs:12,md:6,children:(0,n.jsx)(ei.Z,{fullWidth:!0,error:!!e.errors.teacherId,children:(0,n.jsx)(eh.Qr,{name:"teacherId",control:e.control,render:r=>{var i;let{field:a}=r;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(en.Z,{htmlFor:"teacher-select",children:t("common.teacher")}),(0,n.jsx)(eo.Z,{...a,label:t("common.teacher"),error:!!e.errors.teacherId,inputProps:{name:"teacher",id:"teacher-select"},children:null===(i=e.teachers)||void 0===i?void 0:i.map(e=>(0,n.jsxs)(R.Z,{value:e.id,children:[e.firstName," ",e.lastName]},e.id))}),e.errors.teacherId&&(0,n.jsx)(es.Z,{children:e.errors.teacherId.message})]})}})})}),(0,n.jsx)(p.ZP,{item:!0,xs:12,md:6,children:(0,n.jsx)(ei.Z,{fullWidth:!0,error:!!e.errors.startTime,children:(0,n.jsx)(eh.Qr,{name:"startTime",control:e.control,render:r=>{var i;let{field:a}=r;return(0,n.jsx)(eg(),{showTimeSelect:!0,selected:new Date(a.value),timeIntervals:15,showTimeSelectOnly:!0,dateFormat:"yyyy-MM-dd HH:mm",timeFormat:"HH:mm",id:"starttime-picker",popperPlacement:"bottom-start",onChange:e=>a.onChange(e),customInput:(0,n.jsx)(ea.Z,{fullWidth:!0,label:t("common.startTime"),error:!!e.errors.startTime,helperText:null===(i=e.errors.startTime)||void 0===i?void 0:i.message})})}})})}),(0,n.jsx)(p.ZP,{item:!0,xs:12,md:6,children:(0,n.jsx)(ei.Z,{fullWidth:!0,error:!!e.errors.endTime,children:(0,n.jsx)(eh.Qr,{name:"endTime",control:e.control,render:r=>{var i;let{field:a}=r;return(0,n.jsx)(eg(),{showTimeSelect:!0,selected:new Date(a.value),timeIntervals:15,showTimeSelectOnly:!0,dateFormat:"yyyy-MM-dd HH:mm",timeFormat:"HH:mm",id:"endtime-picker",popperPlacement:"bottom-start",onChange:e=>a.onChange(e),customInput:(0,n.jsx)(ea.Z,{fullWidth:!0,label:t("common.endTime"),error:!!e.errors.endTime,helperText:null===(i=e.errors.endTime)||void 0===i?void 0:i.message})})}})})}),(0,n.jsx)(p.ZP,{item:!0,xs:12,children:(0,n.jsx)(ej,{startTime:new Date(e.watch("startTime")),endTime:new Date(e.watch("endTime")),onRecurrentShiftsChange:e.onRecurrentShiftsChange})}),e.getFieldProps("autoApprovalMaxLimit").visible&&(0,n.jsx)(p.ZP,{item:!0,xs:12,md:6,children:(0,n.jsx)(ei.Z,{fullWidth:!0,error:!!e.errors.autoApprovalMaxLimit,children:(0,n.jsx)(eh.Qr,{name:"autoApprovalMaxLimit",control:e.control,render:r=>{var i;let{field:a}=r;return(0,n.jsx)(el.Z,{title:t("adminPage.shifts.autoApprovalTooltip"),children:(0,n.jsx)(ea.Z,{...a,label:e.getFieldProps("autoApprovalMaxLimit").label,type:"number",error:!!e.errors.autoApprovalMaxLimit,helperText:null===(i=e.errors.autoApprovalMaxLimit)||void 0===i?void 0:i.message})})}})})})]}),(0,n.jsxs)(p.ZP,{container:!0,justifyContent:"flex-end",spacing:2,sx:{mt:4},children:[(0,n.jsx)(h.Z,{onClick:e.onPreviousStep,children:t("common.cancel")}),(0,n.jsx)($.KM,{disabled:!(a&&i&&void 0!==r&&o&&s),onClick:e.onNextStep,children:t("common.next")})]})]})}function eD(e){let{t}=(0,Y.$G)(),r=(0,V.Z)(),i=(0,j.m)(),[a,l]=(0,o.useState)([]),[c,m]=(0,o.useState)([]),u=e.watch("type"),x=async()=>{try{let t=await i.user.search({Roles:[k.i4.Student]});if(!t.ok)throw Error("Failed to fetch students");let r=t.data;if(e.selectedTeacherId&&u===k.IF.OneOnOne){let e=[];
1c.forEach(t=>{let i=r.filter(e=>{var r;return null===(r=e.groupMemberships)||void 0===r?void 0:r.some(e=>e.groupId===t.id)});e.push(...i)}),r=e=Array.from(new Set(e.map(e=>e.id))).map(t=>e.find(e=>e.id===t))}l(r)}catch(e){console.error("Failed to fetch students:",e)}},g=async()=>{try{let t=[];if(e.selectedTeacherId&&u===k.IF.OneOnOne){let r=await i.group.assignedToTeacher({UserId:e.selectedTeacherId});if(!r.ok)throw Error("Failed to fetch groups");t=r.data}else{let e=await i.group.search({});if(!e.ok)throw Error("Failed to fetch groups");t=e.data}let r=t.filter(e=>{var t;return null===(t=e.types)||void 0===t?void 0:t.some(e=>e.type===u)});m(r)}catch(e){console.error("Failed to fetch groups:",e)}};return(0,o.useEffect)(()=>{g()},[]),(0,o.useEffect)(()=>{x(),e.onGroupChange(c)},[c]),(0,n.jsxs)(p.ZP,{container:!0,columnSpacing:2,rowGap:5,direction:"row",children:[(0,n.jsxs)(p.ZP,{item:!0,xs:12,children:[e.getFieldProps("participantUserIds").visible&&(0,n.jsx)(p.ZP,{item:!0,xs:12,style:{marginTop:"16px"},children:(0,n.jsx)(ed.Z,{style:{color:r.palette.text.secondary},children:t("adminPage.shifts.bookUsersDirectly")})}),e.getFieldProps("participantGroupIds").visible&&(0,n.jsx)(p.ZP,{item:!0,xs:12,sx:{mt:4},children:(0,n.jsx)(ei.Z,{fullWidth:!0,error:!!e.errors.participantGroupIds,children:(0,n.jsx)(eh.Qr,{name:"participantGroupIds",control:e.control,render:r=>{let{field:i}=r;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(en.Z,{id:"participantGroupIds-select-label",children:t("adminPage.shifts.participantGroupIdsLabel")}),(0,n.jsxs)(eo.Z,{...i,labelId:"participantGroupIds-select-label",multiple:!0,error:!!e.errors.participantGroupIds,label:t("adminPage.shifts.participantGroupIdsLabel"),MenuProps:{PaperProps:{style:{maxHeight:300}}},renderValue:e=>{console.log({selectedParticipantGroupIds:e});let t=c.filter(t=>null==e?void 0:e.includes(t.id));return t.map(e=>e.name).join(", ")},children:[(0,n.jsxs)(s.Z,{sx:{position:"sticky",top:0,bgcolor:"background.paper",zIndex:1,p:1,display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #e0e0e0"},children:[(0,n.jsx)(d.Z,{variant:"subtitle1",children:t("adminPage.shifts.participantGroupIdsLabel")}),(0,n.jsx)(y.Z,{size:"small",children:(0,n.jsx)(Z.Z,{icon:"mdi:close"})})]}),c.map(e=>{var t;return(0,n.jsxs)(R.Z,{value:e.id,children:[(0,n.jsx)(Q.Z,{checked:null===(t=i.value)||void 0===t?void 0:t.includes(e.id)}),(0,n.jsx)(eb.k,{avatarSrc:"",name:e.name,subText:""})]},e.id)})]}),e.errors.participantGroupIds&&(0,n.jsx)(es.Z,{children:e.errors.participantGroupIds.message})]})}})})}),e.getFieldProps("participantUserIds").visible&&(0,n.jsx)(p.ZP,{item:!0,xs:12,sx:{mt:4},children:(0,n.jsx)(ei.Z,{fullWidth:!0,error:!!e.errors.participantUserIds,children:(0,n.jsx)(eh.Qr,{name:"participantUserIds",control:e.control,render:r=>{let{field:i}=r;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(en.Z,{id:"participantUserIds-select-label",children:t("adminPage.shifts.participantUserIdsLabel")}),(0,n.jsxs)(eo.Z,{...i,labelId:"participantUserIds-select-label",disabled:!a||0===a.length,multiple:!0,error:!!e.errors.participantUserIds,label:t("adminPage.shifts.participantUserIdsLabel"),MenuProps:{PaperProps:{style:{maxHeight:300}}},onChange:t=>{let r=t.target.value;if(e.watchedType!==k.IF.OneOnOne||(0,T.isArray)(r))i.onChange(r);else{var a;(null===(a=i.value)||void 0===a?void 0:a.includes(r))?i.onChange(void 0):i.onChange([r])}},renderValue:e=>{let t=a.filter(t=>{if((0,T.isArray)(e))return e.includes(t.id);t.id});return t.map(e=>"".concat(e.firstName," ").concat(e.lastName)).join(", ")},children:[(0,n.jsxs)(s.Z,{sx:{position:"sticky",top:0,bgcolor:"background.paper",zIndex:1,p:1,display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #e0e0e0"},children:[(0,n.jsx)(d.Z,{variant:"subtitle1",children:t("adminPage.shifts.participantUserIdsLabel")}),(0,n.jsx)(y.Z,{size:"small",children:(0,n.jsx)(Z.Z,{icon:"mdi:close"})})]}),a.map(e=>{var t,r;return(0,n.jsxs)(R.Z,{value:e.id,children:[(0,n.jsx)(Q.Z,{checked:(0,T.isArray)(i.value)?null===(t=i.value)||void 0===t?void 0:t.includes(e.id):i.value===e.id}),(0,n.jsx)(eb.k,{avatarSrc:(null===(r=e.avatar)||void 0===r?void 0:r.src)||"",name:"".concat(e.firstName," ").concat(e.lastName),subText:e.email||""})]},e.id)})]}),e.errors.participantUserIds&&(0,n.jsx)(es.Z,{children:e.errors.participantUserIds.message})]})}})})}),e.getFieldProps("visibleTo").visible&&(0,n.jsx)(p.ZP,{item:!0,xs:12,sx:{mt:6},children:(0,n.jsx)(ed.Z,{style:{color:r.palette.text.secondary},children:t("adminPage.shifts.allowBookingForSelected")})}),e.getFieldProps("visibleTo").visible&&(0,n.jsx)(p.ZP,{item:!0,xs:12,sx:{mt:4},children:(0,n.jsx)(ei.Z,{fullWidth:!0,error:!!e.errors.visibleToGroupIds,children:(0,n.jsx)(eh.Qr,{name:"visibleToGroupIds",control:e.control,render:r=>{let{field:i}=r;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(en.Z,{id:"visibleToGroupIds-select-label",children:t("adminPage.shifts.visibleToGroupIdsLabel")}),(0,n.jsxs)(eo.Z,{...i,labelId:"visibleToGroupIds-select-label",multiple:!0,error:!!e.errors.visibleToGroupIds,label:t("adminPage.shifts.visibleToGroupIdsLabel"),MenuProps:{PaperProps:{style:{maxHeight:300}}},renderValue:e=>{console.log({selectedVisibleToGroupIds:e});let t=c.filter(t=>null==e?void 0:e.includes(t.id));return t.map(e=>e.name).join(", ")},children:[(0,n.jsxs)(s.Z,{sx:{position:"sticky",top:0,bgcolor:"background.paper",zIndex:1,p:1,display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #e0e0e0"},children:[(0,n.jsx)(d.Z,{variant:"subtitle1",children:t("adminPage.shifts.visibleToGroupIdsLabel")}),(0,n.jsx)(y.Z,{size:"small",children:(0,n.jsx)(Z.Z,{icon:"mdi:close"})})]}),c.map(e=>{var t;return(0,n.jsxs)(R.Z,{value:e.id,children:[(0,n.jsx)(Q.Z,{checked:null===(t=i.value)||void 0===t?void 0:t.includes(e.id)}),(0,n.jsx)(eb.k,{avatarSrc:"",name:e.name,subText:""})]},e.id)})]}),e.errors.visibleToGroupIds&&(0,n.jsx)(es.Z,{children:e.errors.visibleToGroupIds.message})]})}})})}),e.getFieldProps("visibleTo").visible&&(0,n.jsx)(p.ZP,{item:!0,xs:12,sx:{mt:4},children:(0,n.jsx)(ei.Z,{fullWidth:!0,error:!!e.errors.visibleToUserIds,children:(0,n.jsx)(eh.Qr,{name:"visibleToUserIds",control:e.control,render:r=>{let{field:i}=r;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(en.Z,{id:"visibleToUserIds-select-label",children:t("adminPage.shifts.visibleToUserIdsLabel")}),(0,n.jsxs)(eo.Z,{...i,labelId:"visibleToUserIds-select-label",multiple:!0,error:!!e.errors.visibleToUserIds,label:t("adminPage.shifts.visibleToUserIdsLabel"),MenuProps:{PaperProps:{style:{maxHeight:300}}},renderValue:e=>{let t=a.filter(t=>null==e?void 0:e.includes(t.id));return t.map(e=>"".concat(e.firstName," ").concat(e.lastName)).join(", ")},children:[(0,n.jsxs)(s.Z,{sx:{position:"sticky",top:0,bgcolor:"background.paper",zIndex:1,p:1,display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #e0e0e0"},children:[(0,n.jsx)(d.Z,{variant:"subtitle1",children:t("adminPage.shifts.visibleToUserIdsLabel")}),(0,n.jsx)(y.Z,{size:"small",children:(0,n.jsx)(Z.Z,{icon:"mdi:close"})})]}),a.map(e=>{var t,r;return(0,n.jsxs)(R.Z,{value:e.id,children:[(0,n.jsx)(Q.Z,{checked:null===(t=i.value)||void 0===t?void 0:t.includes(e.id)}),(0,n.jsx)(eb.k,{avatarSrc:(null===(r=e.avatar)||void 0===r?void 0:r.src)||"",name:"".concat(e.firstName," ").concat(e.lastName),subText:e.email||""})]},e.id)})]}),e.errors.visibleToUserIds&&(0,n.jsx)(es.Z,{children:e.errors.visibleToUserIds.message})]})}})})})]}),(0,n.jsxs)(p.ZP,{container:!0,justifyContent:"flex-end",spacing:2,sx:{mt:4},children:[(0,n.jsx)(h.Z,{onClick:e.onPreviousStep,children:t("common.back")}),(0,n.jsx)($.KM,{disabled:!1,onClick:e.onNextStep,children:t("common.next")})]})]})}function eL(e){let{t}=(0,Y.$G)(),r=(0,V.Z)();console.log({teachers:e.teachers,groups:e.groups,students:e.students});let i=e.watch(),a=e.teachers.find(e=>e.id===i.teacherId),o=()=>{var t;return(null===(t=e.students)||void 0===t?void 0:t.filter(e=>{var t;return null===(t=i.visibleToUserIds)||void 0===t?void 0:t.includes(e.id)}
1))||[]},l=()=>{var t;return(null===(t=e.groups)||void 0===t?void 0:t.filter(e=>{var t;return null===(t=i.visibleToGroupIds)||void 0===t?void 0:t.includes(e.id)}))||[]},c=()=>{var t;return(null===(t=e.students)||void 0===t?void 0:t.filter(e=>{var t;return null===(t=i.participantUserIds)||void 0===t?void 0:t.includes(e.id)}))||[]},m=()=>{var t;return(null===(t=e.groups)||void 0===t?void 0:t.filter(e=>{var t;return null===(t=i.participantGroupIds)||void 0===t?void 0:t.includes(e.id)}))||[]};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(s.Z,{sx:{p:3,border:"1px solid ".concat(r.palette.divider),borderRadius:2,backgroundColor:r.palette.background.paper,mb:3},children:[(0,n.jsx)(d.Z,{variant:"h6",sx:{mb:3,color:r.palette.primary.main},children:t("adminPage.shifts.confirmShiftDetails")}),(0,n.jsxs)(p.ZP,{container:!0,spacing:3,children:[(0,n.jsxs)(p.ZP,{item:!0,xs:12,children:[(0,n.jsx)(d.Z,{variant:"subtitle1",sx:{fontWeight:"bold",mb:1},children:t("adminPage.shifts.basicInformation")}),(0,n.jsxs)(s.Z,{sx:{pl:2},children:[(0,n.jsxs)(d.Z,{variant:"body2",sx:{mb:1},children:[(0,n.jsxs)("strong",{children:[t("common.name"),":"]})," ",i.name||t("adminPage.shifts.notSpecified")]}),(0,n.jsxs)(d.Z,{variant:"body2",sx:{mb:1},children:[(0,n.jsxs)("strong",{children:[t("common.description"),":"]})," ",i.description||t("adminPage.shifts.noDescription")]}),(0,n.jsxs)(d.Z,{variant:"body2",sx:{mb:1},children:[(0,n.jsxs)("strong",{children:[t("adminPage.shifts.shiftType"),":"]})," ",void 0!==i.type?(e=>{switch(e){case k.IF.QueuePass:return t("adminPage.shifts.types.queuePass");case k.IF.OneOnOne:return t("adminPage.shifts.types.oneOnOne");case k.IF.OneToMany:return t("adminPage.shifts.types.oneToMany");case k.IF.Seminar:return t("adminPage.shifts.types.seminar");default:return""}})(i.type):t("adminPage.shifts.notSelected")]}),(0,n.jsxs)(d.Z,{variant:"body2",sx:{mb:1},children:[(0,n.jsxs)("strong",{children:[t("common.teacher"),":"]})," ",a?"".concat(a.firstName," ").concat(a.lastName):t("adminPage.shifts.notSelected")]}),i.autoApprovalMaxLimit&&(0,n.jsxs)(d.Z,{variant:"body2",sx:{mb:1},children:[(0,n.jsxs)("strong",{children:[t("adminPage.shifts.maxAutoApproval"),":"]})," ",i.autoApprovalMaxLimit]})]})]}),(0,n.jsxs)(p.ZP,{item:!0,xs:12,children:[(0,n.jsx)(d.Z,{variant:"subtitle1",sx:{fontWeight:"bold",mb:1},children:t("adminPage.shifts.time")}),(0,n.jsxs)(s.Z,{sx:{pl:2},children:[(0,n.jsxs)(d.Z,{variant:"body2",sx:{mb:1},children:[(0,n.jsxs)("strong",{children:[t("adminPage.shifts.startTime"),":"]})," ",i.startTime?w()(i.startTime).format("YYYY-MM-DD HH:mm"):t("adminPage.shifts.notSpecifiedTime")]}),(0,n.jsxs)(d.Z,{variant:"body2",sx:{mb:1},children:[(0,n.jsxs)("strong",{children:[t("adminPage.shifts.endTime"),":"]})," ",i.endTime?w()(i.endTime).format("YYYY-MM-DD HH:mm"):t("adminPage.shifts.notSpecifiedTime")]}),e.recurrentShifts.length>0&&(0,n.jsxs)(s.Z,{sx:{mt:1},children:[(0,n.jsxs)(d.Z,{variant:"body2",sx:{fontWeight:"bold",mb:1},children:[t("adminPage.shifts.recurrentShifts")," (",e.recurrentShifts.length," ",t("adminPage.shifts.pcs"),"):"]}),(0,n.jsx)(s.Z,{sx:{pl:2,maxHeight:150,overflowY:"auto"},children:e.recurrentShifts.map((e,t)=>(0,n.jsxs)(d.Z,{variant:"body2",sx:{mb:.5},children:[w()(e.start).format("YYYY-MM-DD HH:mm")," - ",w()(e.end).format("HH:mm")]},t))})]})]})]}),(c().length>0||m().length>0)&&(0,n.jsxs)(p.ZP,{item:!0,xs:12,children:[(0,n.jsx)(d.Z,{variant:"subtitle1",sx:{fontWeight:"bold",mb:1},children:t("adminPage.shifts.directlyBooked")}),(0,n.jsxs)(s.Z,{sx:{pl:2},children:[c().length>0&&(0,n.jsxs)(s.Z,{sx:{mb:1},children:[(0,n.jsxs)(d.Z,{variant:"body2",sx:{fontWeight:"bold"},children:[t("adminPage.shifts.users"),":"]}),c().map(e=>(0,n.jsxs)(d.Z,{variant:"body2",sx:{pl:1},children:["• ",e.firstName," ",e.lastName," (",e.email,")"]},e.id))]}),m().length>0&&(0,n.jsxs)(s.Z,{sx:{mb:1},children:[(0,n.jsxs)(d.Z,{variant:"body2",sx:{fontWeight:"bold"},children:[t("adminPage.shifts.groups"),":"]}),m().map(e=>(0,n.jsxs)(d.Z,{variant:"body2",sx:{pl:1},children:["• ",e.name]},e.id))]})]})]}),(o().length>0||l().length>0)&&(0,n.jsxs)(p.ZP,{item:!0,xs:12,children:[(0,n.jsx)(d.Z,{variant:"subtitle1",sx:{fontWeight:"bold",mb:1},children:t("adminPage.shifts.visibleTo")}),(0,n.jsxs)(s.Z,{sx:{pl:2},children:[o().length>0&&(0,n.jsxs)(s.Z,{sx:{mb:1},children:[(0,n.jsxs)(d.Z,{variant:"body2",sx:{fontWeight:"bold"},children:[t("adminPage.shifts.users"),":"]}),o().map(e=>(0,n.jsxs)(d.Z,{variant:"body2",sx:{pl:1}
1,children:["• ",e.firstName," ",e.lastName," (",e.email,")"]},e.id))]}),l().length>0&&(0,n.jsxs)(s.Z,{sx:{mb:1},children:[(0,n.jsxs)(d.Z,{variant:"body2",sx:{fontWeight:"bold"},children:[t("adminPage.shifts.groups"),":"]}),l().map(e=>(0,n.jsxs)(d.Z,{variant:"body2",sx:{pl:1},children:["• ",e.name]},e.id))]})]})]}),0===o().length&&0===l().length&&0===c().length&&0===m().length&&(0,n.jsx)(p.ZP,{item:!0,xs:12,children:(0,n.jsx)(d.Z,{variant:"body2",sx:{fontStyle:"italic",color:r.palette.text.secondary},children:t("adminPage.shifts.noSelections")})})]})]}),(0,n.jsxs)(p.ZP,{container:!0,justifyContent:"flex-start",spacing:2,sx:{mt:4},children:[(0,n.jsx)(h.Z,{onClick:e.onPreviousStep,children:t("common.back")}),(0,n.jsx)($.KM,{onClick:e.onNextStep,children:t("adminPage.shifts.createShift")})]})]})}let eO=()=>{var e,t,r,i,a,C,T,L,O,F,N;let R=(0,j.m)(),{settings:W}=(0,z.r)(),{showConfirmation:G}=(0,B.p)(),[H,E]=(0,o.useState)(!0),[A,q]=(0,o.useState)(null),[Q,$]=(0,o.useState)(null),[V,K]=(0,o.useState)(),[J,ee]=(0,o.useState)(new Date),[et,er]=(0,o.useState)([]),[ei,ea]=(0,o.useState)([]),[en,eo]=(0,o.useState)([]),[es,el]=(0,o.useState)(""),[ed,ec]=(0,o.useState)(null),[ep,em]=(0,o.useState)(!1),{t:eu}=(0,Y.$G)(),eh=e=>M().groupBy(e,e=>{let t=w()(e.startTime).format("YYYY-MM-DD");return"".concat(t)}),ex=e=>{let t=eh(e),r=[];for(let e in t)if(t.hasOwnProperty(e)){let i=t[e],a=new Date(i[0].startTime).toISOString(),n=new Date(i[i.length-1].endTime).toISOString();r.push({id:i[0].id,allDay:!1,start:a,end:n,title:"",url:"",extendedProps:{calendar:"success",time:"",teacher:"".concat(i[0].teacher.firstName," ").concat(i[0].teacher.lastName),name:"".concat(i.length," skift")}})}return r},eg=(e,t,r)=>{if(t&&null!==r){let i=t.toLowerCase().split(" "),a=i.every(t=>{var r,i,a,n,o,s;return(null===(r=e.name)||void 0===r?void 0:r.toLowerCase().includes(t))||(null===(i=e.description)||void 0===i?void 0:i.toLowerCase().includes(t))||(null===(a=e.teacher)||void 0===a?void 0:null===(n=a.firstName)||void 0===n?void 0:n.toLowerCase().includes(t))||(null===(o=e.teacher)||void 0===o?void 0:null===(s=o.lastName)||void 0===s?void 0:s.toLowerCase().includes(t))});return a&&e.type===r}if(!t&&null!==r)return e.type===r;if(t&&null===r){let r=t.toLowerCase().split(" ");return r.every(t=>{var r,i,a,n,o,s;return(null===(r=e.name)||void 0===r?void 0:r.toLowerCase().includes(t))||(null===(i=e.description)||void 0===i?void 0:i.toLowerCase().includes(t))||(null===(a=e.teacher)||void 0===a?void 0:null===(n=a.firstName)||void 0===n?void 0:n.toLowerCase().includes(t))||(null===(o=e.teacher)||void 0===o?void 0:null===(s=o.lastName)||void 0===s?void 0:s.toLowerCase().includes(t))})}return!0},eb=(0,o.useMemo)(()=>{if(!es&&null===ed)return ex(et);let e=et.filter(e=>eg(e,es,ed));return ex(e)},[es,et,ed]),ev=async(e,t)=>{var r;let i={...e,shiftId:t===k.mZ.Approved||t===k.mZ.Waitlist?A:null,userId:null===(r=e.user)||void 0===r?void 0:r.id,status:t},{data:a}=await R.bookedPass.update(i),n=[...ei.map(t=>t.id===e.id?{...a}:t)];ea(n)},ef=[{flex:.3,minWidth:100,field:"avatar",renderHeader:()=>(0,n.jsx)(Z.Z,{icon:"mdi:account-outline",fontSize:20}),renderCell:e=>{var t,r,i,a,o,c;let{row:p}=e;return(0,n.jsxs)(s.Z,{sx:{display:"flex",alignItems:"center"},children:[(0,n.jsx)(l.Z,{alt:(null===(t=p.user)||void 0===t?void 0:t.firstName)||"",sx:{width:"1.875rem",he
1ight:"1.875rem",borderRadius:5},src:(null===(r=p.user)||void 0===r?void 0:null===(i=r.avatar)||void 0===i?void 0:i.src)||""}),(0,n.jsxs)(s.Z,{sx:{display:"flex",alignItems:"flex-start",flexDirection:"column",ml:2},children:[(0,n.jsxs)(d.Z,{variant:"subtitle1",children:[null===(a=p.user)||void 0===a?void 0:a.firstName," ",null===(o=p.user)||void 0===o?void 0:o.lastName]}),(0,n.jsx)(d.Z,{noWrap:!0,variant:"caption",children:"".concat(null===(c=p.user)||void 0===c?void 0:c.email)})]})]})}},{flex:.25,minWidth:80,field:"status",renderHeader:()=>(0,n.jsx)(Z.Z,{icon:"mdi:check-circle-outline",fontSize:20}),renderCell:e=>{let{row:t}=e;switch(t.status){case k.mZ.Approved:return(0,n.jsx)(D.Z,{label:"Approved",skin:"light",color:"success"});case k.mZ.Denied:return(0,n.jsx)(D.Z,{label:"Denied",skin:"light",color:"error"});case k.mZ.Pending:return(0,n.jsx)(D.Z,{label:"Pending",skin:"light",color:"warning"});case k.mZ.Waitlist:return(0,n.jsx)(D.Z,{label:"Waitlist",skin:"light",color:"info"});default:return(0,n.jsx)(n.Fragment,{})}}},{flex:.3,minWidth:125,field:"subject",headerName:eu("adminPage.shifts.subjectColumnTitle"),renderCell:e=>{var t;let{row:r}=e;return(0,n.jsx)(d.Z,{variant:"body2",children:null===(t=r.shift)||void 0===t?void 0:t.name})}},{flex:.3,minWidth:125,field:"teacher",headerName:eu("adminPage.shifts.teacherColumnTitle"),renderCell:e=>{let{row:t}=e;return(0,n.jsx)(d.Z,{variant:"body2",children:"#TODO ADD TEACHER NAME IN SHIFTLIGHTDTO"})}},{flex:.3,minWidth:125,field:"issuedDate",headerName:eu("adminPage.shifts.issuedDateColumnTitle"),renderCell:e=>{let{row:t}=e;return(0,n.jsx)(d.Z,{variant:"body2",children:w()(t.created).format("YYYY-MM-DD")})}},{flex:.1,minWidth:90,sortable:!1,field:"actions",headerName:eu("adminPage.shifts.actionsColumnTitle"),renderCell:e=>{let{row:t}=e;return(0,n.jsx)(s.Z,{sx:{display:"flex",alignItems:"center"},children:(0,n.jsx)(I.Z,{iconProps:{fontSize:20},iconButtonProps:{size:"small"},menuProps:{sx:{"& .MuiMenuItem-root svg":{mr:2}}},options:[{text:eu("adminPage.shifts.approveActionLabel"),icon:(0,n.jsx)(Z.Z,{icon:"mdi:check",fontSize:20,color:"green"}),menuItemProps:{onClick:()=>ev(t,k.mZ.Approved)}},{text:eu("adminPage.shifts.declineACtionLabel"),icon:(0,n.jsx)(Z.Z,{icon:"mdi:close",fontSize:20,color:"red"}),menuItemProps:{onClick:()=>ev(t,k.mZ.Denied)}},{text:eu("adminPage.shifts.pendingActionLabel"),icon:(0,n.jsx)(Z.Z,{icon:"mdi:clock-time-four-outline",fontSize:20}),menuItemProps:{onClick:()=>ev(t,k.mZ.Pending)}},{text:eu("adminPage.shifts.waitlistActionLabel"),icon:(0,n.jsx)(Z.Z,{icon:"mdi:human-queue",fontSize:20}),menuItemProps:{onClick:()=>ev(t,k.mZ.Waitlist)}}]})})}}],ey=(0,o.useCallback)(()=>et.find(e=>e.id===A),[A,et]),ej=e=>{e&&q(e)},ek=e=>{eZ();let t=w()(e.start).toDate();ee(t)},eZ=()=>{ea([]),q(null)},e_=async()=>{try{if(!V&&!H||!(null==V?void 0:V.view)){console.error("No dates set, cannot fetch shifts.");return}let{activeStart:e,activeEnd:t}=V.view,r=await R.shift.search({StartTime:e.toISOString(),EndTime:t.toISOString()});er(r.data)}catch(e){}finally{E(!1)}},eP=async()=>{let e=et.find(e=>e.id===A);if(!e)return;let t=await R.bookedPass.getStudentsInQueue({shiftId:e.id});ea(t.data)},eC=(0,o.useCallback)(()=>{let e=eh(et);return e["".concat(w()(J).format("YYYY-MM-DD"))]},[J,et]),ew=(0,o.useCallback)(async()=>{if(!A)return;let e=await G({message:eu("adminPage.shifts.deleteShiftConfirmationMessage"),title:eu("adminPage.shifts.deleteShiftConfirmationTitle"),confirmButtonText:eu("common.delete")});e&&(await R.shift.delete(A),await e_(),eZ())},[A]);return(0,o.useEffect)(()=>{e_()},[V]),(0,o.useEffect)(()=>{null==Q||Q.setOption("selectable",!0)},[Q]),(0,o.useEffect)(()=>{eP()},[A]),H?(0,n.jsx)("div",{children:"Loading..."}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(c.Z,{spacing:3,children:(0,n.jsxs)(p.ZP,{container:!0,children:[(0,n.jsxs)(p.ZP,{item:!0,xs:12,md:4,children:[(0,n.jsx)(p.ZP,{item:!0,xs:12,children:(0,n.jsx)(_.Z,{className:"app-calendar",sx:{..."bordered"===W.skin&&{border:e=>"1px solid ".concat(e.palette.divider)}},children:(0,n.jsx)(s.Z,{sx:{p:5,pb:0,flexGrow:1,borderRight:e=>"1px solid ".concat(e.palette.divider),borderBottom:e=>"1px solid ".concat(e.palette.divider),backgroundColor:"background.paper"},children:(0,n.jsx)(P.Z,{calendarApi:Q,events:eb,direction:"ltr",calendarsColor:{ETC:"success",Family:"success",Holiday:"primary",Personal:"success",Business:"success"},setCalendarApi:$,onDatesChanged:K,handleSelectEvent:ek,handleLeftSidebarToggle:()=>null,updateEvent:e=>null,handleAddEventSidebarToggle:()=>null,weekNumbers:!0})})})}),(0,n.jsx)(p.ZP,{item:!0,xs:12,children:(0,n.jsx)(s.Z,{sx:{flexGrow:1,p:"20px",width:"100%",borderRight:e=>"1px solid ".concat(e.palette.divider),backgroundColor:"background.paper"},children:(0,n.jsxs)(m.Z,{children:[J?(0,n.jsxs)(p.ZP,{item:!0,xs:12,style:{display:"flex",justifyContent:"space-between",marginBottom:10},children:[(0,n.jsx)(d.Z,{variant:"h6",children:w()(J).format("DD MMM YYYY")}),(0,n.jsx)(h.Z,{variant:"outlined",color:"secondary",onClick:()=>em(!0),children:eu("adminPage.shifts.newShiftButtonLabel")})]}):(0,n.jsx)(u.Z,{severity:"info",children:eu("adminPage.shifts.selectDayDescription")}),!eC()&&J&&(0,n.jsxs)(u.Z,{severity:"info",children:[eu("adminPage.shifts.noShiftsAvailableDescription"),(0,n.jsx)("strong",{children:w()(J).format("YYYY-MM-DD")})]}),eC()&&(0,n.jsx)(p.ZP,{container:!0,xs:12,rowGap:5,children:(0,n.jsx)(p.ZP,{item:!0,xs:12,children:null===(e=eC())||void 0===e?void 0:e.map((e,t)=>{var r,i,a;return(0,n.jsx)(x.ZP,{disablePadding:!0,children:(0,n.jsxs)(g.Z,{selected:A===e.id,onClick:()=>ej(e.id),children:[(0,n.jsx)(b.Z,{children:(0,n.jsx)(l.Z,{src:"/marketplace/materio-mui-react-nextjs-admin-template/demo-3/images/avatars/2.png",alt:"".concat(null===(r=e.teacher)||void 0===r?void 0:r.firstName),sx:{height:32,width:32}})}),(0,n.jsx)(v.Z,{primary:"".concat(w()(e.startTime).format("HH:mm"),"-").concat(w()(e.endTime).format("HH:mm")," - ").concat(null===(i=e.teacher)||void 0===i?void 0:i.firstName," ").concat(null===(a=e.teacher)||void 0===a?void 0:a.lastName)}),(0,n.jsx)(f.Z,{children:(0,n.jsx)(y.Z,{edge:"end",children:(0,n.jsx)(Z.Z,{icon:"mdi:chevron-right",fontSize:"20px"})})})]})},e.id)})})})]})})})]}),(0,n.jsxs)(p.ZP,{item:!0,xs:12,md:8,children:[(0,n.jsx)(X,{shifts:et,onDeleteShift:async e=>{for(let t of e)await R.shift.delete(t);await e_()}}),(0,n.jsxs)(s.Z,{sx:{flexGrow:1,width:"100%",height:"100%",backgroundColor:"background.paper"},children:[(0,n.jsx)(p.ZP,{container:!0,sx:{padding:5},children:(0,n.jsx)(p.ZP,{item:!0,xs:12,children:(null===(t=ey())||void 0===t?void 0:t.teacher)&&(0,n.jsxs)(s.Z,{sx:{display:"flex",alignItems:"center"},children:[(0,n.jsx)(l.Z,{alt:(null===(r=ey())||void 0===r?void 0:null===(i=r.teacher)||void 0===i?void 0:i.firstName)||"",sx:{width:"3.5rem",height:"3.5rem",borderRadius:5},src:(null===(a=ey())||void 0===a?void 0:null===(C=a.teacher)||void 0===C?void 0:null===(T=C.avatar)||void 0===T?void 0:T.src)||""}),(0,n.jsx)(s.Z,{sx:{display:"flex",alignItems:"flex-start",flexDirection:"column",ml:2},children:(0,n.jsxs)(d.Z,{variant:"subtitle1",children:[null===(L=ey())||void 0===L?void 0:null===(O=L.teacher)||void 0===O?void 0:O.firstName," ",null===(F=ey())||void 0===F?void 0:null===(N=F.teacher)||void 0===N?void 0:N.lastName]})})]})})}),(0,n.jsx)(S._,{columns:ef,rows:ei,disableRowSelectionOnClick:!0,pageSizeOptions:[7,10,25,50],checkboxSelection:!0,slots:{toolbar:()=>{var e;return U({onDelete:ew,disableDelete:!(null===(e=ey())||void 0===e?void 0:e.teacher)})}},onRowSelectionModelChange:e=>{eo(e)},rowSelectionModel:en})]})]})]})}),ep&&(0,n.jsx)(eT,{handleDialogClose:()=>em(!1),isBookingDialogOpen:ep,selectedDay:J,onSubmitted:async()=>{await e_()}})]})};eO.acl={action:L.H.Read,subject:L.D.OrgAdminPage};var eF=eO}},function(e){e.O(0,[3662,4885,1069,6886,2395,135,3420,6310,4386,4277,8716,4098,4316,9774,2888,179],function(){return e(e.s=43551)}),_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.