Skip to content

Commit fcdfb79

Browse files
authored
Merge pull request #48 from TaloDev/develop
Release 0.13.0
2 parents d5c0bcc + 7f2ff57 commit fcdfb79

Some content is hidden

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

44 files changed

+1816
-50
lines changed

jest.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ module.exports = {
33
...require('@snowpack/app-scripts-react/jest.config.js')(),
44
collectCoverage: true,
55
coverageReporters: ['lcov'],
6-
coveragePathIgnorePatterns: ['/node_modules/', '/*/_snowpack/*/', '/*/api/*/', '/*/constants/*/']
6+
coveragePathIgnorePatterns: ['/node_modules/', '/*/_snowpack/*/', '/*/api/*/', '/*/constants/*/'],
7+
transformIgnorePatterns: [
8+
'<rootDir>/node_modules/(?!lodash-es)'
9+
]
710
}

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77
"lint": "eslint src/**/*.{js,jsx}"
88
},
99
"dependencies": {
10+
"@dinero.js/currencies": "^2.0.0-alpha.8",
1011
"@hookform/resolvers": "^2.8.8",
1112
"@sentry/react": "^6.19.6",
1213
"@tabler/icons": "^1.68.0",
1314
"@tippyjs/react": "^4.2.5",
1415
"axios": "^0.26.0",
1516
"classnames": "^2.3.1",
1617
"date-fns": "^2.21.3",
18+
"dinero.js": "^2.0.0-alpha.8",
1719
"framer-motion": "^6.3.3",
18-
"lodash.uniqby": "^4.7.0",
20+
"lodash-es": "^4.17.21",
1921
"prop-types": "^15.7.2",
2022
"querystring": "^0.2.1",
2123
"randomcolor": "^0.6.2",
@@ -65,5 +67,5 @@
6567
"lint-staged": {
6668
"*.{js,jsx}": "eslint --fix"
6769
},
68-
"version": "0.12.0"
70+
"version": "0.13.0"
6971
}

src/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function App() {
4848
}
4949

5050
useEffect(() => {
51-
setIntendedUrl(window.location.pathname)
51+
setIntendedUrl(window.location.pathname + window.location.search)
5252
}, [])
5353

5454
useEffect(() => {

src/Router.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const Stats = lazy(() => import(/* webpackChunkName: 'stats' */ './pages/Stats')
3030
const PlayerStats = lazy(() => import(/* webpackChunkName: 'player-stats' */ './pages/PlayerStats'))
3131
const AcceptInvite = lazy(() => import(/* webpackChunkName: 'accept-invite' */ './pages/AcceptInvite'))
3232
const Organisation = lazy(() => import(/* webpackChunkName: 'organisation' */ './pages/Organisation'))
33+
const Billing = lazy(() => import(/* webpackChunkName: 'billing' */ './pages/Billing'))
3334

3435
function Router({ intendedUrl }) {
3536
const user = useRecoilValue(userState)
@@ -47,7 +48,7 @@ function Router({ intendedUrl }) {
4748
<Route exact path={routes.recover} element={<RecoverAccount />} />
4849
<Route exact path={routes.acceptInvite} element={<AcceptInvite />} />
4950

50-
<Route path='*' element={<Navigate to={`${routes.login}?next=${intendedUrl}`} replace />} />
51+
<Route path='*' element={<Navigate to={`${routes.login}?next=${encodeURIComponent(intendedUrl)}`} replace />} />
5152
</Routes>
5253
</main>
5354
}
@@ -61,6 +62,7 @@ function Router({ intendedUrl }) {
6162
<Route exact path={routes.account} element={<Account />} />
6263
<Route exact path={routes.confirmPassword} element={<ConfirmPassword />} />
6364
{canViewPage(user, routes.organisation) && <Route exact path={routes.organisation} element={<Organisation />} />}
65+
{canViewPage(user, routes.billing) && <Route exact path={routes.billing} element={<Billing />} />}
6466

6567
{activeGame &&
6668
<>

src/api/confirmPlan.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import api from './api'
2+
3+
export default (prorationDate, pricingPlanId, pricingInterval) => api.post('/billing/confirm-plan', { prorationDate, pricingPlanId, pricingInterval })

src/api/createCheckoutSession.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import api from './api'
2+
3+
export default (pricingPlanId, pricingInterval) => api.post('/billing/checkout-session', { pricingPlanId, pricingInterval })

src/api/createPortalSession.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import api from './api'
2+
3+
export default () => api.post('/billing/portal-session')
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import useSWR from 'swr'
2+
import buildError from '../utils/buildError'
3+
import api from './api'
4+
5+
const useOrganisationPricingPlan = () => {
6+
const fetcher = async (url) => {
7+
const res = await api.get(url)
8+
return res.data
9+
}
10+
11+
const { data, error } = useSWR(
12+
'/billing/organisation-plan',
13+
fetcher
14+
)
15+
16+
return {
17+
plan: data?.pricingPlan ?? {},
18+
loading: !data && !error,
19+
error: error && buildError(error)
20+
}
21+
}
22+
23+
export default useOrganisationPricingPlan

src/api/usePricingPlanUsage.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import useSWR from 'swr'
2+
import buildError from '../utils/buildError'
3+
import api from './api'
4+
5+
const usePricingPlanUsage = () => {
6+
const fetcher = async (url) => {
7+
const res = await api.get(url)
8+
return res.data
9+
}
10+
11+
const { data, error } = useSWR(
12+
'/billing/usage',
13+
fetcher
14+
)
15+
16+
return {
17+
usage: data?.usage ?? {},
18+
loading: !data && !error,
19+
error: error && buildError(error)
20+
}
21+
}
22+
23+
export default usePricingPlanUsage

src/api/usePricingPlans.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import useSWR from 'swr'
2+
import buildError from '../utils/buildError'
3+
import api from './api'
4+
5+
const usePricingPlans = () => {
6+
const fetcher = async (url) => {
7+
const res = await api.get(url)
8+
return res.data
9+
}
10+
11+
const { data, error } = useSWR(
12+
'/billing/plans',
13+
fetcher
14+
)
15+
16+
return {
17+
plans: data?.pricingPlans ?? [],
18+
loading: !data && !error,
19+
error: error && buildError(error)
20+
}
21+
}
22+
23+
export default usePricingPlans

0 commit comments

Comments
 (0)