"use strict";(self.webpackChunk_mattermost_webapp=self.webpackChunk_mattermost_webapp||[]).push([[152],{78152:(e,t,a)=>{a.r(t),a.d(t,{default:()=>D});var n=a(45697),i=a.n(n),s=(a(39714),a(91058),a(74916),a(23123),a(67294)),r=a(44012),o=a(86733),c=a(11381),l=a(66788),d=a(87760),u=a(38122),m=a(85175),p=a(31055);function f(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function _(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?f(Object(a),!0).forEach((function(t){h(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):f(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function h(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}class D extends s.PureComponent{constructor(e){super(e),h(this,"formatDate",(e=>{const t=(e.getMonth()+1).toString().padStart(2,"0"),a=e.getDate().toString().padStart(2,"0");return[e.getFullYear().toString(),t,a].join("-")})),h(this,"getText",(()=>({modalHeaderText:s.createElement(r.Z,{id:"dnd_custom_time_picker_modal.defaultMsg",defaultMessage:"Disable notifications until"}),confirmButtonText:s.createElement(r.Z,{id:"dnd_custom_time_picker_modal.submitButton",defaultMessage:"Disable Notifications"})}))),h(this,"handleConfirm",(()=>{const e=parseInt(this.state.selectedTime.split(":")[0],10),t=parseInt(this.state.selectedTime.split(":")[1],10),a=new Date(this.state.selectedDate);a.setHours(e,t),a<new Date||this.props.actions.setStatus({user_id:this.props.userId,status:l.gg.DND,dnd_end_time:(0,m.J5)(a),manual:!0,last_activity_at:(0,m.J5)(this.props.currentDate)})})),h(this,"handleDaySelection",(e=>{this.setState(_({selectedDate:e},this.makeTimeMenuList(e)))})),h(this,"makeTimeMenuList",(e=>{const t=[];let a=0,n=0;const i=this.props.currentDate;this.formatDate(i)===this.formatDate(e)&&(a=i.getHours(),n=i.getMinutes(),n>20?(a++,n=0):n=30);for(let e=a;e<24;e++)for(let a=n/30;a<2;a++){const n=e.toString().padStart(2,"0")+":"+(30*a).toString().padStart(2,"0");t.push(n)}return{timeMenuList:t,selectedTime:t[0]}}));const{currentDate:t}=this.props,a=new Date(t);23===t.getHours()&&t.getMinutes()>20&&a.setDate(t.getDate()+1),this.state=_({selectedDate:a,dayPickerStartDate:a},this.makeTimeMenuList(a))}render(){const{modalHeaderText:e,confirmButtonText:t}=this.getText(),{timeMenuList:a,selectedTime:n,selectedDate:i,dayPickerStartDate:l}=this.state,m=a.map((e=>s.createElement(d.Z.ItemAction,{id:"dndTime_dropdown_".concat(e),key:e,text:e,ariaLabel:"".concat(e," hours"),onClick:()=>{this.setState({selectedTime:e})}},e)));return s.createElement(c.Z,{ariaLabel:(0,p._u)("dnd_custom_time_picker_modal.defaultMsg","Disable notifications until"),onExited:this.props.onExited,modalHeaderText:e,confirmButtonText:t,handleConfirm:this.handleConfirm,handleEnterKeyPress:this.handleConfirm,id:"dndCustomTimePickerModal",className:"DndModal modal-overflow"},s.createElement("div",{className:"DndModal__content"},s.createElement("div",null,s.createElement("div",{className:"DndModal__input DndModal__input--no-border"},s.createElement("div",{className:"DndModal__input__label"},s.createElement(r.Z,{id:"dnd_custom_time_picker_modal.date",defaultMessage:"Date"})),s.createElement("i",{className:"icon icon--no-spacing icon-calendar-outline icon--xs icon-14"}),s.createElement(o.default,{value:this.formatDate(i),onDayChange:this.handleDaySelection,dayPickerProps:{selectedDays:i,disabledDays:{before:l}}}))),s.createElement(u.Z,{id:"dropdown-no-caret",stopPropagationOnToggle:!0},s.createElement("button",{className:"DndModal__input",type:"button"},s.createElement("div",{className:"DndModal__input__label"},s.createElement(r.Z,{id:"dnd_custom_time_picker_modal.time",defaultMessage:"Time"})),s.createElement("i",{className:"icon icon--no-spacing icon-clock-outline icon--xs icon-14"}),s.createElement("span",null,n)),s.createElement(d.Z,{openLeft:!1,ariaLabel:"Clear custom status after"},m))))}}h(D,"propTypes",{onExited:i().func.isRequired,userId:i().string.isRequired,currentDate:i().instanceOf(Date).isRequired,actions:i().shape({setStatus:i().func.isRequired}).isRequired})}}]);
//# sourceMappingURL=152.f252d0fa517c6ae4cecf.js.map