-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(onboarding-ui): Remove standalone and introduce offline server r…
…egistration (#1184)
- Loading branch information
1 parent
3386202
commit 695d42a
Showing
24 changed files
with
437 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@rocket.chat/onboarding-ui": patch | ||
--- | ||
|
||
feat(onboarding-ui): Remove standalone and introduce offline server registration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 6 additions & 5 deletions
11
...eServerPage/StandaloneServerPage.spec.tsx → ...rOfflineForm/RegisterOfflineForm.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/onboarding-ui/src/forms/RegisterOfflineForm/RegisterOfflineForm.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 RegisterOfflineForm from './RegisterOfflineForm'; | ||
|
||
type Args = ComponentProps<typeof RegisterOfflineForm>; | ||
|
||
export default { | ||
title: 'forms/RegisterOfflineForm', | ||
component: RegisterOfflineForm, | ||
parameters: { | ||
layout: 'centered', | ||
actions: { argTypesRegex: '^on.*' }, | ||
}, | ||
args: { | ||
clientKey: | ||
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', | ||
}, | ||
} as Meta<Args>; | ||
|
||
export const _RegisterOfflineForm: Story<Args> = (args) => ( | ||
<RegisterOfflineForm {...args} /> | ||
); |
71 changes: 71 additions & 0 deletions
71
packages/onboarding-ui/src/forms/RegisterOfflineForm/RegisterOfflineForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { Form } from '@rocket.chat/layout'; | ||
import { useState, type ReactElement } from 'react'; | ||
import type { SubmitHandler } from 'react-hook-form'; | ||
import { useForm, FormProvider } from 'react-hook-form'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import CopyStep from './steps/CopyStep'; | ||
import PasteStep from './steps/PasteStep'; | ||
|
||
export type RegisterOfflinePayload = { | ||
token: string; | ||
agreement: boolean; | ||
}; | ||
|
||
type RegisterOfflineFormProps = { | ||
termsHref: string; | ||
policyHref: string; | ||
clientKey: string; | ||
onSubmit: SubmitHandler<RegisterOfflinePayload>; | ||
onBackButtonClick: () => void; | ||
}; | ||
|
||
export const Steps = { | ||
COPY: 'copy', | ||
PASTE: 'paste', | ||
}; | ||
|
||
const RegisterOfflineForm = ({ | ||
termsHref, | ||
policyHref, | ||
clientKey, | ||
onSubmit, | ||
onBackButtonClick, | ||
}: RegisterOfflineFormProps): ReactElement => { | ||
const { t } = useTranslation(); | ||
|
||
const [step, setStep] = useState(Steps.COPY); | ||
|
||
const form = useForm<RegisterOfflinePayload>({ | ||
mode: 'onChange', | ||
defaultValues: { | ||
token: '', | ||
agreement: false, | ||
}, | ||
}); | ||
|
||
const { handleSubmit } = form; | ||
|
||
return ( | ||
<FormProvider {...form}> | ||
<Form onSubmit={handleSubmit(onSubmit)}> | ||
<Form.Header> | ||
<Form.Title>{t('form.registerOfflineForm.title')}</Form.Title> | ||
</Form.Header> | ||
{step === Steps.COPY ? ( | ||
<CopyStep | ||
termsHref={termsHref} | ||
policyHref={policyHref} | ||
clientKey={clientKey} | ||
setStep={setStep} | ||
onBackButtonClick={onBackButtonClick} | ||
/> | ||
) : ( | ||
<PasteStep setStep={setStep} /> | ||
)} | ||
</Form> | ||
</FormProvider> | ||
); | ||
}; | ||
|
||
export default RegisterOfflineForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './RegisterOfflineForm'; |
Oops, something went wrong.