({
user,
isSameUser,
sticky,
className,
style,
}: HeaderProps)
| 57 | } |
| 58 | |
| 59 | export function Header({ |
| 60 | user, |
| 61 | isSameUser, |
| 62 | sticky, |
| 63 | className, |
| 64 | style, |
| 65 | }: HeaderProps): ReactElement { |
| 66 | const { user: loggedUser } = useAuthContext(); |
| 67 | const { alerts } = useAlertsContext(); |
| 68 | const logOpportunityNudgeClick = useLogOpportunityNudgeClick( |
| 69 | TargetId.ProfilePage, |
| 70 | ); |
| 71 | const { openModal } = useLazyModal(); |
| 72 | const [isMenuOpen, setIsMenuOpen] = useState(false); |
| 73 | const { follow, unfollow } = useContentPreference(); |
| 74 | const router = useRouter(); |
| 75 | const { data: contentPreference } = useContentPreferenceStatusQuery({ |
| 76 | id: user?.id, |
| 77 | entity: ContentPreferenceType.User, |
| 78 | }); |
| 79 | const { unblock, block } = useContentPreference(); |
| 80 | const { logSubscriptionEvent } = usePlusSubscription(); |
| 81 | const canAward = useCanAwardUser({ |
| 82 | sendingUser: loggedUser, |
| 83 | receivingUser: user as LoggedUser, |
| 84 | }); |
| 85 | const hasCoresAccess = useHasAccessToCores(); |
| 86 | const canPurchaseCores = useCanPurchaseCores(); |
| 87 | const { isJobsEnabled } = useJobsFeature(); |
| 88 | |
| 89 | const onReportUser = React.useCallback( |
| 90 | (defaultBlocked = false) => { |
| 91 | openModal({ |
| 92 | type: LazyModal.ReportUser, |
| 93 | props: { |
| 94 | offendingUser: { |
| 95 | id: user.id, |
| 96 | username: user.username || '', |
| 97 | }, |
| 98 | defaultBlockUser: defaultBlocked, |
| 99 | }, |
| 100 | }); |
| 101 | }, |
| 102 | // eslint-disable-next-line react-hooks/exhaustive-deps |
| 103 | [user], |
| 104 | ); |
| 105 | |
| 106 | const blocked = contentPreference?.status === ContentPreferenceStatus.Blocked; |
| 107 | |
| 108 | const options: MenuItemProps[] = [ |
| 109 | { |
| 110 | icon: <MenuIcon Icon={BlockIcon} />, |
| 111 | label: `${blocked ? 'Unblock' : 'Block'} ${user.username}`, |
| 112 | action: () => |
| 113 | blocked |
| 114 | ? unblock({ |
| 115 | id: user.id, |
| 116 | entity: ContentPreferenceType.User, |
nothing calls this directly
no test coverage detected