const html = require('choo/html'); const { editModal } = require('./editModal'); const userShelvesView = (shelvesController, emit) => { const { __ } = shelvesController.i18n; if (!shelvesController.isLoggedIn) { return [ html`

${__('shelves.no_shelf_selected')}

${__('shelves.not_logged_in')}

`, ]; } if (shelvesController.appState.isFrontend && shelvesController.state.myShelves.length <= 0) { shelvesController.getUserShelves().then(() => { emit(shelvesController.appState.events.RENDER); }); } // Should add a scale of publicity: private, friends only, friends & followers, public return [ html`

${__('shelves.title')}

${shelvesController.state.myShelves.map(shelf => { const deleteButton = html``; return html`

${shelf.name}

${shelf.isDeletable === true ? [ editModal(shelf, shelvesController), [deleteButton], // editModal outputs a modal, which returns an array, so any subsequent html items must also be in an array for Choo to handle it correctly. ] : null }
`; })}
`, ]; } module.exports = { userShelvesView };