mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
use real FilterLists data from API
This commit is contained in:
parent
756fe20dc0
commit
44061745e9
5 changed files with 37 additions and 23 deletions
|
|
@ -1,12 +1,10 @@
|
|||
import React from 'react';
|
||||
import { AllListsTable } from './AllListsTable';
|
||||
import { AllListsTable } from './modules';
|
||||
import './App.css';
|
||||
|
||||
const App: React.FC = () => {
|
||||
return (
|
||||
<div className="App">
|
||||
<AllListsTable></AllListsTable>
|
||||
</div>
|
||||
<AllListsTable></AllListsTable>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<Table
|
||||
columns={columns}
|
||||
rowKey={record => record.id.toString()}
|
||||
dataSource={this.state.data}
|
||||
loading={this.state.loading}
|
||||
/>
|
||||
22
src/FilterLists.Web.V2/src/modules/allListsTable/List.ts
Normal file
22
src/FilterLists.Web.V2/src/modules/allListsTable/List.ts
Normal file
|
|
@ -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[];
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
import { AllListsTable } from './AllListsTable'
|
||||
|
||||
export { AllListsTable }
|
||||
3
src/FilterLists.Web.V2/src/modules/index.ts
Normal file
3
src/FilterLists.Web.V2/src/modules/index.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import { AllListsTable } from './allListsTable'
|
||||
|
||||
export { AllListsTable }
|
||||
Loading…
Reference in a new issue