diff --git a/src/app/[lang]/crag/[cragSlug]/components/crag-routes/crag-route-list/crag-route/difficulty-votes.tsx b/src/app/[lang]/crag/[cragSlug]/components/crag-routes/crag-route-list/crag-route/difficulty-votes.tsx index ff33a967..32d01f11 100644 --- a/src/app/[lang]/crag/[cragSlug]/components/crag-routes/crag-route-list/crag-route/difficulty-votes.tsx +++ b/src/app/[lang]/crag/[cragSlug]/components/crag-routes/crag-route-list/crag-route/difficulty-votes.tsx @@ -34,75 +34,81 @@ function DifficultyVotes({ route, difficultyVotes }: Props) { return ( <> - - - {Object.entries(nrVotesPerDifficulty).map(([difficulty, nrVotes]) => ( - - - + + + + ))} + +
- - - 0 - ? { - width: `${Math.round( - (nrVotes / maxVotesPerDifficulty) * 100 - )}%`, + {difficultyVotes.length > 0 && ( + <> + + + {Object.entries(nrVotesPerDifficulty).map( + ([difficulty, nrVotes]) => ( + + + + + + ) + )} + +
+ + + 0 + ? { + width: `${Math.round( + (nrVotes / maxVotesPerDifficulty) * 100 + )}%`, + } + : {} } - : {} + > + + + {nrVotes !== maxVotesPerDifficulty && + pluralizeNoun("glas", nrVotes)} + + + + {nrVotes === maxVotesPerDifficulty && + pluralizeNoun("glas", nrVotes)} +
+ + + {difficultyVotes.map((vote) => ( + - - - {nrVotes !== maxVotesPerDifficulty && - pluralizeNoun("glas", nrVotes)} - - - - - - ))} - -
- {nrVotes === maxVotesPerDifficulty && - pluralizeNoun("glas", nrVotes)} -
- - - {difficultyVotes.map((vote) => ( - - - - - - ))} - -
- - - {vote.isBase ? "(bazna ocena)" : vote.user?.fullName} - {displayDate(vote.created)}
+ > +
+ + + {vote.isBase ? "(bazna ocena)" : vote.user?.fullName} + {displayDate(vote.created)}
+ + )} ); } diff --git a/src/app/[lang]/crag/[cragSlug]/components/crag-routes/crag-route-list/crag-route/route-grade.tsx b/src/app/[lang]/crag/[cragSlug]/components/crag-routes/crag-route-list/crag-route/route-grade.tsx index dedf4f84..84c85f3b 100644 --- a/src/app/[lang]/crag/[cragSlug]/components/crag-routes/crag-route-list/crag-route/route-grade.tsx +++ b/src/app/[lang]/crag/[cragSlug]/components/crag-routes/crag-route-list/crag-route/route-grade.tsx @@ -1,4 +1,3 @@ -import { useRouter } from "next/navigation"; import Dialog, { DialogSize, } from "../../../../../../../../components/ui/dialog"; @@ -8,6 +7,7 @@ import Grade from "@/components/grade"; import useIsVisible from "@/hooks/useIsVisible"; import { useEffect, useRef, useState } from "react"; import difficultyVotesAction from "./server-actions/difficulty-votes-action"; +import Button from "@/components/ui/button"; interface RouteGradeProps { route: Route; @@ -15,14 +15,8 @@ interface RouteGradeProps { } function RouteGrade({ route, crag }: RouteGradeProps) { - const router = useRouter(); const ref = useRef(null); - const handleOpenRoutePage = () => { - router.push(`/plezalisce/${crag.slug}/smer/${route.slug}`); - }; - const visible = useIsVisible(ref); - const [difficultyVotes, setDifficultyVotes] = useState([]); useEffect(() => { @@ -38,13 +32,12 @@ function RouteGrade({ route, crag }: RouteGradeProps) { ) : ( - {route.difficulty && } - + } dialogSize={DialogSize.medium} title="Glasovi uporabnikov" - confirm={{ label: "Več", callback: handleOpenRoutePage }} cancel={{ label: "Zapri" }} > diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx index a71f466d..92b56f59 100644 --- a/src/components/ui/dialog.tsx +++ b/src/components/ui/dialog.tsx @@ -13,8 +13,8 @@ interface DialogProps { children: ReactElement; title: string; openTrigger: ReactElement; - confirm: { label: string; callback?: () => void }; - cancel: { label: string; callback?: () => void }; + confirm?: { label: string; callback?: () => void }; + cancel?: { label: string; callback?: () => void }; dialogSize?: DialogSize; closeWithEscOrPressOutside?: boolean; closeCallback?: () => void; @@ -80,10 +80,14 @@ function Dialog({ )}
- - + {cancel && ( + + )} + {confirm && ( + + )}