From 43a8c006a11a25e5551617007490e364c0d3d422 Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Thu, 17 Oct 2019 20:56:57 -0600 Subject: [PATCH] Add loggedIn view for home page --- app/i18n/locales/en.json | 5 ++++- app/views/home/controller.js | 17 ++++++++-------- app/views/home/index.js | 3 ++- app/views/home/loggedIn.js | 39 ++++++++++++++++++++++++++++++++++++ app/views/home/loggedOut.js | 4 ++-- 5 files changed, 55 insertions(+), 13 deletions(-) create mode 100644 app/views/home/loggedIn.js diff --git a/app/i18n/locales/en.json b/app/i18n/locales/en.json index 592ea74..b89af53 100644 --- a/app/i18n/locales/en.json +++ b/app/i18n/locales/en.json @@ -16,7 +16,10 @@ "logged_out_community_header": "A Look Inside the Hive", "logged_out_recent_reviews": "Recent Reviews", "logged_out_recent_updates": "Recent Updates", - "logged_out_join_now": "Join Now!" + "logged_out_join_now": "Join Now!", + "logged_in_subtitle": "Welcome!", + "logged_in_updates": "Updates", + "logged_in_interactions": "Interactions" }, "404": { "header": "Oops!", diff --git a/app/views/home/controller.js b/app/views/home/controller.js index cdfffc2..dcb11e1 100644 --- a/app/views/home/controller.js +++ b/app/views/home/controller.js @@ -5,19 +5,18 @@ export class HomeController extends ViewController { // Super passes state, view name, and default state to ViewController, // which stores state in this.appState and the view controller's state to this.state super(state, i18n, 'home', { - recentReviews: [], - recentUpdates: [], + loggedOut: { + recentReviews: [], + recentUpdates: [], + }, + loggedIn: { + updates: [], // statuses, ratings, and reviews from people you follow. + interactions: [], // likes, comments, recommendations, etc. + }, }); // If using controller methods in an input's onchange or onclick instance, // either bind the class's 'this' instance to the method first... // or use `onclick=${() => controller.submit()}` to maintain the 'this' of the class instead. } - - get recentReviews() { - return [...this.state.recentReviews]; - } - get recentUpdates() { - return [...this.state.recentUpdates]; - } } \ No newline at end of file diff --git a/app/views/home/index.js b/app/views/home/index.js index f060a08..52d7898 100644 --- a/app/views/home/index.js +++ b/app/views/home/index.js @@ -2,6 +2,7 @@ import html from 'choo/html'; import { HomeController } from './controller'; // The controller for this view, where processing should happen. import { loggedOutView } from './loggedOut'; +import { loggedInView } from './loggedIn'; // This is the view function that is exported and used in the view manager. export const homeView = (state, emit, i18n) => { @@ -12,7 +13,7 @@ export const homeView = (state, emit, i18n) => { return [ (!controller.isLoggedIn ? loggedOutView(controller, emit) - : html`

lol wut how are u logged in

` + : loggedInView(controller, emit) ), ]; } \ No newline at end of file diff --git a/app/views/home/loggedIn.js b/app/views/home/loggedIn.js new file mode 100644 index 0000000..7243c73 --- /dev/null +++ b/app/views/home/loggedIn.js @@ -0,0 +1,39 @@ +import html from 'choo/html'; + +export const loggedInView = (homeController, emit) => { + const { __ } = homeController.i18n; + + return [ + html`
+

${__('home.logged_in_subtitle')}

+
+
+
+
+

${__('home.logged_in_updates')}

+ +
+
+ ${homeController.state.loggedIn.updates.map(update => reviewCard(homeController, update))} +
+
+
+
+
+
+

${__('home.logged_in_interactions')}

+ +
+
+ ${homeController.state.loggedIn.interactions.map(interaction => reviewCard(homeController, interaction))} +
+
+
+
+
`, + ]; +} \ No newline at end of file diff --git a/app/views/home/loggedOut.js b/app/views/home/loggedOut.js index ac8bf71..fb0344b 100644 --- a/app/views/home/loggedOut.js +++ b/app/views/home/loggedOut.js @@ -57,7 +57,7 @@ export const loggedOutView = (homeController, emit) => { @@ -70,7 +70,7 @@ export const loggedOutView = (homeController, emit) => {