diff --git a/.DS_Store b/.DS_Store
index 0ef59fa..5c59715 100644
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/packages/.DS_Store b/packages/.DS_Store
index 81dbad8..77690e6 100644
Binary files a/packages/.DS_Store and b/packages/.DS_Store differ
diff --git a/packages/ReverseFood/app/_layout.tsx b/packages/ReverseFood/app/_layout.tsx
index 85d7899..2751e60 100644
--- a/packages/ReverseFood/app/_layout.tsx
+++ b/packages/ReverseFood/app/_layout.tsx
@@ -1,5 +1,4 @@
import { Stack } from "expo-router/stack";
-import "react-native-reanimated";
export default function Layout() {
return (
diff --git a/packages/ReverseFood/app/info.js b/packages/ReverseFood/app/info.js
index b438bc7..70cf80f 100644
--- a/packages/ReverseFood/app/info.js
+++ b/packages/ReverseFood/app/info.js
@@ -2,48 +2,44 @@ import {View , Text } from "react-native";
import { our_styles } from "../styles/styles.jsx";
import { useLocalSearchParams } from "expo-router";
import Table from "../components/table.js";
-import SecureStore from "expo-secure-store";
+import * as SecureStore from "expo-secure-store";
import { useEffect, useState } from "react";
-const URL = "http://localhost:18000/image";
+const URL = "http:/10.144.207.193:3000/image";
-export default function info (){
-
- const [myData , setData] = useState({ name : 0, description : 0, foodCategory : 0, ingredients : 0, nutrients : []})
-
+export default info = () => {
+ const [myData , setData] = useState({ name : "Loading", description : "Loading", foodCategory : "Loading", ingredients : "Loading", nutrients : []})
- useEffect(() => {
- const p = useLocalSearchParams();
- fetchData(p)
- ;});
-
- const fetchData = (params) => {SecureStore.getItemAsync("token").then((token) => {
+ async function fetchData () { await SecureStore.getItemAsync("token").then((token) => {
+ const params = useLocalSearchParams();
if (token === undefined) {
console.log("No token found");
}
- fetch(URL + {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- "Authorization": token,
- },
- body: JSON.stringify({
+ let searchData = {
image: params.image,
foodName: params.foodName,
ingredients: params.ingredients,
description: params.description,
- }),
+ };
+ console.log(searchData.foodName, searchData.ingredients, searchData.description);
+ fetch(URL, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ "Authorization": `Bearer ${token}`,
+ },
+ body: JSON.stringify(searchData),
}).then((response) => {
if (response.status === 200) {
response.json().then((myData) => {
- setData(myData);
+ return myData
});
} else {
- return null;
+ console.log("Error: " + response.status);
}
}).catch((error) => {
console.log(error);
@@ -53,13 +49,21 @@ export default function info (){
console.log(error);
return null;
}})};
+
+ useEffect(() => {
+ fetchData().then((data) => {setData({
+ name : data.name, description : (data.name === undefined), foodCategory : data.foodCategory, ingredients : data.ingredients, nutrients : data.nutrients
+ })}).catch((error) => console.log(error))
+ ;}, []);
+
+
+
return
-{(myData === 0) ? "Loading" : myData.name}
+{(myData.name === 0) ? "Loading" : myData.name}
-{(myData === 0) ? "Loading" : myData.description}
-[(myData === 0) ? "Loading" : myData.foodCategory]
-[(myData === 0) ? "Loading" : myData.ingredients]
-
+{myData.name}
+{myData.foodCategory}
+{myData.ingredients}
}
\ No newline at end of file
diff --git a/packages/ReverseFood/components/FoodInput.js b/packages/ReverseFood/components/FoodInput.js
index c2c91df..32a0ab1 100644
--- a/packages/ReverseFood/components/FoodInput.js
+++ b/packages/ReverseFood/components/FoodInput.js
@@ -16,6 +16,9 @@ import { colors, ourStyles } from "../styles/styles.jsx";
import { router } from "expo-router";
import SecureStore from "expo-secure-store";
+function swutchPages(image, foodName, ingredients, desc){
+ router.push({pathname: "info", params: {image: image, foodName: foodName, ingredients: ingredients, description: desc}})
+}
export default function FoodInput() {
@@ -71,9 +74,7 @@ export default function FoodInput() {
value={desc}
>
-
+