"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7665],{"./public/app/core/components/Signup/SignupPage.tsx":(e,a,s)=>{s.r(a),s.d(a,{SignupPage:()=>u,default:()=>m});s("./node_modules/react/index.js");var i,r=s("./packages/grafana-ui/src/index.ts"),n=s("./public/app/core/config.ts"),o=s("./packages/grafana-runtime/src/index.ts"),l=s("./public/app/core/app_events.ts"),d=s("./packages/grafana-data/src/index.ts"),t=s("./public/app/core/components/Login/LoginLayout.tsx"),c=s("./public/app/core/components/PasswordField/PasswordField.tsx"),p=s("./node_modules/react/jsx-runtime.js");const u=e=>{const a={email:e.queryParams.email,code:e.queryParams.code};return(0,p.jsx)(t.dd,{children:(0,p.jsx)(t.$s,{children:(0,p.jsx)(r.Form,{defaultValues:a,onSubmit:async e=>{""===e.name&&delete e.name,delete e.confirm;"redirect-to-select-org"===(await(0,o.getBackendSrv)().post("/api/user/signup/step2",{email:e.email,code:e.code,username:e.email,orgName:e.orgName,password:e.password,name:e.name}).catch((e=>{var a;const s=(null===(a=e.data)||void 0===a?void 0:a.message)||e;l.Z.emit(d.AppEvents.alertWarning,[s])}))).code&&window.location.assign((0,n.iE)().appSubUrl+"/profile/select-org?signup=1"),window.location.assign((0,n.iE)().appSubUrl+"/")},children:({errors:e,register:a,getValues:s})=>{var o,l,d;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(r.Field,{label:"Your name",children:(0,p.jsx)(r.Input,Object.assign({id:"user-name"},a("name"),{placeholder:"(optional)"}))}),(0,p.jsx)(r.Field,{label:"Email",invalid:!!e.email,error:null===(o=e.email)||void 0===o?void 0:o.message,children:(0,p.jsx)(r.Input,Object.assign({id:"email"},a("email",{required:"Email is required",pattern:{value:/^\S+@\S+$/,message:"Email is invalid"}}),{type:"email",placeholder:"Email"}))}),!(0,n.iE)().autoAssignOrg&&(0,p.jsx)(r.Field,{label:"Org. name",children:(0,p.jsx)(r.Input,Object.assign({id:"org-name"},a("orgName"),{placeholder:"Org. name"}))}),(0,n.iE)().verifyEmailEnabled&&(0,p.jsx)(r.Field,{label:"Email verification code (sent to your email)",children:(0,p.jsx)(r.Input,Object.assign({id:"verification-code"},a("code"),{placeholder:"Code"}))}),(0,p.jsx)(r.Field,{label:"Password",invalid:!!e.password,error:null==e||null===(l=e.password)||void 0===l?void 0:l.message,children:(0,p.jsx)(c.Z,Object.assign({id:"new-password",autoFocus:!0,autoComplete:"new-password"},a("password",{required:"Password is required"})))}),(0,p.jsx)(r.Field,{label:"Confirm password",invalid:!!e.confirm,error:null==e||null===(d=e.confirm)||void 0===d?void 0:d.message,children:(0,p.jsx)(c.Z,Object.assign({id:"confirm-new-password",autoComplete:"new-password"},a("confirm",{required:"Confirmed password is required",validate:e=>e===s().password||"Passwords must match!"})))}),(0,p.jsxs)(r.HorizontalGroup,{children:[i||(i=(0,p.jsx)(r.Button,{type:"submit",children:"Submit"})),(0,p.jsx)(r.LinkButton,{fill:"text",href:(0,n.iE)().appSubUrl+"/login",children:"Back to login"})]})]})}})})})},m=u}}]);
//# sourceMappingURL=7665.8128b05ac04b15cbf98d.js.map