PageSourceSearch

https://vilomix.fi/static/js/471.3e80461d.chunk.js

js vilomix.fi collected 2026-09-26 18:42:52 UTC 13,647 bytes, 2 lines download raw bytes

1"use strict";(globalThis.webpackChunk_danishagro_cms=globalThis.webpackChunk_danishagro_cms||[]).push([[471],{471(e,a,l){l.r(a),l.d(a,{Form:()=>j,default:()=>T});var o=l(1462),s=l(4800),i=l(3032),t=l(7379),n=l(8165),r=l(8620),d=l(7229),m=l(9878),u=l(3054),v=l(390),c=l(4432),p=l(7144),h=l(9255),f=l(8434),g=l(7943),C=l(3441),b=l(47),F=l(4505),y=l(1594),x=l(4048);var I=l(456),$=l(9334);const j=e=>{var a,l,j,T;const[D,S]=(0,o.useState)(1),N=(null===e||void 0===e||null===(a=e.formData)||void 0===a||a.formType,null===e||void 0===e||null===(l=e.formData)||void 0===l||l.formType,"Single"===(null===e||void 0===e||null===(j=e.formData)||void 0===j?void 0:j.formType)),{errorMessages:A,validate:P,addErrors:E,getError:M,onInputChange:O,onInputChangeCustomInput:R,handleDataChange:_,participantsData:q,resetParticipantsData:w}=((e,a,l,s,i)=>{const[t,n]=(0,o.useState)([]),{getDictionaryString:r}=(0,y.c)(),d=e=>Array.from({length:e},()=>({name:"",surname:"",mobile:"",accommodation:""})),[m,u]=(0,o.useState)(d(6)),v=(e,a,l)=>{let o=null;l.trim()||(o=`${r(`CustomForm.${a}IsRequired`)}`),c(`participant${e}_${a}`,o)},c=(e,a)=>{n(l=>{const o=l.filter(a=>a.alias!==e);return a?[...o,{alias:e,message:a}]:o})};return{errorMessages:t,setErrorMessages:n,onInputChangeCustomInput:(e,a)=>{const l=(null===t||void 0===t?void 0:t.filter(a=>a.alias!==e))||[];a.trim()||l.push({alias:e,message:`${r(`CustomForm.${e}IsRequired`)}`}),"email"===e&&a.trim()&&(/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)||l.push({alias:e,message:r("CustomForm.EmailIsInvalidFormat")})),n(l)},validate:function(l){var o,s,t,d,u,v,c,p,h,f;const g=[];null===(o=e.allFieldSets)||void 0===o||o.flatMap(e=>{var a;return null!==(a=e.allFields)&&void 0!==a?a:[]}).forEach(a=>{let o;var s;o=null!==l&&void 0!==l&&l[a.alias]&&"08b8057f-06c9-6ca7-3a42-fd1fc2a46eff"===a.fieldTypeId?(null===l||void 0===l||null===(s=l[a.alias])||void 0===s?void 0:s.size)>0:"string"===typeof(null===l||void 0===l?void 0:l[a.alias])?l[a.alias].trim().length>0:Boolean(null===l||void 0===l?void 0:l[a.alias]),!1===o&&a.mandatory&&g.push({alias:a.alias,message:a.requiredErrorMessage||e.requiredErrorMessage.replace("{0}",a.alias)})}),null!==(s=l.firmanavn)&&void 0!==s&&s.trim()||g.push({alias:"firmanavn",message:r("CustomForm.FirmanavnIsRequired")}),null!==(t=l.email)&&void 0!==t&&t.trim()?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(l.email)||g.push({alias:"email",message:r("CustomForm.emailIsInvalidFormat")}):g.push({alias:"email",message:r("CustomForm.EmailIsRequired")}),null!==(d=l.adresse)&&void 0!==d&&d.trim()||g.push({alias:"adresse",message:r("CustomForm.adresseIsRequired")}),null!==(u=l.postnummer)&&void 0!==u&&u.trim()||g.push({alias:"postnummer",message:r("CustomForm.postnummerIsRequired")}),null!==(v=l.by)&&void 0!==v&&v.trim()||g.push({alias:"by",message:r("CustomForm.byIsRequired")}),null!==(c=l.forhandler)&&void 0!==c&&c.trim()||g.push({alias:"forhandler",message:r("CustomForm.forhandlerIsRequired")}),null!==(p=l.dato)&&void 0!==p&&p.trim()||g.push({alias:"dato",message:r("CustomForm.DateIsRequired")});for(let e=0;e<a;e++){var C,b,F;const a=m[e];a&&null!==(C=a.name)&&void 0!==C&&C.trim()||g.push({alias:`participant${e}_name`,message:r("CustomForm.nameIsRequired")}),a&&null!==(b=a.surname)&&void 0!==b&&b.trim()||g.push({alias:`participant${e}_surname`,message:r("CustomForm.surnameIsRequired")}),a&&null!==(F=a.mobile)&&void 0!==F&&F.trim()||g.push({alias:`participant${e}_mobile`,message:r("CustomForm.mobileIsRequired")}),i||a&&void 0!==a.accommodation&&""!==a.accommodation.trim()||g.push({alias:`participant${e}_accommodation`,message:r("CustomForm.AccommodationIsRequired")})}return(null===(h=e.allFieldSets)||void 0===h?void 0:h.some(e=>{var a;return null===(a=e.allFields)||void 0===a?void 0:a.some(e=>"privacyConsent"===e.alias)}))&&!l.privacyConsent&&g.push({alias:"privacyConsent",message:r("CustomForm.PrivacyConsentIsRequired")}),(null===(f=e.allFieldSets)||void 0===f?void 0:f.some(e=>{var a;return null===(a=e.allFields)||void 0===a?void 0:a.some(e=>"dataConsent"===e.alias)}))&&!l.dataConsent&&g.push({alias:"dataConsent",message:r("CustomForm.DataConsentIsRequired")}),n(g),[0===g.length,g]},getError:function(e){return null===t||void 0===t?void 0:t.find(a=>a.alias===e)},addErrors:function(e){const a=[];if(e&&"object"===typeof e){for(const l in e)if(Object.prototype.hasOwnProperty.call(e,l)){const o=e[l];
1Array.isArray(o)?o.forEach(e=>{"string"===typeof e&&a.push({alias:l,message:e})}):"string"===typeof o&&a.push({alias:l,message:o})}n(a)}},onInputChange:e=>{const a=null===t||void 0===t?void 0:t.filter(a=>a.alias!==e);n(a)},resetError:function(e){const a=null===t||void 0===t?void 0:t.filter(a=>a.alias!==e);n(a)},handleDataChange:(e,a,l)=>{const o=m.map((o,s)=>s===e?{...o,[a]:l}:o);u(o),v(e,a,l)},participantsData:m,resetParticipantsData:()=>u(d(a))}})(e.formData,D,0,0,N),[W,k]=(0,o.useState)(""),{checkForFileFields:U,uploadFile:B}=(0,x.l)(),[G,H]=(0,o.useState)(!1),[L,J]=(0,o.useState)(!1),V=(0,o.useRef)(null),[Y,z]=(0,o.useState)(""),{getDictionaryString:K}=(0,y.c)(),{currentCulture:Z}=(0,C.d)(),Q="da-dk"===Z?f.A:g.default,[X,ee]=(0,o.useState)("INIT"),{scrollTo:ae}=(0,n.UJ)(),[le,oe]=(0,o.useState)(!1),[se,ie]=(0,o.useState)(""),te=M("firmanavn"),ne=M("email"),re=M("adresse"),de=M("postnummer"),me=M("by"),ue=M("forhandler"),ve=M("dato"),ce=M("privacyConsent"),pe=M("dataConsent"),he=Array.from({length:6},(e,a)=>({label:`${a+1}`,value:a+1}));return(0,o.useEffect)(()=>{if(le){ae(V.current.offsetParent),J(!0),w(),S(1),ie(""),k("");const e=setTimeout(()=>{oe(!1),J(!1)},1e4);return()=>clearTimeout(e)}},[le,ae]),(0,$.jsxs)("div",{className:I.A.form,ref:V,children:[L||
1!e.formTagline&&!e.formHeadline?null:(0,$.jsxs)("div",{className:I.A.textWrapper,children:[e.formTagline?(0,$.jsx)("span",{children:e.formTagline}):null,e.formHeadline?(0,$.jsx)(i.je,{h3:!0,tag:i.Nw.H3,noMargin:!0,fullWidth:!0,children:e.formHeadline}):null]}),L?null:(0,$.jsx)("form",{onSubmit:async a=>{var l,o,s;null===a||void 0===a||a.preventDefault();const i=new FormData(null===a||void 0===a?void 0:a.target),t={},n=/^\d{2}\.\d{2}\.\d{4}$/,u={};i.forEach((a,l)=>{if("string"===typeof a&&n.test(a)){const[e,o,s]=a.split(".");t[l]=`${s}/${o}/${e}`}else a instanceof File?null!==a&&""!==a.name?t[l]=a:t[l]="":!function(a){return e.formData.allFieldSets.some(e=>e.containers.some(e=>e.fields.some(e=>"fab43f20-a6bf-11de-a28f-9b5755d89593"===e.fieldTypeId&&e.alias===a)))}(l)?t[l]=a:(u[l]||(u[l]=[]),u[l].push(a))});for(const e in u)t[e]=u[e];const[v]=P(t);if(!v)return void H(!0);ee("SUBMITTING");const{hasFile:c,fileFields:p}=U(t);c&&await Promise.all(p.map(async e=>{const[a,l]=await B(null===t||void 0===t?void 0:t[e]);a&&e?t[e]=l:console.log("Error uploading file")}));const h=t,{privacyConsent:f,dataConsent:g,numberOfParticipants:C,...b}=h,F={...b,antal:D.toString(),...g?{dataConsent:g}:{},...f?{privacyConsent:f}:{}};for(let e=1;e<=D;e++)F[`deltager${e}navn`]=t[`deltager${e}navn`],F[`deltager${e}efternavn`]=t[`deltager${e}efternavn`],F[`deltager${e}mobil`]=t[`deltager${e}mobil`],N||(F[`overnatning${e}`]=t[`overnatning${e}`]);const y={dateItemId:se,participants:D,pageId:null===globalThis||void 0===globalThis||null===(l=globalThis.pageContent)||void 0===l?void 0:l.id,cultureCode:Z},x={url:`/umbraco/forms/delivery/api/v1/entries/${null===e||void 0===e||null===(o=e.formData)||void 0===o?void 0:o.id}`,body:{values:F},...y},I=`${(0,d.yS)("ABSOLUTE")}/submitCustomForm?url=/umbraco/forms/delivery/api/v1/entries/${null===e||void 0===e||null===(s=e.formData)||void 0===s?void 0:s.id}`,$=await fetch((0,r.L)(I,"SPA"),{method:"POST",headers:{"Content-Type":"application/json","Api-Key":"88291c19-c109-p!c0-4227-97d2-3e95b7084b92"},body:JSON.stringify(x)});if($.ok){const e=await $.json();422===(null===e||void 0===e?void 0:e.statusCode)?console.log("Der skete en fejl"):(oe(!0),(0,m.d)({event:"contact_form"}),J(!0))}else if(422===$.status){const e=await $.json();E(e.errors),z(e.title),400!==e.statusCode&&"NOT_ENOUGH_ROOM"!==e.errors||k(K("CustomForm.NotEnoughRoom"))}ee("INIT"),H(!0)},noValidate:!0,children:(0,$.jsxs)("fieldset",{className:I.A.fieldset,disabled:"SUBMITTING"===X,children:[G&&(0,$.jsx)($.Fragment,{children:!0===e.formData.showValidationSummary?(0,$.jsxs)("ul",{className:I.A.summaryList,children:[A&&(0,$.jsx)("li",{className:I.A.summaryItem,children:(0,$.jsx)("h4",{children:Y})}),null===A||void 0===A?void 0:A.map((e,a)=>(0,$.jsx)("li",{className:I.A.summaryItem,children:e.alias},a))]}):null}),(0,$.jsx)(c.t,{name:"firmanavn",title:"firmanavn",label:K("CustomForm.CompanyName"),onChange:e=>R("firmanavn",e),invalid:!!te,helperText:null===te||void 0===te?void 0:te.message}),(0,$.jsx)(c.t,{name:"email",title:"email",label:K("CustomForm.Email"),onChange:e=>R("email",e),invalid:!!ne,helperText:null===ne||void 0===ne?void 0:ne.message}),(0,$.jsx)(c.t,{name:"adresse",title:"adresse",label:K("CustomForm.Address"),onChange:e=>R("adresse",e),invalid:!!re,helperText:null===re||void 0===re?void 0:re.message}),(0,$.jsx)(c.t,{name:"postnummer",title:"postnummer",label:K("CustomForm.Zip"),onChange:e=>R("postnummer",e),invalid:!!de,helperText:null===de||void 0===de?void 0:de.message}),(0,$.jsx)(c.t,{name:"by",title:"by",label:K("CustomForm.City"),onChange:e=>R("by",e),invalid:!!me,helperText:null===me||void 0===me?void 0:me.message}),(0,$.jsx)(h.W,{forId:void 0,label:K("CustomForm.ChooseDealer"),invalid:!!ue,helperText:null===ue||void 0===ue?void 0:ue.message,children:(0,$.jsx)(p.v,{id:"forhandler",name:"forhandler",placeholder:K("CustomForm.SelectDealer"),onChange:e=>R("forhandler",e.value),options:e.formData.dealers.map(e=>({label:e,value:e})),fullWidth:!0})}),(0,$.jsx)(h.W,{forId:void 0,label:K("CustomForm.ChooseDate"),invalid:!!ve,helperText:null===ve||void 0===ve?void 0:ve.message,children:(0,$.jsx)(p.v,{id:"dato",name:"dato",placeholder:K("CustomForm.SelectDate"),onChange:a=>{R("dato",a.value);const l=e.formData.dates.find(({date:e})=>(0,v.default)(new Date(e),"dd-MM-yyyy",{locale:Q})===a.value);ie(l?l.id:"")},options:e.formData.dates.map(({date:e,participants:a})=>({label:`${(0,v.default)(new Date(e),"dd-MM-yyyy",{locale:Q})} - ${a} ${K("CustomForm.Participants")}
1`,value:(0,v.default)(new Date(e),"dd-MM-yyyy",{locale:Q})})),fullWidth:!0})}),(0,$.jsx)(h.W,{forId:void 0,label:K("CustomForm.NumberOfParticipants"),children:(0,$.jsx)(p.v,{id:"numberOfParticipantsDropdown",name:"numberOfParticipants",placeholder:K("CustomForm.SelectNumberOfParticipants"),options:he,value:D,onChange:e=>{S(e.value),R("numberOfParticipantsDropdown",e.value.toString())},fullWidth:!0})}),Array.from({length:D},(e,a)=>{var l,o;const s=a+1,i=null===A||void 0===A?void 0:A.find(e=>e.alias===`participant${s}_name`),t=null===A||void 0===A?void 0:A.find(e=>e.alias===`participant${s}_surname`),n=null===A||void 0===A?void 0:A.find(e=>e.alias===`participant${s}_mobile`);let r;return N||(r=null===A||void 0===A?void 0:A.find(e=>e.alias===`participant${s}_accommodation`)),(0,$.jsxs)("div",{children:[(0,$.jsxs)("div",{className:I.A.participantInput,children:[(0,$.jsx)(c.t,{name:`deltager${s}navn`,title:`deltager${s}navn`,label:`${K("CustomForm.ParticipantFirstName")} ${s}`,onChange:e=>_(a,"name",e),invalid:!!i,helperText:null===i||void 0===i?void 0:i.message}),(0,$.jsx)(c.t,{name:`deltager${s}efternavn`,title:`deltager${s}efternavn`,label:`${K("CustomForm.ParticipantSurname")} ${s}`,onChange:e=>_(a,"surname",e),invalid:!!t,helperText:null===t||void 0===t?void 0:t.message}),(0,$.jsx)(c.t,{name:`deltager${s}mobil`,title:`deltager${s}mobil`,label:`${K("CustomForm.ParticipantMobile")} ${s}`,onChange:e=>_(a,"mobile",e),invalid:!!n,helperText:null===n||void 0===n?void 0:n.message,type:"number"})]}),!N&&(0,$.jsx)("div",{className:I.A.participantDropDown,children:(0,$.jsx)(h.W,{forId:void 0,label:`${K("CustomForm.SleepOver")}${s}`,invalid:!!r,helperText:null===(l=r)||void 0===l?void 0:l.message,children:(0,$.jsx)(p.v,{name:`overnatning${s}`,value:(null===(o=q[a])||void 0===o?void 0:o.accommodation)||"",placeholder:K("CustomForm.ChooseOption"),options:[{label:K("CustomForm.Yes"),value:K("CustomForm.Yes")},{label:K("CustomForm.No"),value:K("CustomForm.No")}],onChange:e=>_(a,"accommodation",e.value)})})})]},`participant-${s}`)}),(0,$.jsxs)("div",{className:I.A.checkboxFields,children:[(null===(T=e.formData.allFieldSets)||void 0===T?void 0:T.some(e=>{var a;return null===(a=e.allFields)||void 0===a?void 0:a.some(e=>"privacyConsent"===e.alias)}))&&(0,$.jsx)(h.W,{forId:void 0,label:K("CustomForm.PrivacyConsent"),invalid:!!ce,helperText:null===ce||void 0===ce?void 0:ce.message,className:te?I.A.invalid:null,children:(0,$.jsx)(b._,{name:"privacyConsent",label:(0,$.jsx)(F.O,{html:K("CustomForm.PrivacyConsentText"),noPadding:!0,className:I.A.customLabel}),placeholder:K("CustomForm.PrivacyConsentPlaceholder"),value:"on",onChange:()=>O("privacyConsent"),className:te?I.A.invalid:null})}),(0,$.jsx)(h.W,{forId:void 0,label:K("CustomForm.DataConsent"),invalid:!!pe,helperText:null===pe||void 0===pe?void 0:pe.message,className:pe?I.A.invalid:null,children:(0,$.jsx)(b._,{name:"dataConsent",label:(0,$.jsx)(F.O,{html:K("CustomForm.DataConsentText"),noPadding:!0,className:I.A.customLabel}),placeholder:K("CustomForm.DataConsentPlaceholder"),value:"on",onChange:()=>O("dataConsent"),className:te?I.A.invalid:null})})]}),(0,$.jsxs)("div",{children:["SUBMITTING"===X&&(0,$.jsx)(u.C,{className:I.A.spinner}),(0,$.jsx)(s.r,{title:K("CustomForm.Submit"),submit:!0,disabled:"SUBMITTING"===X})]}),W&&(0,$.jsx)("div",{className:I.A.error,children:W})]})}),L?(0,$.jsx)(t.Receipt,{...e.receipt}):null]})},T=j}}]);
2//# sourceMappingURL=471.3e80461d.chunk.js.map

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.