Skip to content

Commit

Permalink
Remove commented-out code and add console logs for debugging in Answe…
Browse files Browse the repository at this point in the history
…rs component
  • Loading branch information
JohanGrims committed Dec 16, 2024
1 parent 81d2315 commit 6ca774b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/admin/vote/Answers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { db } from "../../firebase";
export default function Answers() {
const { vote, options } = useLoaderData();

console.log(vote);

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

const searchParams = new URLSearchParams(window.location.search);
Expand Down Expand Up @@ -43,6 +45,8 @@ export default function Answers() {
...doc.data(),
}));
setAnswers(answerData);
console.log(answerData);
console.log(vote.id);
setLoading(false);

if (!isFirstLoad) {
Expand Down Expand Up @@ -569,14 +573,11 @@ export default function Answers() {
Answers.loader = async function loader({ params }) {
const { id } = params;
const vote = await getDoc(doc(db, `/votes/${id}`));
const voteData = vote.data();
const voteData = { id, ...vote.data() };
const options = await getDocs(collection(db, `/votes/${id}/options`));
const optionData = options.docs.map((doc) => ({ id: doc.id, ...doc.data() }));
// const answers = await getDocs(collection(db, `/votes/${id}/choices`));
// const answerData = answers.docs.map((doc) => ({ id: doc.id, ...doc.data() }));
return {
vote: voteData,
options: optionData,
// answers: answerData,
};
}
};

0 comments on commit 6ca774b

Please sign in to comment.