Skip to content

Commit

Permalink
feat: add new requirement for Galxe endpoint + check for turtle membe…
Browse files Browse the repository at this point in the history
…rship (#1262)
  • Loading branch information
tcheee authored Aug 27, 2024
1 parent adf747b commit 4f55e8e
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ interface AvailableMissionsListProps {
quests?: Quest[];
pastCampaigns?: string[];
loading: boolean;
isJumperTurtleMember?: boolean;
}

export const AvailableMissionsList = ({
quests,
pastCampaigns,
loading,
isJumperTurtleMember,
}: AvailableMissionsListProps) => {
const isMobile = useMediaQuery((theme: Theme) =>
theme.breakpoints.down('md'),
Expand Down Expand Up @@ -107,6 +109,8 @@ export const AvailableMissionsList = ({
const rewards = quest.attributes.CustomInformation?.['rewards'];
const rewardType =
quest.attributes?.CustomInformation?.['rewardType'];
const missionType =
quest?.attributes?.CustomInformation?.['missionType'];
const rewardRange =
quest.attributes?.CustomInformation?.['rewardRange'];
const chains = quest.attributes.CustomInformation?.['chains'];
Expand Down Expand Up @@ -146,6 +150,13 @@ export const AvailableMissionsList = ({
if (rewardsIds && pastCampaigns) {
completed = checkInclusion(pastCampaigns, rewardsIds);
}
if (
missionType &&
missionType === 'turtle_signature' &&
isJumperTurtleMember
) {
completed = true;
}

return (
<QuestCard
Expand Down
11 changes: 11 additions & 0 deletions src/components/Superfest/Superfest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AvailableMissionsList } from './AvailableMissionsList/AvailableMissions
import { ActiveSuperfestMissionsCarousel } from './ActiveSuperfestMissionsCarousel/ActiveSuperfestMissionsCarousel';
import { useOngoingFestMissions } from 'src/hooks/useOngoingFestMissions';
import { useMerklRewards } from 'src/hooks/useMerklRewardsOnSpecificToken';
import { useTurtleMember } from 'src/hooks/useTurtleMember';

export const Superfest = () => {
//HOOKS
Expand All @@ -22,6 +23,13 @@ export const Superfest = () => {
rewardChainId: 10,
userAddress: account?.address,
});
const {
isMember,
isJumperMember,
isSuccess: isMemberCheckSuccess,
} = useTurtleMember({
userAddress: account?.address,
});

return (
<SuperfestContainer className="superfest">
Expand Down Expand Up @@ -51,6 +59,9 @@ export const Superfest = () => {
quests={quests}
loading={isQuestLoading}
pastCampaigns={pastCampaigns}
isJumperTurtleMember={
isMember && isJumperMember && isMemberCheckSuccess
}
/>
<NFTClaimingBox />
</SuperfestMainBox>
Expand Down
5 changes: 5 additions & 0 deletions src/components/Superfest/SuperfestPage/Banner/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface SuperfestMissionPageVar {
quest: Quest;
baseUrl: string;
pastCampaigns: string[];
isRewardCompleted?: boolean;
}

export interface Chain {
Expand All @@ -36,6 +37,7 @@ export const BannerBox = ({
quest,
baseUrl,
pastCampaigns,
isRewardCompleted,
}: SuperfestMissionPageVar) => {
const isMobile = useMediaQuery((theme: Theme) =>
theme.breakpoints.down('md'),
Expand All @@ -55,6 +57,9 @@ export const BannerBox = ({
if (rewardsIds && pastCampaigns) {
completed = checkInclusion(pastCampaigns, rewardsIds);
}
if (isRewardCompleted) {
completed = true;
}

return (
<>
Expand Down
15 changes: 14 additions & 1 deletion src/components/Superfest/SuperfestPage/SuperfestMisisonPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { InformationAlertBox } from './InformationBox/InformationAlertBox';
import { useMerklRewards } from 'src/hooks/useMerklRewardsOnSpecificToken';
import { useAccounts } from '@/hooks/useAccounts';
import { useMissionsAPY } from 'src/hooks/useMissionsAPY';
import { useTurtleMember } from 'src/hooks/useTurtleMember';

interface SuperfestMissionPageVar {
quest: Quest;
Expand All @@ -34,7 +35,13 @@ export const SuperfestMissionPage = ({
rewardChainId: 10,
userAddress: account?.address,
});

const {
isMember,
isJumperMember,
isSuccess: isMemberCheckSuccess,
} = useTurtleMember({
userAddress: account?.address,
});
const { isLoading, isSuccess, CTAsWithAPYs } = useMissionsAPY(CTAs);

return (
Expand All @@ -47,6 +54,12 @@ export const SuperfestMissionPage = ({
quest={quest}
baseUrl={baseUrl}
pastCampaigns={pastCampaigns}
isRewardCompleted={
missionType === 'turtle_signature' &&
isMemberCheckSuccess &&
isMember &&
isJumperMember
}
/>
{/* Big CTA */}
<MissionCTA
Expand Down
1 change: 1 addition & 0 deletions src/hooks/querries/superfestNFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const availableNFT = gql`
signature: "" # provide a test signature
campaignID: $campaignID # campaign hash id
address: $address # user address
mintCount: 1
}
) {
allow # Is allow user claim nft
Expand Down
33 changes: 32 additions & 1 deletion src/hooks/useTurtleMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ interface UseTurtleProps {

interface UseTurtleRes {
isMember?: boolean;
isJumperMember?: boolean;
isLoading: boolean;
isSuccess: boolean;
}

const JUMPER_REF = 'JUMPER';

export const useTurtleMember = ({
userAddress,
}: UseTurtleProps): UseTurtleRes => {
const TURTLE_CHECK_API = `https://points.turtle.club/user/${userAddress}/exists`;
const TURTLE_REFCHECK_API = `https://points.turtle.club/referral/${userAddress}`;

const { data, isSuccess, isLoading } = useQuery({
queryKey: ['turtleMemberCheck'],
Expand All @@ -33,5 +37,32 @@ export const useTurtleMember = ({
refetchInterval: 1000 * 60 * 60,
});

return { isMember: data, isSuccess, isLoading };
const {
data: refCheck,
isSuccess: refCheckIsSuccess,
isLoading: refCheckIsLoading,
} = useQuery({
queryKey: ['turtleMemberRefCheck'],
queryFn: async () => {
try {
const response = await fetch(TURTLE_REFCHECK_API);
const result = await response.json();
if (result && result.used_referral) {
return result.used_referral === JUMPER_REF;
}
return false;
} catch (err) {
console.log(err);
}
},
enabled: !!userAddress,
refetchInterval: 1000 * 60 * 60,
});

return {
isMember: data,
isJumperMember: refCheck,
isSuccess: isSuccess && refCheckIsSuccess,
isLoading: isLoading && refCheckIsLoading,
};
};

0 comments on commit 4f55e8e

Please sign in to comment.