Skip to content

Commit

Permalink
Expand the view model type to be able to isolate a component's failure
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgiosironi committed Jun 21, 2024
1 parent 57be59a commit 6f601df
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export const constructViewModel = (dependencies: Dependencies): TE.TaskEither<DE
title,
href: `https://labs.sciety.org/categories/articles?category=${title}`,
}))),
TE.map((categories) => ({ categories })),
);
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { renderListItems } from '../../shared-components/list-items';
import { renderSearchForm } from '../../shared-components/search-form';
import { ViewModel } from '../view-model';

const renderSearchCategories = (viewModel: ViewModel) => pipe(
viewModel,
const renderSearchCategories = (categories: ViewModel['categories']) => pipe(
categories,
RA.map((category) => toHtmlFragment(`<a href="${category.href}" class="search-categories-list__link">${category.title}</a>`)),
renderListItems,
(categories) => `
(listContent) => `
<section class="search-categories">
<h2>Browse by category</h2>
<ul role="list" class="search-categories-list">
${categories}
${listContent}
</ul>
</section>
`,
Expand All @@ -25,7 +25,7 @@ export const renderPage = (viewModel: ViewModel): HtmlFragment => pipe(
<h1>Search Sciety</h1>
</header>
${renderSearchForm('', true)}
${renderSearchCategories(viewModel)}
${renderSearchCategories(viewModel.categories)}
`,
toHtmlFragment,
);
2 changes: 1 addition & 1 deletion src/read-side/html-pages/search-page/view-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ type Category = {
href: string,
};

export type ViewModel = ReadonlyArray<Category>;
export type ViewModel = { categories: ReadonlyArray<Category> };

0 comments on commit 6f601df

Please sign in to comment.