2020-09-20 17:19:12 -06:00
|
|
|
const html = require('choo/html');
|
2019-09-07 13:54:44 -06:00
|
|
|
|
2020-09-20 17:19:12 -06:00
|
|
|
const { HomeController } = require('./controller'); // The controller for this view, where processing should happen.
|
|
|
|
const { loggedOutView } = require('./loggedOut');
|
|
|
|
const { loggedInView } = require('./loggedIn');
|
2019-09-07 13:54:44 -06:00
|
|
|
|
|
|
|
// This is the view function that is exported and used in the view manager.
|
2020-09-20 17:19:12 -06:00
|
|
|
const homeView = (state, emit, i18n) => {
|
2019-09-16 12:32:53 -06:00
|
|
|
const controller = new HomeController(state, i18n);
|
2019-09-07 13:54:44 -06:00
|
|
|
|
|
|
|
// Returning an array in a view allows non-shared parent HTML elements.
|
|
|
|
// This one doesn't have the problem right now, but it's good to remember.
|
|
|
|
return [
|
2020-09-21 20:49:02 -06:00
|
|
|
(!controller.isLoggedIn
|
2019-09-13 22:43:07 -06:00
|
|
|
? loggedOutView(controller, emit)
|
2019-10-17 20:56:57 -06:00
|
|
|
: loggedInView(controller, emit)
|
2019-09-13 22:43:07 -06:00
|
|
|
),
|
2019-09-07 13:54:44 -06:00
|
|
|
];
|
2020-09-20 17:19:12 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { homeView };
|