PageSourceSearch

https://fabel.no/_next/static/chunks/469-750f0b9c9cfa6111.js

js fabel.no collected 2026-09-24 08:49:11 UTC 10,621 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[469],{10469:function(e,r,t){t.r(r),t.d(r,{RegistrationForm:function(){return P}});var o,n,a=t(57437),i=t(32290),s=t(37976),l=t(2265),d=t(72323),c=t(20071),m=t(12333),u=t(27648),p=t(29501),x=t(14793),b=t(17946),g=t(35578),f=t(17286),h=t(17503),y=t(83732);let w=/^(?:\+47|47|0047)?\d{8}$/,v={alreadyHaveAccountText:(0,m.iv)({marginBottom:4,textAlign:"center",textStyle:"label.large.book"}),formWrapper:(0,m.iv)({mx:"12px"}),createAccountText:(0,m.iv)({textStyle:"label.large.bold",color:"text",marginBottom:6}),numberError:(0,m.iv)({textStyle:"body.medium",bg:"system.error.inverted",py:"4",px:"16px",borderRadius:"4px"}),link:(0,m.iv)({textDecoration:"underline",cursor:"pointer",_hover:{color:"text"},_active:{color:"text",textDecoration:"none"},_focusVisible:{border:"1px solid {colors.border.focus}"}})},S=e=>{let{onNext:r,stepDescription:t,bannerColor:o,data:{mobile:n,email:s,newsletter:l},onLoginLinkClick:d,overrideLinkToLogin:m,isMobileNumberRegisteredError:S,onTermsAndConditionClick:k,loading:N}=e,{register:j,handleSubmit:T,setValue:E,setError:C,clearErrors:A,formState:{errors:D}}=(0,p.cI)({defaultValues:{mobile:n,email:s,newsletter:l}});return(0,a.jsxs)(i.kC,{direction:"column",paddingTop:"6",gap:"4",children:[t&&(0,a.jsx)(x.j,{color:o,children:t}),!!d&&(0,a.jsxs)("p",{className:v.alreadyHaveAccountText,children:["Har du allerede konto?"," ",(0,a.jsx)(u.default,{href:m||"https://fabel.no/min-konto",className:v.link,children:"Logg inn"})]}),S&&(0,a.jsx)("div",{className:v.numberError,children:"Dette mobilnummeret er allerede knyttet til en konto hos oss. Klikk p\xe5 \xabLogg inn\xbb for fullf\xf8re innloggingen."}),(0,a.jsxs)("div",{className:v.formWrapper,children:[(0,a.jsx)("p",{className:v.createAccountText,children:"Opprett Fabel-konto"}),(0,a.jsx)("form",{onSubmit:T(e=>{if(!e.newsletter){C("newsletter",{type:"manual",message:"Du m\xe5 godta brukervilk\xe5rene for \xe5 opprette en konto."});return}A("newsletter"),r(e)}),children:(0,a.jsxs)(i.gC,{gap:"6",alignItems:"stretch",children:[(0,a.jsx)(f.I,{input:{type:"tel",placeholder:"55 55 55 55",...j("mobile",{required:!0,validate:{invalid_phone_number:e=>{if(!e.match(w))return"Ugyldig telefonnummer"}}})},label:"Mobilnummer",error:(0,c.x)(D.mobile)}),(0,a.jsx)(f.I,{input:{type:"email",...j("email",{required:!0,validate:{invalid_email:y.o}})},label:"Epost",error:(0,c.x)(D.email)}),(0,a.jsxs)(i.M5,{flexDirection:"column",gap:"4",mb:"5px",children:[(0,a.jsx)(g.X,{onChange:e=>{E("newsletter",e),e&&A("newsletter")},label:(0,a.jsxs)(a.Fragment,{children:["Jeg godtar"," ",(0,a.jsx)("button",{className:v.link,onClick:e=>{e.preventDefault(),e.stopPropagation(),k()},children:"Fabels brukervilk\xe5r"})]}),initialValue:l,error:(0,c.x)(D.newsletter)||D.newsletter&&"Du m\xe5 godta brukervilk\xe5rene for \xe5 opprette en konto."}),(0,a.jsxs)(b.zx,{variant:"secondary",children:[N&&(0,a.jsx)(h.T,{variant:"secondaryInverted"}),"Neste"]})]})]})})]})]})};var k=t(73521),N=t(2952);let j={createAccountText:(0,m.iv)({textStyle:"label.large.bold",color:"text",marginBottom:1,marginTop:6}),smsSentBox:(0,m.iv)({borderRadius:"xl",padding:"6px 10px",width:"100%",backgroundColor:"system.warning",color:"text",marginBottom:7}),sendNewCode:(0,m.iv)({textStyle:"label.large.book",color:"green.900"}),sendNewCodeButton:(0,m.iv)({textDecoration:"underline",textDecorationColor:"green.900",cursor:"pointer"}),spinnerWrapper:(0,m.iv)({display:"inline-flex",alignItems:"center",justifyContent:"center",marginLeft:"0.5rem"}),form:(0,m.iv)({display:"flex",flexDirection:"column",minH:0})},T={minLength:"Passord m\xe5 inneholde minst 4 tegn",required:"Dette feltet er obligatorisk"},E=e=>{var r,t;let{onNext:o,onPrevious:n,stepDescription:s,bannerColor:l,loading:d,data:{password:c,error:m},onResendCode:u,resendLoading:g}=e,{register:y,watch:w,handleSubmit:v,setValue:S,formState:{errors:E}}=(0,p.cI)({defaultValues:{password:c}}),C=(0,N.d)(E,T),A=async e=>{e.preventDefault(),u()};return(0,a.jsx)(i.kC,{direction:"column",paddingTop:"6",gap:"4",children:(0,a.jsxs)("form",{onSubmit:v(o),children:[s&&(0,a.jsx)(x.j,{color:l,children:s}),(0,a.jsx)("p",{className:j.createAccountText,children:"Opprett Fabel-konto"}),(0,a.jsx)("div",{className:j.smsSentBox,children:"Vi har sendt deg en SMS med kode."}),(0,a.jsxs)(i.kC,{gap:"6",direction:"column",mx:"12px",children:[(0,a.jsx)(k.u,{onChange:e=>S("code",e),label:"SMS-kode",error:m}),(0,a.jsxs)("p",{className:j.sendNewCode,children:["Ikke mottatt SMS?"," ",g?(0,a.jsx)("span",{className:j.spinnerWrapper,children:(0,a.jsx)(h.T,{variant:"secondaryInverted"})}):(0,a.jsx)("button",{onClick:A,className:j.sendNewCodeButton,children:"Send ny kode"})]}),(0,a.jsx)(f.I,{input:{type:"password",...y("password",{minLength:4,required:!0})},label:"Opprett passord",showHidePassword:!0}),(0,a.jsx)(f.I,{input:{type:"password",...y("repeatPassword",{minLength:4,required:!0,validate:e=>{if(w("password")!==e)return"Passordene er ikke de samme"}})},label:"Gjenta passord",error:null!==(t=null===(r=E.repeatPassword)||void 0===r?void 0:r.message)&&void 0!==t?t:C("repeatPassword"),showHidePassword:!0}),(0,a.jsxs)(i.M5,{gap:"5",mb:"5px",children:[(0,a.jsx)(b.zx,{variant:"link",type:"button",onClick:n,children:"Tilbake"}),(0,a.jsxs)(b.zx,{variant:"secondary",type:"submit",children:[d&&(0,a.jsx)(h.T,{variant:"secondaryInverted"}),"Opprett konto"]})]})]})]})})},C={createAccountText:(0,m.iv)({textStyle:"label.large.bold",color:"text",marginBottom:5,marginTop:6})},A=e=>{let{onNext:r,onPrevious:t,stepDescription:o,bannerColor:n,loading:s,data:{firstName:l,lastName:d}}=e,{register:c,handleSubmit:m,formState:{errors:u}}=(0,p.cI)({defaultValues:{firstName:l,lastName:d}});return(0,a.jsx)(i.kC,{direction:"column",paddingTop:"6",gap:"4",children:(0,a.jsxs)("form",{onSubmit:m(r),children:[o&&(0,a.jsx)(x.j,{color:n,children:o}),(0,a.jsx)("p",{className:C.createAccountText,children:"Opprett Fabel-konto"}),(0,a.jsxs)(i.kC,{gap:"6",direction:"column",mx:"12px",children:[(0,a.jsx)(f.I,{input:c("firstName",{required:!0}),label:"Fornavn",error:u.firstName&&"Du må fylle ut dette feltet"}),(0,a.jsx)(f.I,{input:c("lastName",{required:!0}),label:"Etternavn",error:u.lastName&&"Du må fylle ut dette feltet"}),(0,a.jsxs)(i.M5,{gap:"5",mb:"5px",children:[(0,a.jsx)(b.zx,{variant:"link",type:"button",onClick:t,children:"Tilbake"}),(0,a.jsxs)(b.zx,{variant:"secondary",type:"submit",children:[s&&(0,a.jsx)(h.T,{variant:"secondaryInverted"}),"Neste"]})]})]})]})})};(o=n||(n={})).SET_ACCOUNT_DETAILS="SET_ACCOUNT_DETAILS",o.SET_PERSONAL_DETAILS="SET_PERSONAL_DETAILS",o.SET_PASSWORD="SET_PASSWORD";var D=t(52650),_=t(28364),I=t(74836);function L(e,r){switch(r.type){case n.SET_ACCOUNT_DETAILS:if("mobile"in r.payload&&"email"in r.payload&&"newsletter"in r.payload)return{...e,mobile:r.payload.mobile,email:r.payload.email,newsletter:r.payload.newsletter};break;case n.SET_PERSONAL_DETAILS:if("firstName"in r.payload&&"lastName"in r.payload)return{...e,firstName:r.payload.firstName,lastName:r.payload.lastName};break;case n.SET_PASSWORD:if("password"in r.payload&&"code"in r.payload)return{...e,password:r.payload.password,code:r.payload.code}}return e}let P=e=>{let{onRegisterSuccess:r,showStepper:t=!0,stepsDescription:o,bannerColor:c,overrideLinkToLogin:m,onNextStep:u,onPreviousStep:p,onStepChange:x,onLoginLinkClick:b,onTermsAndConditionClick:g}=e,[f,h]=(0,l.useReducer)(L,{newsletter:!1}),[y,w]=(0,l.useState)(0),[v,k]=(0,l.useState)(!1),N=s.S.registeruser.useMutation(),j=s.S.verifyuser.useMutation(),T=s.S.patchuser.useMutation(),C=s.S.resetPassword.useMutation(),{login:P}
1=(0,D.jt)(),{loading:M,setLoading:O}=(0,I.r)(),R=(0,l.useCallback)(async()=>{if(!f.mobile){console.error("No mobile number available.");return}try{await C.mutateAsync({mobile:f.mobile})}catch(e){console.error("Error resending SMS code:",e)}},[f.mobile,C]),B=(0,l.useCallback)(e=>async t=>{if(h({type:e,payload:t}),O(!0),0===y){if(!("mobile"in t&&"email"in t&&"newsletter"in t))throw Error("Mobile, email, or newsletter data is missing or invalid.");try{k(!1),N.reset();let e={mobile:t.mobile,email:t.email,newsletter:t.newsletter,password:f.password||"",code:f.code||""};await N.mutateAsync(e),w(e=>e+1),null==u||u(),k(!1)}catch(e){console.error("Error during registration:",e),k(!0),O(!1);return}}else if(1===y){if(!("code"in t&&"password"in t))throw Error("Mobile, code, or password data is missing or invalid.");try{let e=f.mobile,r=t.code,o=t.password;if(!("string"==typeof e&&"string"==typeof r&&"string"==typeof o))throw Error("mobile, code or password are of wrong type!");await j.mutateAsync({mobile:e,code:r,password:o}),w(e=>e+1),null==u||u(),k(!1)}catch(e){console.error("Error during verification:",e),k(!0),O(!1);return}}else if(2===y)try{if(!("firstName"in t&&"lastName"in t))throw Error("Missing firstName or lastName");let e={mobile:f.mobile,email:f.email,newsletter:f.newsletter,password:f.password,code:f.code,firstName:t.firstName,lastName:t.lastName};try{if(!await P({username:e.mobile,password:e.password}))throw Error("Login failed. No access token received.");let t=(0,_.s4)();if(!t||"string"!=typeof t)throw Error("Access token not found or invalid.");let o={accessToken:t,email:e.email,firstname:e.firstName,lastname:e.lastName};try{if(await T.mutateAsync(o),T.isError){k(!0),O(!1),console.error("Error occurred while patching user details.");return}r&&r(e),k(!1)}catch(e){console.error("Error during user patching:",e),k(!0),O(!1);return}}catch(e){console.error("Error during login:",e),k(!0),O(!1);return}}catch(e){console.error("Unexpected error:",e),k(!0),O(!1)}O(!1)},[y,u,N,f]),F=(0,l.useCallback)(()=>{null==p||p(),w(e=>e-1)},[p]);return(0,a.jsxs)(i.kC,{flexDirection:"column",minHeight:0,children:[t&&(0,a.jsx)(d.v,{steps:3,currentStep:y}),(0,a.jsx)(i.kC,{flexDirection:"column",children:function(e){switch(e){case 0:return(0,a.jsx)(S,{loading:M,onNext:B(n.SET_ACCOUNT_DETAILS),onPrevious:F,data:{mobile:f.mobile,email:f.email,newsletter:f.newsletter},overrideLinkToLogin:m,stepDescription:null==o?void 0:o[e],bannerColor:c,onLoginLinkClick:b,isMobileNumberRegisteredError:v,onTermsAndConditionClick:g});case 1:return(0,a.jsx)(E,{loading:M,onNext:B(n.SET_PASSWORD),onPrevious:F,data:{error:v?"Feil SMS-kode":void 0,password:f.password},stepDescription:null==o?void 0:o[e],bannerColor:c,onResendCode:R,resendLoading:C.isPending});case 2:return(0,a.jsx)(A,{loading:M,onNext:B(n.SET_PERSONAL_DETAILS),onPrevious:F,data:{firstName:f.firstName,lastName:f.lastName},stepDescription:null==o?void 0:o[e],bannerColor:c});default:return null}}(y)})]})}}}]);

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.