Skip to content

Commit

Permalink
wip: minors code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mewdev committed Jan 25, 2025
1 parent aaad4c2 commit 9645530
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
11 changes: 10 additions & 1 deletion apps/web/app/abc/otazka/[questionNumber]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useQuestionsStore } from "../../providers/storeProvider";
import { Question } from "@repo/schema/dist";
import { useEffect } from "react";
import { useParams } from "next/navigation";

import { ArrowIconLeft, ArrowIconRight } from "@repo/design-system/icons";
import Link from "next/link";

Expand Down Expand Up @@ -93,7 +94,15 @@ export default function Page() {
currentQuestion={currentQuestion}
questionTotal={questions.length}
toggleImportant={() => toggleImportant(currentQuestion)}
yesClick={() => answerYes(currentQuestion)}
// solve redirect !!!
yesClick={() => {
if (currentQuestion === questions.length) {
answerYes(currentQuestion);
console.log("Redirect here!");
} else {
answerYes(currentQuestion);
}
}}
noClick={() => answerNo(currentQuestion)}
yesPressed={question.answerType === true ? true : undefined}
noPressed={question.answerType === false ? true : undefined}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/abc/utils/urlUpdater.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default function UrlUpdater({ children }: Props) {
const path = usePathname();
const currentQuestion = useQuestionsStore((state) => state.currentQuestion);
const rekapitulace = useQuestionsStore((state) => state.isRekapitulace);
const questions = useQuestionsStore((state) => state.questions);
const setIsRekapitulace = useQuestionsStore(
(state) => state.setIsRekapitulace,
);
Expand All @@ -33,12 +34,10 @@ export default function UrlUpdater({ children }: Props) {
} else if (path.includes("navod")) {
setCurrentLocation("navod");
}
console.log(`Current question ${currentQuestion}`);
}, [path]);

// Url updater
useEffect(() => {
console.log("URL updater UE");
function changeUrl() {
// insert conditionals here for edge cases?
if (currentLocation === "otazka") {
Expand All @@ -60,6 +59,7 @@ export default function UrlUpdater({ children }: Props) {
document.title = `Rekapitulace`;
}
}

changeTitle();
changeUrl();
}, [currentQuestion, guideNumber, currentLocation]);
Expand Down
1 change: 0 additions & 1 deletion packages/design-system/src/ui/button/noToggleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ type Props = {
VariantProps<typeof buttonVariants>;

export function NoToggleButton({ pressed, onClick }: Props) {
// console.log("NoToggleButton pressed:", pressed);
return (
<ToggleButton
kind="inverse"
Expand Down
1 change: 0 additions & 1 deletion packages/design-system/src/ui/button/yesToggleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ type Props = {
VariantProps<typeof buttonVariants>;

export function YesToggleButton({ pressed, onClick }: Props) {
// console.log("YesToggleButton pressed:", pressed);
return (
<ToggleButton
kind="inverse"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const ToggleButton = React.forwardRef<React.ElementRef<typeof Button>, Props>(
const [isPressed, setIsPressed] = useState(toggleButtonPressed);
function handlePressed(event: React.MouseEvent<HTMLButtonElement>) {
setIsPressed((prevState) => !prevState);
console.log(`From toggleButton: ${isPressed}`);
if (onClick) {
onClick(event);
}
Expand Down

0 comments on commit 9645530

Please sign in to comment.