Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix espid link when clicking on day #123

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions nextjs-interface/src/app/dashboard/esp/[espId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ export default function Page({ params }: { params: any }) {
</Card>
</div>

<h1>
{from} et {to}
</h1>
<Card className="w-full dark:border-zinc-700 dark:bg-zinc-900">
<CardContent>
<ChartElement data={allData} />
Expand Down
8 changes: 5 additions & 3 deletions nextjs-interface/src/app/ui/dashboard/ChartElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import {
} from "recharts";
import { avgData } from "@/lib/context";
import { ThemeContext } from "@/lib/Theme";
import { useRouter } from "next/navigation";
import { useRouter, usePathname } from "next/navigation";
import { ScanSearch } from "lucide-react";

export function ChartElement({ data }: { data: avgData[] }) {
const { darkMode } = useContext(ThemeContext);
const pathname = usePathname();
const router = useRouter();
const [message, setMessage] = useState<string | null>(null);

Expand Down Expand Up @@ -62,10 +63,11 @@ export function ChartElement({ data }: { data: avgData[] }) {
const from = new Date(clickedDate);
const to = new Date(clickedDate);
to.setDate(to.getDate() + 1);

const espId = pathname.split("/").pop();
router.push(
`/dashboard/esp/1?precision=Hour&from=${from.toISOString()}&to=${to.toISOString()}`,
`/dashboard/esp/${espId}?precision=Hour&from=${from.toISOString()}&to=${to.toISOString()}`,
);

const swissDateFormat = from.toLocaleDateString("fr-CH", {
year: "numeric",
month: "long",
Expand Down