Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add email autofill from search params #16936

Merged
merged 3 commits into from
Sep 22, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,27 @@ export const SignupForm: React.FC = () => {
return yup.object().shape(shape);
}, [showName, showCompanyName]);

return (
<Formik<FormValues>
initialValues={{
const [params] = useSearchParams();
const search = Object.fromEntries(params);

const initialValues = params.get("email")
? {
name: search.firstname ? `${search.firstname} ${search.lastname}` : "",
companyName: search.company,
email: search.email,
dizel852 marked this conversation as resolved.
Show resolved Hide resolved
password: "",
news: true,
}
: {
dizel852 marked this conversation as resolved.
Show resolved Hide resolved
name: "",
companyName: "",
email: "",
password: "",
news: true,
}}
};
return (
<Formik<FormValues>
initialValues={initialValues}
validationSchema={validationSchema}
onSubmit={async (values, { setFieldError, setStatus }) =>
signUp(values).catch((err) => {
Expand Down