"use client"; import { useI18n } from "@/translations/provider"; import { useMarriageProfileQuery } from "@/hooks/marriage/use-profile-main"; import { NavigationButton, type NavigationButtonProps, } from "./navigation-button"; import { hasSupportAccess } from "./support-access"; type PageHeaderProps = { className?: string; /** Props for the left button. Defaults to icon="back". */ leftButton?: NavigationButtonProps; /** Props for the right button. Defaults to icon="support" with support label. */ rightButton?: NavigationButtonProps; /** * When false, skip the profile query entirely. Useful on pages where the * right button has an explicit onClick and no icon resolution is needed * (e.g. Intro's "support" icon that opens a report sheet). * Defaults to true. */ enableProfileQuery?: boolean; profile?: any; /** * When true, header stays fixed/sticky at the top with Flutter native toolbar height (56px), * safe area top padding, and frosted backdrop blur during scroll. */ sticky?: boolean; }; export function PageHeader({ className, leftButton, rightButton, enableProfileQuery = true, profile: profileProp, sticky = false, }: PageHeaderProps) { const { dictionary: t } = useI18n(); // Only fetch profile when needed for icon resolution (subscription/support // visibility depends on profile data). Pages that pass an explicit onClick // for the right button can set enableProfileQuery=false to avoid an // unnecessary API call (e.g. anonymous Intro). const iconFromProp = rightButton?.icon; const isCustomRightButton = !!rightButton?.onClick || (iconFromProp !== undefined && iconFromProp !== "subscription" && iconFromProp !== "support"); const needsProfile = enableProfileQuery && !rightButton?.onClick && !profileProp; const { data: queriedProfile } = useMarriageProfileQuery({ enabled: needsProfile, }); const profile = profileProp !== undefined ? profileProp : queriedProfile; const isMale = profile?.gender === "male"; const { icon: rightButtonIcon, ...rightButtonRest } = rightButton || {}; return (
{leftButton?.className?.includes("hidden") ? (
) : ( )}

{t["Marriage"] || "Marriage"}

{isCustomRightButton ? ( ) : (
{isMale && ( )["Subscription Status"] || (t as Record)["Subscription"] || "Subscription"} /> )} )["More"] || "More"} {...rightButtonRest} />
)}
); } export default PageHeader;