Skip to content

Problema em exibir a lista dos ingredientes selecionados da tela de detalhes no componente recipe/[id].tsx #1

@hunguibek

Description

@hunguibek

Solução: Criar uma função no Supabase
CREATE OR REPLACE FUNCTION get_ingredients_by_recipe_id(p_recipe_id UUID) RETURNS TABLE (id UUID, name character varying, image text) AS $$ BEGIN RETURN QUERY SELECT i.id, i.name, i.image FROM recipes_ingredients ri INNER JOIN ingredients i ON ri.ingredient_id = i.id WHERE ri.recipe_id = p_recipe_id; END; $$ LANGUAGE plpgsql;

Substituir a função findByRecipeId em src\services\ingredientsService.ts por:
async function findByRecipeId(id: string) { const { data } = await supabase.rpc('get_ingredients_by_recipe_id', { p_recipe_id: id }); return data || []; }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions