MCPcopy Create free account
hub / github.com/dailydotdev/apps / Header

Function Header

packages/shared/src/components/profile/Header.tsx:58–304  ·  view source on GitHub ↗
({
  user,
  isSameUser,
  sticky,
  className,
  style,
}: HeaderProps)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

useAuthContextFunction · 0.90
useAlertsContextFunction · 0.90
useLazyModalFunction · 0.90
useContentPreferenceFunction · 0.90
usePlusSubscriptionFunction · 0.90
useCanAwardUserFunction · 0.90
useHasAccessToCoresFunction · 0.90
useCanPurchaseCoresFunction · 0.90
largeNumberFormatFunction · 0.90
getPathnameWithQueryFunction · 0.90

Tested by

no test coverage detected