Files
Epicure/apps/web/lib/feature-prefs.ts
T
Arnaud 274c50c2f6 fix: desktop nav ignored feature toggles; add chatbots toggle (v0.62.0)
Feature toggles (Settings -> Features) were filtered into
visibleNavItems but the desktop horizontal nav still mapped over the
raw NAV_ITEMS list, so hiding a feature only worked on mobile. Both
nav renders now read the same filtered list.

Also adds a Chatbots toggle covering the recipe cooking-chat panel
and the recipe-list cooking assistant, wired end-to-end (schema,
migration, feature-prefs lib, API route, settings form, i18n,
openapi).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-20 23:23:01 +02:00

21 lines
930 B
TypeScript

import { db, userFeaturePrefs, eq } from "@epicure/db";
export type FeatureKey = "nutrition" | "pantry" | "mealPlan" | "shoppingLists" | "collections" | "messages" | "chatbots";
export type FeaturePrefs = Record<FeatureKey, boolean>;
const DEFAULT_PREFS: FeaturePrefs = {
nutrition: true, pantry: true, mealPlan: true, shoppingLists: true, collections: true, messages: true, chatbots: true,
};
/** No row yet means every feature defaults to on — same default the DB columns encode. */
export async function getFeaturePrefs(userId: string): Promise<FeaturePrefs> {
const row = await db.query.userFeaturePrefs.findFirst({ where: eq(userFeaturePrefs.userId, userId) });
if (!row) return { ...DEFAULT_PREFS };
return {
nutrition: row.nutrition, pantry: row.pantry, mealPlan: row.mealPlan,
shoppingLists: row.shoppingLists, collections: row.collections, messages: row.messages,
chatbots: row.chatbots,
};
}