elmeg-demo/frontend/components/social/social-wrapper.tsx

22 lines
753 B
TypeScript

"use client"
import { usePreferences } from "@/contexts/preferences-context"
interface SocialWrapperProps {
type: "comments" | "ratings" | "reviews"
children: React.ReactNode
}
export function SocialWrapper({ type, children }: SocialWrapperProps) {
const { preferences, loading } = usePreferences()
// While loading, show content (assume defaults: wiki_mode=false, show_comments=true, show_ratings=true)
// Only hide once we know the user's preference is explicitly set to hide
if (!loading) {
if (preferences.wiki_mode) return null
if (type === "comments" && !preferences.show_comments) return null
if (type === "ratings" && !preferences.show_ratings) return null
}
return <>{children}</>
}