2023-06-01 13:36:11 +00:00
|
|
|
import React, { useEffect } from "react";
|
2021-09-12 16:36:43 +00:00
|
|
|
import styled from "styled-components";
|
2022-04-13 10:07:11 +00:00
|
|
|
import { Field } from "redux-form";
|
2023-12-25 12:24:46 +00:00
|
|
|
import { FormBodyWrapper } from "./common";
|
2021-10-06 06:11:25 +00:00
|
|
|
import {
|
|
|
|
|
createMessage,
|
|
|
|
|
WELCOME_FORM_EMAIL_ID,
|
2023-05-25 18:21:56 +00:00
|
|
|
WELCOME_FORM_FIRST_NAME,
|
|
|
|
|
WELCOME_FORM_LAST_NAME,
|
2021-10-06 06:11:25 +00:00
|
|
|
WELCOME_FORM_CREATE_PASSWORD,
|
|
|
|
|
WELCOME_FORM_VERIFY_PASSWORD,
|
2023-05-25 18:21:56 +00:00
|
|
|
CONTINUE,
|
|
|
|
|
ONBOARDING_STATUS_GET_STARTED,
|
2023-12-25 12:24:46 +00:00
|
|
|
PRODUCT_UPDATES_CONFIRMATION_LABEL,
|
|
|
|
|
WELCOME_FORM_NON_SUPER_USER_USE_CASE,
|
|
|
|
|
WELCOME_FORM_NON_SUPER_USER_PROFICIENCY_LEVEL,
|
2022-02-11 18:08:46 +00:00
|
|
|
} from "@appsmith/constants/messages";
|
2022-10-05 11:06:49 +00:00
|
|
|
import FormTextField from "components/utils/ReduxFormTextField";
|
2023-10-16 12:07:06 +00:00
|
|
|
import type { FormErrors, InjectedFormProps } from "redux-form";
|
2023-05-19 18:37:06 +00:00
|
|
|
import { FormGroup } from "design-system-old";
|
2023-05-25 18:21:56 +00:00
|
|
|
import { Button, Checkbox } from "design-system";
|
2023-12-25 12:24:46 +00:00
|
|
|
import { proficiencyOptions, useCaseOptions } from "./constants";
|
2023-04-20 09:27:41 +00:00
|
|
|
import { isAirgapped } from "@appsmith/utils/airgapHelpers";
|
2023-05-25 18:21:56 +00:00
|
|
|
import { setFirstTimeUserOnboardingTelemetryCalloutVisibility } from "utils/storage";
|
2023-12-25 12:24:46 +00:00
|
|
|
import RadioButtonGroup from "components/editorComponents/RadioButtonGroup";
|
|
|
|
|
import { Space } from "./NonSuperUserProfilingQuestions";
|
2023-10-16 12:07:06 +00:00
|
|
|
|
|
|
|
|
export interface DetailsFormValues {
|
|
|
|
|
firstName?: string;
|
|
|
|
|
lastName?: string;
|
|
|
|
|
email?: string;
|
|
|
|
|
password?: string;
|
|
|
|
|
verifyPassword?: string;
|
2023-12-25 12:24:46 +00:00
|
|
|
proficiency?: string;
|
2023-10-16 12:07:06 +00:00
|
|
|
useCase?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type SetupFormProps = DetailsFormValues & {
|
|
|
|
|
formSyncErrors?: FormErrors<string, string>;
|
|
|
|
|
} & InjectedFormProps<
|
|
|
|
|
DetailsFormValues,
|
|
|
|
|
{
|
|
|
|
|
formSyncErrors?: FormErrors<string, string>;
|
|
|
|
|
}
|
|
|
|
|
>;
|
2021-09-12 16:36:43 +00:00
|
|
|
|
|
|
|
|
const DetailsFormWrapper = styled.div`
|
|
|
|
|
width: 100%;
|
|
|
|
|
position: relative;
|
|
|
|
|
`;
|
|
|
|
|
|
2023-05-25 18:21:56 +00:00
|
|
|
const StyledFormBodyWrapper = styled(FormBodyWrapper)``;
|
|
|
|
|
|
|
|
|
|
const StyledTabIndicatorWrapper = styled.div`
|
|
|
|
|
display: flex;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const StyledTabIndicator = styled.div<{ isFirstPage?: boolean }>`
|
|
|
|
|
width: 48px;
|
|
|
|
|
height: 3px;
|
|
|
|
|
margin: 0 6px 0 0;
|
|
|
|
|
background-color: ${(props) =>
|
|
|
|
|
props.isFirstPage
|
|
|
|
|
? `var(--ads-v2-color-bg-emphasis);`
|
|
|
|
|
: `var(--ads-v2-color-bg-brand);`};
|
2021-09-12 16:36:43 +00:00
|
|
|
`;
|
|
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
const StyledFormGroup = styled(FormGroup)`
|
|
|
|
|
&& > .bp3-label {
|
|
|
|
|
color: var(--ads-v2-color-fg);
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
2023-12-25 12:24:46 +00:00
|
|
|
const ButtonWrapper = styled.div`
|
|
|
|
|
display: flex;
|
|
|
|
|
margin-top: ${(props) => props.theme.spaces[11]}px;
|
|
|
|
|
gap: ${(props) => props.theme.spaces[4]}px;
|
|
|
|
|
`;
|
|
|
|
|
|
2021-09-12 16:36:43 +00:00
|
|
|
export default function DetailsForm(
|
2023-06-01 13:36:11 +00:00
|
|
|
props: SetupFormProps & { isFirstPage: boolean } & {
|
|
|
|
|
toggleFormPage: () => void;
|
|
|
|
|
},
|
2021-09-12 16:36:43 +00:00
|
|
|
) {
|
|
|
|
|
const ref = React.createRef<HTMLDivElement>();
|
|
|
|
|
|
2023-05-25 18:21:56 +00:00
|
|
|
useEffect(() => {
|
|
|
|
|
const setTelemetryVisibleFalse = async () => {
|
|
|
|
|
await setFirstTimeUserOnboardingTelemetryCalloutVisibility(false);
|
|
|
|
|
};
|
|
|
|
|
setTelemetryVisibleFalse();
|
|
|
|
|
}, []);
|
2023-04-20 09:27:41 +00:00
|
|
|
|
2021-09-12 16:36:43 +00:00
|
|
|
return (
|
|
|
|
|
<DetailsFormWrapper ref={ref}>
|
2023-05-25 18:21:56 +00:00
|
|
|
<StyledTabIndicatorWrapper>
|
|
|
|
|
<StyledTabIndicator />
|
2023-06-01 13:36:11 +00:00
|
|
|
<StyledTabIndicator isFirstPage={props.isFirstPage} />
|
2023-05-25 18:21:56 +00:00
|
|
|
</StyledTabIndicatorWrapper>
|
2021-09-12 16:36:43 +00:00
|
|
|
<StyledFormBodyWrapper>
|
2023-06-01 13:36:11 +00:00
|
|
|
<div
|
|
|
|
|
className={props.isFirstPage ? "block" : "hidden"}
|
|
|
|
|
data-testid="formPage"
|
|
|
|
|
>
|
2023-05-25 18:21:56 +00:00
|
|
|
<div className="flex flex-row justify-between w-100">
|
|
|
|
|
<StyledFormGroup className="!w-52 t--welcome-form-first-name">
|
|
|
|
|
<FormTextField
|
|
|
|
|
autoFocus
|
2023-06-01 13:36:11 +00:00
|
|
|
data-testid="firstName"
|
2023-05-25 18:21:56 +00:00
|
|
|
label={createMessage(WELCOME_FORM_FIRST_NAME)}
|
|
|
|
|
name="firstName"
|
|
|
|
|
placeholder="John"
|
|
|
|
|
type="text"
|
|
|
|
|
/>
|
|
|
|
|
</StyledFormGroup>
|
|
|
|
|
|
|
|
|
|
<StyledFormGroup className="!w-52 t--welcome-form-last-name">
|
|
|
|
|
<FormTextField
|
2023-06-01 13:36:11 +00:00
|
|
|
data-testid="lastName"
|
2023-05-25 18:21:56 +00:00
|
|
|
label={createMessage(WELCOME_FORM_LAST_NAME)}
|
|
|
|
|
name="lastName"
|
|
|
|
|
placeholder="Doe"
|
|
|
|
|
type="text"
|
|
|
|
|
/>
|
|
|
|
|
</StyledFormGroup>
|
|
|
|
|
</div>
|
|
|
|
|
<StyledFormGroup className="t--welcome-form-email">
|
|
|
|
|
<FormTextField
|
2023-06-01 13:36:11 +00:00
|
|
|
data-testid="email"
|
2023-05-25 18:21:56 +00:00
|
|
|
label={createMessage(WELCOME_FORM_EMAIL_ID)}
|
|
|
|
|
name="email"
|
|
|
|
|
placeholder="How can we reach you?"
|
|
|
|
|
type="email"
|
|
|
|
|
/>
|
2021-09-12 16:36:43 +00:00
|
|
|
</StyledFormGroup>
|
2023-05-25 18:21:56 +00:00
|
|
|
<StyledFormGroup className="t--welcome-form-password">
|
|
|
|
|
<FormTextField
|
2023-06-01 13:36:11 +00:00
|
|
|
data-testid="password"
|
2023-05-25 18:21:56 +00:00
|
|
|
label={createMessage(WELCOME_FORM_CREATE_PASSWORD)}
|
|
|
|
|
name="password"
|
|
|
|
|
placeholder="Make it strong!"
|
|
|
|
|
type="password"
|
|
|
|
|
/>
|
2022-02-19 06:26:10 +00:00
|
|
|
</StyledFormGroup>
|
2023-05-25 18:21:56 +00:00
|
|
|
<StyledFormGroup className="t--welcome-form-verify-password">
|
|
|
|
|
<FormTextField
|
|
|
|
|
data-testid="verifyPassword"
|
|
|
|
|
label={createMessage(WELCOME_FORM_VERIFY_PASSWORD)}
|
|
|
|
|
name="verifyPassword"
|
|
|
|
|
placeholder="Type correctly"
|
|
|
|
|
type="password"
|
|
|
|
|
/>
|
|
|
|
|
</StyledFormGroup>
|
|
|
|
|
</div>
|
|
|
|
|
|
2023-06-01 13:36:11 +00:00
|
|
|
{!props.isFirstPage && (
|
2023-05-25 18:21:56 +00:00
|
|
|
<div>
|
2023-12-25 12:24:46 +00:00
|
|
|
<Field
|
|
|
|
|
component={RadioButtonGroup}
|
|
|
|
|
label={createMessage(
|
|
|
|
|
WELCOME_FORM_NON_SUPER_USER_PROFICIENCY_LEVEL,
|
|
|
|
|
)}
|
|
|
|
|
name="proficiency"
|
|
|
|
|
options={proficiencyOptions}
|
|
|
|
|
showSubtitle
|
|
|
|
|
testid="t--user-proficiency"
|
|
|
|
|
/>
|
|
|
|
|
<Space />
|
|
|
|
|
<Field
|
|
|
|
|
component={RadioButtonGroup}
|
|
|
|
|
label={createMessage(WELCOME_FORM_NON_SUPER_USER_USE_CASE)}
|
|
|
|
|
name="useCase"
|
|
|
|
|
options={useCaseOptions}
|
|
|
|
|
testid="t--user-use-case"
|
|
|
|
|
/>
|
|
|
|
|
<Space style={{ marginBottom: "var(--ads-spaces-3)" }} />
|
2023-05-25 18:21:56 +00:00
|
|
|
{!isAirgapped() && (
|
|
|
|
|
<Checkbox defaultSelected name="signupForNewsletter" value="true">
|
2023-12-25 12:24:46 +00:00
|
|
|
{createMessage(PRODUCT_UPDATES_CONFIRMATION_LABEL)}
|
2023-05-25 18:21:56 +00:00
|
|
|
</Checkbox>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2022-02-19 06:26:10 +00:00
|
|
|
)}
|
2023-06-01 13:36:11 +00:00
|
|
|
{props.isFirstPage && (
|
2023-05-31 09:13:25 +00:00
|
|
|
<ButtonWrapper>
|
|
|
|
|
<Button
|
|
|
|
|
className="t--welcome-form-continue-button w-100"
|
|
|
|
|
isDisabled={props.invalid}
|
|
|
|
|
kind="primary"
|
|
|
|
|
onClick={() => {
|
2023-06-01 13:36:11 +00:00
|
|
|
props.toggleFormPage();
|
2023-05-31 09:13:25 +00:00
|
|
|
}}
|
|
|
|
|
size="md"
|
|
|
|
|
type="button"
|
|
|
|
|
>
|
|
|
|
|
{createMessage(CONTINUE)}
|
|
|
|
|
</Button>
|
|
|
|
|
</ButtonWrapper>
|
|
|
|
|
)}
|
2023-06-01 13:36:11 +00:00
|
|
|
{!props.isFirstPage && (
|
2023-05-31 09:13:25 +00:00
|
|
|
<ButtonWrapper>
|
|
|
|
|
<Button
|
|
|
|
|
className="t--welcome-form-submit-button w-100"
|
|
|
|
|
isDisabled={props.invalid}
|
|
|
|
|
kind="primary"
|
|
|
|
|
size="md"
|
|
|
|
|
type="submit"
|
|
|
|
|
>
|
|
|
|
|
{createMessage(ONBOARDING_STATUS_GET_STARTED)}
|
|
|
|
|
</Button>
|
|
|
|
|
</ButtonWrapper>
|
|
|
|
|
)}
|
2021-09-12 16:36:43 +00:00
|
|
|
</StyledFormBodyWrapper>
|
|
|
|
|
</DetailsFormWrapper>
|
|
|
|
|
);
|
|
|
|
|
}
|