Skip to content

Commit

Permalink
Update Rewards Activities (#1921)
Browse files Browse the repository at this point in the history
* update rewards activities

* fix: resolve comments
  • Loading branch information
corlard3y authored Oct 15, 2024
1 parent 628b2dd commit c586fd8
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 10 deletions.
52 changes: 52 additions & 0 deletions src/blocks/illustrations/components/CyberLogoRewards.tsx

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/blocks/illustrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export { default as CommunicationDark } from './components/CommunicationDark';

export { default as CreateChannelPoints } from './components/CreateChannelPoints';

export { default as CyberLogoRewards } from './components/CyberLogoRewards';

export { default as Discord } from './components/Discord';

export { default as EarnOnPush } from './components/EarnOnPush';
Expand Down
10 changes: 10 additions & 0 deletions src/modules/rewards/components/RewardsActivityIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
Twitter,
YellowBonusActivitySubscribers,
PushAlpha,
CyberLogoRewards,
} from 'blocks';
import { quickSwapLogo, priceTrackerLogo, walletTrackerLogo, shapeShiftLogo } from 'common';
import { ActvityType } from 'queries';
Expand Down Expand Up @@ -207,6 +208,15 @@ const RewardsActivityIcon: FC<RewardsActivityIconProp> = ({ type }) => {
);
}

if (type === 'channel_specific_subscriptions:CYBER_CHANNEL') {
return (
<CyberLogoRewards
width={48}
height={48}
/>
);
}

if (type === 'stake_1_uni_v2_lp_epoch' || type === 'stake_1k_push_epoch') {
return (
<StakePushGreyCoin
Expand Down
27 changes: 26 additions & 1 deletion src/modules/rewards/components/RewardsActivityTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const RewardsActivityTitle: FC<RewardsActivityTitleProps> = ({ activityTitle, is
const extractedTitle = getRewardsActivityTitle(activityTitle);

if (extractedTitle) {
const { preText, url, linkedText, postText } = extractedTitle;
const { preText, url, linkedText, postText, secondLinkedText, secondUrl, innerText } = extractedTitle;
return (
<Skeleton isLoading={isLoading}>
<Box
Expand Down Expand Up @@ -50,6 +50,31 @@ const RewardsActivityTitle: FC<RewardsActivityTitleProps> = ({ activityTitle, is
{linkedText}
</Link>

{innerText && (
<Text
variant={variant || 'bl-semibold'}
color={color || 'text-primary'}
as="span"
>
{innerText}
</Text>
)}

{secondLinkedText && secondUrl && (
<Link
to={secondUrl}
isText
target="_blank"
textProps={{
variant: variant || 'bl-semibold',
color: 'text-brand-medium',
display: 'inline-block',
}}
>
{secondLinkedText}
</Link>
)}

<Text
variant={variant || 'bl-semibold'}
color={color || 'text-primary'}
Expand Down
1 change: 1 addition & 0 deletions src/modules/rewards/utils/activityTypeArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const channelSubscriptionActivities: ActvityType[] = [
'channel_specific_subscriptions:QUICKSWAP_CHANNEL',
'channel_specific_subscriptions:WALLETTRACKER_CHANNEL',
'channel_specific_subscriptions:SHAPESHIFT_CHANNEL',
'channel_specific_subscriptions:CYBER_CHANNEL',
];

export const bonusRewardActivities: ActvityType[] = [
Expand Down
35 changes: 26 additions & 9 deletions src/modules/rewards/utils/getRewardsActivityTitle.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
export const getRewardsActivityTitle = (activityTitle: string) => {
const regex = /\[([^\]]+)\]\(([^)]+)\)/;
const match = activityTitle?.match(regex);
if (match) {
const preText = activityTitle.substring(0, match.index);
const linkedText = match[1];
const url = match[2];
if (!activityTitle) return null; // Ensure activityTitle is not null or undefined

const regex = /\[([^\]]+)\]\(([^)]+)\)/g;
const matches = Array.from(activityTitle.matchAll(regex)); // Convert iterator to an array

if (matches.length >= 1) {
const preText = activityTitle.substring(0, matches[0].index);
const linkedText = matches[0][1];
const url = matches[0][2];

let innerText = '';
let secondLinkedText = '';
let secondUrl = '';
let postText = '';
if (match.index) {
postText = activityTitle.substring(match.index + match[0].length);

if (matches.length >= 2) {
innerText = activityTitle.substring(matches[0].index + matches[0][0].length, matches[1].index);
secondLinkedText = matches[1][1];
secondUrl = matches[1][2];
postText = activityTitle.substring(matches[1].index + matches[1][0].length);
} else {
postText = activityTitle.substring(matches[0].index + matches[0][0].length);
}

return {
preText,
linkedText,
url,
postText
innerText,
secondLinkedText,
secondUrl,
postText,
};
} else {
return null;
Expand Down
1 change: 1 addition & 0 deletions src/queries/types/rewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type ActvityType =
| 'channel_specific_subscriptions:WALLETTRACKER_CHANNEL'
| 'channel_specific_subscriptions:PRICETRACKER_CHANNEL'
| 'channel_specific_subscriptions:SHAPESHIFT_CHANNEL'
| 'channel_specific_subscriptions:CYBER_CHANNEL'
| 'stake_1k_push_epoch'
| 'stake_5k_push_epoch'
| 'stake_10k_push_epoch'
Expand Down

0 comments on commit c586fd8

Please sign in to comment.