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

Function ProfileButton

packages/shared/src/components/profile/ProfileButton.tsx:34–296  ·  view source on GitHub ↗
({
  className,
  settingsIconOnly,
}: ProfileButtonProps)

Source from the content-addressed store, hash-verified

32}
33
34export default function ProfileButton({
35 className,
36 settingsIconOnly,
37}: ProfileButtonProps): ReactElement {
38 const { isOpen, onUpdate, wrapHandler } = useInteractivePopup();
39 const { user, isAuthReady } = useAuthContext();
40 const { showIndicator } = useProfileCompletionIndicator();
41 const { streak, isLoading, isStreaksEnabled } = useReadingStreak();
42 const hasCoresAccess = useHasAccessToCores();
43 const [animatedCores, setAnimatedCores] = useState<number | null>(null);
44 const [animatedReputation, setAnimatedReputation] = useState<number | null>(
45 null,
46 );
47 const clearCounterTimersRef = useRef<
48 Partial<Record<QuestRewardType.Reputation | QuestRewardType.Cores, number>>
49 >({});
50 const activeClaimRef = useRef<
51 Partial<Record<QuestRewardType.Reputation | QuestRewardType.Cores, string>>
52 >({});
53 const coresCounterRef = useRef<HTMLDivElement | null>(null);
54 const reputationCounterRef = useRef<HTMLSpanElement | null>(null);
55 const displayedBalance =
56 typeof animatedCores === 'number'
57 ? animatedCores
58 : user?.balance?.amount ?? 0;
59 const displayedReputation =
60 typeof animatedReputation === 'number'
61 ? animatedReputation
62 : user?.reputation;
63
64 const preciseBalance = formatCurrency(displayedBalance, {
65 minimumFractionDigits: 0,
66 });
67
68 const playCounterImpactAnimation = useCallback(
69 (rewardType: QuestRewardType.Reputation | QuestRewardType.Cores) => {
70 const target =
71 rewardType === QuestRewardType.Reputation
72 ? reputationCounterRef.current
73 : coresCounterRef.current;
74
75 if (!target || typeof target.animate !== 'function') {
76 return;
77 }
78
79 target.animate(
80 [
81 { transform: 'scale(1)' },
82 { transform: 'scale(1.2)', offset: 0.45 },
83 { transform: 'scale(1)' },
84 ],
85 {
86 duration: 180,
87 easing: 'cubic-bezier(0.34, 1.56, 0.64, 1)',
88 },
89 );
90 },
91 [],

Callers

nothing calls this directly

Calls 8

useInteractivePopupFunction · 0.90
useAuthContextFunction · 0.90
useReadingStreakFunction · 0.90
useHasAccessToCoresFunction · 0.90
formatCurrencyFunction · 0.90
largeNumberFormatFunction · 0.90
onUpdateFunction · 0.50

Tested by

no test coverage detected