fix: standardize locked-vs-hidden treatment across all 9 per-tier gated features (v0.79.0)
Rule, applied consistently everywhere via a new isFeatureAvailableAnyTier() helper: if a feature is enabled on at least one tier, it stays visible for locked-out viewers with a small "Pro" badge and opens an upgrade prompt on click; if a feature is disabled on every tier, it hides entirely, since there's no upgrade path to point at. Covers: recipe variations, meal/drink pairings, nutrition estimation, Markdown export (5 call sites), weekly nutrition, import from URL, import from photo, and the Instacart grocery-delivery menu item. Previously inconsistent — some hid outright, one showed a lock icon overlapping its own icon. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,7 @@ import { ExpiringLeftovers } from "@/components/pantry/expiring-leftovers";
|
||||
import { scoreRecipesAgainstPantry } from "@/lib/pantry-match";
|
||||
import { dishExpiresAt, daysUntil, isLeftoverExpiringSoon } from "@/lib/leftover-match";
|
||||
import { getPublicUrl } from "@/lib/storage";
|
||||
import { getFeatureFlagMatrix, type Tier } from "@/lib/feature-flags";
|
||||
import { getFeatureFlagMatrix, isFeatureAvailableAnyTier, type Tier } from "@/lib/feature-flags";
|
||||
|
||||
export const metadata: Metadata = {};
|
||||
|
||||
@@ -18,7 +18,9 @@ export default async function PantryPage() {
|
||||
const session = await auth.api.getSession({ headers: await headers() });
|
||||
if (!session) return null;
|
||||
const viewerTier = (session.user as { tier?: string }).tier as Tier | undefined ?? "free";
|
||||
const canExportMarkdown = (await getFeatureFlagMatrix()).markdown_export[viewerTier];
|
||||
const featureFlags = await getFeatureFlagMatrix();
|
||||
const markdownExportLocked = !featureFlags.markdown_export[viewerTier];
|
||||
const markdownExportAvailable = isFeatureAvailableAnyTier(featureFlags, "markdown_export");
|
||||
|
||||
const [items, candidateRecipes, cookedDishes] = await Promise.all([
|
||||
db.query.pantryItems.findMany({
|
||||
@@ -78,7 +80,7 @@ export default async function PantryPage() {
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<PantryPageHeader items={mappedItems} canExportMarkdown={canExportMarkdown} />
|
||||
<PantryPageHeader items={mappedItems} markdownExportAvailable={markdownExportAvailable} markdownExportLocked={markdownExportLocked} />
|
||||
<ExpiringLeftovers leftovers={leftovers} />
|
||||
<ExpiringSoonSuggestions suggestions={suggestions} />
|
||||
<PantryManager key={mappedItems.map((i) => i.id).join(",")} initialItems={mappedItems} />
|
||||
|
||||
Reference in New Issue
Block a user