diff --git a/public/app/core/components/Signup/SignupPage.tsx b/public/app/core/components/Signup/SignupPage.tsx index d0d1bd2c434..c91cb364698 100644 --- a/public/app/core/components/Signup/SignupPage.tsx +++ b/public/app/core/components/Signup/SignupPage.tsx @@ -1,7 +1,8 @@ import React from 'react'; +import { useForm } from 'react-hook-form'; import { getBackendSrv } from '@grafana/runtime'; -import { Form, Field, Input, Button, HorizontalGroup, LinkButton, FormAPI } from '@grafana/ui'; +import { Field, Input, Button, LinkButton, Stack } from '@grafana/ui'; import { getConfig } from 'app/core/config'; import { useAppNotification } from 'app/core/copy/appNotification'; import { GrafanaRouteComponentProps } from 'app/core/navigation/types'; @@ -27,8 +28,15 @@ interface QueryParams { interface Props extends GrafanaRouteComponentProps<{}, QueryParams> {} -export const SignupPage = (props: Props) => { +export const SignupPage = ({ queryParams }: Props) => { const notifyApp = useAppNotification(); + const { + handleSubmit, + formState: { errors }, + register, + getValues, + } = useForm({ defaultValues: { email: queryParams.email, code: queryParams.code } }); + const onSubmit = async (formData: SignupDTO) => { if (formData.name === '') { delete formData.name; @@ -55,72 +63,63 @@ export const SignupPage = (props: Props) => { window.location.assign(getConfig().appSubUrl + '/'); }; - const defaultValues = { - email: props.queryParams.email, - code: props.queryParams.code, - }; - return ( -
- {({ errors, register, getValues }: FormAPI) => ( - <> - - - - - - - {!getConfig().autoAssignOrg && ( - - - - )} - {getConfig().verifyEmailEnabled && ( - - - - )} - - - - - v === getValues().password || 'Passwords must match!', - })} - /> - - - - - - Back to login - - - + + + + + + + + {!getConfig().autoAssignOrg && ( + + + )} - + {getConfig().verifyEmailEnabled && ( + + + + )} + + + + + v === getValues().password || 'Passwords must match!', + })} + /> + + + + + + Back to login + + +
); diff --git a/public/app/core/components/Signup/VerifyEmail.tsx b/public/app/core/components/Signup/VerifyEmail.tsx index e372217e06c..cc255572863 100644 --- a/public/app/core/components/Signup/VerifyEmail.tsx +++ b/public/app/core/components/Signup/VerifyEmail.tsx @@ -1,7 +1,8 @@ import React, { useState } from 'react'; +import { useForm } from 'react-hook-form'; import { getBackendSrv } from '@grafana/runtime'; -import { Form, Field, Input, Button, Legend, Container, HorizontalGroup, LinkButton } from '@grafana/ui'; +import { Field, Input, Button, Legend, Container, LinkButton, Stack } from '@grafana/ui'; import { getConfig } from 'app/core/config'; import { useAppNotification } from 'app/core/copy/appNotification'; import { w3cStandardEmailValidator } from 'app/features/admin/utils'; @@ -12,6 +13,11 @@ interface EmailDTO { export const VerifyEmail = () => { const notifyApp = useAppNotification(); + const { + handleSubmit, + register, + formState: { errors }, + } = useForm(); const [emailSent, setEmailSent] = useState(false); const onSubmit = (formModel: EmailDTO) => { @@ -39,36 +45,32 @@ export const VerifyEmail = () => { } return ( -
- {({ register, errors }) => ( - <> - Verify Email - - - - - - - Back to login - - - - )} -
+
+ Verify Email + + + + + + + Back to login + + +
); };