1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7581],{7581:function(e,t,r){"use strict";r.r(t),r.d(t,{NewsletterSignupFeature:function(){return w}});var i=r(85893),n=r(16740),a=r(94249),l=r(73413),s=r(57267);let o=async e=>(0,l.b)({url:"/engagement-api/v1/apsis/signup/GetSignupForm?organisationShortName=".concat(e),method:"GET"}).then(e=>e.data).catch(e=>{var t,r,i;let n=null!==(i=null==e?void 0:null===(r=e.response)||void 0===r?void 0:null===(t=r.data)||void 0===t?void 0:t.message)&&void 0!==i?i:e;return s.Z.error("NewsletterForm retrieval failed: ".concat(n)),{resultFromDefinitionResponse:{success:!1,errorMessage:e.message}}}),c=async e=>o(e);var d=r(75237),u=r(94184),m=r.n(u),h=r(26680),p=r(67294),x=r(58938),_=r.n(x),N=r(82988);let b=e=>{let{required:t,idName:r,lblName:n,submitTried:a,onChange:l,options:s,errorText:o}=e,[c,d]=(0,p.useState)(null==s?void 0:s.map(e=>({...e,checked:!1}))),[u,m]=(0,p.useState)(void 0);(0,p.useEffect)(()=>{t&&c.every(e=>!1===e.checked)&&a?m(o):m(void 0)},[a,c,t]);let h=e=>{var t;let r=null==e?void 0:null===(t=e.target)||void 0===t?void 0:t.checked;d(null==c?void 0:c.map(t=>{var i;return t.idValue===(null==e?void 0:null===(i=e.target)||void 0===i?void 0:i.value)&&(t.checked=r),t})),l&&l(e.target.form)};return(0,i.jsxs)("fieldset",{children:[(0,i.jsx)("legend",{children:n}),null==s?void 0:s.map(e=>(0,i.jsx)(N.X,{id:e.idName,value:e.idValue,label:e.name,name:r,onChange:e=>h(e),required:t&&c.every(e=>!1===e.checked)},e.idName)),u&&(0,i.jsx)("p",{className:_().NewsLetterSignUp___error,children:u})]})};var v=r(75911),g=r(69460),f=r.n(g);let k=e=>{let{required:t,idName:r,lblName:n,submitTried:a,onChange:l,options:s}=e,[o,c]=(0,p.useState)(""),[d,u]=(0,p.useState)(void 0);(0,p.useEffect)(()=>{t&&0===o.trim().length&&a?u(["Felt skal udfyldes"]):u(void 0)},[a,o,t]);let h=e=>{c(e.target.value),l&&l(e.target.form)};return(0,i.jsxs)("div",{className:m()(f().NewsLetterTextBox),children:[(0,i.jsxs)("label",{className:"",htmlFor:r,children:[n,":"]}),(0,i.jsx)("div",{className:"",children:(0,i.jsx)(v.Ph,{name:r,id:r,required:t,value:o,onChange:e=>h(e),errors:d,children:s.map((e,t)=>(0,i.jsx)("option",{value:e.idValue,children:e.idValue},t))})})]},r)};var C=r(22634);let j=e=>{let{required:t,idName:r,lblName:n,submitTried:a,onChange:l}=e,[s,o]=(0,p.useState)(""),[c,d]=(0,p.useState)(void 0);(0,p.useEffect)(()=>{t&&0===s.trim().length&&a?d(["Felt skal udfyldes"]):d(void 0)},[a,s,t]);let u=e=>{o(e.target.value),l&&l(e.target.form)};return(0,i.jsxs)("div",{className:m()(f().NewsLetterTextBox),children:[(0,i.jsxs)("label",{className:"",htmlFor:r,children:[n,":"]}),(0,i.jsx)("div",{className:"",children:(0,i.jsx)(C.I,{name:r,id:r,type:"text",required:t,placeholder:n,textLeft:!0,value:s,onChange:e=>u(e),errors:c})})]})},S=e=>{let{formFields:t,organisationName:r,submitText:n,noNewslettersSelectedError:a,apiErrorText:l,successText:s,signUpHandler:o}=e,[c,d]=(0,p.useState)(!1),[u,x]=(0,p.useState)(null),[N,v]=(0,p.useState)(!1),[g,f]=(0,p.useState)(!1),[C,S]=(0,p.useState)(!1),w=e=>{f(!1),d(!0),y(e),e.checkValidity()&&(v(!0),o(u).then(e=>{let t=Object.keys(e.data).reduce((t,r)=>t&&e.data[r],!0);f(!t),S(t)}).catch(()=>{f(!0)}).finally(()=>{v(!1)}))},y=e=>{let i=new FormData(e);x({organisationName:r,inputs:{...Object.fromEntries(t.map(e=>"CheckBox"===e.fieldType?[e.idName,i.getAll(e.idName).map(e=>Number(e))]:[e.idName,i.get(e.idName)]))}})};return C?(0,i.jsx)("p",{children:s}):(0,i.jsxs)("form",{noValidate:!0,onSubmit:e=>{e.preventDefault(),w(e.target)},className:m()(_().NewsLetterSignUp),children:[(0,i.jsx)("input",{type:"hidden",value:r,name:"organisationName"}),null==t?void 0:t.map(e=>"TextBox"===e.fieldType?(0,i.jsx)(j,{idName:e.idName,lblName:e.label,required:(null==e?void 0:e.required)==="true",submitTried:c,onChange:e=>y(e)},e.idName):"DropDown"===e.fieldType?(0,i.jsx)(k,{idName:e.idName,lblName:e.label,required:(null==e?void 0:e.required)==="true",submitTried:c,onChange:e=>y(e),options:e.optionList},e.idName):"CheckBox"===e.fieldType?(0,i.jsx)(b,{required:"true"===e.required,idName:e.idName,lblName:e.label,options:e.optionList,onChange:e=>y(e),submitTried:c,errorText:a},e.idName):void 0),g&&(0,i.jsx)("p",{className:m()(_().NewsLetterSignUp___error),children:l}),(0,i.jsx)("p",{children:(0,i.jsx)(h.zx,{type:"submit",disabled:N,children:n})})]})},w=e=>{var t,r;let{content:s,settings:o}=e,u=(0,n.S)(),m=(0,a.AA)(),[h,x]=(0,p.useState)(null),_=null===h,N=null==h?void 0:h.inputFields,b=(null==h?void 0:null===(t=h.resultFromDefinitionResponse)||void 0===t?void 0:t.success)===!1,{signupIdOverride:v}=null!==(r=null==s?void 0:s.properties)&&void 0!==r?r:{},g=v&&""!==v?v:m.theme;return(0,p.useEffect)(()=>{(async()=>{x(await c(g))})()},[g]),(0,i.jsxs)(i.Fragment,{children:[_?(0,i.jsxs)("p",{children:[u.getServiceInfo("FetchingData"),"."]}):null,b?(0,i.jsx)("p",{children:u.getNewsletter("ApiError")}):null,_||b?null:(0,i.jsx)(d.E,{...o,children:(0,i.jsx)(S,{formFields:N,organisationName:h.organisationName,noNewslettersSelectedError:u.getNewsletter("NoNewsletterSelected"),signUpHandler:e=>(0,l.b)("/engagement-api/v1/apsis/subscriber/CreateSubscriber",{params:e,paramsSerializer(e){var t;return"organisationName=".concat(encodeURIComponent(e.organisationName)).concat(null===(t=Object.keys(e.inputs))||void 0===t?void 0:t.map(t=>{if(t.includes("Demographicfield")){let r=isNaN(Number(t.slice(-1)))?"":"&demographicIndex=".concat(t.slice(-1));return"&".concat(t.slice(0,-1),"=").concat(encodeURIComponent(e.input
1s[t])).concat(r)}return Array.isArray(e.inputs[t])?"&".concat(e.inputs[t].map(e=>"".concat(t,"=").concat(encodeURIComponent(e))).join("&")):"&".concat(t,"=").concat(encodeURIComponent(e.inputs[t]))}).join(""))}}),submitText:u.getNewsletter("Subscribe"),apiErrorText:u.getNewsletter("ApiError"),successText:u.getNewsletter("SignupSuccess")})})]})}},82988:function(e,t,r){"use strict";r.d(t,{X:function(){return m}});var i=r(85893),n=r(94184),a=r.n(n),l=r(11319),s=r(67294),o=r(23082),c=r(94594),d=r(54834),u=r.n(d);let m=e=>{let{className:t,id:r,label:n,checked:d,inline:m,name:h,value:p,formRegister:x,disabled:_,hasError:N,helpText:b,helpCtaAriaLabel:v,...g}=e,[f,k]=(0,s.useState)(!1);return(0,i.jsxs)("div",{className:a()(t,u().Checkbox,{[u().Checkbox___inline]:m},{[u().Checkbox___hasError]:N},{[u().Checkbox___disabled]:_}),children:[(0,i.jsx)("input",{type:"checkbox",className:u().Checkbox_input,id:r,disabled:_,defaultChecked:d,value:p,name:h,...x&&{...x.register(x.fieldName,x.options)},...g}),(0,i.jsxs)("label",{className:u().Checkbox_label,htmlFor:r,children:[n,b&&(0,i.jsx)(o.M,{describedById:r+"-help",helpText:b,onClick:()=>{k(!0)},ariaLabel:v,margined:!0})]}),b&&(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(l.u,{show:f,onClose:()=>k(!1),"aria-hidden":!f,children:(0,i.jsx)(c.H,{content:b})})})]})}},54834:function(e){e.exports={Checkbox:"Checkbox_Checkbox__pfFDO",Checkbox___inline:"Checkbox_Checkbox___inline__39WQ9",Checkbox_input:"Checkbox_Checkbox_input__F0n_E",Checkbox_label:"Checkbox_Checkbox_label__xudua",Checkbox___hasError:"Checkbox_Checkbox___hasError__pmG9r",Checkbox___disabled:"Checkbox_Checkbox___disabled__fqqGc"}},58938:function(e){e.exports={NewsLetterSignUp:"NewsLetterSignUp_NewsLetterSignUp__S_hzm",NewsLetterSignUp___error:"NewsLetterSignUp_NewsLetterSignUp___error__ywXqv"}},69460:function(e){e.exports={NewsLetterTextBox:"NewsLetterSignUpTextBox_NewsLetterTextBox__89TWE"}}}]);
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.