fix: IngredientWiki fallback to scientificTerms from API with keywords as benefits
Deploy Canina / deploy (push) Successful in 1m8s
Deploy Canina / deploy (push) Successful in 1m8s
This commit is contained in:
1 parent
f71b22a664
commit
2c47e35153
2 files changed
+22
-1
No files matched your search
@@ -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
|
||||
|
||||
@@ -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<IngredientInfo[]>([]);
|
||||
const [products, setProducts] = useState<Product[]>([]);
|
||||
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 (
|
||||
<div className="bg-white py-12 px-4 overflow-hidden font-vazir" dir="rtl">
|
||||
|
||||
Reference in new issue
Block a user