Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging Release #1378

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/components/ProfilePage/LevelBox/LevelIndicatorsSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Skeleton from '@mui/material/Skeleton';
import { LevelIndicatorWrapper } from './ProgressionBar.style';

export const LevelIndicatorsSkeleton = () => {
return (
<LevelIndicatorWrapper>
<Skeleton
width={135}
height={32}
sx={{ transform: 'unset', borderRadius: '16px' }}
/>
<Skeleton
width={135}
height={32}
sx={{ transform: 'unset', borderRadius: '16px' }}
/>
</LevelIndicatorWrapper>
);
};
60 changes: 37 additions & 23 deletions src/components/ProfilePage/LevelBox/ProgressionBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { LevelData } from '@/types/loyaltyPass';
import { Box } from '@mui/material';
import Skeleton from '@mui/material/Skeleton';
import { LevelIndicator } from './LevelIndicator';
import { LevelIndicatorsSkeleton } from './LevelIndicatorsSkeleton';
import {
LevelIndicatorWrapper,
ProgressionChart,
Expand All @@ -12,12 +15,14 @@ interface ProgressionBarProps {
ongoingValue?: number;
levelData?: LevelData;
hideLevelIndicator?: boolean;
loading?: boolean;
}

export const ProgressionBar = ({
ongoingValue,
levelData,
hideLevelIndicator,
loading,
}: ProgressionBarProps) => {
const calcWidth =
ongoingValue && levelData
Expand All @@ -30,30 +35,39 @@ export const ProgressionBar = ({

return (
<ProgressionContainer hideLevelIndicator={hideLevelIndicator}>
{levelData ? (
<>
<ProgressionChart>
<ProgressionChartScore
ongoingValue={ongoingValue}
calcWidth={calcWidth}
levelData={levelData}
/>
<ProgressionChartBg />
</ProgressionChart>
{!hideLevelIndicator && levelData.level && (
<LevelIndicatorWrapper>
<LevelIndicator
level={levelData.level}
bound={levelData.minPoints}
{!loading && !!levelData ? (
!!levelData && (
<>
<ProgressionChart>
<ProgressionChartScore
ongoingValue={ongoingValue}
calcWidth={calcWidth}
levelData={levelData}
/>
<LevelIndicator
level={levelData.level + 1}
bound={levelData.maxPoints}
/>
</LevelIndicatorWrapper>
)}
</>
) : null}
<ProgressionChartBg />
</ProgressionChart>
{hideLevelIndicator ? null : levelData ? (
<LevelIndicatorWrapper>
<LevelIndicator
level={levelData.level ?? 0}
bound={levelData.minPoints}
/>
<LevelIndicator
level={(levelData.level ?? 0) + 1}
bound={levelData.maxPoints}
/>
</LevelIndicatorWrapper>
) : (
<LevelIndicatorsSkeleton />
)}
</>
)
) : (
<Box>
<Skeleton width={'100%'} height={16} sx={{ transform: 'unset' }} />
{!hideLevelIndicator && <LevelIndicatorsSkeleton />}
</Box>
)}
</ProgressionContainer>
);
};
6 changes: 5 additions & 1 deletion src/components/ProfilePage/LevelBox/TierBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export const TierBox = ({ points, loading }: TierBoxProps) => {
<PointsBox points={points} />
<LevelBox level={levelData.level} loading={loading} />
</TierInfoBox>
<ProgressionBar ongoingValue={points} levelData={levelData} />
<ProgressionBar
ongoingValue={points}
levelData={levelData}
loading={loading}
/>
</Box>
</TierMainBox>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ interface QuestCardProps {
points?: number;
link?: string;
startDate?: string;
action?: string;
endDate?: string;
platformName?: string;
platformImage?: string;
Expand All @@ -67,6 +68,7 @@ interface QuestCardProps {
export const QuestCardDetailled = ({
title,
image,
action,
points,
link,
slug,
Expand Down Expand Up @@ -170,6 +172,7 @@ export const QuestCardDetailled = ({
label={`${rewardsProgress?.earnedXP}`}
tooltip={t('questCard.earnedXPDescription', {
earnedXP: rewardsProgress?.earnedXP,
action: action,
})}
active={true}
>
Expand Down Expand Up @@ -220,9 +223,13 @@ export const QuestCardDetailled = ({
<XPRewardsInfo
bgColor={!completed ? '#31007A' : '#42B852'}
label={`+${points}`}
tooltip={t('questCard.xpToEarnDescription', {
xpToEarn: points,
})}
tooltip={
rewardsProgress &&
t('questCard.xpToEarnDescription', {
xpToEarn: points,
action: action,
})
}
active={true}
>
{!completed ? (
Expand All @@ -237,6 +244,7 @@ export const QuestCardDetailled = ({
{rewardsProgress && (
<ProgressionBar
ongoingValue={rewardsProgress.currentValue}
loading={false}
levelData={{
maxPoints: rewardsProgress.max,
minPoints: rewardsProgress.min,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { XPDisplayBox } from './QuestCard.style';
interface XPRewardsInfoProps {
bgColor: string;
label: string;
tooltip: string;
tooltip?: string;
active?: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,43 @@
import { useTranslation } from 'react-i18next';
import { useOngoingNumericQuests } from 'src/hooks/useOngoingNumericQuests';
import { QuestCardSkeleton } from '../QuestCard/QuestCardSkeleton';
import { QuestCardDetailled } from '../QuestCardDetailled/QuestCardDetailled';

type NumericAction = 'chain_oor' | 'transact_oor' | 'swap_oor' | 'bridge_oor';

export const QuestCarouselNumericItems = () => {
const { t } = useTranslation();

const {
data: ongoingNumericQuests,
isLoading: isongoingNumericQuestsLoading,
} = useOngoingNumericQuests();

const getNumericAction = (type: NumericAction) => {
switch (type) {
case 'chain_oor':
return `${t('questCard.action.chain_oor')}`;
case 'transact_oor':
return `${t('questCard.action.transact_oor')}`;
case 'swap_oor':
return `${t('questCard.action.swap_oor')}`;
default:
return `${t('questCard.action.bridge_oor')}`;
}
};

return !isongoingNumericQuestsLoading
? ongoingNumericQuests?.map((numericQuest, index) => (
<QuestCardDetailled
action={getNumericAction(numericQuest.type as NumericAction)}
key={`available-mission-${index}`}
title={numericQuest.displayName}
image={numericQuest.image}
points={numericQuest.nextRangeXP - numericQuest.currentRangeXP}
points={
numericQuest.currentValue < numericQuest.min
? numericQuest.currentRangeXP
: numericQuest.nextRangeXP - numericQuest.currentRangeXP
}
rewardsProgress={{
min: numericQuest.min,
max: numericQuest.max,
Expand Down
10 changes: 8 additions & 2 deletions src/i18n/resources.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,14 @@ interface Resources {
questCard: {
completed: 'Completed';
join: 'Join';
xpToEarnDescription: 'Complete the progress bar to earn +{{xpToEarn}} addtional XP this month.';
earnedXPDescription: "You've unlocked {{earnedXP}}XP so far this month and this has been added to your total XP balance";
xpToEarnDescription: 'Complete the progress bar by {{action}} to earn +{{xpToEarn}} addtional XP this month.';
earnedXPDescription: "You've unlocked {{earnedXP}}XP by {{action}} so far this month and this has been added to your total XP balance.";
action: {
chain_oor: 'exploring chains';
transact_oor: 'trading';
swap_oor: 'swapping';
bridge_oor: 'bridging';
};
};
missions: {
available: 'Available Missions';
Expand Down
10 changes: 8 additions & 2 deletions src/i18n/translations/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,14 @@
"questCard": {
"completed": "Completed",
"join": "Join",
"xpToEarnDescription": "Complete the progress bar to earn +{{xpToEarn}} addtional XP this month.",
"earnedXPDescription": "You've unlocked {{earnedXP}}XP so far this month and this has been added to your total XP balance."
"xpToEarnDescription": "Complete the progress bar by {{action}} to earn +{{xpToEarn}} addtional XP this month.",
"earnedXPDescription": "You've unlocked {{earnedXP}}XP by {{action}} so far this month and this has been added to your total XP balance.",
"action": {
"chain_oor": "exploring chains",
"transact_oor": "trading",
"swap_oor": "swapping",
"bridge_oor": "bridging"
}
},
"missions": {
"available": "Available Missions",
Expand Down
Loading