Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Moitié committed Mar 11, 2024
2 parents 6df45e1 + 8420340 commit 2b800fd
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 117 deletions.
12 changes: 12 additions & 0 deletions build/api/getCarClasses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { clientGet } from './iracingClient';

// Only used to help get Ring Meister / Draftmaster in check
export default async function getCarClasses() {
const carClassResponse = await clientGet('/data/carclass/get');
return carClassResponse.data.map((carClass) => ({
id: carClass.id,
cars_in_class: carClass.cars_in_class,
name: carClass.car_name,
short_name: carClass.short_name,
}));
}
7 changes: 7 additions & 0 deletions build/scrape.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import getContributors from './api/getContributors';
import getCars from './api/getCars';
import getTracks from './api/getTracks';
import getSeason from './api/getSeason';
import getCarClasses from './api/getCarClasses';

(async () => {
const username = process.env.IWP_USERNAME || 'test';
Expand Down Expand Up @@ -33,4 +34,10 @@ import getSeason from './api/getSeason';
path.join(__dirname, '../src/data/contributors.json'),
JSON.stringify(contributors, null, 2),
);

const carClasses = await getCarClasses();
await writeFile(
path.join(__dirname, '../src/data/car-class.json'),
JSON.stringify(carClasses, null, 2),
);
})();
28 changes: 17 additions & 11 deletions src/components/columns/Car.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as React from 'react';
import classnames from 'classnames';
import intersection from 'lodash.intersection';
import { useTranslation } from 'react-i18next';
import StarIcon from '../icon/StarIcon';
import CarModal from '../modal/CarModal';

Expand All @@ -21,33 +22,38 @@ type Props = {

export default function Car({ race, favouriteCars, ownedCars }: Props) {
const [modalOpen, setModalOpen] = React.useState(false);
const { t } = useTranslation();

const openModal = () => {
setModalOpen(true);
};

const knownCar = race.carIds[0] !== null;

return (
<>
<ClickableCell
className={classnames({
[styles.success]: intersection(ownedCars, race.carIds).length !== 0,
[styles.success]: knownCar ? intersection(ownedCars, race.carIds).length !== 0 : false,
})}
onClick={openModal}
>
{intersection(favouriteCars, race.carIds).length !== 0 ? (
{knownCar && intersection(favouriteCars, race.carIds).length !== 0 ? (
<StarIcon />
) : null}
<span> </span>
{race.carClasses.join(', ')}
{knownCar ? race.carClasses.join(', ') : t('Unknown')}
</ClickableCell>
<CarModal
isOpen={modalOpen}
onClose={() => setModalOpen(false)}
ownedCars={ownedCars}
favouriteCars={favouriteCars}
carIds={race.carIds}
seriesName={race.series}
/>
{knownCar ? (
<CarModal
isOpen={modalOpen}
onClose={() => setModalOpen(false)}
ownedCars={ownedCars}
favouriteCars={favouriteCars}
carIds={race.carIds}
seriesName={race.series}
/>
) : null}
</>
);
}
6 changes: 4 additions & 2 deletions src/components/modal/SeriesModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export default function SeriesModal({ onClose, ownedTracks, ownedCars, isOpen, s
.subtract(1, 'days')
.toDate();

const knownCar = race.carIds[0] !== null;

return (
<tr key={race.week} style={current ? { fontWeight: 700 } : {}}>
<td>
Expand All @@ -80,10 +82,10 @@ export default function SeriesModal({ onClose, ownedTracks, ownedCars, isOpen, s
{showCar ? (
<td
className={classnames({
[styles.success]: intersection(ownedCars, race.carIds).length !== 0,
[styles.success]: knownCar ? intersection(ownedCars, race.carIds).length !== 0 : null,
})}
>
{race.carClasses.join(', ')}
{knownCar ? race.carClasses.join(', ') : t('Unknown')}
</td>
) : null}
<td>
Expand Down
6 changes: 3 additions & 3 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import moment from 'moment';

export const seasonStart = moment('2023-12-12T00:00:00+00:00').utc();
export const seasonEnd = moment('2024-03-11T00:00:00+00:00').utc();
export const weekSeasonStart = moment('2023-12-12T00:00:00+00:00').utc();
export const seasonStart = moment('2024-03-12T00:00:00+00:00').utc();
export const seasonEnd = moment('2024-06-10T00:00:00+00:00').utc();
export const weekSeasonStart = moment('2024-03-12T00:00:00+00:00').utc();

export const firebaseConfig = {
apiKey: 'AIzaSyAWNRqHLhhvhzKl0gkKybocd0nAk2eTlVg',
Expand Down
5 changes: 5 additions & 0 deletions src/data/changelog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import moment from 'moment';

export default [{
date: moment('2024-03-12 00:00:00').utc(),
items: [
'Update to 2024S2',
],
}, {
date: moment('2024-03-06 00:00:00').utc(),
items: [
'Update with new categories',
Expand Down
Loading

0 comments on commit 2b800fd

Please sign in to comment.