Skip to content

Commit

Permalink
fix(AgendaSession): revert to onClick instead of Link to avoid trigge…
Browse files Browse the repository at this point in the history
…r on card button click
  • Loading branch information
mathiazom committed Apr 21, 2024
1 parent 71cea1b commit 3606a67
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/components/modals/Agenda/AgendaSession.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Clear, EventBusy, HourglassTopRounded } from "@mui/icons-material";
import { Avatar, Box, Card, CardContent, Chip, CircularProgress, Tooltip, Typography, useTheme } from "@mui/material";
import IconButton from "@mui/material/IconButton";
import Link from "next/link";
import { useRouter } from "next/navigation";
import React, { useState } from "react";

import ConfirmCancellation from "@/components/schedule/class/ConfirmCancellation";
Expand All @@ -11,7 +11,7 @@ import { useUserConfig } from "@/lib/hooks/useUserConfig";
import { hexWithOpacityToRgb } from "@/lib/utils/colorUtils";
import { ChainIdentifier } from "@/types/chain";
import { ChainConfig, ClassConfig } from "@/types/config";
import { BaseUserSession, SessionStatus } from "@/types/userSessions";
import { SessionStatus, BaseUserSession } from "@/types/userSessions";

export default function AgendaSession({
chain,
Expand All @@ -22,6 +22,7 @@ export default function AgendaSession({
| { classConfig?: never; userSession: BaseUserSession }
)) {
const theme = useTheme();
const router = useRouter();
const { putUserConfig, userConfig } = useUserConfig(chain);

const [showCancelConfirmation, setShowCancelConfirmation] = useState(false);
Expand Down Expand Up @@ -77,16 +78,7 @@ export default function AgendaSession({
}

return (
<Link
href={{
pathname: `/${chain}`,
query: {
[ISO_WEEK_QUERY_PARAM]:
userSession != null ? compactISOWeekString(userSession.classData.startTime) : null,
[CLASS_ID_QUERY_PARAM]: userSession?.classData.id,
},
}}
>
<>
<Card
sx={{
position: "relative",
Expand All @@ -97,6 +89,14 @@ export default function AgendaSession({
backgroundColor: "#111",
},
}}
onClick={() => {
if (!userSession) {
return;
}
router.push(
`/${chain}?${ISO_WEEK_QUERY_PARAM}=${compactISOWeekString(userSession.classData.startTime)}&${CLASS_ID_QUERY_PARAM}=${userSession.classData.id}`,
);
}}
>
<Box
sx={{
Expand Down Expand Up @@ -241,6 +241,6 @@ export default function AgendaSession({
_class={userSession.classData}
/>
)}
</Link>
</>
);
}

0 comments on commit 3606a67

Please sign in to comment.