Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/main/java/com/study/reactTest/StringtoArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ public static String[] stringToArray(String foodName){
String[] arr = foodName.split(",");
for (String item : arr) {
System.out.println(item);
<<<<<<< HEAD
=======
}
return arr;
}

public static String[] stringToArray(){ // 긴 스트링을 스페이스 바 2칸 기준으로 나눠서 배열에 저장
//String food = "Gamjatang Chicken Gomtan";
//String foodString = "불고기 김치 잡채 된장찌개 삼겹살 짱통";
String foodString = StaticData.FoodList;
String[] arr = foodString.split(" "); //
for (String item : arr) {
System.out.println(item);
>>>>>>> 0bc70600ad971915cfe9fed51c8bcd77556398fe
}
return arr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class FoodController {
private final FoodService foodService; // 이 필드를 매개변수로하는 컨트롤러 생성자를 만들어줌

@PostMapping("/compare-food")
<<<<<<< HEAD
public List<FoodDTO> compareFood(@RequestBody Map<String,String> request) {
String foodName=request.get("foodName");
System.out.println(foodName);
Expand All @@ -38,6 +39,10 @@ public List<FoodDTO> compareFood(@RequestBody Map<String,String> request) {
array=StringtoArray.stringToArray(foodName); // 배열 만들어서 안에 음식이름 차례대로 삽입
}

=======
public List<FoodDTO> compareFood(@RequestBody String foodName) {
String[] array = StringtoArray.stringToArray(foodName); // 배열 만들어서 안에 음식이름 차례대로 삽입
>>>>>>> 0bc70600ad971915cfe9fed51c8bcd77556398fe
List<FoodDTO> foodDtoList = foodService.searchFood(array); // 리스트 만들어서 서비스 이용해서 해당 음식 데이터 가져오기

for (FoodDTO foodDTO : foodDtoList) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/ketchup/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
async src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDuISEVEDwkElLoYRbG2EYmbxvvrzJ-W3g&libraries=places,geometry"></script>

<title>Ketchup</title>
<style>
body{
margin: 0;
}
</style>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
7 changes: 3 additions & 4 deletions src/main/ketchup/src/component/Common/BottomNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const Wrapper = styled.div`
bottom: 0;
left: 0;
right: 0;
height: 55px;
border-top: 1px solid #dee2e6;
z-index: 3;
`;
Expand All @@ -27,21 +26,21 @@ const BottomNav = () => {
<BottomNavigationAction
label="Main"
value="main"
icon={<MdHome size={40} />}
icon={<MdHome size="10vw" />}
component={Link} // Link로 변경
to="/main" // 링크의 목적지 설정
/>
<BottomNavigationAction
label="Camera"
value="camera"
icon={<MdCameraAlt size={40} />}
icon={<MdCameraAlt size="10vw" />}
component={Link} // Link로 변경
to="/main/picture"
/>
<BottomNavigationAction
label="Search"
value="search"
icon={<MdSearch size={40} />}
icon={<MdSearch size="10vw" />}
component={Link} // Link로 변경
to="/googleMap" // 링크의 목적지 설정
/>
Expand Down
34 changes: 34 additions & 0 deletions src/main/ketchup/src/component/ResInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,42 @@ const ResInfo = () => {
const name = params.get("name");
//const img = params.get("img"); // 단일 이미지 URL로 변경
const rating = params.get("star");
<<<<<<< HEAD
const location = params.get("location");
//const user_ratings_total = null;
=======
const placeLocation = params.get("location");

const key = `${name}-${placeLocation}`;

useEffect(() => {
const checkAndSaveData = async () => {
const exists = await checkIfDataExists(key);
if (exists) {
const data = await getDataFromFirebase(key);
setMenu(data.menu); // 데이터가 존재하면 menu 상태 업데이트

// menu 문자열을 배열로 변환하고 콘솔에 출력
if (data.menu) {
const menuArray = data.menu.split(",");
const response = await axios.post('http://localhost:8080/compare-food', {
foodName: menu, // Set an empty string or any default value as needed
});
console.log(response.data);
menuArray.forEach((item, index) => {
console.log(`Menu item ${index + 1}: ${item}`);
});
}
} else {
saveToFirebase(name, placeLocation, menu);
}
};

if (name && placeLocation) {
checkAndSaveData();
}
}, [name, placeLocation, key, menu]);
>>>>>>> 0bc70600ad971915cfe9fed51c8bcd77556398fe

const handleSoundImageClick = async () => {
setSoundImageSrc(
Expand Down
84 changes: 47 additions & 37 deletions src/main/ketchup/src/component/RestructureItem.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//메뉴판 재구성 아이템
import { Link } from "react-router-dom";
import styled from "styled-components";
import { useState } from "react";
Expand All @@ -14,7 +13,7 @@ const Box = styled.div`
padding: 20px;
max-width: 300px;
transition: transform 0.2s;

width: 300px; /* 고정 너비 설정 */
display: flex;
flex-direction: column;
align-items: center;
Expand Down Expand Up @@ -60,12 +59,6 @@ const SoundImage = styled.img`
width: 30px;
cursor: pointer;
`;
const CollapsibleDescription = styled.div`
max-height: ${({ isOpen }) => (isOpen ? '1000px' : '100px')};
overflow: hidden;
transition: max-height 0.3s ease-in-out;

`;

const Description = styled.p`
font-size: 1rem;
Expand All @@ -88,14 +81,27 @@ const Icon = styled.span`
margin-right: 5px;
font-size: 2rem;
color: #c35050; // 아이콘의 색상

`;

const MinusIcon = styled(MdRemove)``;
const PlusIcon = styled(MdAdd)``;
const MinusIcon = styled(MdRemove)``;

const AccordionContent = styled.div`
max-height: ${({ isOpen }) => (isOpen ? "500px" : "0")};
overflow: hidden;
transition: max-height 0.3s ease-out;
p {
font-size: 1.0rem; /* 글자 크기 더 작게 설정 */
color: #6d6b6b;
margin: 0;
line-height: 1.5;
}
`;

const RestructureItem = ({ food }) => {
const [soundImageSrc, setSoundImageSrc] = useState("https://img.icons8.com/?size=100&id=2795&format=png&color=000000");
const [isOpen, setIsOpen] = useState(false);

const handleSoundImageClick = async () => {
setSoundImageSrc("https://img.icons8.com/?size=100&id=9982&format=png&color=000000"); // 음향 이미지
try {
Expand All @@ -105,9 +111,10 @@ const RestructureItem = ({ food }) => {
setSoundImageSrc("https://img.icons8.com/?size=100&id=2795&format=png&color=000000");
}
};

const {
id = 1,
foodimage = "",
base64Image = "",
foodcalcium = 0,
foodcalorie = 0,
foodcarbohydrate = 0,
Expand All @@ -123,44 +130,47 @@ const RestructureItem = ({ food }) => {
foodsugars = 0
} = food || {};

console.log(food);

// 각 음식 설명의 접기/펼치기 상태를 관리하는 useState 훅 사용.
const [expanded, setExpanded] = useState({});

const toggleDescription = (id) => {
setExpanded((prevExpanded) => ({
...prevExpanded,
[id]: !prevExpanded[id],
}));
};

return (
<Box key={id}>
{/* 음식 이미지 */}
<ImageWrapper>
<Image src={foodimage ? foodimage : 'http://via.placeholder.com/200'} alt={foodname} />
<Image src={base64Image ? base64Image[0].getUrl() : 'http://via.placeholder.com/200'} alt={foodname} />
</ImageWrapper>

{/* 음식 이름과 소리 이미지 */}
<NameWrapper>
<Name to={`/main/picture/restructure/detail/${id}`}>
{foodname}
</Name>
<SoundImage src={soundImageSrc} onClick={handleSoundImageClick} />
</NameWrapper>
{/* CollapsibleDescription을 사용하여 설명을 감싸고, 접기/펼치기 버튼을 추가합니다. */}
<CollapsibleDescription isOpen={expanded[id]}>
<Description onClick={() => toggleDescription(id)}>{foodprofile}</Description>
</CollapsibleDescription>
{/* 접기/펼치기 버튼을 클릭할 때 해당 음식 설명의 상태를 변경합니다. */}

<ToggleButton onClick={() => toggleDescription(id)}>
{expanded[id] ?
<Icon><MinusIcon /></Icon> :
<Icon><PlusIcon /></Icon>
}

{/* 음식 설명 */}
{!isOpen && <Description>{foodprofile}</Description>}

{/* 아코디언 콘텐츠 */}
{isOpen && (
<AccordionContent isOpen={isOpen}>
<p>calorie: {foodcalorie} kcal</p>
<p>protein: {foodprotein} g</p>
<p>fat: {foodfat} g</p>
<p>carbohydrate: {foodcarbohydrate} g</p>
<p>sugars: {foodsugars} g</p>
<p>calcium: {foodcalcium} mg</p>
<p>iron: {foodiron} mg</p>
<p>potassium: {foodpotassium} mg</p>
<p>salt: {foodsalt} g</p>
</AccordionContent>
)}

{/* + 버튼 */}
<ToggleButton onClick={() => setIsOpen(!isOpen)}>
<Icon>{isOpen ? <MinusIcon /> : <PlusIcon />}</Icon>
</ToggleButton>


</Box>
);
};


export default RestructureItem;
export default RestructureItem;
2 changes: 1 addition & 1 deletion src/main/ketchup/src/component/TTS.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const getSpeech = (text) => {
if (voice) {
utterThis.voice = voice;
} else {
alert("Voice list is empty");
//alert("Voice list is empty");
return;
}

Expand Down
Loading