From 44061745e9ac8608a0af2394d59c0f56674f0e3c Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Sun, 4 Aug 2019 17:48:54 -0500 Subject: [PATCH] use real FilterLists data from API --- src/FilterLists.Web.V2/src/App.tsx | 6 ++--- .../allListsTable}/AllListsTable.tsx | 26 +++++-------------- .../src/modules/allListsTable/List.ts | 22 ++++++++++++++++ .../src/modules/allListsTable/index.ts | 3 +++ src/FilterLists.Web.V2/src/modules/index.ts | 3 +++ 5 files changed, 37 insertions(+), 23 deletions(-) rename src/FilterLists.Web.V2/src/{ => modules/allListsTable}/AllListsTable.tsx (58%) create mode 100644 src/FilterLists.Web.V2/src/modules/allListsTable/List.ts create mode 100644 src/FilterLists.Web.V2/src/modules/allListsTable/index.ts create mode 100644 src/FilterLists.Web.V2/src/modules/index.ts diff --git a/src/FilterLists.Web.V2/src/App.tsx b/src/FilterLists.Web.V2/src/App.tsx index 788e799fd..4eba24811 100644 --- a/src/FilterLists.Web.V2/src/App.tsx +++ b/src/FilterLists.Web.V2/src/App.tsx @@ -1,12 +1,10 @@ import React from 'react'; -import { AllListsTable } from './AllListsTable'; +import { AllListsTable } from './modules'; import './App.css'; const App: React.FC = () => { return ( -
- -
+ ); } diff --git a/src/FilterLists.Web.V2/src/AllListsTable.tsx b/src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx similarity index 58% rename from src/FilterLists.Web.V2/src/AllListsTable.tsx rename to src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx index 09231becc..18deea19b 100644 --- a/src/FilterLists.Web.V2/src/AllListsTable.tsx +++ b/src/FilterLists.Web.V2/src/modules/allListsTable/AllListsTable.tsx @@ -1,28 +1,16 @@ import { Table } from 'antd'; import * as React from "react"; +import { List } from './List'; const columns = [ { title: 'Name', dataIndex: 'name', - sorter: true, - render: (name: { first: any; last: any; }) => `${name.first} ${name.last}`, - width: '20%', - }, - { - title: 'Gender', - dataIndex: 'gender', - filters: [{ text: 'Male', value: 'male' }, { text: 'Female', value: 'female' }], - width: '20%', - }, - { - title: 'Email', - dataIndex: 'email', - }, + } ]; interface State { - data: []; + data: List[]; loading: boolean; } @@ -39,13 +27,12 @@ export class AllListsTable extends React.Component<{}, State> { this.fetch(); } - fetch = () => { + fetch() { this.setState({ loading: true }); - fetch("https://randomuser.me/api") + fetch("/api/v1/lists") .then(response => response.json()) .then(json => { - this.setState({ data: json.results }); - this.setState({ loading: false }) + this.setState({ data: json, loading: false }); }) }; @@ -53,6 +40,7 @@ export class AllListsTable extends React.Component<{}, State> { return ( record.id.toString()} dataSource={this.state.data} loading={this.state.loading} /> diff --git a/src/FilterLists.Web.V2/src/modules/allListsTable/List.ts b/src/FilterLists.Web.V2/src/modules/allListsTable/List.ts new file mode 100644 index 000000000..cbc034223 --- /dev/null +++ b/src/FilterLists.Web.V2/src/modules/allListsTable/List.ts @@ -0,0 +1,22 @@ +export interface List { + id: number; + chatUrl: string; + description: string; + descriptionSourceUrl: string; + donateUrl: string; + emailAddress: string; + forumUrl: string; + homeUrl: string; + issuesUrl: string; + languageIds: number[]; + licenseId: number; + maintainerIds: number[]; + name: string; + policyUrl: string; + publishedDate: string; + submissionUrl: string; + syntaxId: number; + tagIds: number[]; + viewUrl: string; + viewUrlMirrors: string[]; +}; \ No newline at end of file diff --git a/src/FilterLists.Web.V2/src/modules/allListsTable/index.ts b/src/FilterLists.Web.V2/src/modules/allListsTable/index.ts new file mode 100644 index 000000000..fd3e7fb18 --- /dev/null +++ b/src/FilterLists.Web.V2/src/modules/allListsTable/index.ts @@ -0,0 +1,3 @@ +import { AllListsTable } from './AllListsTable' + +export { AllListsTable } \ No newline at end of file diff --git a/src/FilterLists.Web.V2/src/modules/index.ts b/src/FilterLists.Web.V2/src/modules/index.ts new file mode 100644 index 000000000..820f33938 --- /dev/null +++ b/src/FilterLists.Web.V2/src/modules/index.ts @@ -0,0 +1,3 @@ +import { AllListsTable } from './allListsTable' + +export { AllListsTable } \ No newline at end of file