-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDashboardPage.tsx
30 lines (26 loc) · 1016 Bytes
/
DashboardPage.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import React, { useState, ChangeEvent } from "react";
import { Layout, List } from "../components";
import { H2 } from "../components";
import { fetchItemsA, fetchItemsB } from "../api";
import type { Item, MockA, MockB } from "../types";
import {useListReducer} from '../components/ListState'
const getNormalisedMockListA = async () =>
fetchItemsA().then((data: MockA[]): Item[] =>
data.map((d, i) => ({id: `${i}`, status: false, infos: [d.title]}))
);
const getNormalisedMockListB = async () =>
fetchItemsB().then((data: MockB[]): Item[] =>
data.map((d, i) => ({id: `${i}`, status: false, infos: [d.name, d.description, d.link]}))
);
export const DashboardPage = () => {
const [{ items }] = useListReducer();
return (
<Layout>
<H2>
Selected indexes:{" "}
{items.map((item: Item) => item.status ? item.id : '').filter(Boolean).join(", ") || "none"}
</H2>
<List getList={getNormalisedMockListB}></List>
</Layout>
);
}