diff --git a/src/components/login.js b/src/components/login.js
new file mode 100644
index 0000000..09a8ad5
--- /dev/null
+++ b/src/components/login.js
@@ -0,0 +1,20 @@
+import React, { useState } from "react";
+import PropTypes from "prop-types";
+
+export default (player) => {
+ function Login(props) {
+ const [input, setInput] = useState("");
+ return (
+
+ setInput(evt.target.value)} />
+
+
+ );
+ }
+
+ Login.propTypes = {
+ setLoggedIn: PropTypes.func,
+ };
+ return Login;
+};
diff --git a/src/components/mainapp.js b/src/components/mainapp.js
new file mode 100644
index 0000000..30abbd5
--- /dev/null
+++ b/src/components/mainapp.js
@@ -0,0 +1,7 @@
+import React from "react";
+export default () => function MainApp() {
+ return (
+
+
+ );
+};
diff --git a/src/index.js b/src/index.js
index 72ac4fe..c32e453 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,49 +1,20 @@
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";
+import login from "./components/login";
+import mainapp from "./components/mainapp";
+import models from "./models";
-function auth(token) {
- return axios.get(`${config.apiUrl}/auth?token=${encodeURIComponent(token)}`)
- .then((res) => res.data.success);
-}
+const { player } = models(config, axios);
-function Login(props) {
- const [input, setInput] = useState("");
- return (
-
- setInput(evt.target.value)} />
-
-
- );
-}
-
-Login.propTypes = {
- setLoggedIn: PropTypes.func,
-};
-
-function MainApp() {
- return (
-
-
- );
-}
+const Login = login(player);
+const MainApp = mainapp();
function App(){
const [loggedIn, setLoggedIn] = useState(false);
- if (loggedIn){
- return (
-
- );
- }
- else {
- return (
-
- );
- }
+ return loggedIn ? : ;
}
ReactDOM.render(, document.getElementById("root"));
diff --git a/src/models/index.js b/src/models/index.js
new file mode 100644
index 0000000..d325760
--- /dev/null
+++ b/src/models/index.js
@@ -0,0 +1,5 @@
+import player from "./player";
+
+export default (config, axios) => { return {
+ player: player(config, axios),
+};};
diff --git a/src/models/player.js b/src/models/player.js
new file mode 100644
index 0000000..0feadf6
--- /dev/null
+++ b/src/models/player.js
@@ -0,0 +1,6 @@
+export default (config, axios) => {return {
+ auth: (token) => {
+ return axios.get(`${config.apiUrl}/auth?token=${encodeURIComponent(token)}`)
+ .then((res) => res.data.success);
+ },
+};};