From d95573393206bc3931202d363bfb6c54974e0203 Mon Sep 17 00:00:00 2001 From: muhamedsalih-tw <104364298+muhamedsalih-tw@users.noreply.github.com> Date: Fri, 28 Oct 2022 07:37:55 +0530 Subject: Transform welcome component tree to TS (#715) --- src/components/auth/Welcome.tsx | 118 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 src/components/auth/Welcome.tsx (limited to 'src/components/auth/Welcome.tsx') diff --git a/src/components/auth/Welcome.tsx b/src/components/auth/Welcome.tsx new file mode 100644 index 000000000..1aa8da4d6 --- /dev/null +++ b/src/components/auth/Welcome.tsx @@ -0,0 +1,118 @@ +import { Component, ReactElement } from 'react'; +import { observer, inject } from 'mobx-react'; +import { defineMessages, injectIntl, WrappedComponentProps } from 'react-intl'; +import { noop } from 'lodash'; +import serverlessLogin from '../../helpers/serverless-helpers'; +import shuffleArray from '../../helpers/array-helpers'; +import { serverName } from '../../api/apiBase'; +import Link from '../ui/Link'; +import { H1 } from '../ui/headline'; +import { StoresProps } from '../../@types/ferdium-components.types'; +import RecipePreview from '../../models/RecipePreview'; + +const messages = defineMessages({ + signupButton: { + id: 'welcome.signupButton', + defaultMessage: 'Create a free account', + }, + loginButton: { + id: 'welcome.loginButton', + defaultMessage: 'Login to your account', + }, + changeServerMessage: { + id: 'login.changeServerMessage', + defaultMessage: + 'You are using {serverNameParse} Server, do you want to switch?', + }, + changeServer: { + id: 'login.changeServer', + defaultMessage: 'Change here!', + }, + serverless: { + id: 'services.serverless', + defaultMessage: 'Use Ferdium without an Account', + }, +}); + +interface IProps extends Partial, WrappedComponentProps { + loginRoute: string; + signupRoute: string; + changeServerRoute: string; + recipes: RecipePreview[]; +} + +@inject('actions') +@observer +class Welcome extends Component { + constructor(props: IProps) { + super(props); + } + + useLocalServer(): void { + serverlessLogin(this.props.actions); + } + + render(): ReactElement { + const { loginRoute, signupRoute, changeServerRoute, intl } = this.props; + let { recipes } = this.props; + recipes = shuffleArray(recipes); + recipes.length = 8 * 2; + + let serverNameParse = serverName(); + serverNameParse = + serverNameParse === 'Custom' ? 'a Custom' : serverNameParse; + + return ( +
+
+ +
+
+

Ferdium

+
+
+ + {intl.formatMessage(messages.signupButton)} + + + {intl.formatMessage(messages.loginButton)} + +
+ + {intl.formatMessage(messages.changeServerMessage, { + serverNameParse, + })} + + + {intl.formatMessage(messages.changeServer)} + +
+
+ +
+
+ {recipes.map(recipe => ( +
+ +
+ ))} +
+
+ ); + } +} + +export default injectIntl(Welcome); -- cgit v1.2.3-70-g09d2