Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoevanp committed Sep 28, 2023
1 parent 699f10d commit 013b675
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 34 deletions.
43 changes: 14 additions & 29 deletions apps/meteor/client/views/setupWizard/steps/RegisterServerStep.tsx
Original file line number Diff line number Diff line change
@@ -1,57 +1,42 @@
import { RegisterServerPage, StandaloneServerPage } from '@rocket.chat/onboarding-ui';
import { useRoute } from '@rocket.chat/ui-contexts';
import { RegisterServerPage, RegisterOfflinePage } from '@rocket.chat/onboarding-ui';
import type { ReactElement, ComponentProps } from 'react';
import React, { useState } from 'react';

import { useSetupWizardContext } from '../contexts/SetupWizardContext';

const SERVER_OPTIONS = {
REGISTERED: 'REGISTERED',
STANDALONE: 'STANDALONE',
OFFLINE: 'OFFLINE',
};

const RegisterServerStep = (): ReactElement => {
const { goToPreviousStep, currentStep, setSetupWizardData, registerServer, maxSteps, offline, completeSetupWizard } =
const { goToPreviousStep, currentStep, goToNextStep, goToStep, setSetupWizardData, registerServer, maxSteps, offline } =
useSetupWizardContext();
const [serverOption, setServerOption] = useState(SERVER_OPTIONS.REGISTERED);

const router = useRoute('cloud');

const handleRegisterOffline: ComponentProps<typeof RegisterServerPage>['onSubmit'] = async () => {
await completeSetupWizard();
router.push({}, { register: 'true' });
};

const handleRegister: ComponentProps<typeof RegisterServerPage>['onSubmit'] = async (data) => {
if (data.registerType !== 'standalone') {
setSetupWizardData((prevState) => ({ ...prevState, serverData: data }));
await registerServer(data);
}
const handleRegister: ComponentProps<typeof RegisterServerPage>['onSubmit'] = async (data: { email: string; resend?: boolean }) => {
goToNextStep();
setSetupWizardData((prevState) => ({ ...prevState, serverData: data }));
await registerServer(data);
};

const handleConfirmStandalone: ComponentProps<typeof StandaloneServerPage>['onSubmit'] = async ({ registerType }) => {
if (registerType !== 'registered') {
return completeSetupWizard();
}
const handleConfirmOffline: ComponentProps<typeof RegisterOfflinePage>['onSubmit'] = async (/* data: unknown*/) => {
// TODO: CALL REGISTER WITH TOKEN
return goToStep(4);
};

if (serverOption === SERVER_OPTIONS.STANDALONE) {
if (serverOption === SERVER_OPTIONS.OFFLINE) {
return (
<StandaloneServerPage
currentStep={currentStep}
onBackButtonClick={(): void => setServerOption(SERVER_OPTIONS.REGISTERED)}
onSubmit={handleConfirmStandalone}
stepCount={maxSteps}
/>
<RegisterOfflinePage onBackButtonClick={(): void => setServerOption(SERVER_OPTIONS.REGISTERED)} onSubmit={handleConfirmOffline} />
);
}

return (
<RegisterServerPage
onClickRegisterLater={(): void => setServerOption(SERVER_OPTIONS.STANDALONE)}
onClickRegisterOffline={(): void => setServerOption(SERVER_OPTIONS.OFFLINE)}
onBackButtonClick={goToPreviousStep}
stepCount={maxSteps}
onSubmit={offline ? handleRegisterOffline : handleRegister}
onSubmit={handleRegister}
currentStep={currentStep}
offline={offline}
/>
Expand Down
10 changes: 5 additions & 5 deletions apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -5855,7 +5855,8 @@
"onboarding.component.form.action.next": "Next",
"onboarding.component.form.action.skip": "Skip this step",
"onboarding.component.form.action.register": "Register",
"onboarding.component.form.action.registerNow": "Register now",
"onboarding.component.form.action.registerWorkspace": "Register workspace",
"onboarding.component.form.action.registerOffline": "Register offline",
"onboarding.component.form.action.confirm": "Confirm",
"onboarding.component.form.termsAndConditions": "I agree with <1>Terms and Conditions</1> and <3>Privacy Policy</3>",
"onboarding.component.emailCodeFallback": "Didn’t receive email? <1>Resend</1> or <3>Change email</3>",
Expand Down Expand Up @@ -5909,6 +5910,9 @@
"onboarding.form.organizationInfoForm.fields.organizationSize.placeholder": "Select",
"onboarding.form.organizationInfoForm.fields.country.label": "Country",
"onboarding.form.organizationInfoForm.fields.country.placeholder": "Select",
"onboarding.form.registerOfflineForm.title": "Register Offline",
"onboarding.form.registerOfflineForm.description": "If for any reason your workspace can’t be connected to the internet, follow these steps:<1></1>1. Go to: <2>cloud.rocket.chat > Workspaces</2> and click “<3>Register self-managed</3>”<4></4>2. Copy the token and paste it below",
"onboarding.form.registerOfflineForm.fields.registrationToken.inputLabel": "Registration token",
"onboarding.form.registeredServerForm.title": "Register your workspace",
"onboarding.form.registeredServerForm.included.push": "Mobile push notifications",
"onboarding.form.registeredServerForm.included.externalProviders": "Integration with external providers (WhatsApp, Facebook, Telegram, Twitter)",
Expand All @@ -5919,10 +5923,6 @@
"onboarding.form.registeredServerForm.registerLater": "Register later",
"onboarding.form.registeredServerForm.notConnectedToInternet": "The server is not connected to the internet, so you’ll have to do an offline registration for this workspace.",
"onboarding.form.registeredServerForm.registrationEngagement": "Registration allows automatic license updates, notifications of critical vulnerabilities and access to Rocket.Chat Cloud services. No sensitive workspace data is shared; statistics sent to Rocket.Chat is made visible to you within the administration area.",
"onboarding.form.standaloneServerForm.title": "Standalone Server Confirmation",
"onboarding.form.standaloneServerForm.servicesUnavailable": "Some of the services will be unavailable or will require manual setup",
"onboarding.form.standaloneServerForm.publishOwnApp": "In order to send push notitications you need to compile and publish your own app to Google Play and App Store",
"onboarding.form.standaloneServerForm.manuallyIntegrate": "Need to manually integrate with external services",
"Something_Went_Wrong": "Something went wrong",
"Toolbox_room_actions": "Primary Room actions",
"Theme_light": "Light",
Expand Down

0 comments on commit 013b675

Please sign in to comment.