Skip to content

Commit

Permalink
new reward activities + ui fixes (#1889)
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitmalhotra1420 authored Oct 2, 2024
1 parent 44e48d3 commit 0a9559e
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 20 deletions.
15 changes: 7 additions & 8 deletions src/blocks/notification/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Cross } from '../icons';
import { NotificationProps } from './Notification.types';
import { toast, Toaster } from 'sonner';
import { getTextVariantStyles } from 'blocks/Blocks.utils';
import { deviceMediaQ } from 'blocks/theme';

const NotificationContainer = styled.div`
position: relative;
Expand All @@ -13,12 +14,15 @@ const NotificationContainer = styled.div`
display: flex;
flex-direction: row;
align-items: stretch;
max-height: 111px;
min-width: 397px;
max-width: 100%;
height: 111px;
width: 397px;
cursor: pointer;
box-sizing: border-box;
border: var(--border-sm) solid var(--components-in-app-notification-stroke-bg);
overflow: hidden;
@media${deviceMediaQ.mobileL} {
width: -webkit-fill-available;
}
`;

const TextContainer = styled.div`
Expand Down Expand Up @@ -62,7 +66,6 @@ const CloseButton = styled.div`
`;

const NotificationItem: FC<NotificationProps> = ({ onClose, title, description, image, onClick }) => {

const handleNotificationClick = () => onClick?.();

const handleNotificationClose = () => {
Expand Down Expand Up @@ -92,22 +95,19 @@ const NotificationItem: FC<NotificationProps> = ({ onClose, title, description,
const Notification = () => {
return (
<Toaster
style={{ minWidth: '397px', height: '111px' }}
offset={15}
visibleToasts={5}
/>
);
};


// Store the toastId(s) in an array to manage multiple notifications
const toastIds: Array<string | number> = [];

// Export the notification object with show and hide methods
const notification = {
show: (config: NotificationProps) => {
const toastId = toast.custom(() => <NotificationItem {...config} />, {

duration: config.duration || Infinity,
position: config.position || 'bottom-right',
});
Expand All @@ -122,4 +122,3 @@ const notification = {
};

export { notification, Notification };

8 changes: 8 additions & 0 deletions src/common/Common.baseLogos.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './Common.utils';
export * from './Common.form';
export * from './Common.localStorageKeys';
export * from './Common.types';
export * from './Common.baseLogos';
1 change: 1 addition & 0 deletions src/modules/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const Dashboard: FC<DashboardProps> = () => {
display="flex"
flexDirection="column"
gap="spacing-md"
width={{ mm: '340px' }}
>
<FeaturedChannels />
<ChannelVariantsSection />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const FeaturedChannelsListItem: FC<FeaturedChannelsListItemProps> = (props) => {
padding={{ initial: 'spacing-md', ml: 'spacing-md spacing-sm', tb: 'spacing-sm', lp: 'spacing-sm' }}
borderRadius="radius-md"
gap="spacing-xs"
width={{ initial: '290px', ml: 'auto', tb: '278px', lp: '278px' }}
width={{ initial: '290px', mm: '258px', ml: 'auto', tb: '278px', lp: '278px' }}
css={css`
flex-shrink: 0;
`}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/dashboard/components/StakingPools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const StakingPools: FC<StakingPoolsProps> = () => {
</Text>
</Box>
<Box
display="flex"
display={{ initial: 'flex', ml: 'block' }}
gap="spacing-lg"
>
<Box
Expand Down
8 changes: 4 additions & 4 deletions src/modules/rewards/Rewards.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { RewardsTabsList } from './Rewards.types';
export const rewardsTabsList: RewardsTabsList = [
{
value: 'dashboard',
label: 'Dashboard'
label: 'Dashboard',
},
{
value: 'activity',
label: 'Reward Activities'
label: 'Reward Activities',
},
{
value: 'leaderboard',
label: 'Leaderboard'
}
label: 'Leaderboard',
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useVerifyRewards } from '../hooks/useVerifyRewards';
// helpers
import {
bonusRewardActivities,
channelSubscriptionActivities,
dailyRewardActivities,
otherRewardActivities,
stakeRewardActivities,
Expand Down Expand Up @@ -91,7 +92,8 @@ export const ActivityVerificationButton = ({
if (
otherRewardActivities.includes(activityType) ||
bonusRewardActivities.includes(activityType) ||
stakeRewardActivities.includes(activityType)
stakeRewardActivities.includes(activityType) ||
channelSubscriptionActivities.includes(activityType)
) {
return {
isLoading: verifyingRewards,
Expand Down
25 changes: 21 additions & 4 deletions src/modules/rewards/components/RewardsActivitiesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,18 @@ const RewardsActivitiesList: FC<RewardActivitiesProps> = () => {
const activityList = rewardActivitiesResponse?.activities?.map((page) => page) || [];

// Filter activities based on the index
const firstGroupActivities = isLoading
const socialActivities = isLoading
? Array(2).fill(0)
: activityList.filter((activity) => activity.index.startsWith(`social-activity`) && activity?.status === 'ENABLED');

const secondGroupActivities = isLoading
const platformRewardActivities = isLoading
? Array(7).fill(0)
: activityList.filter((activity) => activity.index.startsWith(`reward-activity`) && activity?.status === 'ENABLED');

const channelSubscriptionActivities = activityList.filter(
(activity) => activity.index.startsWith(`channel-subscription`) && activity?.status === 'ENABLED'
);

const { isLocked } = useRewardsContext();

return (
Expand All @@ -45,7 +49,8 @@ const RewardsActivitiesList: FC<RewardActivitiesProps> = () => {
flexDirection="column"
gap="spacing-sm"
>
{firstGroupActivities.map((activity: Activity) => (
{/* These are the social activites Twitter and discord */}
{socialActivities.map((activity: Activity) => (
<RewardsActivitiesListItem
key={activity.activityType}
userId={userDetails?.userId || ''}
Expand Down Expand Up @@ -90,7 +95,19 @@ const RewardsActivitiesList: FC<RewardActivitiesProps> = () => {
</Box>
)}

{secondGroupActivities.map((activity: Activity) => (
{/* Activites related specific channel subscription */}
{channelSubscriptionActivities.map((activity: Activity) => (
<RewardsActivitiesListItem
key={activity.activityType}
userId={userDetails?.userId || ''}
activity={activity}
isLoadingItem={isLoading}
isLocked={isLocked}
/>
))}

{/* These are other platform specifc reward activities */}
{platformRewardActivities.map((activity: Activity) => (
<RewardsActivitiesListItem
key={activity.activityType}
userId={userDetails?.userId || ''}
Expand Down
34 changes: 34 additions & 0 deletions src/modules/rewards/components/RewardsActivityIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
YellowBonusActivitySubscribers,
PushAlpha,
} from 'blocks';
import { quickSwapLogo, priceTrackerLogo, walletTrackerLogo } from 'common';
import { ActvityType } from 'queries';

type RewardsActivityIconProp = {
Expand Down Expand Up @@ -162,6 +163,39 @@ const RewardsActivityIcon: FC<RewardsActivityIconProp> = ({ type }) => {
);
}

if (type === 'channel_specific_subscriptions:QUICKSWAP_CHANNEL') {
return (
<img
width={48}
height={48}
src={quickSwapLogo}
style={{ borderRadius: 'var(--radius-round)' }}
/>
);
}

if (type === 'channel_specific_subscriptions:PRICETRACKER_CHANNEL') {
return (
<img
width={48}
height={48}
src={priceTrackerLogo}
style={{ borderRadius: 'var(--radius-round)' }}
/>
);
}

if (type === 'channel_specific_subscriptions:WALLETTRACKER_CHANNEL') {
return (
<img
width={48}
height={48}
src={walletTrackerLogo}
style={{ borderRadius: 'var(--radius-round)' }}
/>
);
}

if (type === 'stake_1_uni_v2_lp_epoch' || type === 'stake_1k_push_epoch') {
return (
<StakePushGreyCoin
Expand Down
6 changes: 6 additions & 0 deletions src/modules/rewards/utils/activityTypeArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export const otherRewardActivities: ActvityType[] = [
'hold_push_rockstar_nft',
];

export const channelSubscriptionActivities: ActvityType[] = [
'channel_specific_subscriptions:PRICETRACKER_CHANNEL',
'channel_specific_subscriptions:QUICKSWAP_CHANNEL',
'channel_specific_subscriptions:WALLETTRACKER_CHANNEL',
];

export const bonusRewardActivities: ActvityType[] = [
'create_channel_push',
'reach_100_subscribers',
Expand Down
2 changes: 1 addition & 1 deletion src/queries/services/rewards/getRewardsActivities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from 'axios';
import { getRewardsActivitiesModelCreator } from '../../models/rewards';
import { getRewardsBaseURL } from '../../baseURL';

const pageSize = 50;
const pageSize = 100;

export const getRewardsActivities = () =>
axios({
Expand Down
3 changes: 3 additions & 0 deletions src/queries/types/rewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export type ActvityType =
| 'daily_check_in_7_days_day5'
| 'daily_check_in_7_days_day6'
| 'daily_check_in_7_days_day7'
| 'channel_specific_subscriptions:QUICKSWAP_CHANNEL'
| 'channel_specific_subscriptions:WALLETTRACKER_CHANNEL'
| 'channel_specific_subscriptions:PRICETRACKER_CHANNEL'
| 'stake_1k_push_epoch'
| 'stake_5k_push_epoch'
| 'stake_10k_push_epoch'
Expand Down

0 comments on commit 0a9559e

Please sign in to comment.