From 9d42f009bbf7c073d3a48bf65bb9b12775d68b3d Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 15 Mar 2018 20:11:33 +0300 Subject: LoginButton --- vnext/src/components/Discover.js | 13 +++++++------ vnext/src/components/LoginButton.js | 5 +++-- vnext/src/components/Thread.js | 23 +++++++++++++++++++++++ 3 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 vnext/src/components/Thread.js (limited to 'vnext/src/components') diff --git a/vnext/src/components/Discover.js b/vnext/src/components/Discover.js index 2d962bda..7fde3d88 100644 --- a/vnext/src/components/Discover.js +++ b/vnext/src/components/Discover.js @@ -1,6 +1,7 @@ import "whatwg-fetch" import React from "react" import PropTypes from "prop-types" +import queryString from "query-string" import Message from "./Message" @@ -9,7 +10,8 @@ export default class Discover extends React.Component { super(props) this.state = { msgs: [], - loading: false + loading: false, + search: this.props.location.search } this.loadMessages = this.loadMessages.bind(this); } @@ -22,8 +24,7 @@ export default class Discover extends React.Component { } } loadMessages() { - const search = new URLSearchParams(this.props.params); - const url = "https://api.juick.com/messages"; + const url = "https://api.juick.com/messages" + this.state.search; fetch(url) .then(response => { return response.json() @@ -38,13 +39,13 @@ export default class Discover extends React.Component { render() { var nodes = this.state.msgs.map(msg => { return () - }); + }); return ( -
{nodes}
+
{nodes}
) } }; Discover.propTypes = { - msgs: PropTypes.array + msgs: PropTypes.array } diff --git a/vnext/src/components/LoginButton.js b/vnext/src/components/LoginButton.js index cdb62e1a..8d298fa2 100644 --- a/vnext/src/components/LoginButton.js +++ b/vnext/src/components/LoginButton.js @@ -8,14 +8,15 @@ export default class LoginButton extends React.Component { this.props.onAuth(event.data); }, false); } - login() { + login(event) { + event.preventDefault(); let loginWindow = window.open("https://juick.com/login?redirect=false", "Login to Juick", "width=400,height=300,resizeable=no,menubar=no,toolbar=no,scrollbars=no"); loginWindow.window.focus(); } render() { return ( -
{this.props.title}
+ {this.props.title} ) } }; diff --git a/vnext/src/components/Thread.js b/vnext/src/components/Thread.js new file mode 100644 index 00000000..49d9ea4d --- /dev/null +++ b/vnext/src/components/Thread.js @@ -0,0 +1,23 @@ +import "whatwg-fetch" +import React from "react" + +export default class Thread extends React.Component { + constructor(props) { + super(props); + this.state = { + replies: [], + loading: false + } + } + componentDidMount() { + } + render() { + const { user, mid } = this.props.match.params; + return ( +
+

{user}

+

{mid}

+
+ ) + } +} \ No newline at end of file -- cgit v1.2.3