Skip to content

Commit

Permalink
Fix passing food object to Council
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-karlsson committed Apr 5, 2024
1 parent cac43e9 commit 6e7e1af
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 2 additions & 0 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ function App() {
setIsActiveOverlay(true);

if (!topic) {
// Reset from the start
setHumanName("");
setCurrentView("landing");
} else {
// Reset from foods selection
setCurrentView("foods");
}
}
Expand Down
6 changes: 2 additions & 4 deletions client/src/components/Council.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useEffect } from "react";
import io from "socket.io-client";
import foodsData from "../foods.json";
import FoodItem from "./FoodItem";
import Overlay from "./Overlay";
import About from "./About";
Expand All @@ -14,8 +13,7 @@ import useWindowSize from "../hooks/useWindowSize";

function Council({ options }) {
const { foods } = options;
const { foodsData } = foodsData;
const [activeOverlay, setActiveOverlay] = useState(""); // Tracks which overlay to show
const [activeOverlay, setActiveOverlay] = useState("");
const { width: screenWidth } = useWindowSize();

const foodsContainerStyle = {
Expand Down Expand Up @@ -92,7 +90,7 @@ function Council({ options }) {
<div style={foodsContainerStyle}>
{foods.map((food, index) => (
<FoodItem
key={index}
key={food.name}
food={food}
index={index}
total={foods.length}
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/FoodInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ function FoodInfo({ food }) {
return null;
}

console.log(food.name);

const capitalizedFoodName = capitalizeFirstLetter(food.name);

return (
Expand Down
7 changes: 5 additions & 2 deletions client/src/components/FoodItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ function FoodItem({ food, index, total, screenWidth }) {

return (
<div style={foodItemStyle(index, total)}>
<img src={`/images/foods/${food}.png`} style={responsiveStyle} />
<img
src={`/images/foods/${food}.png`}
src={`/images/foods/${food.name}.png`}
style={responsiveStyle}
/>
<img
src={`/images/foods/${food.name}.png`}
style={{ ...responsiveStyle, ...foodImageShadowStyle(index, total) }}
/>
</div>
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/Foods.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ function Foods({ topic, onContinueForward }) {
}

function handleOnMouseEnter(food) {
console.log("Setting current food:", food); // This should log the entire food object

setCurrentFood(food);
}

Expand Down

0 comments on commit 6e7e1af

Please sign in to comment.