|
|
@ -32,7 +32,7 @@ export default function RecipeSuggestion({ route }) {
|
|
|
|
const [colorFilters, setColorFilters] = useState(colors.cardDetail);
|
|
|
|
const [colorFilters, setColorFilters] = useState(colors.cardDetail);
|
|
|
|
const [isLoading, setIsLoading] = useState(true);
|
|
|
|
const [isLoading, setIsLoading] = useState(true);
|
|
|
|
const [response, setResponse] = useState<Recipes[] | undefined>(undefined);
|
|
|
|
const [response, setResponse] = useState<Recipes[] | undefined>(undefined);
|
|
|
|
const [selectedRecipes, setSelectedRecipes] = useState([]);
|
|
|
|
const [selectedRecipes, setSelectedRecipes] = useState<Recipes[]>([]);
|
|
|
|
console.log(selectedRecipes);
|
|
|
|
console.log(selectedRecipes);
|
|
|
|
const recipeService = new RecipesServices();
|
|
|
|
const recipeService = new RecipesServices();
|
|
|
|
const { ingredients } = route.params;
|
|
|
|
const { ingredients } = route.params;
|
|
|
@ -102,7 +102,8 @@ export default function RecipeSuggestion({ route }) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const recipes: Recipes[] = await recipeService.getRecipeWithIngredients(ids);
|
|
|
|
const recipes: Recipes[] = await recipeService.getRecipeWithIngredients(ids);
|
|
|
|
console.log("Les recettes trouvé : " + recipes)
|
|
|
|
console.log("Les recettes trouvé : " + recipes)
|
|
|
|
if(recipes === null){
|
|
|
|
console.log(recipes[0].id)
|
|
|
|
|
|
|
|
if(recipes[0].id != -1 ){
|
|
|
|
setSelectedRecipes(recipes);
|
|
|
|
setSelectedRecipes(recipes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -211,11 +212,21 @@ export default function RecipeSuggestion({ route }) {
|
|
|
|
<SelectedIngredient
|
|
|
|
<SelectedIngredient
|
|
|
|
ingredientList={ingredients}
|
|
|
|
ingredientList={ingredients}
|
|
|
|
onEvent={handleChildEvent}/>
|
|
|
|
onEvent={handleChildEvent}/>
|
|
|
|
<ScrollView style={{ marginTop: "6%" }} horizontal={true}>
|
|
|
|
<ScrollView style={{ marginTop: "6%" }} horizontal={true} contentContainerStyle={{ flexDirection: 'row' }}>
|
|
|
|
<View style={{ marginHorizontal: 10 }} />
|
|
|
|
{Array.isArray(selectedRecipes) && selectedRecipes.length === 0 ? (
|
|
|
|
{recipeElements}
|
|
|
|
<Text>No recipes</Text>
|
|
|
|
<View style={{ marginHorizontal: 10 }} />
|
|
|
|
) : (
|
|
|
|
</ScrollView>
|
|
|
|
selectedRecipes.map((recipe, index) => (
|
|
|
|
|
|
|
|
<View style={{ marginRight: 10, marginLeft: 20}} key={recipe.id}>
|
|
|
|
|
|
|
|
<RecipeElement
|
|
|
|
|
|
|
|
key={recipe.id}
|
|
|
|
|
|
|
|
recipe={recipe}
|
|
|
|
|
|
|
|
navigateDetails={goDetails}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
</ScrollView>
|
|
|
|
<View style={{marginBottom: "20%"}}/>
|
|
|
|
<View style={{marginBottom: "20%"}}/>
|
|
|
|
</LinearGradient>
|
|
|
|
</LinearGradient>
|
|
|
|
</ScrollView>
|
|
|
|
</ScrollView>
|
|
|
|