From f66263609d3d09ca1c1746dc6c3c931827df9aac Mon Sep 17 00:00:00 2001 From: Collin Barrett Date: Fri, 16 Feb 2018 20:47:54 -0600 Subject: [PATCH] modal works! (rough, needs cleanup) --- .../ClientApp/components/Home.tsx | 33 +----------- .../ClientApp/components/ListDetailsModal.tsx | 51 +++++++++++++++---- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/FilterLists.Web/ClientApp/components/Home.tsx b/src/FilterLists.Web/ClientApp/components/Home.tsx index 3d0486ed3..69a2d7c26 100644 --- a/src/FilterLists.Web/ClientApp/components/Home.tsx +++ b/src/FilterLists.Web/ClientApp/components/Home.tsx @@ -41,44 +41,15 @@ export class Home extends React.Component, IFilterListsS { Header: "Details", accessor: "id", - Cell: (d: any) => , - style: { textAlign: "center" }, - width: 100 - }, - { - Header: "View", - accessor: "viewUrl", - Cell: (d: any) => - View, - style: { textAlign: "center" }, - width: 100 - }, - { - Header: "Subscribe", - accessor: "viewUrl", - Cell: (d: any) => - Subscribe, + Cell: (d: any) => , style: { textAlign: "center" }, width: 100 } - ]} - SubComponent={(row: any) => { - return
- - {row.original.description} - -
; - - }}/>; + ]}/>; } } interface IFilterList { id: number; name: string; - description: string; - viewUrl: string; } \ No newline at end of file diff --git a/src/FilterLists.Web/ClientApp/components/ListDetailsModal.tsx b/src/FilterLists.Web/ClientApp/components/ListDetailsModal.tsx index 359b2ea90..dd7948f67 100644 --- a/src/FilterLists.Web/ClientApp/components/ListDetailsModal.tsx +++ b/src/FilterLists.Web/ClientApp/components/ListDetailsModal.tsx @@ -3,18 +3,21 @@ import "isomorphic-fetch"; import * as ReactModal from "react-modal"; export default class ListDetailsModal extends React.Component { + private readonly listId: any; + constructor(props: any) { super(props); - this.state = { - showModal: false - }; - + this.state = { showModal: false, loading: true }; + this.listId = props.listId; this.handleOpenModal = this.handleOpenModal.bind(this); this.handleCloseModal = this.handleCloseModal.bind(this); } handleOpenModal() { this.setState({ showModal: true }); + fetch(`https://api.filterlists.com/v1/lists/${this.listId}`) + .then(response => response.json() as Promise) + .then(data => { this.setState({ filterListdetails: data, loading: false }); }); } handleCloseModal() { @@ -22,16 +25,42 @@ export default class ListDetailsModal extends React.Component { } render() { + const contents = this.state.loading + ? null + : +

{this.state.filterListdetails.name}

+

{this.state.filterListdetails.description}

+ + View + + + Subscribe + + +
; return (
- - - - + + {contents}
); } + +} + +interface IFilterListDetails { + id: number; + name: string; + description: string; + descriptionSourceUrl: string; + viewUrl: string; } \ No newline at end of file