Skip to content

Commit

Permalink
Rename a view model property from the point of view of the component #…
Browse files Browse the repository at this point in the history
  • Loading branch information
LinaKind committed Jun 21, 2024
1 parent 81ccf07 commit a6ab75a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Dependencies } from './dependencies';
import * as DE from '../../../../types/data-error';
import { ViewModel } from '../view-model';

const constructSearchCategories = (dependencies: Dependencies) => pipe(
const constructBrowseByCategory = (dependencies: Dependencies) => pipe(
dependencies.fetchSearchCategories(),
TE.map(RA.map((title) => ({
title,
Expand All @@ -21,10 +21,9 @@ const constructSearchCategories = (dependencies: Dependencies) => pipe(
);

export const constructViewModel = (dependencies: Dependencies): TE.TaskEither<DE.DataError, ViewModel> => pipe(
constructSearchCategories(dependencies),
T.map((categories) => pipe(
categories,
(componentViewModel) => ({ categories: componentViewModel }),
constructBrowseByCategory(dependencies),
T.map((browseByCategory) => pipe(
({ browseByCategory }),
E.right,
)),
);
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { renderListItems } from '../../shared-components/list-items';
import { renderSearchForm } from '../../shared-components/search-form';
import { ViewModel } from '../view-model';

const renderSearchCategories = (viewModel: ViewModel['categories']) => pipe(
const renderSearchCategories = (viewModel: ViewModel['browseByCategory']) => pipe(
viewModel,
O.match(
() => '',
Expand All @@ -32,7 +32,7 @@ export const renderPage = (viewModel: ViewModel): HtmlFragment => pipe(
<h1>Search Sciety</h1>
</header>
${renderSearchForm('', true)}
${renderSearchCategories(viewModel.categories)}
${renderSearchCategories(viewModel.browseByCategory)}
`,
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 @@ -5,4 +5,4 @@ type Category = {
href: string,
};

export type ViewModel = { categories: O.Option<ReadonlyArray<Category>> };
export type ViewModel = { browseByCategory: O.Option<ReadonlyArray<Category>> };

0 comments on commit a6ab75a

Please sign in to comment.