PageSourceSearch

https://davafoods.se/static/js/blocks6.700421c6.chunk.js

js davafoods.se collected 2026-10-07 22:51:43 UTC 9,356 bytes, 2 lines download raw bytes

1"use strict";(globalThis.webpackChunk_danishagro_cms=globalThis.webpackChunk_danishagro_cms||[]).push([[2093,2678],{5539(e,a,s){s.r(a),s.d(a,{FormIntern:()=>j,default:()=>T});var o=s(1462),l=s(4800),t=s(3032),n=s(7379),r=s(8165),i=s(8620),d=s(7229),m=s(9878),u=s(3054),c=s(390),v=s(4432),p=s(7144),h=s(9255),f=s(8434),g=s(7943),C=s(3441),F=s(47),I=s(4505),k=s(1594),x=s(4048);var y=s(456),b=s(9334);const j=e=>{const[a,s]=(0,o.useState)(1),{errorMessages:j,validate:T,addErrors:N,getError:S,onInputChange:E,onInputChangeCustomInput:D}=(e=>{const[a,s]=(0,o.useState)([]),{getDictionaryString:l}=(0,k.c)();return{errorMessages:a,setErrorMessages:s,onInputChangeCustomInput:(e,o)=>{const t=(null===a||void 0===a?void 0:a.filter(a=>a.alias!==e))||[];o.trim()||t.push({alias:e,message:`${l(`CustomForm.${e}IsRequired`)}`}),"kontaktpersonEmail"===e&&o.trim()&&(/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o)||t.push({alias:e,message:l("CustomForm.EmailIsInvalidFormat")})),s(t)},validate:function(a){var o,t,n,r,i,d,m,u,c;const v=[];return null===(o=e.allFieldSets)||void 0===o||o.flatMap(e=>{var a;return null!==(a=e.allFields)&&void 0!==a?a:[]}).forEach(s=>{let o;var l;o=null!==a&&void 0!==a&&a[s.alias]&&"08b8057f-06c9-6ca7-3a42-fd1fc2a46eff"===s.fieldTypeId?(null===a||void 0===a||null===(l=a[s.alias])||void 0===l?void 0:l.size)>0:"string"===typeof(null===a||void 0===a?void 0:a[s.alias])?a[s.alias].trim().length>0:Boolean(null===a||void 0===a?void 0:a[s.alias]),!1===o&&s.mandatory&&v.push({alias:s.alias,message:s.requiredErrorMessage||e.requiredErrorMessage.replace("{0}",s.alias)})}),null!==(t=a.kontaktpersonNavn)&&void 0!==t&&t.trim()||v.push({alias:"kontaktpersonNavn",message:l("CustomForm.kontaktpersonNavnIsRequired")}),null!==(n=a.kontaktpersonEmail)&&void 0!==n&&n.trim()?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a.kontaktpersonEmail)||v.push({alias:"kontaktpersonEmail",message:l("CustomForm.emailIsInvalidFormat")}):v.push({alias:"kontaktpersonEmail",message:l("CustomForm.EmailIsRequired")}),null!==(r=a.cvr)&&void 0!==r&&r.trim()||v.push({alias:"cvr",message:l("CustomForm.cvrIsRequired")}),null!==(i=a.pnr)&&void 0!==i&&i.trim()||v.push({alias:"pnr",message:l("CustomForm.pnrIsRequired")}),null!==(d=a.antalPersoner)&&void 0!==d&&d.trim()||v.push({alias:"antalPersoner",message:l("CustomForm.antalPersonerIsRequired")}),null!==(m=a.forhandler)&&void 0!==m&&m.trim()||v.push({alias:"forhandler",message:l("CustomForm.forhandlerIsRequired")}),null!==(u=a.dato)&&void 0!==u&&u.trim()||v.push({alias:"dato",message:l("CustomForm.DateIsRequired")}),(null===(c=e.allFieldSets)||void 0===c?void 0:c.some(e=>{var a;return null===(a=e.allFields)||void 0===a?void 0:a.some(e=>"dataConsent"===e.alias)}))&&!a.dataConsent&&v.push({alias:"dataConsent",message:l("CustomForm.DataConsentIsRequired")}),s(v),[0===v.length,v]},getError:function(e){return null===a||void 0===a?void 0:a.find(a=>a.alias===e)},addErrors:function(e){const a=[];if(e&&"object"===typeof e){for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const o=e[s];Array.isArray(o)?o.forEach(e=>{"string"===typeof e&&a.push({alias:s,message:e})}):"string"===typeof o&&a.push({alias:s,message:o})}s(a)}},onInputChange:e=>{const o=null===a||void 0===a?void 0:a.filter(a=>a.alias!==e);s(o)},resetError:function(e){const o=null===a||void 0===a?void 0:a.filter(a=>a.alias!==e);s(o)}}})(e.formData),[A,P]=(0,o.useState)(""),{checkForFileFields:M,uploadFile:w}=(0,x.l)(),[$,R]=(0,o.useState)(!1),[q,O]=(0,o.useState)(!1),_=(0,o.useRef)(null),[U,W]=(0,o.useState)(""),{getDictionaryString:B}=(0,k.c)(),{currentCulture:G}=(0,C.d)(),H="da-dk"===G?f.A:g.default,[L,J]=(0,o.useState)("INIT"),{scrollTo:V}=(0,r.UJ)(),[z,K]=(0,o.useState)(!1),[Q,X]=(0,o.useState)(""),Y=S("kontaktpersonNavn"),Z=S("kontaktpersonEmail"),ee=S("cvr"),ae=S("forhandler"),se=S("dato"),oe=S("antalPersoner"),le=S("dataConsent"),te=S("pnr");return(0,o.useEffect)(()=>{if(z){V(_.current.offsetParent),O(!0),s(1),X(""),P("");const e=setTimeout(()=>{K(!1),O(!1)},1e4);return()=>clearTimeout(e)}},[z,V]),(0,b.jsxs)("div",{className:y.A.form,ref:_,children:[q||!e.formTagline&&!e.formHeadline?null:(0,b.jsxs)("div",{className:y.A.textWrapper,children:[e.formTagline?(0,b.jsx)("span",{children:e.formTagline}
1):null,e.formHeadline?(0,b.jsx)(t.je,{h3:!0,tag:t.Nw.H3,noMargin:!0,fullWidth:!0,children:e.formHeadline}):null]}),q?null:(0,b.jsx)("form",{onSubmit:async s=>{var o,l,t;null===s||void 0===s||s.preventDefault();const n=new FormData(null===s||void 0===s?void 0:s.target),r={},u=/^\d{2}\.\d{2}\.\d{4}$/,c={};n.forEach((a,s)=>{if("string"===typeof a&&u.test(a)){const[e,o,l]=a.split(".");r[s]=`${l}/${o}/${e}`}else a instanceof File?null!==a&&""!==a.name?r[s]=a:r[s]="":!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)))}(s)?r[s]=a:(c[s]||(c[s]=[]),c[s].push(a))});for(const e in c)r[e]=c[e];const[v]=T(r);if(!v)return;J("SUBMITTING");const{hasFile:p,fileFields:h}=M(r);p&&await Promise.all(h.map(async e=>{const[a,s]=await w(null===r||void 0===r?void 0:r[e]);a&&e?r[e]=s:console.log("Error uploading file")}));const f=r,{dataConsent:g,numberOfParticipants:C,...F}=f,I={...F,dataConsent:"on"},k={dateItemId:Q,participants:a.toString(),pageId:null===globalThis||void 0===globalThis||null===(o=globalThis.pageContent)||void 0===o?void 0:o.id,cultureCode:G},x={url:`/umbraco/forms/delivery/api/v1/entries/${null===e||void 0===e||null===(l=e.formData)||void 0===l?void 0:l.id}`,body:{values:I},...k},y=`${(0,d.yS)("ABSOLUTE")}/submitCustomForm?url=/umbraco/forms/delivery/api/v1/entries/${null===e||void 0===e||null===(t=e.formData)||void 0===t?void 0:t.id}`,b=await fetch((0,i.L)(y,"SPA"),{method:"POST",headers:{"Content-Type":"application/json","Api-Key":"88291c19-c109-p!c0-4227-97d2-3e95b7084b92"},body:JSON.stringify(x)});if(b.ok){const e=await b.json();422===(null===e||void 0===e?void 0:e.statusCode)?console.log("Der skete en fejl"):(K(!0),(0,m.d)({event:"contact_form"}),O(!0))}else if(422===b.status){const e=await b.json();N(e.errors),W(e.title),400!==e.statusCode&&"NOT_ENOUGH_ROOM"!==e.errors||P(B("CustomForm.NotEnoughRoom"))}J("INIT"),R(!0)},noValidate:!0,children:(0,b.jsxs)("fieldset",{className:y.A.fieldset,disabled:"SUBMITTING"===L,children:[$&&(0,b.jsx)(b.Fragment,{children:!0===e.formData.showValidationSummary?(0,b.jsxs)("ul",{className:y.A.summaryList,children:[j&&(0,b.jsx)("li",{className:y.A.summaryItem,children:(0,b.jsx)("h4",{children:U})}),null===j||void 0===j?void 0:j.map((e,a)=>(0,b.jsx)("li",{className:y.A.summaryItem,children:e.alias},a))]}):null}),(0,b.jsx)(h.W,{forId:void 0,label:B("CustomForm.ChooseDealer"),invalid:!!ae,helperText:null===ae||void 0===ae?void 0:ae.message,children:(0,b.jsx)(p.v,{id:"forhandler",name:"forhandler",placeholder:B("CustomForm.SelectDealer"),onChange:e=>D("forhandler",e.value),options:e.formData.dealers.map(e=>({label:e,value:e})),fullWidth:!0})}),(0,b.jsx)(v.t,{name:"kontaktpersonNavn",title:"kontaktpersonNavn",label:B("CustomForm.ContactPersonName"),onChange:e=>D("kontaktpersonNavn",e),invalid:!!Y,helperText:null===Y||void 0===Y?void 0:Y.message}),(0,b.jsx)(v.t,{name:"kontaktpersonEmail",title:"kontaktpersonEmail",label:B("CustomForm.ContactPersonEmail"),onChange:e=>D("kontaktpersonEmail",e),invalid:!!Z,helperText:null===Z||void 0===Z?void 0:Z.message}),(0,b.jsx)(v.t,{name:"cvr",title:"cvr",label:B("CustomForm.cvr"),onChange:e=>D("cvr",e),invalid:!!ee,helperText:null===ee||void 0===ee?void 0:ee.message}),(0,b.jsx)(v.t,{name:"pnr",title:"pnr",label:B("CustomForm.pnr"),onChange:e=>D("pnr",e),invalid:!!te,helperText:null===te||void 0===te?void 0:te.message}),(0,b.jsx)(h.W,{forId:void 0,label:B("CustomForm.ChooseDate"),invalid:!!se,helperText:null===se||void 0===se?void 0:se.message,children:(0,b.jsx)(p.v,{id:"dato",name:"dato",placeholder:B("CustomForm.SelectDate"),onChange:a=>{D("dato",a.value);const s=e.formData.dates.find(({date:e})=>(0,c.default)(new Date(e),"dd-MM-yyyy",{locale:H})===a.value);X(s?s.id:"")},options:e.formData.dates.map(({date:e,participants:a})=>({label:`${(0,c.default)(new Date(e),"dd-MM-yyyy",{locale:H})} - ${a} ${B("CustomForm.Participants")}`,value:(0,c.default)(new Date(e),"dd-MM-yyyy",{locale:H})})),fullWidth:!0})}),(0,b.jsx)("div",{className:y.A.amountPerson,children:(0,b.jsx)(v.t,{name:"antalPersoner",title:"antalPersoner",label:B("CustomForm.PersonAmount"),onChange:e=>{s(+e),D("antalPersoner",e)},invalid:!!oe,helperText:null===oe||void 0===oe?void 0:oe.message,type:"number"})}),(0,b.jsx)("div",{className:y.A.checkboxFields,children:(0,b.jsx)(h.W,{forId:void 0,label:B("CustomForm.DataConsent"),invalid:!!le,helperText:null===le||void 0===le?void 0:le.message,className:le?y.A.invali
1d:null,children:(0,b.jsx)(F._,{name:"dataConsent",label:(0,b.jsx)(I.O,{html:B("CustomForm.DataConsentText"),noPadding:!0,className:y.A.customLabel}),placeholder:B("CustomForm.DataConsentPlaceholder"),value:"on",onChange:()=>E("dataConsent"),className:Y?y.A.invalid:null})})}),(0,b.jsxs)("div",{children:["SUBMITTING"===L&&(0,b.jsx)(u.C,{className:y.A.spinner}),(0,b.jsx)(l.r,{title:B("CustomForm.Submit"),submit:!0,disabled:"SUBMITTING"===L})]}),A&&(0,b.jsx)("div",{className:y.A.error,children:A})]})}),q?(0,b.jsx)(n.Receipt,{...e.receipt}):null]})},T=j}}]);
2//# sourceMappingURL=blocks6.700421c6.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.