Skip to content

Commit

Permalink
Run Prettier linter
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorbg committed Jan 1, 2024
1 parent c448278 commit de05224
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 40 deletions.
25 changes: 17 additions & 8 deletions tnoodle-ui/src/main/components/FmcTranslationsDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { chunk } from "lodash";
import React, {useCallback, useEffect, useState} from "react";
import React, { useCallback, useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import RootState from "../model/RootState";
import { setFileZip } from "../redux/slice/ScramblingSlice";
Expand Down Expand Up @@ -71,9 +71,7 @@ const FmcTranslationsDetail = ({
};

const updateEventSelectedTranslations = useCallback(
(
selectedTranslations: string[]
) => {
(selectedTranslations: string[]) => {
setExtensionLazily(
fmcWcifEvent,
fmcTranslationsExtensionId,
Expand All @@ -83,16 +81,27 @@ const FmcTranslationsDetail = ({
dispatch(setFileZip());
}
);
}, [dispatch, fmcWcifEvent]
},
[dispatch, fmcWcifEvent]
);

useEffect(() => {
const existingExtensionFmc = findExtension(fmcWcifEvent, fmcTranslationsExtensionId);
const existingExtensionFmc = findExtension(
fmcWcifEvent,
fmcTranslationsExtensionId
);

if (existingExtensionFmc === undefined && suggestedFmcTranslations !== undefined) {
if (
existingExtensionFmc === undefined &&
suggestedFmcTranslations !== undefined
) {
updateEventSelectedTranslations(suggestedFmcTranslations);
}
}, [fmcWcifEvent, updateEventSelectedTranslations, suggestedFmcTranslations]);
}, [
fmcWcifEvent,
updateEventSelectedTranslations,
suggestedFmcTranslations,
]);

const handleTranslation = (id: string, status: boolean) => {
let newSelectedTranslations = selectedTranslations.filter(
Expand Down
66 changes: 38 additions & 28 deletions tnoodle-ui/src/main/components/MbldDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ import { setWcifEvent } from "../redux/slice/WcifSlice";
import { setFileZip } from "../redux/slice/ScramblingSlice";
import WcifEvent from "../model/WcifEvent";
import { mbldCubesExtensionId } from "../util/wcif.util";
import {
useCallback,
useEffect,
useState
} from "react";
import { useCallback, useEffect, useState } from "react";
import {
findAndProcessExtension,
findExtension,
setExtensionLazily, upsertExtension,
setExtensionLazily,
upsertExtension,
} from "../util/extension.util";

interface MbldDetailProps {
Expand All @@ -31,10 +28,8 @@ const MbldDetail = ({ mbldWcifEvent }: MbldDetailProps) => {
const [mbld, setMbld] = useState<number>(MBLD_DEFAULT);

useEffect(() => {
findAndProcessExtension(
mbldWcifEvent,
mbldCubesExtensionId,
(ext) => setMbld(ext.data.requestedScrambles)
findAndProcessExtension(mbldWcifEvent, mbldCubesExtensionId, (ext) =>
setMbld(ext.data.requestedScrambles)
);
}, [mbldWcifEvent]);

Expand All @@ -48,26 +43,39 @@ const MbldDetail = ({ mbldWcifEvent }: MbldDetailProps) => {
};
};

const updateEventMbld = useCallback((mbld: number) => {
setExtensionLazily(
mbldWcifEvent,
mbldCubesExtensionId,
() => buildMbldExtension(mbld),
(newWcifEvent) => {
newWcifEvent.rounds = newWcifEvent.rounds.map((wcifRound) => {
const overrideExtension = buildMbldExtension(mbld);
return upsertExtension(wcifRound, overrideExtension);
});
const updateEventMbld = useCallback(
(mbld: number) => {
setExtensionLazily(
mbldWcifEvent,
mbldCubesExtensionId,
() => buildMbldExtension(mbld),
(newWcifEvent) => {
newWcifEvent.rounds = newWcifEvent.rounds.map(
(wcifRound) => {
const overrideExtension = buildMbldExtension(mbld);
return upsertExtension(
wcifRound,
overrideExtension
);
}
);

dispatch(setWcifEvent(newWcifEvent));
dispatch(setFileZip());
}
);
}, [dispatch, mbldWcifEvent]);
dispatch(setWcifEvent(newWcifEvent));
dispatch(setFileZip());
}
);
},
[dispatch, mbldWcifEvent]
);

useEffect(() => {
const existingExtensionMbld = findExtension(mbldWcifEvent, mbldCubesExtensionId);
const shouldOverride = existingExtensionMbld === undefined || existingExtensionMbld.data.requestedScrambles !== bestMbldAttempt;
const existingExtensionMbld = findExtension(
mbldWcifEvent,
mbldCubesExtensionId
);
const shouldOverride =
existingExtensionMbld === undefined ||
existingExtensionMbld.data.requestedScrambles !== bestMbldAttempt;

if (shouldOverride && bestMbldAttempt !== undefined) {
updateEventMbld(bestMbldAttempt);
Expand All @@ -85,7 +93,9 @@ const MbldDetail = ({ mbldWcifEvent }: MbldDetailProps) => {
className="form-control bg-dark text-white"
type="number"
value={mbld}
onChange={(e) => updateEventMbld(Number(e.target.value))}
onChange={(e) =>
updateEventMbld(Number(e.target.value))
}
min={MBLD_MIN}
required
disabled={generatingScrambles}
Expand Down
8 changes: 5 additions & 3 deletions tnoodle-ui/src/main/components/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { defaultWcif } from "../util/wcif.util";
import Loading from "./Loading";
import "./SideBar.css";
import Wcif from "../model/Wcif";
import {setShowColorPicker} from "../redux/slice/SettingsSlice";
import { setShowColorPicker } from "../redux/slice/SettingsSlice";

const SideBar = () => {
const [loadingUser, setLoadingUser] = useState(false);
Expand Down Expand Up @@ -282,9 +282,11 @@ const SideBar = () => {
checked={showColorPicker}
onChange={(e) => dispatch(setShowColorPicker(e.target.checked))}
/>
<label className="custom-control-label" htmlFor="colorPicker">Show color scheme pickers</label>
<label className="custom-control-label" htmlFor="colorPicker">
Show color scheme pickers
</label>
</div>
)
);

return (
<div className="h-100 pb-2">
Expand Down
2 changes: 1 addition & 1 deletion tnoodle-ui/src/main/redux/Store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { informationSlice } from "./slice/InformationSlice";
import { scramblingSlice } from "./slice/ScramblingSlice";
import { wcifSlice } from "./slice/WcifSlice";
import { eventDataSlice } from "./slice/EventDataSlice";
import {settingsSlice} from "./slice/SettingsSlice";
import { settingsSlice } from "./slice/SettingsSlice";

const store = configureStore({
reducer: {
Expand Down

0 comments on commit de05224

Please sign in to comment.