ISSUE-032 - Progress checkpoint. Have a working "selectedCars" modifying component named GridSelection.
Have a work-in-progress AngledFlag prototype controller that relying on a central state property in the Workspaces portion of the store. It's a bit hacky. But it made me realize that my desire to do silly things with extending interfaces won't work that way I'm going to need to rely on them in the future. I cannot demand more specific data from a state that uses a less specific interface. Rookie mistake. I am also at the mercy of a design flaw when it comes to using React Hooks: The way I organize Workspaces makes React very angry. When I switch between workspaces that rely on hooks to render correctly the whole thing explodes. I believe I need to use components directly to correctly unmount - instead of the very hacky switch statement I have in the form of fetchBroadcastGraphic(). I might need to try seeing if ReactRouter can provide my solution.
This commit is contained in:
1 parent
5d009a3d70
commit
e676c7a95a
17 files changed
+246
-32
No files matched your search
@@ -12,7 +12,7 @@ type MenuItemProps = {
|
|||||||
};
|
};
|
||||||
export const MenuItem = styled(PadBox).attrs(() => ({
|
export const MenuItem = styled(PadBox).attrs(() => ({
|
||||||
padding: ["sm", "lg"],
|
padding: ["sm", "lg"],
|
||||||
})) <MenuItemProps>`
|
}))<MenuItemProps>`
|
||||||
border-radius: ${p => p.theme.design.button.borderRadius};
|
border-radius: ${p => p.theme.design.button.borderRadius};
|
||||||
color: ${p => p.theme.colors.darkGrey};
|
color: ${p => p.theme.colors.darkGrey};
|
||||||
font-family: ${p => p.theme.fonts.f1Regular};
|
font-family: ${p => p.theme.fonts.f1Regular};
|
||||||
|
|||||||
@@ -1,17 +1,34 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
|
||||||
|
import { workspaceSelector } from "../../../features/workspace/workspaceSelector";
|
||||||
|
|
||||||
import { AngledFlag } from "../../BroadcastGraphics/Common/AngledFlag";
|
import { AngledFlag } from "../../BroadcastGraphics/Common/AngledFlag";
|
||||||
import { BasicBlock } from "./styles";
|
import { BasicBlock } from "./styles";
|
||||||
|
|
||||||
|
|
||||||
export function AngledFlagWorkSpace() {
|
export function AngledFlagWorkSpace() {
|
||||||
|
const { prototypeState } = useSelector(workspaceSelector);
|
||||||
|
// const dispatch = useDispatch();
|
||||||
|
// useEffect(() => {
|
||||||
|
// dispatch(setPrototypeState({
|
||||||
|
// angledFlag: {
|
||||||
|
// flagA: "GBR",
|
||||||
|
// flagB: "GBR",
|
||||||
|
// },
|
||||||
|
// }));
|
||||||
|
// }, [currentWorkspaceId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BasicBlock width={750} height={450} color="rgba(30, 30, 30, .7)">
|
<BasicBlock width={750} height={450} color="rgba(30, 30, 30, .7)">
|
||||||
<AngledFlag
|
<AngledFlag
|
||||||
flagMode="country"
|
flagMode="country"
|
||||||
flag="GBR"
|
flag={prototypeState?.angledFlag?.flagA ?? "GBR"}
|
||||||
flagHeight={64}
|
flagHeight={64}
|
||||||
/>
|
/>
|
||||||
<AngledFlag
|
<AngledFlag
|
||||||
flagMode="country"
|
flagMode="country"
|
||||||
flag="MEX"
|
flag={prototypeState?.angledFlag?.flagB ?? "GBR"}
|
||||||
flagHeight={128}
|
flagHeight={128}
|
||||||
/>
|
/>
|
||||||
</BasicBlock>
|
</BasicBlock>
|
||||||
|
|||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
import { PadBox } from "@bedrock-layout/padbox";
|
||||||
|
import { Split } from "@bedrock-layout/split";
|
||||||
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
import { workspaceSelector } from "../../../../features/workspace/workspaceSelector";
|
||||||
|
|
||||||
|
import { setPrototypeState } from "../../../../features/workspace/workspaceSlice";
|
||||||
|
|
||||||
|
import { SlotSelector } from "../../../Common/Inputs/SlotSelector";
|
||||||
|
|
||||||
|
const countries = [
|
||||||
|
"GBR", "NLD", "FIN", "JPN", "FRA", "DEU", "MEX", "POL", "MCO", "CHN", "THA",
|
||||||
|
"CAN", "RUS", "RAF", "AUS", "ESP", "ITA",
|
||||||
|
];
|
||||||
|
export function AngledFlagPrototypeControls() {
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const { prototypeState } = useSelector(workspaceSelector);
|
||||||
|
|
||||||
|
const onChange = (flag: "flagA" | "flagB") => (value: string) => {
|
||||||
|
dispatch(setPrototypeState({
|
||||||
|
angledFlag: {
|
||||||
|
flagA: flag === "flagA" ? value : prototypeState?.angledFlag?.flagA ?? "GBR",
|
||||||
|
flagB: flag === "flagB" ? value : prototypeState?.angledFlag?.flagB ?? "GBR",
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<Split as={PadBox} gutter="md" padding="md">
|
||||||
|
<SlotSelector items={countries} onChange={onChange("flagA")}/>
|
||||||
|
<SlotSelector items={countries} onChange={onChange("flagB")}/>
|
||||||
|
</Split>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./AngledFlagPrototypeControls";
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
import { Grid } from "@bedrock-layout/grid";
|
||||||
|
import { PadBox } from "@bedrock-layout/padbox";
|
||||||
|
|
||||||
|
import { GridSelection } from "../GridSelection";
|
||||||
|
|
||||||
|
export function ChyronPrototypeControls() {
|
||||||
|
return (
|
||||||
|
<Grid gutter="md">
|
||||||
|
<PadBox padding="md">
|
||||||
|
<GridSelection />
|
||||||
|
</PadBox>
|
||||||
|
<span>Launcher/Closer</span>
|
||||||
|
</Grid>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./ChyronPrototypeControls";
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import { InlineCluster } from "@bedrock-layout/inline-cluster";
|
||||||
|
import { findIndex } from "lodash";
|
||||||
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
|
||||||
|
import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector";
|
||||||
|
import { selectedCarsAdd, selectedCarsClear, selectedCarsRemove } from "../../../../features/broadcast/director/broadcastDirectorSlice";
|
||||||
|
import { eventSelector } from "../../../../features/event/eventSelector";
|
||||||
|
import { Car } from "../../../../types/state";
|
||||||
|
import { carMatch } from "../../../../utils/comparators";
|
||||||
|
|
||||||
|
import { DriverLabel, GridItem, SelectionLabel } from "./styles";
|
||||||
|
|
||||||
|
export function GridSelection() {
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const {
|
||||||
|
grid,
|
||||||
|
} = useSelector(eventSelector);
|
||||||
|
const {
|
||||||
|
selectedCars,
|
||||||
|
} = useSelector(broadcastDirectorSelector);
|
||||||
|
|
||||||
|
const carClick = (car: Car, selected: boolean) => () => {
|
||||||
|
if (selected) {
|
||||||
|
dispatch(selectedCarsRemove(car));
|
||||||
|
} else {
|
||||||
|
dispatch(selectedCarsAdd(car));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const carDoubleClick = (car: Car) => () => {
|
||||||
|
dispatch(selectedCarsClear(car));
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<InlineCluster gutter="xs">
|
||||||
|
{grid.map(car => {
|
||||||
|
const selectedIndex = findIndex(selectedCars, carMatch(car));
|
||||||
|
const selected = selectedIndex !== -1;
|
||||||
|
const onClick = carClick(car, selected);
|
||||||
|
const onDoubleClick = carDoubleClick(car);
|
||||||
|
return (
|
||||||
|
<GridItem
|
||||||
|
key={car.driver.id}
|
||||||
|
selected={selected}
|
||||||
|
onClick={onClick}
|
||||||
|
onDoubleClick={onDoubleClick}
|
||||||
|
>
|
||||||
|
<DriverLabel>
|
||||||
|
{car.driver.initials}
|
||||||
|
</DriverLabel>
|
||||||
|
{selected && (
|
||||||
|
<SelectionLabel>{selectedIndex + 1}</SelectionLabel>
|
||||||
|
)}
|
||||||
|
</GridItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</InlineCluster>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./GridSelection";
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import { PadBox } from "@bedrock-layout/padbox";
|
||||||
|
import styled from "styled-components";
|
||||||
|
|
||||||
|
type GridItemProps = {
|
||||||
|
selected: boolean,
|
||||||
|
};
|
||||||
|
export const GridItem = styled(PadBox).attrs(() => ({
|
||||||
|
padding: ["md", "xs"],
|
||||||
|
}))<GridItemProps>`
|
||||||
|
position: relative;
|
||||||
|
width: 4.5ch;
|
||||||
|
border-radius: 0.2em;
|
||||||
|
|
||||||
|
font-family: ${p => p.theme.fonts.f1Regular};
|
||||||
|
font-size: 0.8em;
|
||||||
|
text-align: center;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
|
background-color: ${({ selected }) => selected
|
||||||
|
? p => p.theme.colors.grey
|
||||||
|
: p => p.theme.colors.faintGrey};
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: ${({ selected }) => selected ? p => p.theme.colors.darkGrey : p => p.theme.colors.grey};
|
||||||
|
> span {
|
||||||
|
color: ${p => p.theme.colors.faintGrey};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const DriverLabel = styled.span`
|
||||||
|
text-transform: uppercase;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const SelectionLabel = styled.span`
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
right: 5%;
|
||||||
|
font-size: 0.3em;
|
||||||
|
`;
|
||||||
@@ -3,7 +3,9 @@ import { WorkspaceId, WorkspaceProperties } from "../../types/state";
|
|||||||
|
|
||||||
// Broadcast Graphics
|
// Broadcast Graphics
|
||||||
import { ChyronDriver } from "../../components/BroadcastGraphics/Chyrons/Driver";
|
import { ChyronDriver } from "../../components/BroadcastGraphics/Chyrons/Driver";
|
||||||
|
import { ChyronPrototypeControls } from "../../components/Workspaces/PrototypingControls/ChyronPrototype";
|
||||||
import { AngledFlagWorkSpace } from "../../components/Workspaces/CustomWorkSpaces/AngledFlagWorkSpace";
|
import { AngledFlagWorkSpace } from "../../components/Workspaces/CustomWorkSpaces/AngledFlagWorkSpace";
|
||||||
|
import { AngledFlagPrototypeControls } from "../../components/Workspaces/PrototypingControls/AngledFlagPrototype";
|
||||||
|
|
||||||
type WorkspaceObject = {
|
type WorkspaceObject = {
|
||||||
[id: WorkspaceId]: WorkspaceProperties,
|
[id: WorkspaceId]: WorkspaceProperties,
|
||||||
@@ -42,12 +44,23 @@ export const workspaces: WorkspaceObject = {
|
|||||||
height: 500,
|
height: 500,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
foo: {
|
||||||
|
name: "Foo",
|
||||||
|
overlayIds: [],
|
||||||
|
previewWindowDimensions: { width: 500, height: 500 },
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export function fetchBroadcastGraphic(workspaceId: WorkspaceId): [ReactNode, ReactNode] {
|
export function fetchBroadcastGraphic(workspaceId?: WorkspaceId): [ReactNode, ReactNode] {
|
||||||
switch(workspaceId) {
|
switch(workspaceId) {
|
||||||
case "chyronDriver": return [ChyronDriver(), null];
|
case "chyronDriver": return [
|
||||||
case "angledFlag": return [AngledFlagWorkSpace(), null];
|
ChyronDriver(),
|
||||||
|
ChyronPrototypeControls(),
|
||||||
|
];
|
||||||
|
case "angledFlag": return [
|
||||||
|
AngledFlagWorkSpace(),
|
||||||
|
AngledFlagPrototypeControls(),
|
||||||
|
];
|
||||||
default: return [null, null];
|
default: return [null, null];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,13 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|||||||
import { findIndex } from "lodash";
|
import { findIndex } from "lodash";
|
||||||
|
|
||||||
import { RootState, Car } from "../../../types/state";
|
import { RootState, Car } from "../../../types/state";
|
||||||
|
import { Optional } from "../../../types/util";
|
||||||
|
import { carMatch } from "../../../utils/comparators";
|
||||||
|
|
||||||
const initialState: RootState["broadcastDirector"] = {
|
const initialState: RootState["broadcastDirector"] = {
|
||||||
selectedCars: [],
|
selectedCars: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
const carMatch = (targetCar: Car) => (checkedCar: Car) =>
|
|
||||||
checkedCar.driver.id === targetCar.driver.id;
|
|
||||||
|
|
||||||
export const broadcastDirectorSlice = createSlice({
|
export const broadcastDirectorSlice = createSlice({
|
||||||
name: "broadcastDirector",
|
name: "broadcastDirector",
|
||||||
initialState,
|
initialState,
|
||||||
@@ -31,8 +30,16 @@ export const broadcastDirectorSlice = createSlice({
|
|||||||
state.selectedCars.slice(index + 1),
|
state.selectedCars.slice(index + 1),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
selectedCarsClear: (state) => {
|
/**
|
||||||
|
* Shortcut to clear out selected cars. There is also a trick - if you
|
||||||
|
* @param action Car (optional) - if provided, it'll clear all and add this.
|
||||||
|
*/
|
||||||
|
selectedCarsClear: (state, action: PayloadAction<Optional<Car>>) => {
|
||||||
|
if (action.payload == null) {
|
||||||
state.selectedCars = [];
|
state.selectedCars = [];
|
||||||
|
} else {
|
||||||
|
state.selectedCars = [action.payload];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||||
|
|
||||||
import { CourseFlag, RootState } from "../../types/state";
|
import { CourseFlag, RootState } from "../../types/state";
|
||||||
import { getDriver } from "../../utils/dataLookup";
|
import { cloneDriver } from "../../utils/dataLookup";
|
||||||
|
|
||||||
const initialState: RootState["event"] = {
|
const initialState: RootState["event"] = {
|
||||||
trackName: "Melbourne",
|
trackName: "Melbourne",
|
||||||
@@ -19,26 +19,26 @@ const initialState: RootState["event"] = {
|
|||||||
lapCount: 10,
|
lapCount: 10,
|
||||||
},
|
},
|
||||||
grid: [
|
grid: [
|
||||||
{ position: 1, driver: getDriver("verstappen") },
|
{ position: 1, driver: cloneDriver("verstappen") },
|
||||||
{ position: 3, driver: getDriver("hamilton") },
|
{ position: 3, driver: cloneDriver("hamilton") },
|
||||||
{ position: 2, driver: getDriver("bottas") },
|
{ position: 2, driver: cloneDriver("bottas") },
|
||||||
{ position: 4, driver: getDriver("perez") },
|
{ position: 4, driver: cloneDriver("perez") },
|
||||||
{ position: 5, driver: getDriver("sainz") },
|
{ position: 5, driver: cloneDriver("sainz") },
|
||||||
{ position: 6, driver: getDriver("norris") },
|
{ position: 6, driver: cloneDriver("norris") },
|
||||||
{ position: 7, driver: getDriver("leclerc") },
|
{ position: 7, driver: cloneDriver("leclerc") },
|
||||||
{ position: 8, driver: getDriver("ricciardo") },
|
{ position: 8, driver: cloneDriver("ricciardo") },
|
||||||
{ position: 9, driver: getDriver("gasly") },
|
{ position: 9, driver: cloneDriver("gasly") },
|
||||||
{ position: 10, driver: getDriver("alonso") },
|
{ position: 10, driver: cloneDriver("alonso") },
|
||||||
{ position: 11, driver: getDriver("ocon") },
|
{ position: 11, driver: cloneDriver("ocon") },
|
||||||
{ position: 12, driver: getDriver("vettel") },
|
{ position: 12, driver: cloneDriver("vettel") },
|
||||||
{ position: 13, driver: getDriver("stroll") },
|
{ position: 13, driver: cloneDriver("stroll") },
|
||||||
{ position: 14, driver: getDriver("tsunoda") },
|
{ position: 14, driver: cloneDriver("tsunoda") },
|
||||||
{ position: 15, driver: getDriver("russell") },
|
{ position: 15, driver: cloneDriver("russell") },
|
||||||
{ position: 16, driver: getDriver("raikkonen") },
|
{ position: 16, driver: cloneDriver("raikkonen") },
|
||||||
{ position: 17, driver: getDriver("latifi") },
|
{ position: 17, driver: cloneDriver("latifi") },
|
||||||
{ position: 18, driver: getDriver("giovinazzi") },
|
{ position: 18, driver: cloneDriver("giovinazzi") },
|
||||||
{ position: 19, driver: getDriver("schumacher") },
|
{ position: 19, driver: cloneDriver("schumacher") },
|
||||||
{ position: 20, driver: getDriver("mazepin") },
|
{ position: 20, driver: cloneDriver("mazepin") },
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||||
import { RootState, WorkspaceId, WorkspaceProperties } from "../../types/state";
|
import { PrototypeState, RootState, WorkspaceId, WorkspaceProperties } from "../../types/state";
|
||||||
|
|
||||||
const initialState: RootState["workspace"] = {
|
const initialState: RootState["workspace"] = {
|
||||||
workspaceId: "",
|
workspaceId: "",
|
||||||
@@ -9,6 +9,7 @@ const initialState: RootState["workspace"] = {
|
|||||||
overlayIds: [],
|
overlayIds: [],
|
||||||
previewWindowDimensions: { width: 0, height: 0 },
|
previewWindowDimensions: { width: 0, height: 0 },
|
||||||
},
|
},
|
||||||
|
prototypeState: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpdateWorkspaceAction = {
|
export type UpdateWorkspaceAction = {
|
||||||
@@ -30,6 +31,9 @@ export const workspaceSlice = createSlice({
|
|||||||
state.workspaceId = action.payload.workspaceId;
|
state.workspaceId = action.payload.workspaceId;
|
||||||
state.workspaceProperties = action.payload.workspaceProperties;
|
state.workspaceProperties = action.payload.workspaceProperties;
|
||||||
},
|
},
|
||||||
|
setPrototypeState: (state, action: PayloadAction<PrototypeState>) => {
|
||||||
|
state.prototypeState = action.payload;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -37,5 +41,6 @@ export const {
|
|||||||
setWorkspaceId,
|
setWorkspaceId,
|
||||||
setAnimatedBG,
|
setAnimatedBG,
|
||||||
updateWorkspace,
|
updateWorkspace,
|
||||||
|
setPrototypeState,
|
||||||
} = workspaceSlice.actions;
|
} = workspaceSlice.actions;
|
||||||
export default workspaceSlice.reducer;
|
export default workspaceSlice.reducer;
|
||||||
@@ -3,6 +3,8 @@ import { configureStore, combineReducers } from "@reduxjs/toolkit";
|
|||||||
import pageDimensions from "./features/pageDimensions/pageDimensionsSlice";
|
import pageDimensions from "./features/pageDimensions/pageDimensionsSlice";
|
||||||
import workspace from "./features/workspace/workspaceSlice";
|
import workspace from "./features/workspace/workspaceSlice";
|
||||||
import overlayTool from "./features/overlayTool/overlayToolSlice";
|
import overlayTool from "./features/overlayTool/overlayToolSlice";
|
||||||
|
import event from "./features/event/eventSlice";
|
||||||
|
import broadcastDirector from "./features/broadcast/director/broadcastDirectorSlice";
|
||||||
import broadcastGraphics from "./features/broadcast/graphics/broadcastGraphicsSlice";
|
import broadcastGraphics from "./features/broadcast/graphics/broadcastGraphicsSlice";
|
||||||
|
|
||||||
export const store = configureStore({
|
export const store = configureStore({
|
||||||
@@ -10,6 +12,8 @@ export const store = configureStore({
|
|||||||
pageDimensions,
|
pageDimensions,
|
||||||
workspace,
|
workspace,
|
||||||
overlayTool,
|
overlayTool,
|
||||||
|
event,
|
||||||
|
broadcastDirector,
|
||||||
broadcastGraphics,
|
broadcastGraphics,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
Vendored
+7
@@ -22,6 +22,7 @@ export interface Workspace {
|
|||||||
workspaceId: WorkspaceId;
|
workspaceId: WorkspaceId;
|
||||||
animatedBG: boolean;
|
animatedBG: boolean;
|
||||||
workspaceProperties: WorkspaceProperties;
|
workspaceProperties: WorkspaceProperties;
|
||||||
|
prototypeState: Optional<PrototypeState>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type WorkspaceId = string;
|
export type WorkspaceId = string;
|
||||||
@@ -30,6 +31,12 @@ export interface WorkspaceProperties {
|
|||||||
overlayIds: OverlayIds;
|
overlayIds: OverlayIds;
|
||||||
previewWindowDimensions: Dimensions;
|
previewWindowDimensions: Dimensions;
|
||||||
}
|
}
|
||||||
|
export interface PrototypeState {
|
||||||
|
angledFlag?: {
|
||||||
|
flagA: string;
|
||||||
|
flagB: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Overlay Tool
|
// Overlay Tool
|
||||||
export interface OverlayTool {
|
export interface OverlayTool {
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import { Car } from "../types/state";
|
||||||
|
|
||||||
|
export const carMatch = (targetCar: Car) => (checkedCar: Car) =>
|
||||||
|
checkedCar.driver.id === targetCar.driver.id;
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { cloneDeep } from "lodash";
|
||||||
import { drivers, teams, teamNumberStyles, NumberStyle } from "../domain/data/teams";
|
import { drivers, teams, teamNumberStyles, NumberStyle } from "../domain/data/teams";
|
||||||
import { Driver, DriverId, Team, TeamId } from "../types/state";
|
import { Driver, DriverId, Team, TeamId } from "../types/state";
|
||||||
|
|
||||||
@@ -11,10 +12,16 @@ import { Driver, DriverId, Team, TeamId } from "../types/state";
|
|||||||
export function getDriver(driverId: DriverId): Driver {
|
export function getDriver(driverId: DriverId): Driver {
|
||||||
return drivers[driverId];
|
return drivers[driverId];
|
||||||
}
|
}
|
||||||
|
export function cloneDriver(driverId: DriverId): Driver {
|
||||||
|
return cloneDeep(drivers[driverId]);
|
||||||
|
}
|
||||||
|
|
||||||
export function getTeam(teamId: TeamId): Team {
|
export function getTeam(teamId: TeamId): Team {
|
||||||
return teams[teamId];
|
return teams[teamId];
|
||||||
}
|
}
|
||||||
|
export function cloneTeam(teamId: TeamId): Team {
|
||||||
|
return cloneDeep(teams[teamId]);
|
||||||
|
}
|
||||||
|
|
||||||
export function getTeamNumberStyle(teamId: TeamId): NumberStyle {
|
export function getTeamNumberStyle(teamId: TeamId): NumberStyle {
|
||||||
return teamNumberStyles[teamId];
|
return teamNumberStyles[teamId];
|
||||||
|
|||||||
Reference in new issue
Block a user