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

${__('shelves.no_shelf_selected')}

${__('shelves.not_logged_in')}

`, ]; } if (shelvesController.state.myShelves.length <= 0) { shelvesController.getUserShelves().then(() => { emit('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 }
`; })}
`, ]; }