diff --git a/routes/PartiesRoute/index.tsx b/routes/PartiesRoute/index.tsx deleted file mode 100644 index 2b29226b..00000000 --- a/routes/PartiesRoute/index.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import React from 'react' - -interface State { - parties: {id: string, hash: string}[] -} - -class PartiesRoute extends React.Component { - state: State - - constructor(props: any) { - super(props) - this.state = { - parties: [] - } - } - - getParties() { - fetch('http://localhost:3001/parties/') - .then(response => response.json()) - .then(parties => this.setState({ - parties: parties - })) - } - - render() { - this.getParties() - const items = this.state.parties.map((party: {id: string, hash: string }) => -
  • {party.hash}
  • - ) - return ( -
    -

    A list of parties

    - -
    - ) - } -} - -export default PartiesRoute \ No newline at end of file diff --git a/routes/ProfileRoute/index.tsx b/routes/ProfileRoute/index.tsx deleted file mode 100644 index b199ac1f..00000000 --- a/routes/ProfileRoute/index.tsx +++ /dev/null @@ -1,132 +0,0 @@ -import React, { useEffect, useState } from 'react' -import { withCookies, useCookies } from 'react-cookie' -import { useParams, useNavigate } from 'react-router-dom' -import api from '~utils/api' - -import GridRep from '~components/GridRep' -import GridRepCollection from '~components/GridRepCollection' -import { composeInitialProps } from 'react-i18next' - -interface Props { - username: string -} - -interface User { - id: string - username: string - granblueId: number -} - -interface Party { - id: string - shortcode: string - weapons: GridWeapon[] -} - -const ProfileRoute: React.FC = () => { - const params = useParams() - const navigate = useNavigate() - - const [cookies, setCookie] = useCookies(['user']) - - const [found, setFound] = useState(false) - const [loading, setLoading] = useState(true) - const [parties, setParties] = useState([]) - const [user, setUser] = useState({ - id: '', - username: '', - granblueId: 0 - }) - - const username = params.username || '' - - useEffect(() => { - console.log(`Fetching profile for ${username}...`) - fetchProfile(username) - }, []) - - async function fetchProfile(username: string) { - api.endpoints.users.getOne({ id: username }) - .then(response => { - setUser({ - id: response.data.user.id, - username: response.data.user.username, - granblueId: response.data.user.granblue_id - }) - setParties(response.data.user.parties) - }) - .then(() => { - setFound(true) - setLoading(false) - }) - .catch(error => { - if (error.response != null) { - if (error.response.status == 404) { - setFound(false) - } - } else { - console.error(error) - } - }) - } - - function render() { - const content = (parties && parties.length > 0) ? renderGrids() : renderNoGrids() - return ( -
    -

    {user.username}

    - {content} -
    - ) - } - - function goTo(shortcode: string) { - navigate(`/p/${shortcode}`) - } - - function renderGrids() { - return ( - - { - parties.map((party, i) => { - return - }) - } - - ) - } - - function renderNoGrids() { - return ( -
    -

    This user has no grids.

    -
    - ) - } - - function renderNotFound() { - return ( -
    -

    That user doesn't exist.

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