1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5320],{55320:function(e,n,t){t.r(n);var r=t(47568),i=t(828),o=t(97582),a=t(85893),c=t(67294),u=t(80728),s=t(11163),l=t(4566),d=t(36812),p=t(6171),h=t(60219),m=t(24969),f=t(48689),x=t(31365),g=t(638),v=t(12069),y=t(71230),j=t(15746),Z=t(71577),b=t(79531),w=t(85963),I=t(72269),C=t(51009),S=t(30214),k=t(27484),A=t.n(k),F=t(17806),P=t(43032),L={owner:"Owner",user:"Guest"},_=function(e,n){return{uid:e.uid||n,name:e.name||"announcement",url:e.url,mimeType:e.mimeType||"",status:"done"}},B=function(e){var n=e.fileList,t=void 0===n?[]:n,r=e.onChange;return(0,a.jsx)(x.Z,{accept:"image/*,.pdf,application/pdf",listType:"picture-card",maxCount:1,fileList:t,beforeUpload:function(){return!1},onChange:r,children:t.length>=1?null:"Upload"})};n.default=(0,u.HJ)((0,s.withRouter)((function(e){var n=(0,c.useState)(!1),t=n[0],u=n[1],s=(0,c.useState)(!1),k=s[0],E=s[1],T=(0,i.Z)(g.Z.useForm(),1)[0],q=(0,c.useState)(""),D=q[0],H=q[1],U=(0,c.useState)("owner"),M=U[0],O=U[1],Y=(0,c.useState)([]),N=Y[0],R=Y[1],V=(0,c.useState)([]),z=V[0],W=V[1],G=(0,c.useState)(!1),J=G[0],K=G[1];(0,c.useEffect)((function(){var n=e.router.query.audience,t=e.router.query.announcementId;if("owner"!==n&&"user"!==n||O(n),t){var i=function(){var e=(0,r.Z)((function(){var e,n,r,i,a,c,s,l,d,p;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,F.Z.getAnnouncementInfoById(t)];case 1:return(null===(r=o.sent())||void 0===r?void 0:r.message)||!(null===r||void 0===r?void 0:r._id)?(u(!0),[2]):(O(r.audience),i=Boolean(r.companyBased),a=[],(null===(e=r.sets)||void 0===e?void 0:e.length)?a=r.sets.map((function(e,n){var t,i;return{companyId:String((null===(t=e.companyId)||void 0===t?void 0:t._id)||e.companyId||""),content:(null===(i=e.content)||void 0===i?void 0:i.url)?[_(e.content,"".concat(r._id,"-").concat(n))]:[]}})):i&&(d=((null===(c=r.companyIds)||void 0===c?void 0:c.length)?r.companyIds:r.companyId?[r.companyId]:[]).map((function(e){return String((null===e||void 0===e?void 0:e._id)||e)})).filter(Boolean),p=(null===(s=r.attachments)||void 0===s?void 0:s.length)?r.attachments:(null===(l=r.image)||void 0===l?void 0:l.url)?[r.image]:[],a=d.map((function(e,n){var t;return{companyId:e,content:(null===(t=p[n])||void 0===t?void 0:t.url)?[_(p[n],"".concat(r._id,"-").concat(n))]:[]}}))),T.setFieldsValue({title:r.title,linkUrl:r.linkUrl||"",duration:[A().unix(r.startDate),A().unix(r.endDate)],companyBased:i,repeatShow:Boolean(r.repeatShow),sets:a}),!i&&(null===(n=r.image)||void 0===n?void 0:n.url)&&R([_(r.image,r._id)]),[2])}}))}));return function(){return e.apply(this,arguments)}}();E(!0),H(t),i()}}),[e.router.query.announcementId,e.router.query.audience]),(0,c.useEffect)((function(){if("owner"===M){var e=!1;return P.Z.getCompanyList().then((function(n){if(!e&&Array.isArray(n)){var t=new Set;W(n.filter((function(e){var n=String((null===e||void 0===e?void 0:e._id)||"");return!(!n||t.has(n))&&(t.add(n),!0)})))}})),function(){e=!0}}}),[M]);var Q=function(e,n,t){return(null===t||void 0===t?void 0:t.originFileObj)?(e.append(n,t.originFileObj),!0):!!(null===t||void 0===t?void 0:t.url)&&(e.append(n,JSON.stringify({name:t.name||"",uid:t.uid||"",url:t.url,mimeType:t.mimeType||""})),!0)},X=function(){var n=(0,r.Z)((function(){var n,t,r,i,a,c,u,s,l,d,p;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(J)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,T.validateFields()];case 2:return n=o.sent(),[3,4];case 3:return o.sent(),[2];case 4:if(t="owner"===M&&Boolean(n.companyBased),(r=new FormData).append("audience",M),r.append("title",n.title),r.append("linkUrl",n.linkUrl||""),r.append("startDate",n.duration[0].unix()),r.append("endDate",n.duration[1].unix()),r.append("companyBased",t?"true":"false"),r.append("repeatShow",n.repeatShow?"true":"false"),t){if(i=n.sets||[],a=i.map((function(e){return null===e||void 0===e?void 0:e.companyId})).filter(Boolean),!i.length||a.length!==i.length)return v.Z.warning({content:"Each pair needs a company and content."}),[2];if(new Set(a).size!==a.length)return v.Z.warning({content:"Each company can only be added once."}),[2];
1for(r.append("setCount",String(i.length)),c=0;c<i.length;c+=1)if(s=null===(u=i[c].content)||void 0===u?void 0:u[0],r.append("setCompanyId_".concat(c),i[c].companyId),!Q(r,(null===s||void 0===s?void 0:s.originFileObj)?"setContent_".concat(c):"setExisting_".concat(c),s))return v.Z.warning({content:"Each pair needs a company and content."}),[2]}else if(l=N[0],!Q(r,(null===l||void 0===l?void 0:l.originFileObj)?"image":"existingImage",l))return v.Z.warning({content:"An image or PDF is required."}),[2];K(!0),o.label=5;case 5:return o.trys.push([5,,10,11]),k?[4,F.Z.updateAnnouncement(D,r)]:[3,7];case 6:return p=o.sent(),[3,9];case 7:return[4,F.Z.addAnnouncement(r)];case 8:p=o.sent(),o.label=9;case 9:return(null===(d=p)||void 0===d?void 0:d.message)?[2]:(v.Z.success({content:"Announcement ".concat(k?"update":"create"," successful."),onOk:function(){e.router.push("/admin/announcement")}}),[3,11]);case 10:return K(!1),[7];case 11:return[2]}}))}));return function(){return n.apply(this,arguments)}}(),$=(0,a.jsx)(d.m,{style:{backgroundColor:"#fff",marginTop:4},title:"".concat(L[M]||"Announcement"," announcement"),backIcon:(0,a.jsx)(p.Z,{}),onBack:function(){return e.router.push("/admin/announcement")}});return(0,a.jsx)(l.Z,{ViewPageHeader:$,children:(0,a.jsx)(y.Z,{justify:"center",children:(0,a.jsxs)(j.Z,{xs:24,md:24,style:{backgroundColor:"#fff",padding:16,borderRadius:8},children:[(0,a.jsxs)(y.Z,{justify:"space-between",align:"middle",style:{marginBottom:16},children:[(0,a.jsxs)(j.Z,{style:{fontSize:18,fontWeight:600},children:[L[M]," announcement"]}),(0,a.jsx)(j.Z,{children:!t&&(0,a.jsx)(Z.ZP,{type:"primary",loading:J,icon:k?(0,a.jsx)(h.Z,{}):(0,a.jsx)(m.Z,{}),onClick:X,children:k?"Save":"Create"})})]}),t?(0,a.jsx)(S.Z,{}):(0,a.jsx)(g.Z,{form:T,layout:"vertical",children:(0,a.jsxs)(y.Z,{gutter:16,children:[(0,a.jsx)(j.Z,{xs:24,md:12,children:(0,a.jsx)(g.Z.Item,{name:"title",label:"Title",rules:[{required:!0,message:"Announcement title is required."}],children:(0,a.jsx)(b.Z,{placeholder:"Internal title"})})}),(0,a.jsx)(j.Z,{xs:24,md:12,children:(0,a.jsx)(g.Z.Item,{name:"duration",label:"Duration",rules:[{required:!0,message:"Announcement duration is required."}],children:(0,a.jsx)(w.Z.RangePicker,{disabledDate:function(e){return e&&e<A()().startOf("day")},showTime:{format:"hh:mm A"},format:"DD-MM-YYYY hh:mm A",style:{width:"100%"},placeholder:["Start Date","End Date"]})})}),(0,a.jsx)(j.Z,{xs:24,md:12,children:(0,a.jsx)(g.Z.Item,{name:"linkUrl",label:"URL (optional)",children:(0,a.jsx)(b.Z,{placeholder:"https:// or /path"})})}),"owner"===M?(0,a.jsx)(j.Z,{xs:24,md:12,children:(0,a.jsx)(g.Z.Item,{name:"companyBased",label:"Limit to company",valuePropName:"checked",extra:"Off shows this announcement to every owner.",children:(0,a.jsx)(I.Z,{onChange:function(e){var n;e&&!(null===(n=T.getFieldValue("sets"))||void 0===n?void 0:n.length)&&T.setFieldValue("sets",[{}])}})})}):null,(0,a.jsx)(j.Z,{xs:24,md:12,children:(0,a.jsx)(g.Z.Item,{name:"repeatShow",label:"Always show",valuePropName:"checked",extra:"On shows this announcement again every new session.",children:(0,a.jsx)(I.Z,{})})}),"owner"===M?(0,a.jsx)(g.Z.Item,{noStyle:!0,shouldUpdate:function(e,n){return e.companyBased!==n.companyBased||(e.sets||[]).map((function(e){return null===e||void 0===e?void 0:e.companyId})).join("|")!==(n.sets||[]).map((function(e){return null===e||void 0===e?void 0:e.companyId})).join("|")},children:function(e){var n=e.getFieldValue;return n("companyBased")?(0,a.jsx)(j.Z,{xs:24,children:(0,a.jsx)(g.Z.List,{name:"sets",children:function(e,t){var r=t.add,i=t.remove;return(0,a.jsxs)("div",{children:[e.map((function(t,r){var o=new Set((n("sets")||[]).map((function(e,n){return n===r?null:null===e||void 0===e?void 0:e.companyId})).filter(Boolean));return(0,a.jsx)("div",{style:{marginBottom:16,padding:16,border:"1px solid #f0f0f0",borderRadius:8},children:(0,a.jsxs)(y.Z,{gutter:16,align:"top",children:[(0,a.jsx)(j.Z,{xs:24,md:10,children:(0,a.jsx)(g.Z.Item,{name:[t.name,"companyId"],label:"Company",rules:[{required:!0,message:"Company is required."}],children:(0,a.jsx)(C.Z,{showSearch:!0,optionFilterProp:"label",placeholder:"Select company",options:z.map((function(e){return{value:String(e._id),label:e.companyName,disabled:o.has(String(e._id))}}))})})}),(0,a.jsx)(j.Z,{xs:24,md:10,children:(0,a.jsx)(g.Z.Item,{name:[t.name,"content"],label:"Content",valuePropName:"fileList",getValueFromEvent:function(e){return((null===e||void 0===e?void 0:e.fileList)||[]).slice(-1)},rules:[{required:!0,message:"Content is required."}],extra:"Image or PDF",children:(0,a.jsx)(B,{})})}),(0,a.jsx)(j.Z,{xs:24,md:4,children:(0,a.jsx)(g.Z.Item,{label:" ",children:(0,a.jsx)(Z.ZP,{danger:!0,icon:(0,a.jsx)(f.Z,{}),disabled:e.length<2,onClick:function(){return i(t.name)},children:"Remove"})})})]})},t.key)})),(0,a.jsx)(Z.ZP,{icon:(0,a.jsx)(m.Z,{}),onClick:function(){return r({})},children:"Add pair"})]})}})}):(0,a.jsx)(j.Z,{xs:24,children:(0,a.jsx)(g.Z.Item,{label:"Content",required:!0,extra:"Image or PDF",children:(0,a.jsx)(x.Z,{accept:"image/*,.pdf,application/pdf",listType:"picture-card",maxCount:1,fileList:N,beforeUpload:function(){return!1},onChange:function(e){var n=e.fileList;return R(n.slice(-1))},children:N.length>=1?null:"Upload"})})})}}):(0,a.jsx)(j.Z,{xs:24,children:(0,a.jsx)(g.Z.Item,{label:"Content",required:!0,extra:"Image or PDF",children:(0,a.jsx)(x.Z,{accept:"image/*,.pdf,application/pdf",listType:"picture-card",maxCount:1,fileList:N,beforeUpload:function(){return!1},onChange:function(e){var n=e.fileList;return R(n.slice(-1))},children:N.length>=1?null:"Upload"})})})]})})]})})})})))},4566:function(e,n,t){t.d(n,{Z:function(){return U}});var r=t(4111),i=t(51438),o=t(52951),a=t(14924),c=t(88029),u=t(60460),s=t(85893),l=t(67294),d=t(41664),p=t.n(d),h=t(25675),m=t.n(h),f=t(30381),x=t.n(f),g=t(45697),v=t.n(g),y=t(29815),j=t(11163),Z=t(68508),b=t(65885),w=t(92443),I=t(57640),C=(t(3758),t(80728)),S=Z.Z.SubMenu,k=(0,j.withRouter)((0,C.HJ)((function(e){var n=(0,l.useState)(!1),t=n[0],r=n[1],i=(0,l.useState)(""),o=i[0],a=i[1],c=(0,l.useState)(""),u=c[0],d=c[1];(0,l.useEffect)((function(){p()}));var p=function(){var n=e.router.query.id,t="";I.Fs.forEach((function(e){e.code!==n?(e.subMenu&&e.subMenu.forEach((function(r){r.code!==n?r.alias&&r.alias.forEach((function(i){if(i===n)return t=e.code,void(n=r.code)})):t=e.code})),e.alias&&e.alias.forEach((function(r){if(r===n)return t=e.code,void(n=e.code)}))):t=e.code})),a(n),d(t),r(!0)};return t&&(0,s.jsxs)(Z.Z,{theme:"dark",mode:"inline",defaultOpenKeys:[u],defaultSelectedKeys:o,style:{border:null},children:[function(){var n=e.contextProvider.userInfo.permissions,t=(0,y.Z)(I.Fs);return t=t.filter((function(e){return(0,I.cY)(e.permissionCode,n)})),t.map((function(t){if(t.subMenu){var r=t.subMenu.filter((function(e){return(0,I.cY)(e.permissionCode,n)}));return r.length?(0,s.jsx)(S,{title:t.label,icon:t.icon,children:r.map((function(n){var t=n.path;
1if("my-credit-requests"===n.code){var r,i,o=null===(r=e.contextProvider)||void 0===r||null===(i=r.userInfo)||void 0===i?void 0:i._id;t="".concat(n.path,"?userId=").concat(o)}return(0,s.jsx)(Z.Z.Item,{icon:n.icon,children:(0,s.jsx)("a",{href:t,children:n.label})},n.code)}))},t.code):null}return(0,s.jsx)(Z.Z.Item,{icon:t.icon,children:(0,s.jsx)("a",{href:t.path,children:t.label})},t.code)}))}(),(0,s.jsx)(Z.Z.Item,{onClick:function(){var e=new b.Z;e.remove("jwt",{path:"/"}),e.remove("isAdmin",{path:"/"}),setTimeout((function(){window.location.reload()}),500)},icon:(0,s.jsx)(w.Z,{}),children:"Logout"},"logout")]})}))),A=t(19944),F=t(84477),P=t(7371),L=t(97183),_=t(71230),B=t(15746),E=L.Z.Header,T=L.Z.Content,q=L.Z.Footer,D=L.Z.Sider,H=function(e){(0,c.Z)(t,e);var n=(0,u.Z)(t);function t(){var e;return(0,i.Z)(this,t),e=n.apply(this,arguments),(0,a.Z)((0,r.Z)(e),"state",{collapsed:!1}),(0,a.Z)((0,r.Z)(e),"toggle",(function(){e.setState({collapsed:!e.state.collapsed})})),e}return(0,o.Z)(t,[{key:"componentDidMount",value:function(){this.mounted=!0}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"render",value:function(){var e=this,n=this.state.collapsed,t=this.props.children,r=(0,s.jsx)(E,{style:{backgroundColor:"#fff",padding:0,minHeight:"64px",lineHeight:"64px"},children:l.createElement(this.state.collapsed?A.Z:F.Z,{onClick:this.toggle,style:{fontSize:16,cursor:"pointer",marginLeft:16}})});return(0,s.jsxs)(L.Z,{style:{minHeight:"100vh",margin:-8},children:[(0,s.jsxs)(D,{trigger:null,collapsible:!0,collapsed:n,collapsedWidth:window.innerWidth<576?0:80,breakpoint:"xl",onBreakpoint:function(n){return e.setState({collapsed:n})},style:{zIndex:100,color:"#fff",minHeight:"100vh",boxShadow:"0px 0px 16px #8c8c8c"},width:256,children:[(0,s.jsx)(_.Z,{type:"flex",justify:"center",children:(0,s.jsx)(B.Z,{style:{cursor:"pointer"},children:n?(0,s.jsx)(_.Z,{type:"flex",justify:"center",children:(0,s.jsx)(B.Z,{span:24,children:(0,s.jsx)(p(),{href:"/admin/dashboard",children:(0,s.jsx)("div",{style:{marginTop:8,marginLeft:8},children:(0,s.jsx)(m(),{layout:"intrinsic",src:"/logo/MHG-logo-white-13.png",alt:"Logo",width:50,height:50,objectFit:"contain"})})})})}):(0,s.jsx)(_.Z,{type:"flex",justify:"center",children:(0,s.jsx)(B.Z,{style:{textAlign:"center"},children:(0,s.jsx)(p(),{href:"/admin/dashboard",children:(0,s.jsx)("div",{style:{marginTop:8},children:(0,s.jsx)(m(),{layout:"intrinsic",src:"/logo/MHG-logo-white-12.png",alt:"Logo",width:200,height:50,objectFit:"contain"})})})})})})}),(0,s.jsx)(k,{selectedMenu:this.props.menu})]}),(0,s.jsxs)(L.Z,{children:[r,this.props.ViewPageHeader&&(0,s.jsx)("div",{style:{padding:0},children:this.props.ViewPageHeader}),(0,s.jsx)(T,{style:{padding:16,backgroundColor:"#f0f2f5",minHeight:280},children:(0,s.jsx)(s.Fragment,{children:t})}),(0,s.jsx)(q,{children:(0,s.jsx)(_.Z,{type:"flex",justify:"end",children:(0,s.jsx)(B.Z,{children:(0,s.jsxs)("span",{children:[(0,s.jsx)(P.Z,{})," Copyright MAPLEHOME"," ",x()().format("YYYY")]})})})})]})]})}}]),t}(l.Component),U=H;H.propTypes={children:v().any,ViewPageHeader:v().any}},30214:function(e,n,t){var r=t(85893),i=(t(67294),t(22850)),o=t(22181),a=t(18429),c=i.Z.Paragraph,u=i.Z.Text;n.Z=function(){return(0,r.jsx)(o.ZP,{status:"error",title:"Hit Error",subTitle:"Please check and modify the following information before resubmitting.",extra:[],children:(0,r.jsxs)("div",{className:"desc",children:[(0,r.jsx)(c,{children:(0,r.jsx)(u,{strong:!0,style:{fontSize:16},children:"The content you submitted has the following error:"})}),(0,r.jsxs)(c,{children:[(0,r.jsx)(a.Z,{className:"site-result-demo-error-icon"})," ","Invalid input info"]}),(0,r.jsxs)(c,{children:[(0,r.jsx)(a.Z,{className:"site-result-demo-error-icon"})," Your are not authorized to access restricted resources"]})]})})}},17806:function(e,n,t){var r=t(1898).wR;n.Z={getAnnouncementList:function(e){return r.get("/api/announcement",{params:{audience:e}}).then((function(e){return e})).catch((function(e){return e}))},getActiveAnnouncement:function(e){return r.get("/api/announcement/active",{params:{audience:e}}).then((function(e){return e})).catch((function(e){return e}))},getAnnouncementInfoById:function(e){return r.get("/api/announcement/"+e).then((function(e){return e})).catch((function(e){return e}))},addAnnouncement:function(e){return r.post("/api/announcement",e,{headers:{"Content-Type":"multipart/form-data"}}).then((function(e){return e})).catch((function(e){return e}))},updateAnnouncement:function(e,n){return r.patch("/api/announcement/"+e,n,{headers:{"Content-Type":"multipart/form-data"}}).then((function(e){return e})).catch((function(e){return e}))},deleteAnnouncement:function(e){return r.delete("/api/announcement/"+e).then((function(e){return e})).catch((function(e){return e}))}}},43032:function(e,n,t){var r=t(1898).wR,i={getCompanyList:function(){return r.get("/api/company").then((function(e){return e})).catch((function(e){return e}))},addCompany:function(e){return r.post("/api/company",e).then((function(e){return e})).catch((function(e){return e}))}
1,editCompany:function(e,n){return r.patch("/api/company/".concat(e),n).then((function(e){return e})).catch((function(e){return e}))},deleteCompany:function(e){return r.delete("/api/company/"+e).then((function(e){return e})).catch((function(e){return e}))},getCompanyPropertyList:function(e){return r.get("/api/property/properties-with-company").then((function(e){return e})).catch((function(e){return e}))}};n.Z=i}}]);
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.