Skip to content

Commit

Permalink
#401: Prevented start and end chapters from being out of order
Browse files Browse the repository at this point in the history
  • Loading branch information
tombogle committed Sep 18, 2023
1 parent 98a83a7 commit 454eee3
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ export default function BookSelection() {
const [endChapter, setEndChapter] = useState(chapterCount);

const onSelectChangeStartChapter = (_event: SyntheticEvent<Element, Event>, value: unknown) => {
setStartChapter((value as ChapterNumberOption).chapterNum);
const newStartChapterNum = (value as ChapterNumberOption).chapterNum;
setStartChapter(newStartChapterNum);
if (newStartChapterNum > endChapter) setEndChapter(newStartChapterNum);
};

const onSelectChangeEndChapter = (_event: SyntheticEvent<Element, Event>, value: unknown) => {
setEndChapter((value as ChapterNumberOption).chapterNum);
const newEndChapterNum = (value as ChapterNumberOption).chapterNum;
setEndChapter(newEndChapterNum);
if (newEndChapterNum < startChapter) setStartChapter(newEndChapterNum);
};

return (
Expand Down

0 comments on commit 454eee3

Please sign in to comment.