🐛 refresh exam detail when route id changes
Browse files at this commit7122c92c94a9ef21e56f247e08dd73615e72099fParent: d9ee743- fix
- 🐛 refresh exam detail when route id changes
2 changed files +4 -12
src/pages/exam-detail-page.tsxmodified+2 -6
| @@ -1,4 +1,4 @@ | ||
| 1 | -import { Link, useLocation, useNavigate, useParams } from "@tanstack/solid-router"; | |
| 1 | +import { Link, useLocation, useNavigate } from "@tanstack/solid-router"; | |
| 2 | 2 | import { For, Show, Suspense, createMemo, createResource, createSignal } from "solid-js"; |
| 3 | 3 | import { deleteExamById } from "@/api/deleteExamById"; |
| 4 | 4 | import { deleteExamResultByUserId } from "@/api/deleteExamResultByUserId"; |
| @@ -57,16 +57,12 @@ export default function ExamDetailPage() { | ||
| 57 | 57 | |
| 58 | 58 | function ExamDetailContent() { |
| 59 | 59 | const location = useLocation(); |
| 60 | - const params = useParams({ from: "/exams/$id" }); | |
| 61 | 60 | const auth = useAuth(); |
| 62 | 61 | const navigate = useNavigate(); |
| 63 | 62 | const t = useT(); |
| 64 | 63 | const { locale } = usePreferences(); |
| 65 | 64 | const now = createNow(); |
| 66 | - const id = createMemo(() => { | |
| 67 | - location(); | |
| 68 | - return params().id; | |
| 69 | - }); | |
| 65 | + const id = createMemo(() => decodeURIComponent(location().pathname.split("/").pop() ?? "")); | |
| 70 | 66 | |
| 71 | 67 | const [exam, { refetch: refetchExam }] = createResource(id, (examId) => getExamById(examId)); |
| 72 | 68 | const [settings] = createResource(() => getSettings()); |
src/pages/exam-room-page.tsxmodified+2 -6
| @@ -1,4 +1,4 @@ | ||
| 1 | -import { Link, useLocation, useParams } from "@tanstack/solid-router"; | |
| 1 | +import { Link, useLocation } from "@tanstack/solid-router"; | |
| 2 | 2 | import { Show, Suspense, createMemo, createResource } from "solid-js"; |
| 3 | 3 | import { getExamById } from "@/api/getExamById"; |
| 4 | 4 | import { getMyCourses } from "@/api/getMyCourses"; |
| @@ -23,13 +23,9 @@ export default function ExamRoomPage() { | ||
| 23 | 23 | |
| 24 | 24 | function ExamRoomContent() { |
| 25 | 25 | const location = useLocation(); |
| 26 | - const params = useParams({ from: "/exam-room/$id" }); | |
| 27 | 26 | const auth = useAuth(); |
| 28 | 27 | const t = useT(); |
| 29 | - const id = createMemo(() => { | |
| 30 | - location(); | |
| 31 | - return params().id; | |
| 32 | - }); | |
| 28 | + const id = createMemo(() => decodeURIComponent(location().pathname.split("/").pop() ?? "")); | |
| 33 | 29 | const [exam] = createResource(id, (examId) => getExamById(examId)); |
| 34 | 30 | const [mine] = createResource( |
| 35 | 31 | () => (auth.user()?.role === "student" ? true : null), |