1import{r as t}from"./index-928ed2fb.js";import{v as L}from"./email-validation-b4698f6c.js";import{j as R,a as n}from"./react-component-loader-04e4e7ad.js";import"./_commonjsHelpers-725317a4.js";import"./entry-client-7e4bd37e.js";const X=({salary:S,mail:d,salaryAverage:k,lowerQuartileAverage:I,monthlySalaryAverage:N,peopleCount:P,sector:A,countingPeriod:C,yearsOfPractice:_,age:j,education:x,region:O,workarea:T,privatePositionGroup:B,branch:M,includeBonus:G,overtime:Q,selection2:a,onSent:m,hideSecondsAfterSuccess:h=4,receiptText:q,resources:e,endpoint:F="/api/salary/sendmail"})=>{const v=t.useId(),b=t.useId(),[u,p]=t.useState(d??""),[y,E]=t.useState(!1),[l,i]=t.useState(null),[c,w]=t.useState(!1);t.useEffect(()=>{p(r=>r||d||"")},[d]),t.useEffect(()=>{if(!c)return;const r=setTimeout(()=>w(!1),h*1e3);return()=>clearTimeout(r)},[c,h]);const H=async()=>{i(null);const r=L(u,e.emailRequiredErrorMessage,e.emailInvalidErrorMessage);if(!r.valid){i(r.error??e.emailInvalidErrorMessage);return}E(!0);const K={mailAddress:u,body:{salary:S,salaryAverage:k,peopleCount:P,lowerQuartileAverage:I,monthlySalaryAverage:N,countingPeriod:C,sector:A,age:j,yearsOfPractice:_,education:x,region:O,workarea:T,privatePositionGroup:B,branch:M,includeBonus:G,overtime:Q,receiptText:q,...a?{salaryAverage2:a.salaryAverage,peopleCount2:a.peopleCount,lowerQuartileAverage2:
1a.lowerQuartileAverage,monthlySalaryAverage2:a.monthlySalaryAverage,sector2:a.sector,countingPeriod2:a.countingPeriod,yearsOfPractice2:a.yearsOfPractice,age2:a.age,education2:a.education,region2:a.region,workarea2:a.workarea,privatePositionGroup2:a.privatePositionGroup,branch2:a.branch,includeBonus2:a.includeBonus,overtime2:a.overtime}:{}}};try{const o=await fetch(F,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(K)});if(!o.ok)throw new Error(await o.text()||"Kunne ikke sende e-post");let g=!1;try{const s=await o.json();g=typeof s=="boolean"?s:!!(s!=null&&s.success)}catch{g=!0}g?(w(!0),p(d??""),m==null||m()):i(e.error)}catch(o){console.error("Salary calculator: sending result e-mail failed",o),i(e.error)}finally{E(!1)}},f=c,J=!!u&&!y&&!f;return R("div",{className:"salary-calculator__email",children:[n("label",{className:"salary-calculator__email-label",htmlFor:v,children:e.emailLabel}),n("input",{id:v,type:"email",placeholder:e.placeholder,className:"salary-calculator__email-input",value:u,"aria-invalid":!!l,"aria-describedby":l?b:void 0,onChange:r=>{p(r.target.value),l&&i(null)},disabled:y||f}),!f&&n("button",{type:"button",className:"btn btn--primary",onClick:H,disabled:!J,children:y?e.sending:e.sendButton}),c&&n("p",{className:"success",role:"status",children:e.success}),l&&n("p",{className:"error",role:"alert",id:b,children:l})]})};export{X as default};
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.