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

feat(onboarding-ui): Request trial form #505

Merged
merged 9 commits into from
Aug 3, 2021
11 changes: 11 additions & 0 deletions packages/onboarding-ui/.i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@
"mobile": "and recompile mobile apps with your certificates"
}
}
},
"requestTrialForm": {
"request": "Request Trial",
"emailAddr": {
tassoevan marked this conversation as resolved.
Show resolved Hide resolved
"label": "Email address",
"placeholder": "Enter email address"
},
"hasWorkspace": {
"label": "Already registered a workspace?",
"description": "Use the same email address to continue"
}
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { Meta, Story } from '@storybook/react';
import type { ComponentProps } from 'react';

import RequestTrialForm from './RequestTrialForm';

type Args = ComponentProps<typeof RequestTrialForm>;

export default {
title: 'forms/RequestTrialForm',
component: RequestTrialForm,
parameters: {
layout: 'centered',
actions: { argTypesRegex: '^on.*' },
},
args: {
onSubmit: (data) => console.log(data),
tassoevan marked this conversation as resolved.
Show resolved Hide resolved
},
} as Meta<Args>;

export const _RequestTrialForm: Story<Args> = (args) => (
<RequestTrialForm {...args} />
);
_RequestTrialForm.storyName = 'RequestTrialForm';
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { Button, Field, FieldGroup, TextInput } from '@rocket.chat/fuselage';
import type { ReactElement } from 'react';
import { useForm, SubmitHandler } from 'react-hook-form';
import { useTranslation } from 'react-i18next';

import Form from '../../common/Form';

type RequestTrialPayload = {
email: string;
};

type RequestTrialFormProps = {
onSubmit: SubmitHandler<RequestTrialPayload>;
};

const RequestTrialForm = ({
onSubmit,
}: RequestTrialFormProps): ReactElement => {
const { t } = useTranslation();

const {
handleSubmit,
register,
formState: { isValidating, isSubmitting, isValid },
watch,
} = useForm<RequestTrialPayload>({ mode: 'onChange' });

watch('email');
tassoevan marked this conversation as resolved.
Show resolved Hide resolved

return (
<Form onSubmit={handleSubmit(onSubmit)}>
<FieldGroup>
<Field>
<Field.Label>
{t('form.requestTrialForm.emailAddr.label')}
tassoevan marked this conversation as resolved.
Show resolved Hide resolved
</Field.Label>
<Field.Row>
<TextInput
tassoevan marked this conversation as resolved.
Show resolved Hide resolved
{...register('email', { required: true })}
tassoevan marked this conversation as resolved.
Show resolved Hide resolved
placeholder={t('form.requestTrialForm.emailAddr.placeholder')}
tassoevan marked this conversation as resolved.
Show resolved Hide resolved
/>
</Field.Row>
</Field>
<Field>
<Field.Label>
{t('form.requestTrialForm.hasWorkspace.label')}
</Field.Label>
<Field.Description>
{t('form.requestTrialForm.hasWorkspace.description')}
</Field.Description>
</Field>
</FieldGroup>
<Form.Footer>
<Button
type='submit'
primary
disabled={isValidating || isSubmitting || !isValid}
>
{t('form.requestTrialForm.request')}
</Button>
</Form.Footer>
</Form>
);
};

export default RequestTrialForm;
1 change: 1 addition & 0 deletions packages/onboarding-ui/src/forms/RequestTrialForm/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './RequestTrialForm';