1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6294],{41072:function(e,a,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/registrer-ny-produsent",function(){return t(48960)}])},62816:function(e,a,t){"use strict";var r=t(94137),n=t(94534),s=t(68873);a.Z=new class{async getOrganization(e){try{return await (0,s.t)("/organizations/".concat(e),{})}catch(e){console.log(e)}}async updateOrganization(e){try{return await (0,r.A)("/organizations/".concat(e.id),e)}catch(e){console.log(e)}}async getUsersByOrganizationID(e){try{let a=await (0,n.C)("/organizations/".concat(e,"/users?size=12&page=1"));return a.result}catch(e){console.log(e)}}async getMainUser(e){try{let a=await (0,n.C)("/organizations/".concat(e,"/main-user"));return a.result}catch(e){console.log(e)}}}},7574:function(e,a,t){"use strict";var r=t(97582),n=t(94534),s=t(9785);let TranslationService=class TranslationService{async getNameSpace(e){try{let a=await (0,n.C)("/api/translate/nb-NO/namespace/".concat(e));return a.items}catch(e){console.log(e)}}async getNameSpace
1s(e){try{let a=await (0,n.C)("/api/translate/nb-NO/namespaces/".concat(e.join(",")));return a.data}catch(e){console.log(e)}}};(0,r.gn)([s.UT],TranslationService.prototype,"getNameSpace",null),(0,r.gn)([s.UT],TranslationService.prototype,"getNameSpaces",null),a.Z=new TranslationService},86759:function(e,a,t){"use strict";var r=t(85893),n=t(42235),s=t(80258);t(67294),a.Z=e=>{let{open:a,setHide:t}=e;return(0,r.jsx)(n.Z,{className:"loading-modal-dialog",show:a,fullscreen:!0,onHide:t,children:(0,r.jsx)(n.Z.Body,{children:(0,r.jsx)("div",{className:"justify-content-center align-items-center d-flex h-100",children:(0,r.jsx)(s.Z,{})})})})}},36459:function(e,a,t){"use strict";var r=t(85893),n=t(11163);a.Z=e=>{let{headlineText:a,onIconClick:t}=e,s=(0,n.useRouter)();return(0,r.jsxs)("div",{className:"m3-top-app-bar",children:[(0,r.jsx)("button",{onClick:t||(()=>s.back()),type:"button",className:"m3-icon-button",style:{fontSize:"24px"},children:(0,r.jsx)("span",{className:"material-icons-outlined",children:"arrow_back"})}),(0,r.jsx)("div",{className:"headline",children:a})]})}},94346:function(e,a,t){"use strict";var r,n,s,i,l,o;t.d(a,{Xd:function(){return n},fI:function(){return s},zm:function(){return r}}),(i=r||(r={})).Own="own",i.Rental="rental",i.Certified="certified",(l=n||(n={})).EHF="ehf",l.Email="email",(o=s||(s={})).New="new",o.Approved="approved",o.Approving="approving",o.ReApproved="re-approved",o.TasksCompleted="tasks-completed",o.Rejected="rejected",o.Deleted="deleted"},48960:function(e,a,t){"use strict";t.r(a),t.d(a,{default:function(){return registrer_ny_produsent}});var r=t(85893),n=t(82401),s=t(67294),i=t(94346);let CompanySection=e=>{var a,t,n,s,l;let{handleInputChange:o,handleSelectChange:c,formErrors:d}=e;return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("section",{className:"register-form_new-company-fields",children:[(0,r.jsxs)("div",{className:"form-field form-outline",children:[(0,r.jsx)("input",{id:"auth_reg_producer_display_name",name:"displayName",className:"disable-for-existing form-control ".concat(d.displayName?"is-invalid":""),type:"text",onChange:o,placeholder:""}),(0,r.jsx)("label",{htmlFor:"auth_reg_producer_display_name",className:"",children:"Visningsnavn *"}),(0,r.jsx)("div",{className:"invalid-feedback ms-3",children:null!==(a=d.displayName)&&void 0!==a?a:""})]}),(0,r.jsx)("hr",{}),(0,r.jsxs)("fieldset",{className:"",children:[(0,r.jsx)("div",{className:"title mb-2",children:"Bes\xf8ksadresse"}),(0,r.jsx)("p",{className:"guideline",children:"Fylles inn dersom du holder til p\xe5 annen adresse enn det som st\xe5r registrert i Br\xf8nn\xf8ysundregisteret"}),(0,r.jsxs)("div",{className:"form-field form-outline",children:[(0,r.jsx)("input",{id:"auth_reg_producer_visiting_address",name:"addresses",defaultValue:"",className:"disable-for-existing form-control ",type:"text",onChange:o,placeholder:""}),(0,r.jsx)("label",{htmlFor:"auth_reg_producer_visiting_address",className:"",children:"Adresse"}),(0,r.jsx)("div",{className:"invalid-feedback ms-3"})]}),(0,r.jsxs)("div",{className:"form-field form-outline",children:[(0,r.jsx)("input",{id:"auth_reg_producer_visiting_postal_code",name:"visitingPostalCode",defaultValue:"",className:"disable-for-existing form-control ",type:"text",onChange:o,placeholder:""}),(0,r.jsx)("label",{htmlFor:"auth_reg_producer_visiting_postal_code",className:"",children:"Postnummer"}),(0,r.jsx)("div",{className:"invalid-feedback ms-3"})]}),(0,r.jsxs)("div",{className:"form-field form-outline",children:[(0,r.jsx)("input",{id:"auth_reg_producer_visiting_postal_place",name:"visitingPostalPlace",defaultValue:"",className:"disable-for-existing form-control ",type:"text",onChange:o,placeholder:""}),(0,r.jsx)("label",{htmlFor:"auth_reg_producer_visiting_postal_place",className:"",children:"Poststed"}),(0,r.jsx)("div",{className:"invalid-feedback ms-3"})]}),(0,r.jsx)("hr",{})]}),(0,r.jsxs)("fieldset",{className:"mb-4",children:[(0,r.jsx)("div",{className:"title mb-2",children:"Annet"}),(0,r.jsx)("p",{className:"guideline mb-4",children:" Dette vil v\xe6re kontaktnummeret og motta SMS-meldinger. Dette mobilnummeret er kun synlig for Matmerk\n administrator og vises ikke i offentlig firmaprofil."}),(0,r.jsxs)("div",{className:"form-field form-outline",children:[(0,r.jsx)("input",{id:"auth_reg_producer_company_email",name:"producerEmail",className:"form-control ".concat(d.producerEmail?"is-invalid":""),type:"text",onCh
1ange:o,placeholder:""}),(0,r.jsx)("label",{htmlFor:"auth_reg_producer_company_email",className:"",children:"Selskaps epost *"}),(0,r.jsx)("div",{className:"invalid-feedback ms-3",children:null!==(t=d.producerEmail)&&void 0!==t?t:""})]}),(0,r.jsxs)("div",{className:"form-field form-outline",children:[(0,r.jsx)("input",{id:"auth_reg_producer_company_telephone",name:"producerPhoneNumber",defaultValue:"",className:"form-control ".concat(d.producerPhoneNumber?"is-invalid":""),type:"text",onChange:o,placeholder:""}),(0,r.jsx)("label",{htmlFor:"auth_reg_producer_company_telephone",className:"",children:"Telefonnummer *"}),(0,r.jsx)("div",{className:"invalid-feedback ms-3",children:null!==(n=d.producerPhoneNumber)&&void 0!==n?n:""})]}),(0,r.jsxs)("div",{className:"form-field form-outline",children:[(0,r.jsxs)("select",{id:"auth_reg_producer_invoice_type",name:"invoiceType",className:"form-select ".concat(d.invoiceType?"is-invalid":""),onChange:c,defaultValue:"",children:[(0,r.jsx)("option",{disabled:!0,value:"",children:"Velgâ¦"}),(0,r.jsx)("option",{value:i.Xd.EHF,id:"0",children:"EHF (elektronisk handelsformat)"}),(0,r.jsx)("option",{value:i.Xd.Email,id:"1",children:"E-post"})]}),(0,r.jsx)("label",{htmlFor:"auth_reg_producer_invoice_type",className:"",children:"Faktura type *"}),(0,r.jsx)("div",{className:"invalid-feedback ms-3",children:null!==(s=d.invoiceType)&&void 0!==s?s:""})]}),(0,r.jsxs)("div",{className:"form-field form-outline",children:[(0,r.jsxs)("select",{id:"auth_reg_producer_production_type",name:"productionType",className:"form-select ".concat(d.productionType?"is-invalid":""),defaultValue:"",onChange:c,children:[(0,r.jsx)("option",{disabled:!0,value:"",children:"Velgâ¦"}),(0,r.jsx)("option",{value:i.zm.Own,id:"0",children:"Egen produksjon"}),(0,r.jsx)("option",{value:i.zm.Rental,id:"1",children:"Kun leieproduksjon"}),(0,r.jsx)("option",{value:i.zm.Certified,id:"2",children:"Sertifisert produsent"})]}),(0,r.jsx)("label",{htmlFor:"auth_reg_producer_production_type",className:"",children:"Type produksjon *"}),(0,r.jsx)("div",{className:"invalid-feedback ms-3",children:null!==(l=d.productionType)&&void 0!==l?l:""})]}),(0,r.jsxs)("div",{className:"form-field form-outline",children:[(0,r.jsx)("input",{id:"auth_reg_producer_gln",name:"glnNumber",defaultValue:"",className:"form-control ",type:"text",onChange:o,placeholder:""}),(0,r.jsx)("label",{htmlFor:"auth_reg_producer_gln",className:"",children:"GLN-nummer"}),(0,r.jsx)("div",{className:"invalid-feedback ms-3"})]})]})]})})};var l=t(62816),o=t(98332),c=t(11163),d=t(41645),u=t(86759),m=t(22920),p=t(80438),h=t(60324),g=t(7574),f=t(9473),v=t(52638),x=t(25675),j=t.n(x);let RegisterForm=()=>{var e,a,t,i,x,N;let[y,_]=(0,s.useState)(!1),[b,k]=(0,s.useState)(!1),[w,S]=(0,s.useState)({}
1),[C,F]=(0,s.useState)(!1),[E,T]=(0,s.useState)(!1),[P,R]=(0,s.useState)(),[z,O]=(0,s.useState)(!1),A=(0,c.useRouter)(),[I,U]=(0,s.useState)(!0),[D,Z]=(0,s.useState)(!1),[V,M]=(0,s.useState)(""),[B,H]=(0,s.useState)(!1),{notify_error:L,common:$}=p,[q,X]=(0,s.useState)({}),[K,W]=(0,s.useState)(),[G,J]=(0,s.useState)(!1);(0,f.v9)(v.tH);let createUser=async e=>{try{let r=localStorage.getItem("user_info"),n=localStorage.getItem("ssn"),s=r?JSON.parse(r):null;if(!s)return m.Am.error("Ugyldig data!"),console.log("You need to login via ID-Porten to create a user."),!1;let i=s.email;if(!n||!i)return m.Am.error("Ugyldig data!"),console.log("User information is incomplete. Please go back to resubmit the information."),!1;let l={ssn:n,email:i.toLowerCase(),hasAcceptedTerms:!0,organizationID:V,role:d.F.Producer,producerData:e},c=await o.Z.createUser(l);if(200!==c.status){var a,t;let e=null==c?void 0:null===(t=c.response)||void 0===t?void 0:null===(a=t.data)||void 0===a?void 0:a.errorCode,r=K&&K[e]?K[e]:"".concat($.error);return m.Am.error(r),!1}return c.result}catch(e){return console.log("error:",e),m.Am.error("Ukjent feil skjedde!"),!1}finally{O(!1)}},{validate:Q}=(0,h.ZP)({validationRules:{displayName:b&&P?[[h.C1,"Visningsnavn er p\xe5krevd."]]:void 0,producerEmail:b&&P?[[h.Do,"Selskaps epost er ugyldig."]]:void 0,producerPhoneNumber:b&&P?[[h.C1,"Telefonnummer er p\xe5krevd."]]:void 0,invoiceType:b&&P?[[h.C1,"Faktura type er p\xe5krevd."]]:void 0,productionType:b&&P?[[h.C1,"Type produksjon er p\xe5krevd."]]:void 0},formInput:w}),handleFormValidation=()=>{Q().then(()=>{handleFormSubmit(),X({})}).catch(e=>{X(e)})},handleFormSubmit=async()=>{var e;let a;if(console.log("values",w),!I){m.Am.error("".concat(L.submit_purchaser_register_form_verify_token));return}if(O(!0),B){let e=await o.Z.checkPassword(w.email,w.password);if(!e){m.Am.error("".concat(L.submit_producer_register_form)),O(!1);return}}let t={displayName:w.displayName,addressVisiting:{postalCode:w.visitingPostalCode,postalPlace:w.visitingPostalPlace,addresses:[null!==(e=w.addresses)&&void 0!==e?e:""]},email:w.producerEmail,phoneNumber:w.producerPhoneNumber,invoiceType:w.invoiceType,productionType:w.productionType,glnNumber:w.glnNumber};if(O(!0),D){let e=localStorage.getItem("ssn"),r=await o.Z.assignMainUserToAnotherType({ssn:e,organizationRefID:V,producerData:t});a=!!r}else a=await createUser(t);if(O(!1),!a)return;let r=a.isMainUser||D?"/":"/registrer/request/?producerID=".concat(a.producerID);A.push(r)},handleOrgNumberChange=async()=>{if(!V)return null;_(!0),F(!1),T(!1),k(!1),Z(!1);let e=await l.Z.getOrganization(V);if(200!==e.status)return _(!1),F(!0);e.result.producer||k(!0),handleCheckMainUser(),T(!0),F(!1),R(e.result),_(!1)},setCanSubmitForm=()=>{Q().then(()=>{J(!0)}).catch(()=>{J(!1)})},handleCheckMainUser=async()=>{Z(!1);let e=localStorage.getItem("ssn"),a=await o.Z.checkIsMainUserOfOrganization({ssn:e,organizationRefID:V});a&&Z(!0)},getNamespaces=async()=>{let e=await g.Z.getNameSpace("error-message");e&&W(e)};return(0,s.useEffect)(()=>{getNamespaces()},[]),(0,s.useEffect)(()=>{(Object.keys(w).length||P)&&setCanSubmitForm()},[w,P]),(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{id:"register-producer-form",className:"register-form",children:[(0,r.jsx)("div",{className:"row",children:(0,r.jsx)("div",{className:"col-md-8",children:(0,r.jsx)("div",{className:"title mb-4",children:"Selskapsinformasjon"})})}),(0,r.jsxs)("div",{className:"mb-4 col-12 d-flex align-items-start flex-column flex-md-row",style:{marginBottom:"24px",gap:"16px"},children:[(0,r.jsxs)("div",{className:"form-outline",style:{marginBottom:0},children:[(0,r.jsx)("input",{id:"auth_reg_producer_org_number",placeholder:"",name:"org_number",onKeyDown:e=>{"Enter"===e.key&&handleOrgNumberChange()},onChange:e=>{T(!1),M(e.target.value.replace(/ /g,""))},value:V,className:"form-control ".concat(C&&!E&&"is-invalid"),autoFocus:!0,t
1ype:"text",required:!0}),(0,r.jsx)("label",{htmlFor:"auth_reg_producer_org_number",children:"Organisasjonsnummer * "}),(0,r.jsx)("div",{className:"invalid-feedback ms-3",children:C&&!E&&"Ugyldig organisasjonsnummer."})]}),(0,r.jsx)("button",{className:"m3-btn btn btn-outline-primary",disabled:V.length<9,onClick:()=>{T(!1),handleOrgNumberChange()},style:{marginTop:"8px"},children:"Hent organisasjon"})]}),y?(0,r.jsx)(n.p,{}):E&&P&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"d-flex align-items-center gap-3 ps-3 mb-4 col-12",children:[(0,r.jsx)("div",{children:(0,r.jsx)("span",{className:"material-icons-outlined",children:"business"})}),(0,r.jsxs)("div",{className:"d-flex flex-column",children:[(0,r.jsx)("div",{className:"company-name",children:null==P?void 0:P.name}),(0,r.jsx)("div",{className:"address",children:"".concat(null==P?void 0:null===(a=P.address)||void 0===a?void 0:null===(e=a.addresses)||void 0===e?void 0:e.join(" ")).concat((null==P?void 0:null===(t=P.address)||void 0===t?void 0:t.postalCode)?", ".concat(null==P?void 0:null===(i=P.address)||void 0===i?void 0:i.postalCode):""," ").concat(null!==(N=null==P?void 0:null===(x=P.address)||void 0===x?void 0:x.postalPlace)&&void 0!==N?N:"")})]})]}),(D||null==P||!P.producer)&&((null==P?void 0:P.producer)||(null==P?void 0:P.purchaser))&&!D?(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"col-12 d-flex flex-column align-items-center justify-content-center",style:{padding:"50px 0px"},children:[(0,r.jsx)(j(),{src:"/assets/images/secure-login.png",width:410,height:285,alt:"Register lock",className:"img-fluid"}),(0,r.jsxs)("div",{className:"",style:{margin:"16px 0px",fontSize:"16px",color:"var(--schemes-on-surface)",maxWidth:"360px",textAlign:"center"},children:["Du har ikke tilgang til \xe5 opprette innkj\xf8perprofil for ",null==P?void 0:P.name,".",(0,r.jsx)("br",{}),"Tar kontakt med hovedbrukeren i din bedrift."]})]})}):(0,r.jsx)(r.Fragment,{children:b&&P?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"col-12",children:(0,r.jsx)(CompanySection,{handleInputChange:e=>{if("terms"===e.target.name)return S({...w,[e.target.name]:e.target.checked});S({...w,[e.target.name]:e.target.value})},handleSelectChange:e=>{S({...w,[e.target.name]:e.target.value})},organizationInfo:P,formErrors:q})}),(0,r.jsxs)("div",{className:"col-12 d-flex align-items-center justify-content-end gap-3 form-actions",children:[(0,r.jsx)("button",{type:"button",onClick:()=>A.back(),className:"m3-btn btn text-decoration-none",children:"Avbyrt"}),(0,r.jsxs)("div",{className:"custom-tooltip",children:[(0,r.jsx)("span",{className:"tooltiptext tooltip-top ".concat(G?"d-none":""),children:"Vennligst fyll ut alle obligatoriske felt."}),(0,r.jsx)("button",{disabled:!G,type:"button",onClick:handleFormValidation,className:"m3-btn btn btn-primary",children:"Registrer som produsent"})]})]})]}):(0,r.jsxs)("div",{className:"col-12 d-flex flex-column align-items-center justify-content-center",style:{padding:"50px 0px"},children:[(0,r.jsx)(j(),{src:"/assets/images/secure-login.png",width:410,height:285,alt:"Register lock",className:"img-fluid"}),(0,r.jsxs)("div",{className:"",style:{margin:"16px 0px",fontSize:"16px",color:"var(--schemes-on-surface)"},children:["Det finnes allerede en Produsentprofil knyttet til ",null==P?void 0:P.name,"."]}),(0,r.jsx)("button",{type:"button",onClick:handleFormValidation,className:"m3-btn btn btn-primary",children:"Be om tilgang"})]})}),(0,r.jsx)(u.Z,{open:z,setHide:()=>O(!1)})]})]})})};var N=t(1327),y=t(33805),_=t(28700),b=t(36459),registrer_ny_produsent=()=>((0,s.useEffect)(()=>{let e=localStorage.getItem("user_info"),a=e?JSON.parse(e):null;(0,_.HV)("ssn")&&a&&a.email&&a.lastName&&a.firstName||(window.location.href="/login")},[]),(0,r.jsx)(y.o,{meta:(0,r.jsx)(N.h,{title:"Lokalmat - Register ny Produsent",description:"Lokalmat - Bransjeportalen for lokalmat for hele Norge - Stiftelsen Norsk Mat",canonical:"".concat("https://www.lokalmat.no","/registrer-ny-produsent")}
1),isProfileView:!0,children:(0,r.jsxs)("main",{id:"main-content",children:[(0,r.jsx)(b.Z,{headlineText:"Opprett Produsentprofil"}),(0,r.jsx)("div",{className:"container register-producer-page",children:(0,r.jsxs)("div",{id:"registerbox",children:[(0,r.jsxs)("header",{className:"c-page-header d-none",children:[(0,r.jsx)("div",{className:"row",children:(0,r.jsx)("div",{className:"col-md-12",children:(0,r.jsx)("h1",{children:"Registrer ny Produsent"})})}),(0,r.jsx)("div",{className:"row",children:(0,r.jsx)("div",{className:"col-md-12",children:(0,r.jsx)("p",{className:"lead"})})})]}),(0,r.jsx)("div",{className:"row pb-5",children:(0,r.jsx)(RegisterForm,{})})]})})]})}))},60324:function(e,a,t){"use strict";t.d(a,{C1:function(){return required},Do:function(){return email},Ei:function(){return minLength},HQ:function(){return url},K$:function(){return numberWithDigits},Rx:function(){return number},aG:function(){return shouldNotMatched},oh:function(){return isMatched},pA:function(){return numberRegex}});var r=t(67294),n=t(37670);let isBoolean=e=>!0===e||!1===e,required=(e,a,t)=>"number"==typeof e[a]&&e[a]?{}:e[a]&&e[a].length?{}:{[a]:t||"This field is required"},number=(e,a)=>isNaN(e[a])&&{[a]:"Invalid field data"},numberRegex=(e,a,t)=>{let r=RegExp("^[0-9]*$");return r.test(e[a])?{}:{[a]:t||"Not valid number!"}},numberWithDigits=(e,a,t,r)=>{let n=e[a].replace(/ /g,""),s=new RegExp("^[0-9]{".concat(t,"}$"));return s.test(n)?{}:{[a]:r||"Not valid number!"}},url=(e,a)=>""!==e[a].trim()&&!(0,n.r4)(e[a])&&{[a]:"Invalid URL"},email=(e,a,t)=>{var r;let n=new RegExp(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/);return n.test(null===(r=e[a])||void 0===r?void 0:r.trim())?{}:{[a]:t||"Not valid email address!"}},isMatched=(e,a,t,r)=>e[a]!==t&&{[a]:r||"Not match"},shouldNotMatched=(e,a,t,r)=>e[a]===t&&{[a]:r||"Should not match"},minLength=(e,a,t,r)=>!e[a]||e[a].length<t&&{[a]:r||"Invalid min length"};a.ZP=e=>{let{validationRules:a,formInput:t}=e,[n,s]=(0,r.useState)(null),validation=()=>{let e={};return Object.keys(a).forEach(r=>{let n=a[r];n&&n.forEach(a=>{if(!e[r]){let n;if(!isBoolean(a)){if(!0===Array.isArray(a)){let[e,...s]=a;n=e(t,r,...s)}else n=a(t,r)}!1===a&&(n={[r]:"Invalid value"}),n&&(e={...e,...n})}})}),e};return{validate:()=>new Promise((e,a)=>{let t=validation();0===Object.keys(t).length?(s({}),e("Success")):(s(t),a(t))}),errors:n,setErrors:s}}},37670:function(e,a,t){"use strict";t.d(a,{mE:function(){return validateNumber},r4:function(){return validateURL}});let validateNumber=(e,a,t)=>{let r=RegExp("^[0-9]*$");return a||t?(r=new RegExp("^[0-9]{".concat(a,",").concat(t,"}$"))).test(e):r.test(e)},validateURL=e=>{let a=RegExp("(https?://)?([\\da-z.-]+)\\.([a-z.]{2,6})[/\\w .-]*/?");return a.test(e)}}},function(e){e.O(0,[2632,2962,3185,3752,1964,6624,9774,2888,179],function(){return e(e.s=41072)}),_N_E=e.O()}]);
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.