Skip to content

Commit

Permalink
Add email autofill from search params (#16936)
Browse files Browse the repository at this point in the history
* Add email autofill from search params
  • Loading branch information
letiescanciano committed Sep 22, 2022
1 parent f28d5f3 commit 7f2c8be
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Field, FieldProps, Formik } from "formik";
import React, { useMemo } from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { useSearchParams } from "react-router-dom";
import styled from "styled-components";
import * as yup from "yup";

Expand Down Expand Up @@ -195,15 +196,19 @@ export const SignupForm: React.FC = () => {
return yup.object().shape(shape);
}, [showName, showCompanyName]);

const [params] = useSearchParams();
const search = Object.fromEntries(params);

const initialValues = {
name: `${search.firstname ?? ""} ${search.lastname ?? ""}`.trim(),
companyName: search.company ?? "",
email: search.email ?? "",
password: "",
news: true,
};
return (
<Formik<FormValues>
initialValues={{
name: "",
companyName: "",
email: "",
password: "",
news: true,
}}
initialValues={initialValues}
validationSchema={validationSchema}
onSubmit={async (values, { setFieldError, setStatus }) =>
signUp(values).catch((err) => {
Expand Down

0 comments on commit 7f2c8be

Please sign in to comment.