From 9d583bcc1245c1b62d56f325b30a8d7f0fda1e90 Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Tue, 11 Apr 2017 16:45:46 +0300 Subject: [PATCH] InboxPage routing and tabs with translations --- src/app.test.js | 5 +- src/containers/InboxPage/InboxPage.css | 16 +++++++ src/containers/InboxPage/InboxPage.js | 44 +++++++++++------ src/containers/InboxPage/InboxPage.test.js | 9 +++- .../__snapshots__/InboxPage.test.js.snap | 48 ++++++++----------- src/routesConfiguration.js | 19 +++++--- src/translations/en.json | 5 ++ 7 files changed, 94 insertions(+), 52 deletions(-) create mode 100644 src/containers/InboxPage/InboxPage.css diff --git a/src/app.test.js b/src/app.test.js index 534ddcbc..425693a9 100644 --- a/src/app.test.js +++ b/src/app.test.js @@ -65,8 +65,9 @@ describe('Application', () => { '/l/listing-title-slug/1234/edit': '/login', '/l/listing-title-slug/1234/checkout': '/login', '/u/1234/edit': '/login', - '/orders': '/login', - '/sales': '/login', + '/inbox': '/login', + '/inbox/orders': '/login', + '/inbox/sales': '/login', '/order/1234': '/login', '/order/1234/discussion': '/login', '/order/1234/details': '/login', diff --git a/src/containers/InboxPage/InboxPage.css b/src/containers/InboxPage/InboxPage.css new file mode 100644 index 00000000..5aa94ed1 --- /dev/null +++ b/src/containers/InboxPage/InboxPage.css @@ -0,0 +1,16 @@ +.title { + margin: 1rem; +} + +.tab { + float: left; + margin-left: 1rem; + font-size: 20px; + letter-spacing: -0.5px; + text-decoration: none; +} + +.activeTab { + font-weight: bold; + text-decoration: underline; +} diff --git a/src/containers/InboxPage/InboxPage.js b/src/containers/InboxPage/InboxPage.js index 7768f802..75606155 100644 --- a/src/containers/InboxPage/InboxPage.js +++ b/src/containers/InboxPage/InboxPage.js @@ -1,28 +1,42 @@ -/* eslint-disable arrow-body-style */ import React, { PropTypes } from 'react'; -import { PageLayout, NamedLink } from '../../components'; +import { FormattedMessage, injectIntl, intlShape } from 'react-intl'; +import { PageLayout, NamedLink, H1 } from '../../components'; -const InboxPage = props => { - const { filter } = props; - const ids = ['some-id-1', 'some-id-2']; +import css from './InboxPage.css'; - const toLink = id => { - return filter === 'orders' - ? {id} order details - : {id} sale details; - }; +export const InboxPageComponent = props => { + const { tab, intl } = props; + + const ordersTitle = intl.formatMessage({ id: 'InboxPage.ordersTitle' }); + const salesTitle = intl.formatMessage({ id: 'InboxPage.salesTitle' }); + const title = tab === 'orders' ? ordersTitle : salesTitle; return ( - - + +

+ +

+
); }; const { oneOf } = PropTypes; -InboxPage.propTypes = { filter: oneOf(['orders', 'sales']).isRequired }; +InboxPageComponent.propTypes = { + tab: oneOf(['orders', 'sales']).isRequired, + + // from injectIntl + intl: intlShape.isRequired, +}; + +const InboxPage = injectIntl(InboxPageComponent); export default InboxPage; diff --git a/src/containers/InboxPage/InboxPage.test.js b/src/containers/InboxPage/InboxPage.test.js index 5652fe07..ab40c7c8 100644 --- a/src/containers/InboxPage/InboxPage.test.js +++ b/src/containers/InboxPage/InboxPage.test.js @@ -1,10 +1,15 @@ import React from 'react'; import { renderShallow } from '../../util/test-helpers'; -import InboxPage from './InboxPage'; +import { fakeIntl } from '../../util/test-data'; +import { InboxPageComponent } from './InboxPage'; describe('InboxPage', () => { it('matches snapshot', () => { - const tree = renderShallow(); + const props = { + tab: 'orders', + intl: fakeIntl, + }; + const tree = renderShallow(); expect(tree).toMatchSnapshot(); }); }); diff --git a/src/containers/InboxPage/__snapshots__/InboxPage.test.js.snap b/src/containers/InboxPage/__snapshots__/InboxPage.test.js.snap index 9f99bc4e..8347e444 100644 --- a/src/containers/InboxPage/__snapshots__/InboxPage.test.js.snap +++ b/src/containers/InboxPage/__snapshots__/InboxPage.test.js.snap @@ -1,31 +1,25 @@ exports[`InboxPage matches snapshot 1`] = ` -
    -
  • - - some-id-1 - order details - -
  • -
  • - - some-id-2 - order details - -
  • -
+ title="InboxPage.ordersTitle"> +

+ +

+
`; diff --git a/src/routesConfiguration.js b/src/routesConfiguration.js index a372e396..2f3b3530 100644 --- a/src/routesConfiguration.js +++ b/src/routesConfiguration.js @@ -154,18 +154,25 @@ const routesConfiguration = [ component: props => , }, { - path: '/orders', + path: '/inbox', auth: true, exact: true, - name: 'OrdersPage', - component: props => , + name: 'InboxPage', + component: () => , }, { - path: '/sales', + path: '/inbox/orders', auth: true, exact: true, - name: 'SalesPage', - component: props => , + name: 'InboxOrdersPage', + component: props => , + }, + { + path: '/inbox/sales', + auth: true, + exact: true, + name: 'InboxSalesPage', + component: props => , }, { path: '/order/:id', diff --git a/src/translations/en.json b/src/translations/en.json index f1579d9f..c34bbcaa 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -37,6 +37,11 @@ "HeroSearchForm.search": "Search", "HeroSection.subTitle": "The largest online community to rent music studios", "HeroSection.title": "Book Studiotime anywhere", + "InboxPage.title": "Inbox", + "InboxPage.ordersTitle": "Inbox: Orders", + "InboxPage.salesTitle": "Inbox: Sales", + "InboxPage.ordersTabTitle": "Guest", + "InboxPage.salesTabTitle": "Host", "ModalInMobile.closeModal": "Close modal", "ListingPage.ctaButtonMessage": "Book {title}", "ListingPage.loadingListingData": "Loading listing data",