Skip to content

Commit d5c0bcc

Browse files
authored
Merge pull request #46 from TaloDev/develop
Release 0.12.0
2 parents dac7c7d + 2a8f153 commit d5c0bcc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1688
-1458
lines changed

.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
TAILWIND_DISABLE_TOUCH=true
22

3-
SNOWPACK_PUBLIC_API_URL=http://localhost:3000/
3+
SNOWPACK_PUBLIC_API_URL=http://localhost:3000
44

55
SNOWPACK_PUBLIC_SENTRY_DSN=
66
SNOWPACK_PUBLIC_SENTRY_ENV=dev

.env.production

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
SNOWPACK_PUBLIC_API_URL=${API_URL}
22

3-
SNOWPACK_PUBLIC_SENTRY_DSN=https://b857733793ac4aacb2b7c5d36873a1ba@o406248.ingest.sentry.io/5273330
3+
SNOWPACK_PUBLIC_SENTRY_DSN=${SENTRY_DSN}
44
SNOWPACK_PUBLIC_SENTRY_ENV=prod

jest.setup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import '@testing-library/jest-dom'
22

33
// eslint-disable-next-line no-undef
4-
process.env.SNOWPACK_PUBLIC_API_URL = 'http://talo.test/'
4+
process.env.SNOWPACK_PUBLIC_API_URL = 'http://talo.test'

package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,28 @@
99
"dependencies": {
1010
"@hookform/resolvers": "^2.8.8",
1111
"@sentry/react": "^6.19.6",
12-
"@tabler/icons": "^1.60.0",
12+
"@tabler/icons": "^1.68.0",
1313
"@tippyjs/react": "^4.2.5",
1414
"axios": "^0.26.0",
1515
"classnames": "^2.3.1",
1616
"date-fns": "^2.21.3",
17-
"framer-motion": "^4.1.16",
18-
"lodash.isequal": "^4.5.0",
17+
"framer-motion": "^6.3.3",
1918
"lodash.uniqby": "^4.7.0",
2019
"prop-types": "^15.7.2",
2120
"querystring": "^0.2.1",
2221
"randomcolor": "^0.6.2",
2322
"react": "^17.0.2",
2423
"react-dom": "^17.0.2",
2524
"react-focus-lock": "^2.8.1",
26-
"react-hook-form": "^7.28.1",
25+
"react-hook-form": "^7.31.2",
2726
"react-required-if": "^1.0.3",
2827
"react-resize-detector": "^6.7.1",
29-
"react-router-dom": "^5.2.0",
28+
"react-router-dom": "^6.3.0",
3029
"react-select": "^5.2.1",
3130
"recharts": "^2.0.9",
32-
"recoil": "^0.2.0",
31+
"recoil": "0.7.2",
3332
"spinners-react": "^1.0.6",
34-
"swr": "^1.0.1",
33+
"swr": "^1.3.0",
3534
"use-debounce": "^7.0.1",
3635
"yup": "^0.32.11"
3736
},
@@ -66,5 +65,5 @@
6665
"lint-staged": {
6766
"*.{js,jsx}": "eslint --fix"
6867
},
69-
"version": "0.11.1"
68+
"version": "0.12.0"
7069
}

postcss.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// eslint-disable-next-line no-undef
22
module.exports = {
33
plugins: {
4+
'postcss-nesting': {},
45
tailwindcss: {},
5-
autoprefixer: {},
6-
'postcss-nesting': {}
6+
autoprefixer: {}
77
}
88
}

src/App.jsx

Lines changed: 18 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,25 @@
1-
import React, { useState, useEffect, lazy, Suspense } from 'react'
2-
import { Redirect, Route, Switch, useHistory } from 'react-router-dom'
1+
import React, { useState, useEffect, Suspense } from 'react'
2+
import { useNavigate } from 'react-router-dom'
33
import * as Sentry from '@sentry/react'
4-
import { useRecoilState, useRecoilValue } from 'recoil'
4+
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
55
import refreshAccess from './api/refreshAccess'
66
import userState from './state/userState'
77
import Loading from './components/Loading'
8-
import NavBar from './components/NavBar'
9-
import routes from './constants/routes'
108
import gamesState from './state/gamesState'
119
import activeGameState from './state/activeGameState'
1210
import AuthService from './services/AuthService'
13-
import canViewPage from './utils/canViewPage'
14-
import GlobalBanners from './components/GlobalBanners'
11+
import Router from './Router'
1512

16-
const Login = lazy(() => import(/* webpackChunkName: 'login' */ './pages/Login'))
17-
const Dashboard = lazy(() => import(/* webpackChunkName: 'dashboard' */ './pages/Dashboard'))
18-
const Events = lazy(() => import(/* webpackChunkName: 'events' */ './pages/Events'))
19-
const Players = lazy(() => import(/* webpackChunkName: 'players' */ './pages/Players'))
20-
const Register = lazy(() => import(/* webpackChunkName: 'register' */ './pages/Register'))
21-
const PlayerProps = lazy(() => import(/* webpackChunkName: 'player-props' */ './pages/PlayerProps'))
22-
const APIKeys = lazy(() => import(/* webpackChunkName: 'api-keys' */ './pages/APIKeys'))
23-
const PlayerEvents = lazy(() => import(/* webpackChunkName: 'player-events' */ './pages/PlayerEvents'))
24-
const Demo = lazy(() => import(/* webpackChunkName: 'demo' */ './pages/Demo'))
25-
const DataExports = lazy(() => import(/* webpackChunkName: 'data-exports' */ './pages/DataExports'))
26-
const Leaderboards = lazy(() => import(/* webpackChunkName: 'leaderboards' */ './pages/Leaderboards'))
27-
const LeaderboardEntries = lazy(() => import(/* webpackChunkName: 'leaderboard-entries' */ './pages/LeaderboardEntries'))
28-
const Account = lazy(() => import(/* webpackChunkName: 'account' */ './pages/Account'))
29-
const ConfirmPassword = lazy(() => import(/* webpackChunkName: 'confirm-password' */ './pages/ConfirmPassword'))
30-
const Verify2FA = lazy(() => import(/* webpackChunkName: 'verify-2FA' */ './pages/Verify2FA'))
31-
const RecoverAccount = lazy(() => import(/* webpackChunkName: 'recover-account' */ './pages/RecoverAccount'))
32-
const Activity = lazy(() => import(/* webpackChunkName: 'activity' */ './pages/Activity'))
33-
const Stats = lazy(() => import(/* webpackChunkName: 'stats' */ './pages/Stats'))
34-
const PlayerStats = lazy(() => import(/* webpackChunkName: 'player-stats' */ './pages/PlayerStats'))
35-
const AcceptInvite = lazy(() => import(/* webpackChunkName: 'accept-invite' */ './pages/AcceptInvite'))
36-
const Organisation = lazy(() => import(/* webpackChunkName: 'organisation' */ './pages/Organisation'))
13+
function AppLoading() {
14+
return (
15+
<main className='w-full flex items-center justify-center'>
16+
<Loading />
17+
</main>
18+
)
19+
}
3720

38-
const App = () => {
39-
const [user, setUser] = useRecoilState(userState)
21+
function App() {
22+
const setUser = useSetRecoilState(userState)
4023

4124
const [isRefreshing, setRefreshing] = useState(true)
4225
const [hasTriedRefreshing, setTriedRefreshing] = useState(false)
@@ -45,7 +28,7 @@ const App = () => {
4528
const games = useRecoilValue(gamesState)
4629
const [activeGame, setActiveGame] = useRecoilState(activeGameState)
4730

48-
const history = useHistory()
31+
const navigate = useNavigate()
4932

5033
const handleRefreshSession = async () => {
5134
try {
@@ -72,72 +55,20 @@ const App = () => {
7255
if (!hasTriedRefreshing && intendedUrl) {
7356
handleRefreshSession()
7457
} else if (hasTriedRefreshing) {
75-
history.replace(intendedUrl)
58+
navigate(intendedUrl, { replace: true })
7659
}
7760
}, [intendedUrl, hasTriedRefreshing])
7861

7962
useEffect(() => {
8063
if (!activeGame && games.length > 0) setActiveGame(games[0])
8164
}, [activeGame, games])
8265

83-
const appLoading = (
84-
<main className='w-full flex items-center justify-center'>
85-
<Loading />
86-
</main>
87-
)
8866

89-
if (isRefreshing) return appLoading
67+
if (isRefreshing) return <AppLoading />
9068

9169
return (
92-
<Suspense fallback={appLoading}>
93-
{!AuthService.getToken() &&
94-
<main className='bg-gray-800 w-full'>
95-
<Switch>
96-
<Route exact path={routes.login} component={Login} />
97-
<Route exact path={routes.register} component={Register} />
98-
<Route exact path={routes.demo} component={Demo} />
99-
<Route exact path={routes.verify2FA} component={Verify2FA} />
100-
<Route exact path={routes.recover} component={RecoverAccount} />
101-
<Route exact path={routes.acceptInvite} component={AcceptInvite} />
102-
103-
<Redirect to={`${routes.login}?next=${intendedUrl}`} />
104-
</Switch>
105-
</main>
106-
}
107-
108-
{AuthService.getToken() &&
109-
<div className='w-full flex flex-col'>
110-
<NavBar />
111-
<main className='bg-gray-800 p-4 md:p-8 text-white'>
112-
<GlobalBanners />
113-
114-
<Switch>
115-
<Route exact path={routes.dashboard} component={Dashboard} />
116-
<Route exact path={routes.account} component={Account} />
117-
<Route exact path={routes.confirmPassword} component={ConfirmPassword} />
118-
{canViewPage(user, routes.organisation) && <Route exact path={routes.organisation} component={Organisation} />}
119-
120-
{activeGame &&
121-
<>
122-
<Route exact path={routes.players} component={Players} />
123-
<Route exact path={routes.events} component={Events} />
124-
{canViewPage(user, routes.apiKeys) && <Route exact path={routes.apiKeys} component={APIKeys} />}
125-
<Route exact path={routes.playerProps} component={PlayerProps} />
126-
<Route exact path={routes.playerEvents} component={PlayerEvents} />
127-
{canViewPage(user, routes.dataExports) && <Route exact path={routes.dataExports} component={DataExports} />}
128-
<Route exact path={routes.leaderboards} component={Leaderboards} />
129-
<Route exact path={routes.leaderboardEntries} component={LeaderboardEntries} />
130-
{canViewPage(user, routes.activity) && <Route exact path={routes.activity} component={Activity} />}
131-
<Route exact path={routes.stats} component={Stats} />
132-
<Route exact path={routes.playerStats} component={PlayerStats} />
133-
</>
134-
}
135-
136-
<Redirect to={routes.dashboard} />
137-
</Switch>
138-
</main>
139-
</div>
140-
}
70+
<Suspense fallback={<AppLoading />}>
71+
<Router intendedUrl={intendedUrl} />
14172
</Suspense>
14273
)
14374
}

src/Router.jsx

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import React, { lazy } from 'react'
2+
import PropTypes from 'prop-types'
3+
import { Navigate, Route, Routes } from 'react-router-dom'
4+
import { useRecoilValue } from 'recoil'
5+
import userState from './state/userState'
6+
import NavBar from './components/NavBar'
7+
import routes from './constants/routes'
8+
import activeGameState from './state/activeGameState'
9+
import AuthService from './services/AuthService'
10+
import canViewPage from './utils/canViewPage'
11+
12+
const Login = lazy(() => import(/* webpackChunkName: 'login' */ './pages/Login'))
13+
const Dashboard = lazy(() => import(/* webpackChunkName: 'dashboard' */ './pages/Dashboard'))
14+
const Events = lazy(() => import(/* webpackChunkName: 'events' */ './pages/Events'))
15+
const Players = lazy(() => import(/* webpackChunkName: 'players' */ './pages/Players'))
16+
const Register = lazy(() => import(/* webpackChunkName: 'register' */ './pages/Register'))
17+
const PlayerProps = lazy(() => import(/* webpackChunkName: 'player-props' */ './pages/PlayerProps'))
18+
const APIKeys = lazy(() => import(/* webpackChunkName: 'api-keys' */ './pages/APIKeys'))
19+
const PlayerEvents = lazy(() => import(/* webpackChunkName: 'player-events' */ './pages/PlayerEvents'))
20+
const Demo = lazy(() => import(/* webpackChunkName: 'demo' */ './pages/Demo'))
21+
const DataExports = lazy(() => import(/* webpackChunkName: 'data-exports' */ './pages/DataExports'))
22+
const Leaderboards = lazy(() => import(/* webpackChunkName: 'leaderboards' */ './pages/Leaderboards'))
23+
const LeaderboardEntries = lazy(() => import(/* webpackChunkName: 'leaderboard-entries' */ './pages/LeaderboardEntries'))
24+
const Account = lazy(() => import(/* webpackChunkName: 'account' */ './pages/Account'))
25+
const ConfirmPassword = lazy(() => import(/* webpackChunkName: 'confirm-password' */ './pages/ConfirmPassword'))
26+
const Verify2FA = lazy(() => import(/* webpackChunkName: 'verify-2FA' */ './pages/Verify2FA'))
27+
const RecoverAccount = lazy(() => import(/* webpackChunkName: 'recover-account' */ './pages/RecoverAccount'))
28+
const Activity = lazy(() => import(/* webpackChunkName: 'activity' */ './pages/Activity'))
29+
const Stats = lazy(() => import(/* webpackChunkName: 'stats' */ './pages/Stats'))
30+
const PlayerStats = lazy(() => import(/* webpackChunkName: 'player-stats' */ './pages/PlayerStats'))
31+
const AcceptInvite = lazy(() => import(/* webpackChunkName: 'accept-invite' */ './pages/AcceptInvite'))
32+
const Organisation = lazy(() => import(/* webpackChunkName: 'organisation' */ './pages/Organisation'))
33+
34+
function Router({ intendedUrl }) {
35+
const user = useRecoilValue(userState)
36+
const activeGame = useRecoilValue(activeGameState)
37+
38+
return (
39+
<>
40+
{!AuthService.getToken() &&
41+
<main className='bg-gray-800 w-full'>
42+
<Routes>
43+
<Route exact path={routes.login} element={<Login />} />
44+
<Route exact path={routes.register} element={<Register />} />
45+
<Route exact path={routes.demo} element={<Demo />} />
46+
<Route exact path={routes.verify2FA} element={<Verify2FA />} />
47+
<Route exact path={routes.recover} element={<RecoverAccount />} />
48+
<Route exact path={routes.acceptInvite} element={<AcceptInvite />} />
49+
50+
<Route path='*' element={<Navigate to={`${routes.login}?next=${intendedUrl}`} replace />} />
51+
</Routes>
52+
</main>
53+
}
54+
55+
{AuthService.getToken() &&
56+
<div className='w-full flex flex-col'>
57+
<NavBar />
58+
<main className='bg-gray-800 p-4 md:p-8 text-white'>
59+
<Routes>
60+
<Route exact path={routes.dashboard} element={<Dashboard />} />
61+
<Route exact path={routes.account} element={<Account />} />
62+
<Route exact path={routes.confirmPassword} element={<ConfirmPassword />} />
63+
{canViewPage(user, routes.organisation) && <Route exact path={routes.organisation} element={<Organisation />} />}
64+
65+
{activeGame &&
66+
<>
67+
<Route exact path={routes.players} element={<Players />} />
68+
<Route exact path={routes.events} element={<Events />} />
69+
{canViewPage(user, routes.apiKeys) && <Route exact path={routes.apiKeys} element={<APIKeys />} />}
70+
<Route exact path={routes.playerProps} element={<PlayerProps />} />
71+
<Route exact path={routes.playerEvents} element={<PlayerEvents />} />
72+
{canViewPage(user, routes.dataExports) && <Route exact path={routes.dataExports} element={<DataExports />} />}
73+
<Route exact path={routes.leaderboards} element={<Leaderboards />} />
74+
<Route exact path={routes.leaderboardEntries} element={<LeaderboardEntries />} />
75+
{canViewPage(user, routes.activity) && <Route exact path={routes.activity} element={<Activity />} />}
76+
<Route exact path={routes.stats} element={<Stats />} />
77+
<Route exact path={routes.playerStats} element={<PlayerStats />} />
78+
</>
79+
}
80+
81+
<Route path='*' element={<Navigate to={routes.dashboard} replace />} />
82+
</Routes>
83+
</main>
84+
</div>
85+
}
86+
</>
87+
)
88+
}
89+
90+
Router.propTypes = {
91+
intendedUrl: PropTypes.string
92+
}
93+
94+
export default Router

src/api/useLeaderboardEntries.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const useLeaderboardEntries = (id, page) => {
1212
}
1313

1414
const { data, error, mutate } = useSWR(
15-
[`leaderboards/${id}/entries`, page],
15+
[`/leaderboards/${id}/entries`, page],
1616
fetcher
1717
)
1818

src/api/useLeaderboards.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const useLeaderboards = (activeGame) => {
1212
}
1313

1414
const { data, error, mutate } = useSWR(
15-
['leaderboards', activeGame],
15+
['/leaderboards', activeGame],
1616
fetcher
1717
)
1818

src/api/useOrganisation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const useOrganisation = () => {
99
}
1010

1111
const { data, error, mutate } = useSWR(
12-
'organisations/current',
12+
'/organisations/current',
1313
fetcher
1414
)
1515

0 commit comments

Comments
 (0)