From 2aecb184ce435fc21103a7c0c3d7ff273a453223 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 19 Jan 2018 21:21:13 -0500 Subject: [PATCH] #5 start updating react-router --- package.json | 4 +- src/components/Base.js | 16 +- src/components/Home.js | 2 +- src/components/index.js | 193 +++-------------------- src/components/portal/Category/Tribes.js | 30 ++++ 5 files changed, 63 insertions(+), 182 deletions(-) diff --git a/package.json b/package.json index ab38a9a..164e5a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chaoticbackup", - "version": "1.0.0", + "version": "1.0.1", "description": "Chaotic Backup", "scripts": { "start": "webpack-dev-server -d --inline --host 0.0.0.0 --history-api-fallback --progress", @@ -22,7 +22,7 @@ "react-dom": "^16.0.0", "react-interactive": "^0.8.1", "react-process-string": "^1.2.0", - "react-router": "^3.2.0", + "react-router": "^4.2.0", "react-router-dom": "^4.2.2", "react-transition-group": "^1.2.1", "whatwg-fetch": "^2.0.3" diff --git a/src/components/Base.js b/src/components/Base.js index 924ed94..ee072e0 100644 --- a/src/components/Base.js +++ b/src/components/Base.js @@ -1,18 +1,16 @@ import React from 'react'; -import PropTypes from 'prop-types'; import Interactive from 'react-interactive'; -import { Link } from 'react-router'; +import { Link } from 'react-router-dom'; import s from '../styles/app.style'; +import {Children} from './index'; const language = "ENG"; const bkgrnd = "05"; -const propTypes = { - children: PropTypes.element.isRequired, - routes: PropTypes.array.isRequired, -}; +export default function Base(props) { + + const children = ; -function App({ children, routes }) { return (
@@ -122,7 +120,3 @@ function App({ children, routes }) {
); } - -App.propTypes = propTypes; - -export default App; diff --git a/src/components/Home.js b/src/components/Home.js index f36b2dd..32525a1 100644 --- a/src/components/Home.js +++ b/src/components/Home.js @@ -1,6 +1,6 @@ import React from 'react'; import Interactive from 'react-interactive'; -import { Link } from 'react-router'; +import { Link } from 'react-router-dom'; import s from '../styles/home.style'; function Home() { diff --git a/src/components/index.js b/src/components/index.js index 8c671bd..b6b8774 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -1,180 +1,37 @@ import React from 'react'; import { render } from 'react-dom'; -import { Router, Route, IndexRoute, browserHistory } from 'react-router'; +import { BrowserRouter as Router, Route } from 'react-router-dom'; /* Common Components */ -import App from './Base'; +import Base from './Base'; import {PageNotFound, UnderConstruction} from './Snippets'; /* Home Component */ import Home from './Home'; import EnterTheCode from './account/EnterTheCode'; -/* Test Components */ -import ExampleHome from './example/Home'; -import ExampleBase from './example/Base'; -import ExampleComponent from './example/ExampleComponent'; -import ExampleTwoDeepComponent from './example/ExampleTwoDeepComponent'; - -/* Collection */ -import CollectionHome from './collection/Home'; - -/* Portal */ -import PortalBase from './portal/Base'; -import PortalHome from './portal/Home'; -import Attacks from './portal/Category/Attacks'; -import SingleAttack from './portal/Single/Attack'; -import Battlegear from './portal/Category/Battlegear'; -import SingleBattlegear from './portal/Single/Battlegear'; -import Creatures from './portal/Category/Creatures'; -import SingleCreature from './portal/Single/Creature'; -import Locations from './portal/Category/Locations'; -import SingleLocation from './portal/Single/Location'; -import Mugic from './portal/Category/Mugic'; -import SingleMugic from './portal/Single/Mugic'; -import Tribes from './portal/Category/Tribes'; - - -const routes = ( - - - - {/* Test */} - - - - - - {/* Construction */} - - - {/* EnterTheCode */} - - - {/* Collection */} - - - - - - {/* Portal */} - - - - {/* Attacks */} - - - - - {/* Battlegear */} - - - - - {/* Locations */} - - - - - {/* Creatures */} - {/* Todo this isn't needed (tribe checking handled by components) */} - - - - - - - - - - - - - - - - - {/* Mugic */} - - - - - - - - - - - - - - - - - - - - {/* OverWorld */} - - - - - - - - - - {/* UnderWorld */} - - - - - - - - - - {/* Mipedian */} - - - - - - - - - - {/* Danian */} - - - - - - - - - - {/* Generic */} - - - - - - - - - - - - - - -); - render( - , - document.getElementById('root'), + + + + ,document.getElementById('root'), ); + +function App() { + return ( +
+ +
+ ); +} + +export function Children(props) { + console.log(props); + const match = props.match; + return ( +
+ + +
+ ); +} diff --git a/src/components/portal/Category/Tribes.js b/src/components/portal/Category/Tribes.js index 0a3ce13..f97ce04 100644 --- a/src/components/portal/Category/Tribes.js +++ b/src/components/portal/Category/Tribes.js @@ -17,11 +17,41 @@ export default class Tribes extends React.Component { return (
{this.props.children}
); } + const store = API; + let path = this.props.location.pathname.split("/"); if (path[path.length-1] == "") path.pop(); // Remove trailing backslash let tribe = path[2]; + if (store.urls === null || + store.portal === null || + store.cards === null) { + return (Loading...); + } + + if (!store.tribes.includes(tribe)) { + return( +
+ Danian +
+ OverWorld +
+ UnderWorld +
+ Mipedian +
+ ); + } + return (

{tribe}