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): CloudOrganizationInfo Page #498

Merged
merged 9 commits into from
Aug 18, 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
3 changes: 2 additions & 1 deletion packages/onboarding-ui/.i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"steps": "Step {{currentStep}} of {{stepCount}}",
"action": {
"back": "Back",
"next": "Next"
"next": "Next",
"skip": "Skip this step"
},
"requiredField": "This field is required",
"termsAndConditions": "I agree with <1>Terms and Conditions</1> and <3>Privacy Policy</3>"
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.
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
Expand Up @@ -3,6 +3,7 @@ import styled from '@rocket.chat/styled';
import { sans } from '../helpers/tokenFontFamilies';

export const Wrapper = styled('div')`
width: 100%;
box-sizing: border-box;
padding: 56px 16px 28px;
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import {
TextInput,
Select,
SelectOptions,
Box,
} from '@rocket.chat/fuselage';
import type { ReactElement } from 'react';
import { useBreakpoints } from '@rocket.chat/fuselage-hooks';
import type { ReactElement, ReactNode } from 'react';
import { useForm, SubmitHandler, Controller } from 'react-hook-form';
import { useTranslation } from 'react-i18next';

Expand All @@ -28,9 +30,11 @@ type OrganizationInfoFormProps = {
organizationIndustryOptions: SelectOptions;
organizationSizeOptions: SelectOptions;
countryOptions: SelectOptions;
confirmText?: ReactNode;
initialValues?: OrganizationInfoPayload;
onSubmit: SubmitHandler<OrganizationInfoPayload>;
onBackButtonClick: () => void;
onClickSkip?: () => void;
};

const OrganizationInfoForm = ({
Expand All @@ -40,11 +44,15 @@ const OrganizationInfoForm = ({
organizationIndustryOptions,
organizationSizeOptions,
countryOptions,
confirmText,
initialValues,
onSubmit,
onBackButtonClick,
onClickSkip,
}: OrganizationInfoFormProps): ReactElement => {
const { t } = useTranslation();
const breakpoints = useBreakpoints();
const isMobile = !breakpoints.includes('md');

const {
register,
Expand Down Expand Up @@ -161,13 +169,24 @@ const OrganizationInfoForm = ({
</FieldGroup>
</Form.Container>
<Form.Footer>
<ButtonGroup flexGrow={1}>
<ButtonGroup vertical={isMobile} flexGrow={1}>
<Button onClick={onBackButtonClick}>
{t('component.form.action.back')}
</Button>

<Button type='submit' primary disabled={isValidating || isSubmitting}>
{t('component.form.action.next')}
{confirmText ?? t('component.form.action.next')}
</Button>

{onClickSkip && (
<Box withTruncatedText flexGrow={1}>
<ButtonGroup flexGrow={1} align='end'>
<Button nude info onClick={onClickSkip}>
{t('component.form.action.skip')}
</Button>
</ButtonGroup>
</Box>
)}
</ButtonGroup>
</Form.Footer>
</Form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,16 @@ export default {
export const _OrganizationInfoPage: Story<Args> = (args) => (
<OrganizationInfoPage {...args} />
);

_OrganizationInfoPage.storyName = 'OrganizationInfoPage';

export const _CloudOrganizationInfoPage: Story<Args> = (args) => (
<OrganizationInfoPage {...args} />
);

_CloudOrganizationInfoPage.storyName = 'CloudOrganizationInfoPage';
_CloudOrganizationInfoPage.args = {
title: 'Your Workspace is Ready!',
description: 'Organization info will help us personalize your workspace',
confirmText: 'Go to workspace',
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ReactElement } from 'react';
import type { ReactElement, ReactNode } from 'react';
import type { SubmitHandler } from 'react-hook-form';

import BackgroundLayer from '../../common/BackgroundLayer';
Expand All @@ -7,22 +7,26 @@ import OrganizationInfoForm from '../../forms/OrganizationInfoForm';
import type { OrganizationInfoPayload } from '../../forms/OrganizationInfoForm/OrganizationInfoForm';

type OrganizationInfoPageProps = {
title?: string;
description?: string;
currentStep: number;
stepCount: number;
organizationTypeOptions: (readonly [string, string])[];
organizationIndustryOptions: (readonly [string, string])[];
organizationSizeOptions: (readonly [string, string])[];
countryOptions: (readonly [string, string])[];
initialValues?: OrganizationInfoPayload;
confirmText?: ReactNode;
onSubmit: SubmitHandler<OrganizationInfoPayload>;
onBackButtonClick: () => void;
onClickSkip?: () => void;
};

const OrganizationInfoPage = (
props: OrganizationInfoPageProps
): ReactElement => (
<BackgroundLayer>
<FormPageLayout>
<FormPageLayout title={props.title} description={props.description}>
<OrganizationInfoForm {...props} />
</FormPageLayout>
</BackgroundLayer>
Expand Down