From 1c1d5a924133bf345f97abf18417cc9a93e4fa1f Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Tue, 31 Oct 2017 10:12:21 -0500 Subject: [PATCH] replace weather demo with FilterLists API --- .../ClientApp/components/Home.tsx | 47 ++++++++----------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/src/FilterLists.Web/ClientApp/components/Home.tsx b/src/FilterLists.Web/ClientApp/components/Home.tsx index 0f00267c5..9cf778e40 100644 --- a/src/FilterLists.Web/ClientApp/components/Home.tsx +++ b/src/FilterLists.Web/ClientApp/components/Home.tsx @@ -2,20 +2,20 @@ import * as React from "react"; import { RouteComponentProps } from "react-router"; import "isomorphic-fetch"; -interface FetchDataExampleState { - forecasts: WeatherForecast[]; +interface IFilterListsState { + filterLists: IFilterList[]; loading: boolean; } -export class Home extends React.Component, FetchDataExampleState> { +export class Home extends React.Component, IFilterListsState> { constructor() { super(); - this.state = { forecasts: [], loading: true }; + this.state = { filterLists: [], loading: true }; - fetch("api/SampleData/WeatherForecasts") - .then(response => response.json() as Promise) + fetch("https://api.filterlists.com/v1/lists") + .then(response => response.json() as Promise) .then(data => { - this.setState({ forecasts: data, loading: false }); + this.setState({ filterLists: data, loading: false }); }); } @@ -24,32 +24,26 @@ export class Home extends React.Component, FetchDataExam ?

Loading...

- : Home.renderForecastsTable(this.state.forecasts); + : Home.renderFilterListsTable(this.state.filterLists); return
-

Weather forecast

-

This component demonstrates fetching data from the server.

- { contents } + {contents}
; } - private static renderForecastsTable(forecasts: WeatherForecast[]) { + private static renderFilterListsTable(filterLists: IFilterList[]) { return - - - - + + - {forecasts.map(forecast => - - - - - + {filterLists.map(filterList => + + + )} @@ -57,9 +51,8 @@ export class Home extends React.Component, FetchDataExam } } -interface WeatherForecast { - dateFormatted: string; - temperatureC: number; - temperatureF: number; - summary: string; +interface IFilterList { + id: number; + name: string; + description: string; } \ No newline at end of file
DateTemp. (C)Temp. (F)SummaryNameDescription
{ forecast.dateFormatted }{ forecast.temperatureC }{ forecast.temperatureF }{ forecast.summary }
{filterList.name}{filterList.description}