1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7715],{25948:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/agency/tenancy-amendment/[id]",function(){return t(54158)}])},54158:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return ee}});var r=t(34727),o=t(32692),a=t(97582),i=t(85893),s=t(67294),l=t(24844),c=t(22920),d=t(11163),u=t.n(d),m=t(74865),p=t.n(m),h=t(45697),f=t.n(h),g=t(20648),y=t(28644),x=t(36411),v=t(59870),A=t(97892),C=t(81631),b=t(99664),_=t(5601),w=t(38504),L=t(21911),E=t(41041),T=t(9953),Z=t(51948),N=t(2815),I=t(60479),D=t(52069),j=function(e){var n=e.status,t=(0,x.Z)("sm"),r=(0,D.Z)(),o=[{title:"Create",percent:0,current:["CREATING_DOCUMENTS"].includes(n),titleProps:{type:"label-medium"}},{title:"Signature",percent:50,current:["AWAITING_SIGNAGE"].includes(n),titleProps:{type:"label-medium"}},{title:"Completed",percent:100,current:["FULLY_SIGNED","COMPLETED","CANCELLED"].includes(n),titleProps:{type:"label-medium"}}];return(0,i.jsx)(I.Z,{flexGrow:"1",stages:o,color:"CANCELLED"===n?r.colors.fail:r.colors.primary,vertical:t,pt:t?"0px":"30px"})};j.propTypes={status:f().string};var k=j,S=t(7413),O=t(27484),U=t.n(O),M=t(84110),P=t.n(M),F=t(21702),G=t(15226),R=t(29156),V=t(30594);U().extend(P());var W=function(e){var n=e.amendment,t=(0,s.useState)(!0),r=t[0],o=t[1],a=(0,D.Z)(),l=(0,s.useMemo)((function(){var e=n.timeline.sort((function(e,n){return new Date(e.date).getTime()<new Date(n.date).getTime()?1:-1}));return"CREATING_DOCUMENTS"===n.status&&e.unshift({id:"updatedAt",event:"Last autosaved",date:n.updatedAt}),e}),[n]);return(0,i.jsx)(F.Z,{p:"20px",border:"none",shadow:"none",flexShrink:0,mr:["0px","0px","0px","0px","20px"],width:"100%",children:(0,i.jsxs)(w.Z,{maxWidth:["100%","100%","100%","100%","210px"],children:[(0,i.jsx)(V.Z,{text:"Timeline",isOpen:r,toggleOpen:function(){o(!r)}}),(0,i.jsx)(R.Z,{collapsed:!r,children:(0,i.jsx)(w.Z,{mt:"12px",children:(0,i.jsx)(S.Z,{children:l.map((function(e){return(0,i.jsxs)(S.Z.Item,{dot:(0,i.jsx)(G.Z,{size:"6px",color:a.colors.primary}),children:[e.event," - ",U()(e.date).fromNow()]},e._id)}))})})})]})})};W.propTypes={amendment:f().object};var Y=W,X=function(e){var n=e.amendment,t=e.handleClickRestore,r=e.handleClickCancel,o=e.markAsComplete,a=e.markAsUncomplete,s=e.markAsUnsigned,l=(0,x.Z)("md");return(0,i.jsxs)(w.Z,{display:"flex",flexDirection:"column",alignItems:"center",flexGap:"4px",mr:l?"0px":"20px",children:["CANCELLED"===n.status&&!l&&(0,i.jsx)(E.Z,{minWidth:"210px",onClick:t,children:"Restore Amendment"}),!["CREATING_DOCUMENTS","FULLY_SIGNED","COMPLETED","CANCELLED"].includes(n.status)&&!l&&(0,i.jsx)(E.Z,{minWidth:"210px",onClick:o,children:"Mark As Complete"}),"COMPLETED"===n.status&&!l&&(0,i.jsx)(E.Z,{buttonStyle:"discourage",minWidth:"210px",onClick:a,children:"Uncomplete"}),"FULLY_SIGNED"===n.status&&!l&&(0,i.jsx)(E.Z,{buttonStyle:"discourage",minWidth:"210px",onClick:s,children:"Undo Signing"}),!["FULLY_SIGNED","COMPLETED","CANCELLED"].includes(n.status)&&!l&&(0,i.jsx)(E.Z,{buttonStyle:"discourage",minWidth:"210px",onClick:r,children:"Cancel Amendment"}),(0,i.jsx)(Y,{amendment:n})]})};X.propTypes={amendment:f().object,handleClickRestore:f().func,handleClickCancel:f().func,markAsComplete:f().func,markAsUncomplete:f().func};var B=X,q=t(44938),z=function(e){var n,t,o,d,u,m,p,h,f,g,y,x,v,A,C,b,_,L,T,Z,N,I=e.amendment,D=e.markAsComplete,j=e.onExportAgreement,k=e.reloadData,S=(0,l.Kw)((function(e){return e.me})),O=(0,l.WX)((function(e){return e.modals.showModal})),U=(0,l.WX)((function(e){return e.modals.hideModal})),M=(0,s.useMemo)((function(){switch(I.status){case"FULLY_SIGNED":var e,n,t;return{title:"Tenancy Amendment Fully Signed",subtitle:"You can mark this Tenancy Amendment as complete".concat((null===S||void 0===S||null===(e=S.data)||void 0===e||null===(n=e.agency)||void 0===n||null===(t=n.enabledIntegrations)||void 0===t?void 0:t.palace)?" or send to Palace to complete":"",".")};case"COMPLETED":return{title:"Completed Tenancy Amendment",subtitle:"This Tenancy Amendment has been completed, you can view and download the signed documents below."};case"CANCELLED":return{title:"This Tenancy Amendment has been cancelled",subtitle:"Restoring this will take you back to the previous stage prior to cancelling"};default:return{title:"This Tenancy Amendment is not yet complete",subtitle:"This Tenancy Amendment does not have all of the required information to be marked as complete."}}}),[I]);!function(){var e=(0,r.Z)((function(){var e,n;return(0,a.__generator)(this,(function(t){switch(t.label){case 0:O({name:"LOADING_V2",props:{title:"Downloading your agreement...",themeName:"light",spinner:"dots"}}),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,j()];case 2:return e=t.sent(),O({name:"DOWNLOAD_AND_SEND",props:{themeName:"light",files:e.files,otherFileOptions:e.otherFileOptions,allowSend:!0,recipients:e.recipients,title:"Your exported files",width:"550px",agreement:I.agreement,onSend:function(){return k()}}}),k(),[3,4];case 3:return n=t.sent(),c.Am.error(n.message),[3,4];case 4:return U("LOADING_V2"),[2]}}))}))}();return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(q.Z,{title:null===M||void 0===M?void 0:M.title,subtitle:null===M||void 0===M?void 0:M.subtitle}),"CANCELLED"!==I.status&&(0,i.jsx)(i.Fragment,{children:((null===I||void 0===I||null===(n=I.agreement)||void 0===n?void 0:n.signedPDF)||(null===I||void 0===I?void 0:I.signedAgreements))&&(0,i.jsxs)(w.Z,{mt:"24px",display:"flex",justifyContent:"space-between",width:"100%",children:[(0,i.jsx)(w.Z,{children:(null===(t=I.agreement)||void 0===t||null===(o=t.signedPDF)||void 0===o?void 0:o.secureURL)?(0,i.jsx)(E.Z,{external:!0,opensNewTab:!0,href:null===(d=I.agreement)||void 0===d||null===(u=d.signedPDF)||void 0===u?void 0:u.secureURL,mr:"10px",children:"View Signed Tenancy Amendment"}):(0,i.jsx)(w.Z,{display:"flex",flexDirection:"column",children:I.signedAgreements.map((function(e){return(0,i.jsxs)(E.Z,{external:!0,opensNewTab:!0,href:e.secureURL,mr:"10px",children:["View ",e.name]},e.id)}))})}),(0,i.jsxs)(w.Z,{display:"flex",width:"100%",justifyContent:"flex-end",children:["FULLY_SIGNED"===I.status&&(0,i.jsx)(E.Z,{onClick:D,mr:"10px",children:"Mark as complete"}),(null===S||void 0===S||null===(m=S.data)||void 0===m||null===(p=m.agency)||void 0===p||null===(h=p.enabledIntegrations)||void 0===h?void 0:h.palace)&&(null===I||void 0===I?void 0:I.completedPalaceTenancyCode)&&(0,i.jsx)(E.Z,{buttonStyle:"secondary",onClick:function(){var e=window.location.pathname,n="https:",t=window.location.hostname;t.indexOf("localhost")>-1&&(n="http:"),e="".concat(n,"//").concat(t).concat(e),window.open("https://app.getpalace.com/Tenancy/Edit/".concat(I.details.palaceTenancyCode,"?redirectUrl=").concat(encodeURIComponent(e)),"_blank")},mr:"10px",children:"View In Palace"}),(null===S||void 0===S||null===(f=S.data)||void 0===f||null===(g=f.agency)||void 0===g||null===(y=g.enabledIntegrations)||void 0===y?void 0:y.palace)&&!(null===I||void 0===I?void 0:I.completedPalaceTenancyCode)&&(0,i.jsx)(E.Z,{buttonStyle:"secondary",onClick:function(){O({name:"FLOW_V2",props:{flowId:"send-document-to-palace",width:"700px",isModal:!0,submitButtonLabel:"Next",initialAnswers:{documentType:"Tenancy Amendment",amendmentId:I._id,TenancyCode:I.details.palaceTenancyCode,PropertyCode:I.details.palacePropertyCode},onComplete:(0,r.Z)((function(){return(0,a.__generator)(this,(function(e){return U("send-document-to-palace"),c.Am.success("Pushed to Palace successfully!"),k(),[2]}))}
1))}})},mr:"10px",children:"Send To Palace"}),(null===S||void 0===S||null===(x=S.data)||void 0===x||null===(v=x.agency)||void 0===v||null===(A=v.enabledIntegrations)||void 0===A?void 0:A.propertyme)&&(null===I||void 0===I||null===(C=I.metadata)||void 0===C||null===(b=C.propertyme)||void 0===b?void 0:b.TenancyId)&&(0,i.jsx)(E.Z,{buttonStyle:"secondary",onClick:function(){var e=window.location.pathname,n="https:",t=window.location.hostname;t.indexOf("localhost")>-1&&(n="http:"),e="".concat(n,"//").concat(t).concat(e),window.open("https://manager.propertyme.com/#/property/card/".concat(I.metadata.propertyme.LotId,"?redirectUrl=").concat(encodeURIComponent(e)),"_blank")},mr:"10px",children:"View In PropertyMe"}),(null===S||void 0===S||null===(_=S.data)||void 0===_||null===(L=_.agency)||void 0===L||null===(T=L.enabledIntegrations)||void 0===T?void 0:T.propertyme)&&!(null===I||void 0===I||null===(Z=I.metadata)||void 0===Z||null===(N=Z.propertyme)||void 0===N?void 0:N.TenancyId)&&(0,i.jsx)(E.Z,{buttonStyle:"secondary",onClick:function(){var e,n,t,o,i;O({name:"FLOW_V2",props:{flowId:"send-amendment-to-propertyme",width:"700px",isModal:!0,flowStateId:"new",submitButtonLabel:"Send To PropertyMe",initialAnswers:{amendmentId:I._id,details:{propertyId:(null===I||void 0===I||null===(e=I.metadata)||void 0===e||null===(n=e.propertyme)||void 0===n?void 0:n.LotId)||(null===I||void 0===I||null===(t=I.property)||void 0===t||null===(o=t.metadata)||void 0===o||null===(i=o.propertyme)||void 0===i?void 0:i.LotId)}},onComplete:(0,r.Z)((function(){return(0,a.__generator)(this,(function(e){return c.Am.success("Pushed to PropertyMe successfully!"),k(),U("FLOW_V2"),[2]}))}))}})},mr:"10px",children:"Send To PropertyMe"})]})]})})]})};z.propTypes={amendment:f().object,markAsComplete:f().func,onExportAgreement:f().func,reloadData:f().func};var H=z,K=t(22447);function J(){var e=(0,o.Z)(["\n margin-left: auto;\n margin-right; auto;\n margin-bottom: 40px 40px 60px;\n padding-right: 20px;\n padding-left: 20px;\n width: 100%;\n\n @media (max-width: ",") {\n padding: 0;\n }\n"]);return J=function(){return e},e}var Q=(0,g.ZP)(w.Z).withConfig({componentId:"sc-f58cc9ba-0"})(J(),(function(e){return e.theme.breakpoints.md})),$=function(e){var n=e.loadedAmendment,t=(0,v.Z)(),o=(0,x.Z)("md"),d=(0,l.WX)((function(e){return e.modals.showModal})),m=(0,l.WX)((function(e){return e.modals.hideModal})),h=(0,l.WX)((function(e){return e.confetti.show})),f=(0,s.useState)(n),A=f[0],C=f[1];(0,s.useEffect)((function(){C(n)}),[n]),(0,s.useEffect)((function(){var e=setInterval((function(){N()}),1e4);return function(){return clearInterval(e)}}));var b=[{label:"Home",href:"/"},{label:"Tenancy Amendment",href:"/agency/tenancy-amendment"},A.property.address.short],N=function(){var e=(0,r.Z)((function(){var e,n;return(0,a.__generator)(this,(function(r){switch(r.label){case 0:p().start(),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,t.getAmendment(A._id)];case 2:return e=r.sent(),C(e),[3,4];case 3:return n=r.sent(),console.error(n),c.Am.error(n.message),[3,4];case 4:return p().done(),[2]}}))}));return function(){return e.apply(this,arguments)}}(),I=function(){var e=(0,r.Z)((function(){return(0,a.__generator)(this,(function(e){return d({name:"CONFIRM_V3",props:{title:"Are you sure?",themeName:"light",width:"500px",description:"You are about to cancel this Tenancy Amendment.<br/><br/>Do you wish to continue?",onConfirm:(0,r.Z)((function(){var e;return(0,a.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,t.cancelTenancyAmendment(A._id)];case 1:return n.sent(),u().push("/agency/tenancy-amendment"),c.Am.success("Cancelled Tenancy Amendment"),[3,3];case 2:return e=n.sent(),c.Am.error(e.message),[3,3];case 3:return[2]}}
1))})),confirmButtonLabel:"Yes, please",cancelButtonLabel:"No, thanks",destructive:!0}}),[2]}))}));return function(){return e.apply(this,arguments)}}(),D=function(){var e=(0,r.Z)((function(){return(0,a.__generator)(this,(function(e){return d({name:"CONFIRM_V3",props:{themeName:"light",width:"500px",title:"Are you sure you wish to restore this Tenancy Amendment?",description:"Reinstating this Tenancy Amendment will re-open it and allow you to continue processing.",confirmButtonLabel:"Restore Tenancy Amendment",onConfirm:(0,r.Z)((function(){var e;return(0,a.__generator)(this,(function(n){switch(n.label){case 0:m("CONFIRM_V3"),d({name:"LOADING_V2",props:{title:"Restoring Tenancy Amendment...",themeName:"light",spinner:"dots"}}),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.restoreTenancyAmendment(A._id)];case 2:return n.sent(),c.Am.success("This Tenancy Amendment has been restored"),N(),[3,4];case 3:return e=n.sent(),c.Am.error(e.message),[3,4];case 4:return m("LOADING_V2"),[2]}}))}))}}),[2]}))}));return function(){return e.apply(this,arguments)}}(),j=function(){var e=(0,r.Z)((function(e){var n,r,o;return(0,a.__generator)(this,(function(a){switch(a.label){case 0:return n=e.subject,r=e.body,o=e.docs,[4,t.sendAgreement(A.agreement._id,{subject:n,body:r,send:!0,docs:o})];case 1:return a.sent(),[2]}}))}));return function(n){return e.apply(this,arguments)}}(),S=function(){var e=(0,r.Z)((function(){return(0,a.__generator)(this,(function(e){switch(e.label){case 0:return[4,t.exportAgreement(A.agreement._id)];case 1:return[2,e.sent()]}}))}));return function(){return e.apply(this,arguments)}}(),O=function(){var e=(0,r.Z)((function(e){return(0,a.__generator)(this,(function(n){switch(n.label){case 0:return[4,t.uploadSignedAmendment(A._id,e)];case 1:return n.sent(),N(),[2]}}))}));return function(n){return e.apply(this,arguments)}}(),U=function(){var e=(0,r.Z)((function(){var e;return(0,a.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,t.markAmendmentAsComplete(A._id)];case 1:return n.sent(),N(),h(),[3,3];case 2:return e=n.sent(),c.Am.error(e.message),[3,3];case 3:return[2]}}
1))}));return function(){return e.apply(this,arguments)}}(),M=function(){var e=(0,r.Z)((function(){return(0,a.__generator)(this,(function(e){return d({name:"CONFIRM_V3",props:{themeName:"light",width:"500px",title:"Uncomplete Tenancy Amendment?",description:"Are you sure you want to uncomplete this amendment? <br/>You\u2019ll be directed back to full signed stage and all signed documents will be available for you to view/download.",confirmButtonLabel:"Uncomplete",buttonStyle:"discourage",onConfirm:(0,r.Z)((function(){var e;return(0,a.__generator)(this,(function(n){switch(n.label){case 0:m("CONFIRM_V3"),d({name:"LOADING_V2",props:{title:"Uncompleting Tenancy Amendment...",themeName:"light",spinner:"dots"}}),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.markAmendmentAsUncomplete(A._id)];case 2:return n.sent(),N(),[3,4];case 3:return e=n.sent(),c.Am.error(e.message),[3,4];case 4:return m("LOADING_V2"),[2]}}))}))}}),[2]}))}));return function(){return e.apply(this,arguments)}}(),P=function(){var e=(0,r.Z)((function(){return(0,a.__generator)(this,(function(e){return d({name:"CONFIRM_V3",props:{themeName:"light",width:"500px",title:"Undo signing",description:"Are you sure you want to undo the signing?<br/>All digitally signed documents will be removed and you\u2019ll be required to restart the signing process. Any uploaded files will be still available for you to access.",confirmButtonLabel:"Undo Signing",buttonStyle:"discourage",onConfirm:(0,r.Z)((function(){var e;return(0,a.__generator)(this,(function(n){switch(n.label){case 0:m("CONFIRM_V3"),d({name:"LOADING_V2",props:{title:"Unsigning agreement...",themeName:"light",spinner:"dots"}}),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.manuallyMarkAgreementAsUnsigned(A.agreement._id)];case 2:return n.sent(),N(),[3,4];case 3:return e=n.sent(),c.Am.error(e.message),[3,4];case 4:return m("LOADING_V2"),[2]}}))}))}}),[2]}))}));return function(){return e.apply(this,arguments)}}();return(0,i.jsx)(g.f6,{theme:y.Z,children:(0,i.jsxs)(_.Z,{children:[(0,i.jsxs)(Q,{mt:"20px",mb:"30px",maxWidth:"100%",children:[(0,i.jsx)(Z.Z,{items:b,mt:"20px"}),(0,i.jsxs)(w.Z,{mt:"20px",p:[null,null,null,"10px 20px 10px 20px"],background:"#FFF",borderRadius:"10px",children:[(0,i.jsx)(w.Z,{display:["block","flex"],justifyContent:"space-between",alignItems:"center",children:(0,i.jsx)(L.Z,{type:"large-headline",mb:"8px",children:A.property.address.short})}),(0,i.jsx)(T.Z,{mb:"20px"}),o&&"CANCELLED"===A.status&&(0,i.jsx)(E.Z,{onClick:D,mb:"20px",stretch:!0,children:"Restore Amendment"}),o&&!["CREATING_DOCUMENTS","FULLY_SIGNED","COMPLETED","CANCELLED"].includes(A.status)&&(0,i.jsx)(E.Z,{onClick:U,mb:"20px",stretch:!0,children:"Mark As Complete"}),o&&"COMPLETED"===A.status&&(0,i.jsx)(E.Z,{buttonStyle:"discourage",onClick:M,mb:"20px",stretch:!0,children:"Uncomplete"}),o&&"FULLY_SIGNED"===A.status&&(0,i.jsx)(E.Z,{buttonStyle:"discourage",onClick:P,mb:"20px",stretch:!0,children:"Undo Signing"}),o&&!["FULLY_SIGNED","COMPLETED","CANCELLED"].includes(A.status)&&(0,i.jsx)(E.Z,{onClick:I,buttonStyle:"discourage",mb:"20px",stretch:!0,children:"Cancel Amendment"}),(0,i.jsx)(w.Z,{display:"flex",children:(0,i.jsx)(k,{status:A.status})})]})]}),(0,i.jsx)(Q,{mt:"0px",maxWidth:"100%",children:(0,i.jsxs)(w.Z,{display:"flex",flexDirection:["column","column","column","column","row"],children:[(0,i.jsx)(B,{amendment:A,handleClickRestore:D,handleClickCancel:I,markAsComplete:U,markAsUncomplete:M,markAsUnsigned:P}),(0,i.jsxs)(w.Z,{position:"relative",width:"100%",overflowX:"auto",children:[["CREATING_DOCUMENTS","AWAITING_SIGNAGE"].includes(A.status)&&(0,i.jsx)(K.Z,{agreement:A.agreement,title:"Amendment of Tenancy",type:"Tenancy Amendment",context:A,onSendAgreement:j,onExportAgreement:S,onUploadAgreement:O,markAsComplete:U,reloadData:N}),["FULLY_SIGNED","COMPLETED","CANCELLED"].includes(A.status)&&(0,i.jsx)(H,{amendment:A,markAsComplete:U,onExportAgreement:S,reloadData:N})]})]})})]})})};$.getInitialProps=function(){var e=(0,r.Z)((function(e){var n,t,r,o,i,s,l;return(0,a.__generator)(this,(function(a){switch(a.label){case 0:return[4,(0,A.ZP)(e,{requiresAuth:!0})];
1case 1:if(a.sent(),!(r=e.store.getState().me.data.agency)||!r.enabledFeatures.amendments)return[2,(0,b.Z)("/",e)];o=(null===(n=e.query)||void 0===n?void 0:n.id)||(null===(t=e.params)||void 0===t?void 0:t.id),s=new C.Z(e),a.label=2;case 2:return a.trys.push([2,4,,5]),[4,s.getAmendment(o)];case 3:return i=a.sent(),[3,5];case 4:return[2,{statusCode:(l=a.sent()).statusCode||500,title:"Uh oh!",message:String(l)}];case 5:return[2,{loadedAmendment:i}]}}))}));return function(n){return e.apply(this,arguments)}}(),$.propTypes={loadedAmendment:f().object.isRequired};var ee=(0,N.Z)($)}},function(e){e.O(0,[8153,1517,4032,5601,8124,9058,9774,2888,179],(function(){return n=25948,e(e.s=n);var n}));var n=e.O();_N_E=n}]);
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.