diff --git a/src/index.js b/src/index.js index 6ffbf3a..72ac4fe 100644 --- a/src/index.js +++ b/src/index.js @@ -1,15 +1,49 @@ -import React from 'react' -import ReactDOM from 'react-dom' -import './index.css' +import React, { useState } from "react"; +import ReactDOM from "react-dom"; +import PropTypes from "prop-types"; +import "./index.css"; +import { config } from "./config"; +import axios from "axios"; -class App extends Component { - render() { - return ( -
-

Hello, React!

-
- ) - }; +function auth(token) { + return axios.get(`${config.apiUrl}/auth?token=${encodeURIComponent(token)}`) + .then((res) => res.data.success); } -ReactDOM.render(, document.getElementById('root')); +function Login(props) { + const [input, setInput] = useState(""); + return ( +
+ setInput(evt.target.value)} /> + +
+ ); +} + +Login.propTypes = { + setLoggedIn: PropTypes.func, +}; + +function MainApp() { + return ( +
+
+ ); +} + +function App(){ + const [loggedIn, setLoggedIn] = useState(false); + if (loggedIn){ + return ( + + ); + } + else { + return ( + + ); + } +} + +ReactDOM.render(, document.getElementById("root")); diff --git a/src/sample.config.js b/src/sample.config.js new file mode 100644 index 0000000..d30912c --- /dev/null +++ b/src/sample.config.js @@ -0,0 +1,4 @@ +const config = { + apiUrl: "http://localhost:5000" +}; +export { config };