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

Function Header

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

Source from the content-addressed store, hash-verified

57}
58
59export 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,

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
useJobsFeatureFunction · 0.90
largeNumberFormatFunction · 0.90

Tested by

no test coverage detected