Skip to content

Commit

Permalink
Refactor URL search parameter retrieval in Answers component for impr…
Browse files Browse the repository at this point in the history
…oved readability
  • Loading branch information
JohanGrims committed Dec 12, 2024
1 parent ce40ddd commit 4f345de
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/admin/vote/Answers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ export default function Answers() {

const [loading, setLoading] = React.useState(true);

const search = new URLSearchParams(window.location.search).get("search");
const grade = new URLSearchParams(window.location.search).get("grade");
const listIndex = new URLSearchParams(window.location.search).get(
"listIndex"
);
const searchParams = new URLSearchParams(window.location.search);
const search = searchParams.get("search");
const grade = searchParams.get("grade");
const listIndex = searchParams.get("listIndex");

const [mode, setMode] = React.useState(
search || grade || listIndex ? "by-name" : "by-option"
Expand Down

0 comments on commit 4f345de

Please sign in to comment.