1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4698],{94576:(e,t,r)=>{r.d(t,{H:()=>s,k:()=>o});var a=r(33333),n=r(20951);function o(e){var t;let r=(0,a.Q)(n.S).insurances.insuranceHistory.useQuery(["insurance-history-"+e],{params:{propertyId:e}},{enabled:e>0});return(null==(t=r.data)?void 0:t.status)===200?r.data.body.insurances:[]}function s(e){var t;let r=(0,a.Q)(n.S).insurances.insuranceHistory.useQuery(["insurance-history-"+e],{params:{propertyId:e}},{enabled:e>0});if((null==(t=r.data)?void 0:t.status)===200)return r.data.body.insurances[0]}},95586:(e,t,r)=>{r.d(t,{A:()=>x});var a=r(37876),n=r(14232),o=r(41553),s=r(13810),u=r(88992),i=r(85461),m=r(67946),l=r(65734),c=r(42298),d=r(3884),g=r(64207),y=r(21148),f=r(20951),p=r(78625),h=r(73072);function x(e){let{propertyId:t,insurance:r,onClose:x}=e,{toast:P}=(0,p.dj)(),b=(0,i.jE)(),E=(0,u.mN)({resolver:(0,s.u)(h.updateInsuranceRequestSchema)});n.useEffect(()=>{r?(E.setValue("insuranceId",r.insuranceId),E.setValue("insuranceProvider",r.insuranceProvider),E.setValue("insuranceCostPa",r.insuranceCostPa),E.setValue("insuranceExpiryDate",r.insuranceExpiryDate),r.comments&&E.setValue("comments",r.comments)):E.reset()},[r]);let j=f.S.insurances.updateInsurance.useMutation({onSuccess:()=>{b.invalidateQueries({queryKey:["insurance-history-"+t]}),P({title:"Success",description:"Insurance updated"}),x()},onError:e=>{console.error(e),P({title:"Error",description:"Failed to update insurance",variant:"destructive"})}}),N=async(e,t)=>{null==t||t.preventDefault(),j.mutate({body:e})};return(0,a.jsx)(l.lG,{open:!0,onOpenChange:e=>{!1===e&&x()},children:(0,a.jsxs)(l.Cf,{onInteractOutside:e=>{e.preventDefault()},children:[(0,a.jsx)(l.q5,{}),(0,a.jsx)(l.L3,{className:"mb-6 text-lg font-medium",children:"Edit Existing Insurance"}),(0,a.jsx)(d.lV,{...E,children:(0,a.jsxs)("form",{onSubmit:E.handleSubmit(N),id:"edit-insurance-form",children:[(0,a.jsxs)(o.G,{children:[(0,a.jsx)(y.z,{form:E,fieldKey:"insuranceProvider",fieldLabel:"Insurance Provider",searchable:!0,options:(0,y.k)(h.insuranceProviders)}),(0,a.jsx)(g.OO,{form:E,fieldKey:"insuranceCostPa",fieldLabel:"Insurance Cost pa",Icon:m.A}),(0,a.jsx)(g.Lh,{form:E,fieldKey:"insuranceExpiryDate",fieldLabel:"Insurance Expiry Date",fieldError:E.formState.errors.insuranceExpiryDate}),(0,a.jsx)(g.Vq,{form:E,fieldKey:"comments",fieldLabel:"Comments",className:"h-24",containerClassName:"phone:col-span-2"})]}),(0,a.jsxs)(l.Es,{children:[(0,a.jsx)(c.$,{variant:"secondaryCta",text:"Cancel",onClick:x}),(0,a.jsx)(c.$,{variant:"primaryCta",text:"Save Changes",type:"submit"})]})]})})]})})}},97448:(e,t,r)=>{r.d(t,{A:()=>j});var a=r(37876),n=r(14232),o=r(85042),s=r(13810),u=r(88992),i=r(68386),m=r(85461),l=r(67946),c=r(65734),d=r(42298),g=r(3884),y=r(64207),f=r(21148),p=r(41553),h=r(20951),x=r(78625),P=r(73072),b=r(95522),E=r(3193);function j(e){let{propertyId:t,mortgage:r,onClose:o}=e,{toast:i}=(0,x.dj)(),l=(0,m.jE)(),y=(0,u.mN)({resolver:(0,s.u)(P.updateMortgageRequestSchema)});n.useEffect(()=>{if(r){var e;y.setValue("mortgageId",r.mortgageId),y.setValue("mortgageType",null!=(e=r.mortgageType)?e:void 0),r.outstandingDebt&&y.setValue("outstandingDebt",r.outstandingDebt),r.mortgageLender&&y.setValue("mortgageLender",r.mortgageLender),r.mortgageProduct&&y.setValue("mortgageProduct",r.mortgageProduct),r.mortgageInterestRate&&y.setValue("mortgageInterestRate",r.mortgageInterestRate),r.mortgagePaymentPcm&&y.setValue("mortgagePaymentPcm",r.mortgagePaymentPcm),r.expiryDate&&y.setValue("expiryDate",r.expiryDate),r.mortgageTerm&&y.setValue("mortgageTerm",r.mortgageTerm),r.mortgageDiscountedAmount&&y.setValue("mortgageDiscountedAmount",r.mortgageDiscountedAmount),r.termExpiryDate&&y.setValue("termExpiryDate",r.termExpiryDate),r.mortgageAccountNumber&&y.setValue("mortgageAccountNumber",r.mortgageAccountNumber),r.lenderEmail&&y.setValue("lenderEmail",r.lenderEmail),r.phoneNumber&&y.setValue("phoneNumber",r.phoneNumber),r.countryCode&&y.setValue("countryCode",r.countryCode),r.phonePrefix&&y.setValue("phonePrefix",r.phonePrefix),r.comments&&y.setValue("comments",r.comments)}},[r]);let[f]=y.watch(["mortgageType"]),p=h.S.mortgages.updateMortgage.useMutation({onSuccess:()=>
1{l.invalidateQueries({queryKey:["mortgage-history-"+t]}),l.invalidateQueries({queryKey:["properties"]}),l.invalidateQueries({queryKey:["search-tasks"]}),i({title:"Success",description:"Mortgage updated"}),o()},onError:e=>{console.error(e),i({title:"Error",description:"Failed to update mortgage",variant:"destructive"})}}),b=async(e,t)=>{null==t||t.preventDefault(),p.mutate({body:e})};return(0,a.jsx)(c.lG,{open:!0,onOpenChange:e=>{!1===e&&o()},children:(0,a.jsxs)(c.Cf,{className:"flex h-[85dvh] flex-col tablet:h-[min(720px,85dvh)]",onInteractOutside:e=>{e.preventDefault()},children:[(0,a.jsx)(c.q5,{}),(0,a.jsx)(c.L3,{className:"mb-6 text-lg font-medium",children:"Edit Existing Mortgage"}),(0,a.jsx)(g.lV,{...y,children:(0,a.jsxs)("form",{onSubmit:y.handleSubmit(b),id:"edit-mortgage-form",className:"flex min-h-0 flex-1 flex-col",children:[(0,a.jsxs)(E.FK,{className:"min-h-0 w-full flex-1 pr-1",children:[(0,a.jsx)(N,{form:y}),(0,a.jsx)("p",{className:"my-5",children:f===P.mortgageTypesEnum.InterestOnly?"Edit your monthly payment below:":"Currently we donât have the ability to calculate your monthly payment. Please enter it below."}),(0,a.jsx)(v,{form:y})]}),(0,a.jsxs)(c.Es,{children:[(0,a.jsx)(d.$,{variant:"secondaryCta",text:"Cancel",type:"button",onClick:o}),(0,a.jsx)(d.$,{variant:"primaryCta",text:"Save Changes",type:"submit"})]})]})})]})})}function N(e){let{form:t}=e,[r,n,s,u,m]=t.watch(["mortgageType","mortgageProduct","mortgageInterestRate","outstandingDebt","mortgageDiscountedAmount"]),c=(0,i.ns)();return(0,a.jsxs)(p.G,{children:[(0,a.jsx)(f.z,{form:t,fieldKey:"mortgageType",fieldLabel:"Mortgage Type",options:(0,f.k)(P.mortgageTypes),onChangeCustom:()=>t.setValue("mortgagePaymentPcm",0)}),(0,a.jsx)(y.OO,{form:t,fieldKey:"outstandingDebt",fieldLabel:"Outstanding Debt",Icon:l.A,onChangeCustom:function(e){if(r!==P.mortgageTypesEnum.InterestOnly||void 0===s)return null;let a=parseFloat(e.target.value);if(isNaN(a)||a<0)return t.setValue("mortgagePaymentPcm",0),null;switch(n){case P.mortgageProductsEnum.Fixed:return t.setValue("mortgagePaymentPcm",Math.round((s/100*a/12+Number.EPSILON)*100)/100),null;case P.mortgageProductsEnum.Discounted:if(m)return t.setValue("mortgagePaymentPcm",Math.round((a*(s/100-m/100)/12+Number.EPSILON)*100)/100),null;case P.mortgageProductsEnum.StandardVariableRate:return t.setValue("mortgagePaymentPcm",Math.round((s/100*a/12+Number.EPSILON)*100)/100),null;case P.mortgageProductsEnum.Tracker:return null!==c&&t.setValue("mortgagePaymentPcm",Math.round((a*(c/100+s/100)/12+Number.EPSILON)*100)/100),null}}}),(0,a.jsx)(f.z,{form:t,fieldKey:"mortgageLender",fieldLabel:"Mortgage Lender",searchable:!0,options:(0,f.k)(P.mortgageLenders)}),(0,a.jsx)(f.z,{form:t,fieldKey:"mortgageProduct",fieldLabel:"Mortgage Product",options:(0,f.k)(P.mortgageProducts)}),(0,a.jsx)(y.OO,{form:t,fieldKey:"mortgageInterestRate",fieldLabel:n===P.mortgageProductsEnum.Fixed?"Interest Rate %":n===P.mortgageProductsEnum.Tracker?"Tracker Increase %":"Lender's SVR %",onChangeCustom:function(e){if(r!==P.mortgageTypesEnum.InterestOnly||void 0===u)return null;let a=parseFloat(e.target.value);if(isNaN(a)||a<0||a>100)return t.setValue("mortgagePaymentPcm",0),null;switch(n){case P.mortgageProductsEnum.Fixed:return t.setValue("mortgagePaymentPcm",Math.round((a/100*u/12+Number.EPSILON)*100)/100),null;case P.mortgageProductsEnum.Discounted:if(m)return t.setValue("mortgagePaymentPcm",Math.round((u*(a/100-m/100)/12+Number.EPSILON)*100)/100),null;case P.mortgageProductsEnum.StandardVariableRate:return t.setValue("mortgagePaymentPcm",Math.round((a/100*u/12+Number.EPSILON)*100)/100),null;case P.mortgageProductsEnum.Tracker:return null!==c&&t.setValue("mortgagePaymentPcm",Math.round((u*(c/100+a/100)/12+Number.EPSILON)*100)/100),null}}}),(0,a.jsx)(y.FO,{form:t,fieldKey:"mortgageAccountNumber",fieldLabel:"Mortgage Account Number"}),(0,a.jsx)(y.FO,{form:t,fieldKey:"lenderEmail",fieldLabel:"Lender Email",Icon:o.A}),(0,a.jsx)(b.A,{form:t,fieldKeyCountryCode:"countryCode",fieldKeyPhonePrefix:"phonePrefix",fieldKeyPhoneNumber:"phoneNumber"})]})}function v(e){let{form:t}=e;return(0,a.jsxs)(p.G,{children:[(0,a.jsx)(y.OO,{form:t,fieldKey:"mortgagePaymentPcm",fieldLabel:"Payment pcm",Icon:l.A}),(0,a.jsx)(y.Lh,{form:t,fieldKey:"expiryDate",fieldLabel:"Fixed Term Expiry",fieldError:t.formState.errors.expiryDate,hint:"This is the expiry date of the fixed term element of your mortgage, normally 2 or 5 years in term"}),(0,a.jsx)(y.Lh,{form:t,fieldKey:"termExpiryDate",fieldLabel:"Mortgage Term Expiry",fieldError:t.formState.errors.termExpiryDate,hint:"This is the expiry of the entire mortgage, normally over 20 years"}),(0,a.jsx)(y.Vq,{form:t,fieldKey:"comments",fieldLabel:"Comments",className:"h-24",containerClassName:"phone:col-span-2"})]})}}}]);
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.