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

Function QuestButton

packages/shared/src/components/quest/QuestButton.tsx:632–1256  ·  view source on GitHub ↗
({
  compact = false,
  panelOnly = false,
}: QuestButtonProps)

Source from the content-addressed store, hash-verified

630};
631
632export const QuestButton = ({
633 compact = false,
634 panelOnly = false,
635}: QuestButtonProps): ReactElement => {
636 const router = useRouter();
637 const { optOutLevelSystem } = useSettingsContext();
638 const { user } = useAuthContext();
639 const { data, isPending, isError } = useQuestDashboard();
640 const {
641 mutate: claimQuestReward,
642 isPending: isClaimPending,
643 variables,
644 } = useClaimQuestReward();
645
646 const level = data?.level?.level ?? 1;
647 const levelProgress = data?.level ? getLevelProgress(data.level) : 0;
648 const showLevelSystem = !optOutLevelSystem;
649 const claimableCount = useMemo(() => getClaimableQuestCount(data), [data]);
650 const claimingQuestId = isClaimPending ? variables?.userQuestId : undefined;
651 const [rewardFlightLayers, setRewardFlightLayers] = useState<
652 QuestRewardFlightLayerState[]
653 >([]);
654 const [levelFireworkParticles, setLevelFireworkParticles] = useState<
655 QuestLevelFireworkParticle[]
656 >([]);
657 const [animatedLevel, setAnimatedLevel] = useState<number | null>(null);
658 const [animatedLevelProgress, setAnimatedLevelProgress] = useState<
659 number | null
660 >(null);
661 const [animatingClaimRotationIds, setAnimatingClaimRotationIds] = useState<
662 string[]
663 >([]);
664 const [claimedStampRotationIds, setClaimedStampRotationIds] = useState<
665 string[]
666 >([]);
667 const [
668 animatingClaimedStampRotationIds,
669 setAnimatingClaimedStampRotationIds,
670 ] = useState<string[]>([]);
671 const [deferredClaimedStampRotationIds, setDeferredClaimedStampRotationIds] =
672 useState<string[]>([]);
673 const progressTimersRef = useRef<number[]>([]);
674 const claimedStampTimersRef = useRef<number[]>([]);
675 const currentProgressAnimationRotationIdRef = useRef<string | null>(null);
676 const renderedLevel = animatedLevel ?? level;
677 const renderedLevelProgress = animatedLevelProgress ?? levelProgress;
678 const triggerTooltipContent = data?.level
679 ? `Total XP: ${data.level.totalXp.toLocaleString('de-DE')}`
680 : 'Quests';
681 const triggerButtonSize = compact ? ButtonSize.Small : ButtonSize.Medium;
682 const triggerButtonVariant = compact
683 ? ButtonVariant.Tertiary
684 : ButtonVariant.Float;
685 const triggerVisualSize = compact ? 32 : QUEST_LEVEL_PROGRESS_SIZE;
686 const triggerProgressStroke = compact ? 3 : QUEST_LEVEL_PROGRESS_STROKE;
687 const triggerProgressRadius = (triggerVisualSize - triggerProgressStroke) / 2;
688 const triggerProgressCircumference = 2 * Math.PI * triggerProgressRadius;
689 const triggerVisualClassName = compact ? 'size-8' : 'size-10';

Callers

nothing calls this directly

Calls 14

useSettingsContextFunction · 0.90
useAuthContextFunction · 0.90
useQuestDashboardFunction · 0.90
useClaimQuestRewardFunction · 0.90
getClaimableQuestCountFunction · 0.90
useScrollFadeFunction · 0.90
getQuestRewardHitAtFunction · 0.90
getLevelProgressFunction · 0.85
completeLevelAnimationFunction · 0.85
pushMethod · 0.80
openMethod · 0.80

Tested by

no test coverage detected