/* eslint react/no-unused-prop-types: 0 */
// @flow
import React, { Component } from 'react';
import withRedux from 'next-redux-wrapper';
import withReduxSaga from 'next-redux-saga';
import { isNil } from 'ramda';
import initStore from 'store/initStore';
import notifyBugsnagWrapper from 'helpers/notifyBugsnagWrapper';
// Api
import { getCompanyBySlug } from 'store/api/company';
import { fetchCompanySuccess } from 'store/actions/company';
import type { CompanyType } from 'types/company';
// Components
import Layout from 'components/Layout';
// Containers
type Props = {
title: string,
description: string,
company: CompanyType,
user: {
isAdmin: boolean
}
};
// eslint-disable-next-line no-unused-vars
const { parse } = require('url');
class RevenuePage extends Component<Props> {
static async getInitialProps({ store, query, req }) {
const { slug, version } = query;
await Layout.getInitialProps({ store, req });
// If user use back browser btn req can be undefined
if (!req) return {};
const isPhone = req.device.type == 'phone';
const userAgent = req ? req.headers['user-agent'] : navigator.userAgent;
const [ company ] = await Promise.all([
getCompanyBySlug(slug, userAgent)
]);
if (!company) {
throw new Error('Company is empty');
} else {
await Promise.all([
store.dispatch(fetchCompanySuccess(company)),
company.companyType === 'investor'
? store.dispatch(fetchBucketsSuccess(company.portfolio))
: () => null
]);
}
return { company, version, isPhone, slug, query };
}
render() {
// eslint-disable-next-line react/prop-types
const { company, user, version } = this.props;
const title = 'Explore Company Data with Craft';
const metaData = {
title,
description: 'Visualize company data with Craft.',
ogTitle: title
};
return (
<Layout metaData={metaData}>
<div className="container"><h1>Revenue Test Page</h1></div>
</Layout>
);
}
}
const mapStateToProps = state => ({
company: state.company
});
export default withRedux(initStore, mapStateToProps)(
withReduxSaga(RevenuePage)
);
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.