From 2c47e351534c22298bb84bc00250a8e12aabee84 Mon Sep 17 00:00:00 2001 From: devops Date: Tue, 14 Jul 2026 12:27:43 +0000 Subject: [PATCH] fix: IngredientWiki fallback to scientificTerms from API with keywords as benefits --- backend/Dockerfile | 1 + .../application/components/IngredientWiki.tsx | 22 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 14ac4b52..d06a7363 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -8,6 +8,7 @@ RUN npx prisma generate && npm run build FROM node:22-alpine RUN apk add --no-cache openssl +RUN mkdir -p /app/uploads && chown node:node /app/uploads WORKDIR /app COPY --from=builder /app/package*.json ./ COPY --from=builder /app/node_modules ./node_modules diff --git a/frontend/application/components/IngredientWiki.tsx b/frontend/application/components/IngredientWiki.tsx index d5beb92e..57c2c58f 100644 --- a/frontend/application/components/IngredientWiki.tsx +++ b/frontend/application/components/IngredientWiki.tsx @@ -11,6 +11,7 @@ import { useRouter } from 'next/navigation'; export default function IngredientWiki() { const router = useRouter(); const texts = useSettingsStore(state => state.texts); + const scientificTerms = useSettingsStore(state => state.scientificTerms); const [ingredientsWiki, setIngredientsWiki] = useState([]); const [products, setProducts] = useState([]); const [searchQuery, setSearchQuery] = useState(""); @@ -31,12 +32,31 @@ export default function IngredientWiki() { description: item.description, benefits: Array.isArray(item.benefits) ? item.benefits : [] }))); + return; } } catch (e) { console.error("Failed to parse ingredients_wiki:", e); } } - }, [texts]); + const terms = Object.values(scientificTerms); + if (terms.length > 0) { + setIngredientsWiki(terms.map((t: any) => { + let benefits: string[] = []; + if (t.keywords) { + try { + const parsed = typeof t.keywords === 'string' ? JSON.parse(t.keywords) : t.keywords; + if (Array.isArray(parsed)) benefits = parsed; + } catch (e) {} + } + return { + id: t.key, + name: t.term, + description: t.definition, + benefits + }; + })); + } + }, [texts, scientificTerms]); return (