diff --git a/pages/index.tsx b/pages/index.tsx deleted file mode 100644 index 7b1540f2..00000000 --- a/pages/index.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import type { NextPage } from 'next' -import Head from 'next/head' -import styles from '../styles/Home.module.css' - -import { CookiesProvider } from 'react-cookie' -import { BrowserRouter } from 'react-router-dom' - -import App from '~/components/App' - -const Home: NextPage = () => { - if (typeof window === "undefined") - return null - - return ( - - - - - - ) -} - -export default Home diff --git a/routes/NewRoute/index.tsx b/routes/NewRoute/index.tsx deleted file mode 100644 index 9ac20b2c..00000000 --- a/routes/NewRoute/index.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import React from 'react' -import Party from '~components/Party' - -const NewRoute: React.FC = () => { - function callback(path: string) { - // This is scuffed, how do we do this natively? - window.history.replaceState(null, `Grid Tool`, `${path}`) - } - - return ( -
- -
- ) -} - -export default NewRoute \ No newline at end of file diff --git a/routes/PartyRoute/index.tsx b/routes/PartyRoute/index.tsx deleted file mode 100644 index b1db1fdf..00000000 --- a/routes/PartyRoute/index.tsx +++ /dev/null @@ -1,135 +0,0 @@ -import React, { useEffect, useState } from 'react' -import { withCookies, useCookies } from 'react-cookie' -import { useParams } from 'react-router-dom' -import api from '~utils/api' - -import Party from '~components/Party' -import Button from '~components/Button' - -interface Props { - hash: string -} - - -const PartyRoute: React.FC = () => { - const params = useParams() - - const [found, setFound] = useState(false) - const [loading, setLoading] = useState(true) - const [editable, setEditable] = useState(false) - - const [characters, setCharacters] = useState>({}) - const [weapons, setWeapons] = useState>({}) - const [summons, setSummons] = useState>({}) - - const [mainWeapon, setMainWeapon] = useState() - const [mainSummon, setMainSummon] = useState() - const [friendSummon, setFriendSummon] = useState() - - const [partyId, setPartyId] = useState('') - const [extra, setExtra] = useState(false) - const [cookies, setCookie] = useCookies(['user']) - const shortcode = params.hash || '' - - - useEffect(() => { - fetchGrid(shortcode) - }, []) - - async function fetchGrid(shortcode: string) { - return api.endpoints.parties.getOne({ id: shortcode }) - .then(response => { - const party = response.data.party - - const partyUser = party.user_id - const loggedInUser = (cookies.user) ? cookies.user.user_id : '' - - if (partyUser != undefined && loggedInUser != undefined && partyUser === loggedInUser) - setEditable(true) - - let characters: GridArray = {} - let weapons: GridArray = {} - let summons: GridArray = {} - - party.characters.forEach((gridCharacter: GridCharacter) => { - if (gridCharacter.position != null) - characters[gridCharacter.position] = gridCharacter.character - }) - - party.weapons.forEach((gridWeapon: GridWeapon) => { - if (gridWeapon.mainhand) - setMainWeapon(gridWeapon.weapon) - else if (!gridWeapon.mainhand && gridWeapon.position != null) - weapons[gridWeapon.position] = gridWeapon.weapon - }) - - party.summons.forEach((gridSummon: GridSummon) => { - if (gridSummon.main) - setMainSummon(gridSummon.summon) - else if (gridSummon.friend) - setFriendSummon(gridSummon.summon) - else if (!gridSummon.main && !gridSummon.friend && gridSummon.position != null) - summons[gridSummon.position] = gridSummon.summon - }) - - setExtra(response.data.party.is_extra) - setFound(true) - setLoading(false) - setCharacters(characters) - setWeapons(weapons) - setSummons(summons) - setPartyId(party.id) - }) - .catch(error => { - if (error.response != null) { - if (error.response.status == 404) { - setFound(false) - setLoading(false) - } - } else { - console.error(error) - } - }) - } - - function render() { - return ( -
- -
- ) - } - - function renderNotFound() { - return ( -
-

There's no grid here.

- -
- ) - } - - if (!found && !loading) { - return renderNotFound() - } else if (found && !loading) { - return render() - } else { - return (
) - } -} - -export default - withCookies( - PartyRoute - ) \ No newline at end of file