({
compact = false,
panelOnly = false,
}: QuestButtonProps)
| 630 | }; |
| 631 | |
| 632 | export 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'; |
nothing calls this directly
no test coverage detected