Skip to content
Snippets Groups Projects
Commit 03a2ab5c authored by Gustav Kylberg's avatar Gustav Kylberg
Browse files

upvote bug fixed

parent e129298f
No related branches found
No related tags found
2 merge requests!231merged in dev,!227upvote bug fixed
......@@ -28,18 +28,15 @@ class IdeaCard {
const user = JSON.parse(tmp)[0];
try {
let suggestion = await getSuggestions({ id: this.suggestionID });
let suggestion = await await getObjectById("suggestion", this.suggestionID);
console.log(suggestion); // Check if each suggestion has the 'upvotes' array
// Check if suggestion and suggestion[0] are defined
if (!suggestion || suggestion.length === 0 || !suggestion[0]) {
// Check if suggestion and suggestion are defined
if (!suggestion || suggestion.length === 0) {
console.error("Suggestion not found or is invalid");
return false;
}
if (suggestion[0].upvotes.includes(user.id)) {
if (suggestion.upvotes.includes(user.id)) {
return true;
}
} catch (error) {
......@@ -62,10 +59,10 @@ class IdeaCard {
this.upvoteCount++;
} else {
this.upvoteCount--;
}
return upvoted;
}
private header: string;
private department: string;
private name: string;
......@@ -97,6 +94,7 @@ class IdeaCard {
// <img src="images/upvoteIcon.png" class ="upvoteIcon" alt="upvoteIcon">
async generateHTML() {
const userHasUpvoted = await this.hasUserUpvoted();
const upvoteColor = userHasUpvoted ? "purple" : "white";
const strokeColor = userHasUpvoted ? "purple" : "grey";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment