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 page #515

Merged
merged 7 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion packages/onboarding-ui/.i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"tryGold": "Try our best Gold plan for 14 days for free",
"availability": "High availability",
"auditing": "Message audit panel / Audit logs",
"integrations": "1,000 integrations",
"engagement": "Engagement Dashboard",
"ldap": "LDAP enhanced sync",
"omnichannel": "Omnichannel premium",
"sla": "SLA: Premium",
Expand All @@ -49,6 +49,10 @@
"button": {
"text": "Request new link"
}
},
"requestTrial": {
"title": "Request a 30-\u2060day Trial",
"subtitle": "Try our enterprise solution for free"
}
},
"form": {
Expand Down
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.
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.
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
@@ -1,4 +1,5 @@
import type { Meta, Story } from '@storybook/react';
import { countries } from 'countries-list';
import type { ComponentProps } from 'react';

import RequestTrialForm from './RequestTrialForm';
Expand All @@ -15,6 +16,22 @@ export default {
args: {
validateEmail: (email) =>
email === '[email protected]' ? 'invalid email' : true,
organizationSizeOptions: [
['0', '1-10 people'],
['1', '11-50 people'],
['2', '51-100 people'],
['3', '101-250 people'],
['4', '251-500 people'],
['5', '501-1000 people'],
['6', '1001-4000 people'],
['7', '4000 or more people'],
],
countryOptions: [
...Object.entries(countries).map<readonly [string, string]>(
([code, { name }]) => [code, name]
),
['worldwide', 'Worldwide'],
],
},
} as Meta<Args>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
import { Button, Field, FieldGroup, EmailInput } from '@rocket.chat/fuselage';
import {
Button,
Field,
FieldGroup,
EmailInput,
Select,
SelectOptions,
} from '@rocket.chat/fuselage';
import type { ReactElement } from 'react';
import { useForm, SubmitHandler, Validate } from 'react-hook-form';
import { useForm, SubmitHandler, Validate, Controller } from 'react-hook-form';
import { useTranslation } from 'react-i18next';

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

type RequestTrialPayload = {
email: string;
organizationSize: string;
country: string;
};

type RequestTrialFormProps = {
organizationSizeOptions: SelectOptions;
countryOptions: SelectOptions;
onSubmit: SubmitHandler<RequestTrialPayload>;
validateEmail: Validate<string>;
};

const RequestTrialForm = ({
organizationSizeOptions,
countryOptions,
onSubmit,
validateEmail,
}: RequestTrialFormProps): ReactElement => {
Expand All @@ -23,6 +36,7 @@ const RequestTrialForm = ({
const {
handleSubmit,
register,
control,
formState: { isValidating, isSubmitting, isValid, errors },
} = useForm<RequestTrialPayload>({ mode: 'onChange' });

Expand All @@ -45,6 +59,49 @@ const RequestTrialForm = ({
</Field.Row>
{errors?.email && <Field.Error>{errors.email.message}</Field.Error>}
</Field>
<Field>
<Field.Label>
{t('form.organizationInfoForm.fields.organizationSize.label')}
</Field.Label>
<Field.Row>
<Controller
name='organizationSize'
control={control}
rules={{ required: true }}
render={({ field }) => (
<Select
{...field}
options={organizationSizeOptions}
placeholder={t(
'form.organizationInfoForm.fields.organizationSize.placeholder'
)}
error={errors?.email?.message || undefined}
/>
)}
/>
</Field.Row>
</Field>
<Field>
<Field.Label>
{t('form.organizationInfoForm.fields.country.label')}
</Field.Label>
<Field.Row>
<Controller
name='country'
control={control}
rules={{ required: true }}
render={({ field }) => (
<Select
{...field}
options={countryOptions}
placeholder={t(
'form.organizationInfoForm.fields.country.placeholder'
)}
/>
)}
/>
</Field.Row>
</Field>
<Field>
<Field.Label>
{t('form.requestTrialForm.hasWorkspace.label')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { renderToStaticMarkup } from 'react-dom/server';
import { useTranslation } from 'react-i18next';

import List from '../../common/List';
import DescriptionIcon from './DescriptionIcon';
import PlanFeatureIcon from '../../common/PlanFeatureIcon';

const Description = (): ReactElement => {
const { t } = useTranslation();

const icon = useMemo(
() => encodeURIComponent(renderToStaticMarkup(<DescriptionIcon />)),
() => encodeURIComponent(renderToStaticMarkup(<PlanFeatureIcon />)),
[]
);

Expand All @@ -20,7 +20,7 @@ const Description = (): ReactElement => {
<List color='alternative' spacing='x16' icon={icon}>
<List.Item>{t('page.cloudDescription.availability')}</List.Item>
<List.Item>{t('page.cloudDescription.auditing')}</List.Item>
<List.Item>{t('page.cloudDescription.integrations')}</List.Item>
<List.Item>{t('page.cloudDescription.engagement')}</List.Item>
<List.Item>{t('page.cloudDescription.ldap')}</List.Item>
<List.Item>{t('page.cloudDescription.omnichannel')}</List.Item>
<List.Item>{t('page.cloudDescription.sla')}</List.Item>
Expand Down
28 changes: 28 additions & 0 deletions packages/onboarding-ui/src/pages/RequestTrialPage/Description.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ReactElement, useMemo } from 'react';
import { renderToStaticMarkup } from 'react-dom/server';
import { useTranslation } from 'react-i18next';

import List from '../../common/List';
import PlanFeatureIcon from '../../common/PlanFeatureIcon';

const Description = (): ReactElement => {
const { t } = useTranslation();

const icon = useMemo(
() => encodeURIComponent(renderToStaticMarkup(<PlanFeatureIcon />)),
[]
);

return (
<List color='alternative' spacing='x16' icon={icon}>
<List.Item>{t('page.cloudDescription.availability')}</List.Item>
<List.Item>{t('page.cloudDescription.auditing')}</List.Item>
<List.Item>{t('page.cloudDescription.engagement')}</List.Item>
<List.Item>{t('page.cloudDescription.ldap')}</List.Item>
<List.Item>{t('page.cloudDescription.omnichannel')}</List.Item>
<List.Item>{t('page.cloudDescription.push')}</List.Item>
</List>
);
};

export default Description;
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type { Story, Meta } from '@storybook/react';
import { countries } from 'countries-list';
import type { ComponentProps } from 'react';

import RequestTrialPage from './RequestTrialPage';

type Args = ComponentProps<typeof RequestTrialPage>;

export default {
title: 'pages/RequestTrialPage',
component: RequestTrialPage,
parameters: {
actions: { argTypesRegex: '^on.*' },
layout: 'fullscreen',
},
args: {
validateEmail: (email) =>
email === '[email protected]' ? 'invalid email' : true,
organizationSizeOptions: [
['0', '1-10 people'],
['1', '11-50 people'],
['2', '51-100 people'],
['3', '101-250 people'],
['4', '251-500 people'],
['5', '501-1000 people'],
['6', '1001-4000 people'],
['7', '4000 or more people'],
],
countryOptions: [
...Object.entries(countries).map<readonly [string, string]>(
([code, { name }]) => [code, name]
),
['worldwide', 'Worldwide'],
],
},
} as Meta<Args>;

export const _RequestTrialPage: Story<Args> = (args) => (
<RequestTrialPage {...args} />
);
_RequestTrialPage.storyName = 'RequestTrialPage';
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Box } from '@rocket.chat/fuselage';
import type { ComponentProps, ReactElement } from 'react';
import { useTranslation, Trans } from 'react-i18next';

import BackgroundLayer from '../../common/BackgroundLayer';
import FormPageLayout from '../../common/FormPageLayout';
import RequestTrialForm from '../../forms/RequestTrialForm';
import Description from './Description';

type RequestTrialPageProps = ComponentProps<typeof RequestTrialForm>;

const RequestTrialPage = (props: RequestTrialPageProps): ReactElement => {
const { t } = useTranslation();

return (
<BackgroundLayer>
<FormPageLayout
description={<Description />}
title={t('page.requestTrial.title')}
subtitle={t('page.requestTrial.subtitle')}
>
<RequestTrialForm {...props} />
<Box mbs='x28' color='alternative' display='inline' textAlign='center'>
<Trans i18nKey='page.alreadyHaveAccount'>
Already have an account?
<Box
is='a'
color='primary-400'
textDecorationLine='none'
href='https://cloud.rocket.chat/login'
target='_blank'
rel='noopener noreferrer'
>
Manage your workspaces.
</Box>
</Trans>
</Box>
</FormPageLayout>
</BackgroundLayer>
);
};

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