https://mellro.com/_next/static/chunks/pages/contrato/painel/editar-contrato-17cfb8908c3ea5fad824.js
1_N_E=(window.webpackJsonp_N_E=window.webpackJsonp_N_E||[]).push([[92,51],{"3zeS":function(e,t,a){e.exports={container:"contrato_container__1IQnr",contentContainer:"contrato_contentContainer__3Pd_s",warningContainer:"contrato_warningContainer__1gv-V",alertContainer:"contrato_alertContainer__EWj0f",topAlertsContainer:"contrato_topAlertsContainer__2byE0",topAlertItem:"contrato_topAlertItem__38c05",filterContainer:"contrato_filterContainer__-W4Rl",searchAllInput:"contrato_searchAllInput__2znCM",contratoListContainer:"contrato_contratoListContainer__sEJZx",accordionToggle:"contrato_accordionToggle__3_XjK",accordionCard:"contrato_accordionCard__h-kX1",cardHeader:"contrato_cardHeader__2S4E2",containerIconCardHeader:"contrato_containerIconCardHeader__1zUgt",cardTitle:"contrato_cardTitle__2x_2w",rowInfoContract:"contrato_rowInfoContract__30SWV",infoContract:"contrato_infoContract__2WXfK",titleRow:"contrato_titleRow__Ds-qU",titleRowContent:"contrato_titleRowContent__3viD3",datatableContainer:"contrato_datatableContainer__VwNlH",tabsContainer:"contrato_tabsContainer__lcKV_",buttonsContainer:"contrato_buttonsContainer__3O7Kp",buttonsTitleRow:"contrato_buttonsTitleRow__3MgHj",sectionEnvolvidosContainer:"contrato_sectionEnvolvidosContainer__14Kn6",usersInfoContainer:"contrato_usersInfoContainer__1UHMo",sectionDocumentosContainer:"contrato_sectionDocumentosContainer__30g3J",documentItemContainer:"contrato_documentItemContainer__25aYq",documentItemButtonContainer:"contrato_documentItemButtonContainer__15RPy",documentItemIconContainer:"contrato_documentItemIconContainer__3e33f",vistoriaContainer:"contrato_vistoriaContainer__3TBP4",vistoriaItemsContainer:"contrato_vistoriaItemsContainer__3OX8Z",documentItemContent:"contrato_documentItemContent__Bq0gP",bannerAvisoAntecipacao:"contrato_bannerAvisoAntecipacao__1gAeP",bannerAvisoAntecipacaoContent:"contrato_bannerAvisoAntecipacaoContent__LG_ij",sucessoContainer:"contrato_sucessoContainer__p4gZu",label:"contrato_label__8ygm9",sectionValorAntecipacao:"contrato_sectionValorAntecipacao__26J29",inputContainer:"contrato_inputContainer__e8ByW",divisorAntecipacaoPendente:"contrato_divisorAntecipacaoPendente__2x8_s",secaoAntecipacaoPendente:"contrato_secaoAntecipacaoPendente__2Miz9",gridInfosAntecipacaoPendente:"contrato_gridInfosAntecipacaoPendente__ah1rI",infosAntecipacaoPendente:"contrato_infosAntecipacaoPendente__2Ghwj",boxBlue:"contrato_boxBlue__17ryS",boxYellow:"contrato_boxYellow__bRPhW",boxInfo:"contrato_boxInfo__1cwHO",painelContrato:"contrato_painelContrato__pHkAS"}},CZPf:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/contrato/painel/editar-contrato",function(){return a("g0EZ")}])},g0EZ:function(e,t,a){"use strict";a.r(t),a.d(t,"default",(function(){return N}));var n=a("nKUr"),o=a("xvhg"),r=a("vJKn"),i=a.n(r),l=a("rg98"),c=a("q1tI"),s=a("wd/R"),d=a.n(s),u=a("/MKj"),_=a("KYPV"),v=a("s/Ur"),m=a("tTGf"),p=a("IP2g"),f=a("20a2"),b=a("3zeS"),j=a.n(b),h=a("lf5Q"),g=a("sjMd"),x=a("CmbD"),y=a("Le6n"),C=a("qqpD"),O=a("lqRf"),w=a("gvZk"),A=a("hw50"),Y=a("LPlD"),D=a.n(Y),S=a("OKMn");function M(e,t){var a;if("undefined"===typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(a=function(e,t){if(!e)return;if("string"===typeof e)return I(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);"Object"===a&&e.constructor&&(a=e.constructor.name);if("Map"===a||"Set"===a)return Array.from(e);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return I(e,t)}(e))||t&&e&&"number"===typeof e.length){a&&(e=a);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,i=!0,l=!1;return{s:function(){a=e[Symbol.iterator]()},n:function(){var e=a.next();return i=e.done,e},e:function(e){l=!0,r=e},f:function(){try{i||null==a.return||a.return()}finally{if(l)throw r}}}}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=new Array(t);a<t;a++)n[a]=e[a];return n}function N(){var e,t=Object(f.useRouter)(),a=Object(u.d)((function(e){return e.user})).user,r=Object(v.useMediaQuery)({query:"(max-width: 997px)"}),s=null===t||void 0===t||null===(e=t.query)||void 0===e?void 0:e.contractId,b=Object(c.useState)(!0),Y=b[0],I=b[1],N=Object(c.useState)(null),F=N[0],P=N[1],E=Object(c.useState)(!1),T=E[0],R=E[1],k=Object(c.useState)(null),B=k[0],V=k[1],z=Object(c.useState)(null),q=z[0],W=z[1],G=Object(c.useState)(!1),H=G[0],K=G[1],X=function(e){var t=(e||"").toString().trim();if(!/^\d{2}\/\d{2}\/\d{4}$/.test(t))return null;var a=d()(t,"DD/MM/YYYY",!0);return a.isValid()?a:null},$=function(e){e.preventDefault(),P(null),window.scrollTo(0,0),T?R(!1):s?t.push("/contrato/painel/".concat(s)):t.back()},Z=function(){var e=Object(l.a)(i.a.mark((function e(a,n){var o,r,l,c,u,_,v,m,p,f,b,j;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=n.setSubmitting,r=n.setTouched,P(null),window.scrollTo(0,0),r({adjust_rent:!0,
1change_due_date:!0,new_rent_value:!0,due_date:!0}),T){e.next=8;break}return R(!0),o(!1),e.abrupt("return");case 8:return e.prev=8,l={},a.adjust_rent&&(c=Object(A.Xb)(a.new_rent_value),l.new_base_value=c,l.next_rent_value=c),a.change_due_date&&(u=d()(a.due_date,"DD/MM/YYYY").format("YYYY-MM-DD"),l.new_due_date=u),_=null,a.change_due_date&&a.due_date&&(_=d()(a.due_date,"DD/MM/YYYY").subtract(2,"days").format("YYYY-MM-DD")),v={contract_id:s,type:"PAYMENT",sign_expiration_date:_,contract_new_info:l},e.next=17,Object(O.f)(v);case 17:return t.push({pathname:"/contrato/painel/".concat(s),query:{alert:"contractual-edit-sent"}}),e.abrupt("return");case 21:e.prev=21,e.t0=e.catch(8),j=(null===e.t0||void 0===e.t0||null===(m=e.t0.response)||void 0===m||null===(p=m.data)||void 0===p?void 0:p.message)||(null===e.t0||void 0===e.t0||null===(f=e.t0.response)||void 0===f||null===(b=f.data)||void 0===b?void 0:b.error)||"N\xe3o foi poss\xedvel enviar sua solicita\xe7\xe3o. Tente novamente.",P({type:"danger",text:j});case 25:return e.prev=25,o(!1),e.finish(25);case 28:case"end":return e.stop()}}),e,null,[[8,21,25,28]])})));return function(t,a){return e.apply(this,arguments)}}();Object(c.useEffect)((function(){d.a.locale("pt-br"),function(){var e=Object(l.a)(i.a.mark((function e(){var n,r,l,c,u,_,v,m,p,f,b,j,h,g,x,y;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a){e.next=3;break}return I(!1),e.abrupt("return");case 3:if(s){e.next=6;break}return I(!1),e.abrupt("return");case 6:return e.prev=6,I(!0),u={contract_id:s,is_paid:!1,type:"monthly",due_date_gte:d()().format("YYYY-MM-DD"),$limit:10,$sort:{due_date:1}},e.next=11,Promise.all([Object(O.M)(s),Object(w.d)(u),Object(O.q)(s)]);case 11:if(_=e.sent,v=Object(o.a)(_,3),m=v[0],p=v[1],f=v[2],b=null===m||void 0===m||null===(n=m.data)||void 0===n||null===(r=n.data)||void 0===r?void 0:r.entity,j=(null===f||void 0===f||null===(l=f.data)||void 0===l?void 0:l.data)||[],null===b||void 0===b||!b.in_annual_adjustment_period){e.next=22;break}return K(!0),P({type:"danger",text:"Contrato em renova\xe7\xe3o, aguarde a finaliza\xe7\xe3o para realizar aditivos ao contrato"}),e.abrupt("return");case 22:h=M(j);try{for(h.s();!(g=h.n()).done;)"AWAITING_SIGN"===g.value.status&&t.push("/contrato/painel/".concat(s))}catch(i){h.e(i)}finally{h.f()}V(b||null),x=(null===p||void 0===p||null===(c=p.data)||void 0===c?void 0:c.data)||[],y=x.find((function(e){return"monthly"===(null===e||void 0===e?void 0:e.type)}))||null,W(y),e.next=33;break;case 30:e.prev=30,e.t0=e.catch(6),P({type:"danger",text:"N\xe3o foi poss\xedvel carregar os dados do contrato."});case 33:return e.prev=33,I(!1),e.finish(33);case 36:case"end":return e.stop()}}),e,null,[[6,30,33,36]])})));return function(){return e.apply(this,arguments)}}()()}),[s,null===a||void 0===a?void 0:a.id]);return Object(n.jsxs)("div",{children:[Object(n.jsx)(h.i,{title:"Mellro - Editar contrato"}),Object(n.jsx)(S.C,{onClickBackButton:function(){return t.push("/contrato/painel/".concat(s))}}),Object(n.jsxs)("div",{className:"".concat(j.a.container," ").concat(j.a.painelContrato),children:[Object(n.jsx)(S.w,{stepperData:{showStepper:!0,currentStep:T?2:1,totalSteps:2,title:T?"Resumo":"Dados"},title:"Editar contrato",subtitle:"Preencha com os detalhes para editar seu contrato.",leftImage:"/grafismos/grafismo-4.png",leftImagePadding:9,breadcrumbs:[{text:"Home",href:"/"},{text:"Contratos",href:"/contrato"},{text:"Painel do contrato",href:"/contrato/painel/".concat(s)},{text:"Editar contrato",href:"#"}]}),Object(n.jsx)(x.a,{loading:Y,children:Object(n.jsx)("div",{className:j.a.contentContainer,style:{maxWidth:752},children:H?F&&Object(n.jsx)(g.a,{message:F,onClose:function(){return P(null)}}):Object(n.jsx)(_.d,{initialValues:{adjust_rent:!1,change_due_date:!1,new_rent_value:"",due_date:""},validate:function(e){var t={};if(e.adjust_rent){var a=(e.new_rent_value||"").toString().trim();if(a){var n=Number(Object(A.Xb)(a));(!Number.isFinite(n)||n<=0)&&(t.new_rent_value="Informe um valor v\xe1lido.")}else t.new_rent_value="Informe o novo valor do aluguel."}if(e.change_due_date){var o=(e.due_date||"").toString().trim();if(o){var r=d()(o,"DD/MM/YYYY",!0);if(r.isValid()){var i=d()().add(30,"days").startOf("day");r.isBefore(i)&&(t.due_date="Selecione uma data com pelo menos 30 dias a partir de hoje.")}else t.due_date="Informe uma data v\xe1lida."}else t.due_date="Informe a nova data de vencimento."}return t},validateOnMount:!0,onSubmit:Z,children:function(e){var t,a,o,i,l,c,s,u,_=e.values,v=e.errors,f=e.touched,b=e.handleSubmit,j=e.setFieldValue,x=e.setFieldTouched,O=_.adjust_rent&&!v.new_rent_value,w=_.change_due_date&&!v.due_date&&!!X(_.due_date),Y=O||w,S=function(e){var t,a;if(null!==e&&void 0!==e&&e.adjust_rent){var n=((null===e||void 0===e?void 0:e.new_rent_value)||"").toString().trim(),o=Number(Object(A.Xb)(n));if(Number.isFinite(o)&&o>0)return o}var r=Number(null===B||void 0===B||null===(t=B.details)||void 0===t||null===(a=t.values)||void 0===a?void 0:a.rent);return Number.isFinite(r)&&r>0?r:0}(_),M=w?X(_.due_date):null,I=M?M.clone().subtract(2,"days").format("DD/MM/YYYY"):"--";I=M?M.clone().subtract(2,"days").format("DD/MM/YYYY"):null!==q&&void 0!==q&&q.due_date?d()(null===q||void 0===q?void 0:q.due_date).clone().subtract(2,"days").format("DD/MM/YYYY"):"--";var N=function(){if(null===q||void 0===q||!q.due_date)return null;var e=d()(q.due_date);return e.isValid()?e.utc().format("YYYY-MM-DD"):void 0}(),E=w?M.format("YYYY-MM-DD"):N,k=Y&&N&&E&&S?function(e){var t=e.baseRent,a=e.oldDueDateISO,n=e.newDueDateISO,o=d()(a,"YYYY-MM-DD",!0),r=d()(n,"YYYY-MM-DD",!0);if(!o.isValid()||!r.isValid())return null;var i=Math.abs(o.diff(r,"days")),l=Number(t)*i/30;o.isAfter(r)&&(l*=-1);var c=Number(t)+l;return Number.isFinite(c)?c:null}({baseRent:S,oldDueDateISO:N,newDueDateISO:E}):null;return Object(n.jsxs)("form",{noValidate:!0,autoComplete:"off",onSubmit:b,children:[F&&Object(n.jsx)(g.a,{message:F,onClose:function(){return P(null)}}),T?Object(n.jsxs)("div",{className:D.a.containerAddress,style:{alignItems:"flex-start",paddingBottom:120,marginTop:32},children:[Object(n.jsxs)("div",{children:[Object(n.jsx)("p",{className:D.a.boldGrande,style:{color:"#3F6281"},children:"Confira os dados"}),Object(n.jsx)("p",{className:D.a.regularMedio,children:"Revise suas informa\xe7\xf5es. Se estiverem corretas, clique em Confirmar e Enviar. O aditivo ser\xe1 enviado para todas as partes assinarem e, ap\xf3s as assinaturas, as mudan\xe7as no contrato ser\xe3o aplicadas."})]}),Object(n.jsx)("p",{className:D.a.boldGrande,style:{color:"#3F6281",marginTop:"16px"},children:"Aluguel mensal"}),Object(n.jsxs)("div",{className:D.a.containerAssetEditContract,style:{width:"100%",display:"flex",flexDirection:r?"column":"row",gap:r?44:16},children:[Object(n.jsx)(C.a,{icon:m.Nc,figureStyle:{backgroundColor:"#E7F5FF"},iconStyle:{color:"#339AF0"},titleStyle:{color:"#87A1B8",fontSize:14},valueStyle:{color:"#3F6281",fontSize:16,fontWeight:700},title:"Novo valor do aluguel",value:_.adjust_rent&&_.new_rent_value?"R$ ".concat(_.new_rent_value):null!==B&&void 0!==B&&null!==(l=B.details)&&void 0!==l&&null!==(c=l.values)&&void 0!==c&&c.rent?Object(A.D)(null===B||void 0===B||null===(s=B.details)||void 0===s||null===(u=s.values)||void 0===u?void 0:u.rent):"R$ --"}),_.change_due_date?Object(n.jsx)(C.a,{icon:m.S,figureStyle:{backgroundColor:"#E7F5FF"},iconStyle:{color:"#339AF0"},titleStyle:{color:"#87A1B8",fontSize:14},valueStyle:{color:"#3F6281",fontSize:16,fontWeight:700},title:"Nova data de vencimento",value:_.due_date||"DD/MM/AAAA"}):null]}),Object(n.jsxs)("p",{onClick:function(){return R(!1)},className:D.a.boldPequeno,style:{color:"#339AF0",cursor:"pointer"},children:[Object(n.jsx)(p.a,{icon:m.g,style:{marginRight:6}}),"Voltar e editar"]}),Object(n.jsxs)("div",{className:"d-flex flex-column",style:{gap:8},children:[Object(n.jsx)("p",{className:D.a.boldGrande,style:{color:"#3F6281",marginTop:"16px"},children:"Detalhes autom\xe1ticos:"}),Object(n.jsx)("p",{className:D.a.regularMicro,children:"Por padr\xe3o, o sistema sempre ajusta os detalhes a seguir de forma autom\xe1tica, usando como base as novas configura\xe7\xf5es do aluguel mensal."})]}),Object(n.jsxs)("div",{className:D.a.containerAssetEditContract,style:{width:"100%",display:"flex",flexDirection:r?"column":"row",gap:r?44:16},children:[Object(n.jsx)(C.a,{icon:m.re,figureStyle:{backgroundColor:"#E7F5FF"},iconStyle:{color:"#339AF0"},titleStyle:{color:"#87A1B8",fontSize:14},valueStyle:{color:"#3F6281",fontSize:16,fontWeight:700},title:"Data m\xe1xima de assinatura",value:I}),Object(n.jsx)(C.a,{icon:m.Q,figureStyle:{backgroundColor:"#E7F5FF"},iconStyle:{color:"#339AF0"},titleStyle:{color:"#87A1B8",fontSize:14},valueStyle:{color:"#3F6281",fontSize:16,fontWeight:700},title:"Pr\xf3ximo pagamento proporcional",value:null!=k?Object(A.D)(k):"R$ --"})]})]}):Object(n.jsxs)("div",{className:D.a.containerAddress,style:{alignItems:"flex-start",paddingBottom:120},children:[Object(n.jsx)("p",{className:D.a.regularMedio,children:"Aqui na Mell.ro, queremos tornar sua vida mais f\xe1cil. Pensando nisso, criamos uma forma simples e r\xe1pida para voc\xea fazer ajustes no seu c
1ontrato de aluguel. Preencha o formul\xe1rio, revise as informa\xe7\xf5es e pronto! Seu aditivo ser\xe1 enviado para assinatura."}),Object(n.jsx)("p",{className:D.a.boldGrande,style:{color:"#3F6281",marginTop:"16px"},children:"Ajustar valor do aluguel"}),Object(n.jsx)(C.c,{name:"adjust_rent",checked:_.adjust_rent,label:"Ajustar o valor do meu aluguel",onToggle:function(e){j("adjust_rent",e)}}),_.adjust_rent&&Object(n.jsx)("div",{className:D.a.containerAssetEditContract,style:{width:"100%"},children:Object(n.jsx)(C.b,{icon:m.he,title:"Valor atual do aluguel",value:null!==B&&void 0!==B&&null!==(t=B.details)&&void 0!==t&&null!==(a=t.values)&&void 0!==a&&a.rent?Object(A.D)(null===B||void 0===B||null===(o=B.details)||void 0===o||null===(i=o.values)||void 0===i?void 0:i.rent):"R$ --",children:Object(n.jsx)(C.d,{name:"new_rent_value",label:"Novo valor do aluguel",tooltipText:"Ao alterar o valor do aluguel, todos os pr\xf3ximos pagamentos ser\xe3o ajustados.\n Pagamentos em aberto n\xe3o ser\xe3o ajustados.",icon:m.F,value:_.new_rent_value,placeholder:"000.000.000,00",width:248,setFieldValue:j,setFieldTouched:x,error:v.new_rent_value,touched:f.new_rent_value,mask:"currency"})})}),Object(n.jsx)("p",{className:D.a.boldGrande,style:{color:"#3F6281",marginTop:"16px"},children:"Alterar data de vencimento"}),Object(n.jsx)(C.c,{name:"change_due_date",checked:_.change_due_date,label:"Alterar data de vencimento",onToggle:function(e){j("change_due_date",e)}}),_.change_due_date&&Object(n.jsx)("div",{className:D.a.containerAssetEditContract,style:{width:"100%"},children:Object(n.jsx)(C.b,{icon:m.W,title:"Pr\xf3ximo vencimento previsto",value:N?d()(N,"YYYY-MM-DD").format("DD/MM/YYYY"):"DD/MM/AAAA",children:Object(n.jsx)(C.d,{name:"due_date",label:"Nova data de vencimento",tooltipText:"Essa altera\xe7\xe3o vale a partir do pr\xf3ximo pagamento exibido. \n O valor desse pagamento ser\xe1 ajustado proporcionalmente \xe0 nova data escolhida.",icon:m.R,value:_.due_date,placeholder:"DD/MM/AAAA",width:248,setFieldValue:j,setFieldTouched:x,error:v.due_date,touched:f.due_date,mask:"date"})})}),Y?Object(n.jsxs)(n.Fragment,{children:[Object(n.jsx)("p",{className:D.a.boldGrande,style:{color:"#3F6281",marginTop:"16px"},children:"Detalhes autom\xe1ticos"}),Object(n.jsxs)("div",{className:D.a.containerAssetEditContract,children:[Object(n.jsx)(C.b,{icon:m.re,title:"Data m\xe1xima de assinatura",value:I,description:"Por padr\xe3o o sistema sempre configura a data m\xe1xima de assinatura para dois dias antes do pr\xf3ximo vencimento."}),w?Object(n.jsx)(C.b,{icon:m.Q,title:"Pr\xf3ximo pagamento proporcional",value:null!=k?Object(A.D)(k):"R$ --",description:"O pr\xf3ximo pagamento ter\xe1 uma ajuste proporcional a nova data de vencimento escolhida."}):null]})]}):null]}),Object(n.jsx)(h.g,{styleContainerCenter:{maxWidth:752},leftButtons:Object(n.jsx)(y.c,{colorButton:"secundary",onClick:$,type:"button",title:"Voltar",style:{width:r?"100%":"89px",height:38,fontSize:14,borderRadius:6,minWidth:r?"76px":"89px"},styleContainer:{height:44,marginRight:8}}),styleButtonsRight:{width:r?"100%":"auto"},rightButtons:Object(n.jsx)(y.c,{type:"submit",title:T?"Confirmar e enviar":"Revisar",colorButton:"primary",disabled:Object.keys(v||{}).length>0||!_.adjust_rent&&!_.change_due_date,style:{width:r?"100%":T?"153px":"104px",height:38,fontSize:14,borderRadius:6},styleContainer:{height:44,marginLeft:r?"auto":"0px"}}),styleContainer:{width:r?"100%":"100vw",paddingRight:8,left:0}})]})}})})})]})]})}}},[["CZPf",0,1,5,7,6,12,16,13,17,2,3,4,8,9,10,11,14,15,18,20,23,61]]]);
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.