Skip to content

Commit

Permalink
Merge pull request #42 from dappforce/dev/epic
Browse files Browse the repository at this point in the history
Contest Integration
  • Loading branch information
teodorus-nathaniel authored Sep 10, 2024
2 parents f7a60c9 + 19fcf97 commit 064e5d7
Show file tree
Hide file tree
Showing 21 changed files with 600 additions and 106 deletions.
Binary file added src/assets/emojis/calendar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/emojis/finish.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/emojis/trophy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/components/TabButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ export default function TabButtons({
return (
<div
className={cx(
'grid grid-cols-2 gap-px rounded-full bg-background-light text-sm font-medium',
'grid gap-px rounded-full bg-background-light text-sm font-medium',
className
)}
style={{ gridTemplateColumns: `repeat(${tabs.length}, 1fr)` }}
>
{tabs.map((tab) => (
<Button
Expand Down
13 changes: 7 additions & 6 deletions src/components/chats/hooks/useTokenGatedRequirement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { ExternalTokenChain } from '@/services/datahub/generated-query'
import { getBalanceQuery } from '@/services/datahub/leaderboard/points-balance/query'
import { useMyMainAddress } from '@/stores/my-account'
import { formatBalanceToNumber } from '@/utils/formatBalance'
import { convertToBigInt } from '@/utils/strings'
import { IdentityProvider } from '@subsocial/data-hub-sdk'

Expand Down Expand Up @@ -66,15 +67,15 @@ export default function useTokenGatedRequirement(
)
passRequirement =
convertToBigInt(tokenBalance?.amount ?? 0) >= externalTokenRequirement
amountRequired = Number(
externalTokenRequirement /
BigInt(10 ** Number(contentContainer?.externalToken?.decimals ?? 0))
amountRequired = formatBalanceToNumber(
externalTokenRequirement,
contentContainer?.externalToken?.decimals ?? 0
)
requiredToken = contentContainer?.externalToken?.name ?? ''
currentToken = tokenBalance
remainingNeeded = Number(
(externalTokenRequirement - convertToBigInt(tokenBalance?.amount ?? 0)) /
BigInt(10 ** Number(contentContainer?.externalToken?.decimals ?? 0))
remainingNeeded = formatBalanceToNumber(
externalTokenRequirement - convertToBigInt(tokenBalance?.amount ?? 0),
contentContainer?.externalToken?.decimals ?? 0
)
} else if (pointsRequirement > 0) {
isLoading = loadingPoints
Expand Down
5 changes: 1 addition & 4 deletions src/hooks/useRedirectToTgBotOnDesktop.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getReferralIdInUrl } from '@/components/referral/ReferralUrlChanger'
import { getReferralLink } from '@/components/referral/utils'
import { isTouchDevice } from '@/utils/device'
import { useMiniAppRaw } from '@tma.js/sdk-react'
import { useEffect } from 'react'
import useIsMounted from './useIsMounted'
Expand All @@ -11,9 +10,7 @@ const useRedirectToTgBotOnDesktop = () => {

const hasTelegramLoginInfo = app?.result
useEffect(() => {
const isMobile = isTouchDevice()

if (!isMobile && !hasTelegramLoginInfo && isMounted) {
if (!hasTelegramLoginInfo && isMounted) {
window.location.href = getReferralLink(getReferralIdInUrl())
}
}, [hasTelegramLoginInfo, isMounted])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { isDef } from '@subsocial/utils'
import { useState } from 'react'
import LeaderboardModal from '../FriendsPage/LeaderboardModal'

const ContestPreview = () => {
const HomePageContestPreview = () => {
const { data: referrersData } = getReferralLeaderboardQuery(true).useQuery({})
const [isOpen, setIsOpen] = useState(false)

Expand Down Expand Up @@ -79,4 +79,4 @@ const ContestPreviewItem = ({ item, withDivider }: ContestPreviewItemProps) => {
)
}

export default ContestPreview
export default HomePageContestPreview
4 changes: 2 additions & 2 deletions src/modules/telegram/HomePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { env } from '@/env.mjs'
import useTgNoScroll from '@/hooks/useTgNoScroll'
import PointsWidget from '@/modules/points/PointsWidget'
import Image from 'next/image'
import ContestPreview from './ContestPreview'
import HomePageContestPreview from './HomePageContestPreview'
import MemesPreview from './MemesPreview'
import TasksPreview from './TasksPreview'

Expand Down Expand Up @@ -32,7 +32,7 @@ const HomePageContent = () => {
chatId={env.NEXT_PUBLIC_MAIN_CHAT_ID}
hubId={env.NEXT_PUBLIC_MAIN_SPACE_ID}
/>
<ContestPreview />
<HomePageContestPreview />
<TasksPreview />
</div>
)
Expand Down
3 changes: 2 additions & 1 deletion src/modules/telegram/MenuPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ function MenuPageContent({ setPage }: ContentProps) {
},
],
[
{ title: 'Leaderboards', icon: '🏆', href: '/tg/leaderboards' },
{ title: 'Contests', icon: '🏆', href: '/tg/channels/contests' },
{ title: 'Leaderboards', icon: '🥇', href: '/tg/leaderboards' },
{ title: 'Airdrop', icon: '💰', href: '/tg/airdrop' },
{ title: 'Premium Features', icon: '🎩', href: '/tg/premium' },
{ title: 'Tap The Cat', icon: '🐈', href: '/tg/tap' },
Expand Down
Loading

0 comments on commit 064e5d7

Please sign in to comment.