wisemapping-frontend/packages/login/src/components/Header.tsx

66 lines
1.9 KiB
TypeScript
Raw Normal View History

import React from 'react';
import { FormattedMessage } from 'react-intl'
2020-12-06 17:24:53 +01:00
import { Link } from 'react-router-dom'
2020-12-06 08:08:55 +01:00
const logo = require('../images/header-logo.png')
2020-12-06 06:28:00 +01:00
interface HeaderProps {
type: string;
}
class Header extends React.Component<HeaderProps, HeaderProps> {
constructor(props: HeaderProps) {
super(props);
2020-12-06 06:28:00 +01:00
this.state = props;
}
render() {
let signUpButton;
let signInButton;
let text;
const pageType = this.state.type;
if (pageType === 'only-signup') {
text = <span className="header-area-content-span"><span><FormattedMessage id="header.donthaveaccount" defaultMessage="Don't have an account ?" /></span></span>;
signUpButton = <SignUpButton className="header-area-right2" />;
} else if (pageType === 'only-signin') {
text = <span className="header-area-content-span"><span><FormattedMessage id="header.haveaccount" defaultMessage="Already have an account?" /></span></span>;
signUpButton = <SignInButton className="header-area-right2" />;
} else {
2020-12-06 06:28:00 +01:00
signUpButton = <SignUpButton className="header-area-right2" />
signInButton = <SignInButton className="header-area-right2" />;
}
return (
<nav>
<div className="header">
2020-12-06 17:24:53 +01:00
<span className="header-logo"><Link to="/"><img src={String(logo)} alt="logo" /></Link></span>
{text}
{signUpButton}
{signInButton}
</div>
</nav>
)
};
}
2020-12-06 06:28:00 +01:00
interface ButtonProps {
className: string;
}
const SignInButton = (props: ButtonProps) => {
return (
<span className={`button-style1 ${props.className}`}>
2020-12-06 06:28:00 +01:00
<a href="/c/login"><FormattedMessage id="login.signin" defaultMessage="Sign In" /></a>
</span>);
}
2020-12-06 06:28:00 +01:00
const SignUpButton = (props: ButtonProps) => {
return (
<span className={`button-style1 ${props.className}`}>
2020-12-06 17:24:53 +01:00
<Link to="/c/user/registration"><FormattedMessage id="login.signup" defaultMessage="Sign Up" /></Link>
2020-12-06 06:28:00 +01:00
</span>);
}
export default Header;