diff --git a/frontend/src/components/Camera/Camera.jsx b/frontend/src/components/Camera/Camera.jsx index 729f990..ed4fa34 100644 --- a/frontend/src/components/Camera/Camera.jsx +++ b/frontend/src/components/Camera/Camera.jsx @@ -37,13 +37,13 @@ export default function Camera() { .then((res) => { setEngFoodName(res.data) }).catch((err) => { - console.log(err) + }) setStatus(status+1); } } const handleYes = useCallback ((name) => { - console.log(name) + axios.get(`${process.env.REACT_APP_API_URL}/food/check?name=${name}`) .then((res) => { if (res.data.checkFlag === -1) { @@ -56,9 +56,9 @@ export default function Camera() { setStatus(0); navigate(`/ingredient/${res.data.id}`); } - console.log(res); + }).catch((err) => { - console.log(err) + }) }, [navigate]); @@ -93,7 +93,7 @@ export default function Camera() { }); handleStream(stream); } catch (err) { - console.log(err); + } }; } @@ -116,7 +116,7 @@ export default function Camera() { const context = canvas.getContext('2d'); context.drawImage(video, 0, 0, canvas.width, canvas.height); const dataUrl = canvas.toDataURL('image/png') - // console.log(dataUrl) + imageMaker(dataUrl); } }, []); @@ -153,7 +153,7 @@ export default function Camera() { .then((res) => { setEngFoodName(res.data) }).catch((err) => { - console.log(err) + }) setStatus(1); } diff --git a/frontend/src/components/Cart/Cart.jsx b/frontend/src/components/Cart/Cart.jsx index 940bd29..fbdc49f 100644 --- a/frontend/src/components/Cart/Cart.jsx +++ b/frontend/src/components/Cart/Cart.jsx @@ -33,7 +33,7 @@ export default function Cart() { .then((res) => { setCartItems(res.data) }).catch((err) => { - console.log(err) + }) // fetchCartItems(); @@ -41,9 +41,9 @@ export default function Cart() { // Check if the SDK is initialized if (Kakao.isInitialized()) { - console.log('Kakao SDK initialized.'); + } else { - console.error('Failed to initialize Kakao SDK.'); + } }, []); @@ -90,7 +90,7 @@ export default function Cart() { return response.data.data.url; } catch (error) { - console.error('Error uploading image to server:', error); + return null; } } @@ -104,7 +104,7 @@ export default function Cart() { // Upload the captured image to the Spring server const imageUrl = await uploadImageToImgbb(imageBlob); - console.log(imageUrl) + if (imageUrl) { Kakao.Link.sendDefault({ diff --git a/frontend/src/components/Cart/CartUtils.js b/frontend/src/components/Cart/CartUtils.js index 46df48b..f668ae6 100644 --- a/frontend/src/components/Cart/CartUtils.js +++ b/frontend/src/components/Cart/CartUtils.js @@ -10,9 +10,9 @@ export const toggleExpandUtil = (prevExpanded, ingredient) => ({ }; export const selectItemUtil = (prevSelectedItems, item, index) => { - console.log(prevSelectedItems) + if (prevSelectedItems[index].some((selectedItem) => selectedItem.ingredientName === item.ingredientName)) { - console.log('Item already added.'); + return prevSelectedItems; } const newSelectedItems = [...prevSelectedItems]; diff --git a/frontend/src/components/Categories/Category.jsx b/frontend/src/components/Categories/Category.jsx index 8eb54a1..fa3fabc 100644 --- a/frontend/src/components/Categories/Category.jsx +++ b/frontend/src/components/Categories/Category.jsx @@ -23,18 +23,18 @@ export default function Category({ categoryList, isChosen, setIsChosen, setPart, }); setPart(ingreAxios.data) } catch(error) { - console.error('Error cheapIngre data: ', error); + } } catch (error) { - console.error('Error cheap data: ', error); + } } else if (chosen === 'Vegetable' || chosen === 'Meat' || chosen === 'Popular') { try { const ingreAxios = await axios.get(`${process.env.REACT_APP_API_URL}/ingredient/${chosen}`, {params}); setPart(ingreAxios.data) } catch (error) { - console.error('Error VegiMeatPop data: ', error); + } } } diff --git a/frontend/src/components/Dish.jsx b/frontend/src/components/Dish.jsx index c23d880..0286cbe 100644 --- a/frontend/src/components/Dish.jsx +++ b/frontend/src/components/Dish.jsx @@ -72,7 +72,7 @@ function useRecipeAPI() { setOriginData(response.data); }) .catch(() => { - console.log('There are no nutrient data.'); + }); } }, [data]); diff --git a/frontend/src/components/Ingredient.jsx b/frontend/src/components/Ingredient.jsx index 28f0580..e769ad5 100644 --- a/frontend/src/components/Ingredient.jsx +++ b/frontend/src/components/Ingredient.jsx @@ -22,11 +22,11 @@ function useIngredientPrice() { useEffect(() => { axios.get(`${process.env.REACT_APP_API_URL}/deal/detail`, { params }) .then(function (response) { - console.log(response.data) + setData(response.data); }) .catch(function (err) { - console.log(err); + }); }, []); return data; @@ -46,7 +46,7 @@ function useRelatedFoodAPI(cardData) { setData(response.data.slice(0, 3)); }) .catch(function (err) { - console.log(err); + }); } }, [cardData]); @@ -81,7 +81,7 @@ function useNutrition() { setData(nutrientData); }) .catch(() => { - console.log('There is no nutrient data'); + }); }, []); return data; @@ -107,7 +107,7 @@ const useCardData = () => { setData(response.data); }) .catch(function (err) { - console.log(err); + }); }, []); return data; diff --git a/frontend/src/components/Main.js b/frontend/src/components/Main.js index 2166827..a9b0743 100644 --- a/frontend/src/components/Main.js +++ b/frontend/src/components/Main.js @@ -50,7 +50,7 @@ function Main() { const dishAxios = await axios.get(`${process.env.REACT_APP_API_URL}/recipe/Popular`, {params}); setDish(dishAxios.data) const ingreAxios = await axios.get(`${process.env.REACT_APP_API_URL}/ingredient/Popular`, {params}); - console.log(ingreAxios.data) + setIngredients(ingreAxios.data) setIngreName(ingreAxios.data[0].name) const priceChangeAxios = await axios.get(`${process.env.REACT_APP_API_URL}/deal/change`, {params}); @@ -68,11 +68,11 @@ function Main() { setIngreDish(ingreDishAxios.data.slice(0, 4)) } catch (error) { - console.error('Error fetching data: ', error); + } } catch (error) { - console.error('Error fetching data: ', error); + } }; const groupDataBySmall = (data) => { diff --git a/frontend/src/components/acoounts/SignUp.jsx b/frontend/src/components/acoounts/SignUp.jsx index 37133c7..a6d754f 100644 --- a/frontend/src/components/acoounts/SignUp.jsx +++ b/frontend/src/components/acoounts/SignUp.jsx @@ -72,17 +72,17 @@ export default function SignUp() { if (response.status === 201) { // 회원가입 성공 시 할 일 - console.log('회원가입 성공', response.data); + navigate('/login'); } else { // 회원가입 실패 시 할 일 - console.log('회원가입 실패', response.data); + } } catch (error) { - console.error('회원가입 오류 : ', error); + } - // console.log('회원가입 정보: ', { email, password, name, gender }) + } return (
diff --git a/frontend/src/components/profile/Profile.jsx b/frontend/src/components/profile/Profile.jsx index b512b79..2fb5a74 100644 --- a/frontend/src/components/profile/Profile.jsx +++ b/frontend/src/components/profile/Profile.jsx @@ -26,14 +26,10 @@ export default function Profile() { try { const response = await axios.get(`${process.env.REACT_APP_API_URL}/record/get`, { headers: headers }); const responseData = response.data; - console.log(response.data) const today = getToday(); - console.log(today) - const todaysData = responseData.filter((entry) => new Date(entry.eatDate) >= today); - console.log(todaysData) - + const todaysData = responseData.filter((entry) => new Date(entry.eatDate) >= today); const totalCalories = todaysData.reduce((total, entry) => total + entry.kcal, 0); - console.log(totalCalories) + const nutrition = { carbs: todaysData.reduce((total, entry) => total + entry.carb, 0), fat: todaysData.reduce((total, entry) => total + entry.fat, 0), @@ -44,18 +40,15 @@ export default function Profile() { 'sugar (g)': todaysData.reduce((total, entry) => total + entry.sugar, 0), 'salt (mg)': todaysData.reduce((total, entry) => total + entry.salt, 0), }; - console.log(other) const lastWeeksData = responseData .filter((entry) => isWithinLastWeek(new Date(entry.eatDate))) .sort((a, b) => new Date(b.eatDate) - new Date(a.eatDate)); // 최신 날짜가 먼저 오도록 정렬 - console.log(lastWeeksData) const ingestedFood = lastWeeksData.map((entry) => { const kcalPer100g = entry.kcal / (entry.servingSize / 100); const foodName = entry.foodName; return [foodName, kcalPer100g]; }); - console.log(ingestedFood) setProfile({ name: responseData[0].user.name, totalCalories, @@ -64,7 +57,7 @@ export default function Profile() { ingestedFood, }) } catch (error) { - console.log('err'); + } }; fetchData(); @@ -80,21 +73,6 @@ const logOut = () => { localStorage.removeItem('hancook-token'); navigate('/login') } - -// function useFetchProfile() { -// const headers = { -// 'Authorization': `Bearer ${localStorage.getItem('hancook-token')}`, -// 'Content-Type': 'application/json', -// }; - -// useEffect(() => { -// axios.get(`${process.env.REACT_APP_API_URL}/record/get`, { headers: headers }) -// .then(res=>createProfile(res.data)) -// .catch (() => { -// console.log('err'); -// }) -// }) -// } const isWithinLastWeek = (date) => { const today = getToday(); @@ -102,49 +80,6 @@ const isWithinLastWeek = (date) => { return date >= oneWeekAgo && date < new Date(today.valueOf() + 24 * 60 * 60 * 1000); }; -// const createProfile = (responseData) => { -// const today = getToday(); -// const todaysData = responseData.filter((entry) => new Date(entry.eatDate) >= today); -// console.log(todaysData) - -// const totalCalories = todaysData.reduce((total, entry) => total + entry.kcal, 0); -// const nutrition = { -// carbs: todaysData.reduce((total, entry) => total + entry.carb, 0), -// fat: todaysData.reduce((total, entry) => total + entry.fat, 0), -// protein: todaysData.reduce((total, entry) => total + entry.protein, 0), -// }; -// const other = { -// 'cholesterol (mg)': todaysData.reduce((total, entry) => total + entry.cholesterol, 0), -// 'sugar (g)': todaysData.reduce((total, entry) => total + entry.sugar, 0), -// 'salt (mg)': todaysData.reduce((total, entry) => total + entry.salt, 0), -// }; - -// const lastWeeksData = responseData -// .filter((entry) => isWithinLastWeek(new Date(entry.eatDate))) -// .sort((a, b) => new Date(b.eatDate) - new Date(a.eatDate)); // 최신 날짜가 먼저 오도록 정렬 - -// const ingestedFood = lastWeeksData.map((entry) => { -// const kcalPer100g = entry.kcal / (entry.servingSize / 100); -// const foodName = entry.foodName; -// return [foodName, kcalPer100g]; -// }); - -// console.log({ -// name: responseData[0].user.name, -// totalCalories, -// nutrition, -// other, -// ingestedFood, -// }) - -// return { -// name: responseData[0].user.name, -// totalCalories, -// nutrition, -// other, -// ingestedFood, -// }; -// }; return ( diff --git a/frontend/src/components/search/Search.jsx b/frontend/src/components/search/Search.jsx index 2a66711..10fef31 100644 --- a/frontend/src/components/search/Search.jsx +++ b/frontend/src/components/search/Search.jsx @@ -33,7 +33,6 @@ export default function Search() { setResult(response.data) setLoading(false) }).catch(err => { - console.log(err) setLoading(false) }) }