import html from 'choo/html'; import { reviewCard } from '../partials/reviewCard'; import { starRating } from '../partials/starRating'; import { modal } from '../partials/modal'; export const resultDetails = (searchController, result, emit = () => {}) => { const { __ } = searchController.i18n; const modalId = `result_${result.uri}`; const buttonHTML = html``; const tabNames = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']; const modalContent = html`

Covers

${typeof result.covers === 'undefined' ? html`` : html`
${result.covers.map((cover, index) => { return [ html``, // html``, ]; })}
${result.covers.map((cover, index, allCovers) => { return html`
${cover.uri.replace(':', ' ').toUpperCase()}, Published: ${cover.publishDate} ${typeof allCovers[index - 1] === 'undefined' ? null : html`` } ${typeof allCovers[index + 1] === 'undefined' ? null : html`` }
`; })}
` }

${__('interaction.average_rating')}

${starRating(result.averageRating)} ${result.reviews.map(review => { return reviewCard(searchController, review); })}

${__('search.see_book_details')}

`; return modal(modalId, searchController, modalContent, { styles: "width:90%;", buttonHTML, // This should be replaced with buttonHTML containing the ratings and number of reviews etc. headerText: result.name, onShow: () => { if (typeof result.covers === 'undefined') { searchController.getCovers(result.uri).then(() => emit('render')); } }, }); }