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:
@@ -18,7 +18,7 @@ import { buttonVariants } from "@/components/ui/button";
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { ExportMarkdownButton } from "@/components/shared/export-markdown-button";
|
||||
import { getFeatureFlagMatrix, type Tier } from "@/lib/feature-flags";
|
||||
import { getFeatureFlagMatrix, isFeatureAvailableAnyTier, type Tier } from "@/lib/feature-flags";
|
||||
import { EmptyState } from "@/components/shared/empty-state";
|
||||
import { collectionToMarkdown } from "@/lib/markdown/collection";
|
||||
import { getMessages } from "@/lib/i18n/server";
|
||||
@@ -33,7 +33,9 @@ export default async function CollectionPage({ params }: Params) {
|
||||
if (!session) return null;
|
||||
const m = getMessages((session.user as { locale?: string }).locale);
|
||||
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 col = await db.query.collections.findFirst({
|
||||
where: and(eq(collections.id, id), collectionVisibleToViewer(session.user.id)),
|
||||
@@ -85,13 +87,14 @@ export default async function CollectionPage({ params }: Params) {
|
||||
} />
|
||||
<TooltipContent>{m.collections.exportPdf}</TooltipContent>
|
||||
</Tooltip>
|
||||
{canExportMarkdown && <ExportMarkdownButton
|
||||
{markdownExportAvailable && <ExportMarkdownButton
|
||||
markdown={collectionToMarkdown({
|
||||
name: col.name,
|
||||
description: col.description,
|
||||
recipes: recipeList,
|
||||
})}
|
||||
filename={col.name}
|
||||
locked={markdownExportLocked}
|
||||
/>}
|
||||
</>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user