Skip to content

Commit 01701e5

Browse files
committed
Hook up read side
1 parent f4b2534 commit 01701e5

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as TE from 'fp-ts/TaskEither';
2+
import {FailureWithStatus} from '../../types/failure-with-status';
3+
import {ViewModel} from './view-model';
4+
import {User} from '../../types';
5+
import {UUID} from 'io-ts-types';
6+
import {SharedReadModel} from '../../read-models/shared-state';
7+
8+
export const constructViewModel =
9+
(readModel: SharedReadModel) =>
10+
(user: User): TE.TaskEither<FailureWithStatus, ViewModel> => {
11+
12+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {pipe} from 'fp-ts/lib/function';
2+
import * as TE from 'fp-ts/TaskEither';
3+
import {constructViewModel} from './construct-view-model';
4+
import {render} from './render';
5+
import {Query} from '../query';
6+
import {safe, toLoggedInContent} from '../../types/html';
7+
8+
export const troubleTickets: Query = deps => user =>
9+
pipe(
10+
user,
11+
constructViewModel(deps.sharedReadModel),
12+
TE.map(render),
13+
TE.map(toLoggedInContent(safe('Trouble Tickets')))
14+
);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {pipe} from 'fp-ts/lib/function';
2+
import {html} from '../../types/html';
3+
import {ViewModel} from './view-model';
4+
5+
export const render = (viewModel: ViewModel) =>
6+
pipe(
7+
viewModel,
8+
(_viewModel: ViewModel) => html`
9+
<div class="stack">
10+
<h1>Trouble tickets</h1>
11+
</div>
12+
`
13+
);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {DateTime} from 'luxon';
2+
import * as O from 'fp-ts/Option';
3+
4+
export type ViewModel = {
5+
isSuperUser: boolean;
6+
troubleTicketData: ReadonlyArray<{
7+
responseSubmitted: DateTime;
8+
emailAddress: O.Option<string>;
9+
whichEquipment: O.Option<string>;
10+
submitterName: O.Option<string>;
11+
submitterMembershipNumber: O.Option<number>;
12+
submittedResponse: Record<string, string>;
13+
}>;
14+
};

0 commit comments

Comments
 (0)