Skip to content

Commit 8fad344

Browse files
committed
Merge branch 'wca-group-generators' into beta
2 parents deb3f6c + 28c85ea commit 8fad344

57 files changed

Lines changed: 890 additions & 6739 deletions

Some content is hidden

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

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
REACT_APP_VERSION=$npm_package_version
1+
VITE_WCA_ORIGIN=https://staging.worldcubeassociation.org

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
npm run lint && CI=true npm test
4+
CI=true npm test

public/index.html renamed to index.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
5+
<link rel="icon" href="/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<meta name="theme-color" content="#3997b0" />
88
<meta
@@ -13,13 +13,14 @@
1313
manifest.json provides metadata used when your web app is installed on a
1414
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
1515
-->
16-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
16+
<link rel="manifest" href="/manifest.json" />
17+
1718
<!--
1819
Notice the use of %PUBLIC_URL% in the tags above.
1920
It will be replaced with the URL of the `public` folder during the build.
2021
Only files inside the `public` folder can be referenced from the HTML.
2122
22-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
23+
Unlike "/favicon.ico" or "favicon.ico", "/favicon.ico" will
2324
work correctly both with client-side routing and a non-root public URL.
2425
Learn how to configure a non-root public URL by running `npm run build`.
2526
-->
@@ -42,6 +43,8 @@
4243
</head>
4344
<body>
4445
<noscript>You need to enable JavaScript to run this app.</noscript>
46+
<script type="module" src="/src/index.tsx"></script>
47+
4548
<div id="root"></div>
4649
<!--
4750
This HTML file is a template.

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
"@types/react-dom": "^18.0.6",
2222
"@typescript-eslint/eslint-plugin": "^5.39.0",
2323
"@typescript-eslint/parser": "^5.39.0",
24+
"@vitejs/plugin-react": "^4.0.4",
2425
"@wca/helpers": "^1.1.5",
2526
"clsx": "^1.1.1",
27+
"country-flag-icons": "^1.5.7",
2628
"date-fns": "^2.30.0",
2729
"export-to-csv": "^0.2.1",
2830
"fuse.js": "^6.6.2",
@@ -40,20 +42,23 @@
4042
"react-papaparse": "^4.1.0",
4143
"react-redux": "^7.2.6",
4244
"react-router-dom": "^6.2.1",
43-
"react-scripts": "5.0.0",
4445
"react-transition-group": "^4.4.5",
4546
"redux": "^4.1.2",
4647
"redux-thunk": "^2.4.1",
4748
"reselect": "^4.1.6",
4849
"typescript": "^4.8.4",
50+
"vite": "^4.4.9",
51+
"vite-plugin-pwa": "^0.16.4",
52+
"vite-plugin-svgr": "^3.2.0",
53+
"vite-tsconfig-paths": "^4.2.0",
4954
"wca-group-generators": "^0.1.1",
5055
"web-vitals": "^2.1.4"
5156
},
5257
"scripts": {
53-
"start": "REACT_APP_GIT_SHA=`git rev-parse --short HEAD` GENERATE_SOURCEMAP=false react-scripts start",
54-
"build": "REACT_APP_GIT_SHA=`git rev-parse --short HEAD` react-scripts build",
58+
"start": "VITE_GIT_SHA=`git rev-parse --short HEAD` GENERATE_SOURCEMAP=false vite",
59+
"build": "VITE_GIT_SHA=`git rev-parse --short HEAD` tsc && vite build",
5560
"lint": "eslint ./",
56-
"test": "react-scripts test --passWithNoTests",
61+
"test": "npm run lint",
5762
"prepare": "husky install",
5863
"prettier": "prettier \"src/**/*.js\" --write"
5964
},
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import React from 'react';
1+
import { makeStyles } from '@material-ui/core';
22
import { Divider } from '@mui/material';
33
import Grid from '@mui/material/Grid';
44
import Link from '@mui/material/Link';
55
import Typography from '@mui/material/Typography';
66
import grey from '@mui/material/colors/grey';
7-
import { makeStyles } from '@mui/styles';
87
import { WCA_ORIGIN } from '../lib/wca-env';
98

109
const useStyles = makeStyles((theme) => ({
@@ -29,8 +28,8 @@ const links = [
2928
{ text: 'GitHub', url: 'https://github.com/coder13/delegateDashboard' },
3029
{ text: 'Contact', url: 'mailto:choover11@gmail.com' },
3130
{
32-
text: `${process.env.REACT_APP_GIT_SHA}`,
33-
url: `https://github.com/coder13/delegateDashboard/commit/${process.env.REACT_APP_GIT_SHA}`,
31+
text: `${import.meta.env.VITE_GIT_SHA}`,
32+
url: `https://github.com/coder13/delegateDashboard/commit/${import.meta.env.VITE_GIT_SHA}`,
3433
},
3534
];
3635

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { Outlet } from 'react-router-dom';
32
import { Alert, AlertTitle } from '@mui/material';
43
import { styled } from '@mui/system';
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React from 'react';
2-
import { Routes, Route, Outlet, Navigate } from 'react-router-dom';
1+
import { Routes, Route, Outlet, Navigate, useNavigate, useParams } from 'react-router-dom';
2+
import usePageTracking from '../hooks/usePageTracking';
33
import {
44
Layout as CompetitionLayout,
55
Home as CompetitionHomePage,
@@ -42,7 +42,7 @@ const Comp404 = () => {
4242
};
4343

4444
const Navigation = () => {
45-
// usePageTracking(process.env.REACT_APP_GA_MEASUREMENT_ID);
45+
usePageTracking(import.meta.env.VITE_GA_MEASUREMENT_ID);
4646

4747
return (
4848
<Routes>

src/App/index.js renamed to src/App/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect } from 'react';
1+
import { useEffect } from 'react';
22
import { useDispatch } from 'react-redux';
33
import { useAuth } from '../providers/AuthProvider';
44
import { fetchCompetitions } from '../store/actions';
File renamed without changes.

src/components/CompetitionSummaryCard.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
import { Competition } from '@wca/helpers';
2-
import { intlFormat } from 'date-fns';
2+
import { useMemo } from 'react';
33
import { useSelector } from 'react-redux';
44
import { Card, CardContent, Typography } from '@mui/material';
55
import { shortEventNameById } from '../lib/events';
66
import { acceptedRegistrations } from '../lib/persons';
7-
import { pluralize } from '../lib/utils';
87

98
export default function CompetitionSummary() {
109
const wcif = useSelector((state: { wcif: Competition }) => state.wcif);
1110
const approvedRegistrations = acceptedRegistrations(wcif.persons);
1211

13-
const formattedDate = intlFormat(new Date(wcif.schedule.startDate), {
14-
weekday: 'short',
15-
year: 'numeric',
16-
month: 'short',
17-
day: 'numeric',
18-
});
12+
const startDate = useMemo(() => {
13+
const start = new Date(wcif.schedule.startDate);
14+
start.setHours(start.getHours() + new Date().getTimezoneOffset() / 60);
15+
return start;
16+
}, [wcif]);
17+
18+
const endDate = useMemo(() => {
19+
if (wcif.schedule.numberOfDays <= 1) return undefined;
20+
21+
const end = new Date(wcif.schedule.startDate);
22+
end.setDate(startDate.getDate() + wcif.schedule.numberOfDays);
23+
return end;
24+
}, [startDate, wcif.schedule.numberOfDays, wcif.schedule.startDate]);
1925

2026
return (
2127
<Card>
@@ -25,15 +31,17 @@ export default function CompetitionSummary() {
2531
</Typography>
2632
<Typography>
2733
<b>Date: </b>
28-
{formattedDate} ({pluralize(wcif.schedule.numberOfDays, 'day', 'days')})
34+
{startDate.toLocaleDateString()}
35+
{endDate ? ` - ${endDate.toLocaleDateString()}` : ''}
2936
</Typography>
3037
<Typography>
3138
<b>Competitors: </b>
3239
{approvedRegistrations.length}
3340
</Typography>
3441
<Typography>
3542
<b>Events: </b>
36-
{wcif.events.map((event) => shortEventNameById(event.id)).join(', ')}
43+
{wcif.events.map((event) => shortEventNameById(event.id)).join(', ')} (
44+
{wcif.events.length})
3745
</Typography>
3846
</CardContent>
3947
</Card>

0 commit comments

Comments
 (0)