-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scoutgame telegram quest and claim page (#4961)
* Scoutgametelegram * Remove twa from main package * Add validation of initData * Update env * Update secret name * Revert not found deletion * Update model * Initial daily claim gallery * Added next reward countdown * Improved daily claim styling * Added bonus claim card * Claim daily reward action and schema * Removed scout quest models * Update import charmClient * Fixed broken build issues * Add one e2e test * Fixed broken stuffs * Fixed images * Fixed tsconfig * Bumped core * Fixed broken tscofig * Updated core * Bumped core * Added quests * Updated how we handle the user and avatar * Added claim quest point * Bumped core * Remove @root from scoutgametelegram * resolved pr comments * Update bg image * Added tests for claim daily reward * Added tests for get daily claims * Added tests for complete quest * Fixed broken type issues * Fixed broken tests * Fixed window is not defined error * Bumped core * Added support for daily claim events * Fixed issue with claim date * log error loading user * Fixed broken tests --------- Co-authored-by: Valentin L <[email protected]>
- Loading branch information
1 parent
c290c7e
commit fd385ef
Showing
46 changed files
with
1,254 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function FriendsPage() { | ||
return <div>FriendsPage</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { QuestsPage } from 'components/quests/QuestsPage'; | ||
import { getDailyClaims } from 'lib/claims/getDailyClaims'; | ||
import { getQuests } from 'lib/quests/getQuests'; | ||
import { getUserFromSession } from 'lib/session/getUserFromSession'; | ||
|
||
export default async function Quests() { | ||
const user = await getUserFromSession(); | ||
|
||
if (!user) { | ||
return null; | ||
} | ||
|
||
const dailyClaims = await getDailyClaims(user.id); | ||
const quests = await getQuests(user.id); | ||
return <QuestsPage dailyClaims={dailyClaims} quests={quests} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Box } from '@mui/material'; | ||
|
||
import { InfoBackgroundImage } from 'components/layout/InfoBackgroundImage'; | ||
import type { DailyClaim } from 'lib/claims/getDailyClaims'; | ||
import type { QuestInfo } from 'lib/quests/getQuests'; | ||
|
||
import { DailyClaimGallery } from './components/DailyClaimGallery/DailyClaimGallery'; | ||
import { QuestsList } from './components/QuestsList/QuestsList'; | ||
|
||
export function QuestsPage({ dailyClaims, quests }: { dailyClaims: DailyClaim[]; quests: QuestInfo[] }) { | ||
return ( | ||
<> | ||
<InfoBackgroundImage /> | ||
<Box sx={{ px: 5 }}> | ||
<DailyClaimGallery dailyClaims={dailyClaims} /> | ||
</Box> | ||
<Box sx={{ px: 1 }}> | ||
<QuestsList quests={quests} /> | ||
</Box> | ||
</> | ||
); | ||
} |
85 changes: 85 additions & 0 deletions
85
apps/scoutgametelegram/components/quests/components/DailyClaimGallery/DailyClaimCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
'use client'; | ||
|
||
import CheckCircleIcon from '@mui/icons-material/CheckCircle'; | ||
import { Stack, Typography } from '@mui/material'; | ||
import { DateTime } from 'luxon'; | ||
import Image from 'next/image'; | ||
import { useAction } from 'next-safe-action/hooks'; | ||
|
||
import { claimDailyRewardAction } from 'lib/claims/claimDailyRewardAction'; | ||
import type { DailyClaim } from 'lib/claims/getDailyClaims'; | ||
|
||
import { DailyClaimGift } from './DailyClaimGift'; | ||
|
||
export function DailyClaimCard({ dailyClaim }: { dailyClaim: DailyClaim }) { | ||
const { execute: claimDailyReward, isExecuting } = useAction(claimDailyRewardAction); | ||
const currentWeekDay = DateTime.fromJSDate(new Date()).weekday; | ||
const isPastDay = currentWeekDay > dailyClaim.day; | ||
const isClaimToday = currentWeekDay === dailyClaim.day; | ||
const isClaimed = dailyClaim.claimed; | ||
const buttonLabel = isClaimToday && !isClaimed ? 'Claim' : dailyClaim.isBonus ? 'Bonus' : `Day ${dailyClaim.day}`; | ||
const canClaim = isClaimToday && !isClaimed && !isExecuting; | ||
const variant = isPastDay ? 'disabled' : isClaimToday ? 'secondary' : 'primary'; | ||
|
||
return ( | ||
<Stack | ||
sx={{ | ||
backgroundColor: isClaimed | ||
? 'background.light' | ||
: isPastDay | ||
? 'background.dark' | ||
: isClaimToday | ||
? 'secondary.main' | ||
: 'primary.dark', | ||
height: 90, | ||
paddingBottom: 0.25, | ||
borderRadius: 1, | ||
alignItems: 'center', | ||
position: 'relative', | ||
cursor: canClaim ? 'pointer' : 'default' | ||
}} | ||
onClick={() => { | ||
if (canClaim) { | ||
claimDailyReward({ isBonus: dailyClaim.isBonus, dayOfWeek: currentWeekDay }); | ||
} | ||
}} | ||
> | ||
<Stack flex={1} position='relative' alignItems='center' justifyContent='center' width='100%'> | ||
{!isClaimed ? ( | ||
<Stack sx={{ position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)' }}> | ||
{dailyClaim.isBonus ? ( | ||
<Stack direction='row' gap={0.5} alignItems='flex-end'> | ||
<DailyClaimGift variant={variant} size={44} /> | ||
<DailyClaimGift variant={variant} size={70} /> | ||
<DailyClaimGift variant={variant} size={44} /> | ||
</Stack> | ||
) : ( | ||
<DailyClaimGift variant={variant} size={64} /> | ||
)} | ||
</Stack> | ||
) : ( | ||
<CheckCircleIcon | ||
fontSize='small' | ||
color='secondary' | ||
sx={{ | ||
position: 'absolute', | ||
top: 5, | ||
right: 5 | ||
}} | ||
/> | ||
)} | ||
<Stack direction='row' gap={0.5} alignItems='center' zIndex={1} top={7.5} position='relative'> | ||
<Typography fontWeight={600}>{dailyClaim.isBonus ? '+3' : '+1'}</Typography> | ||
<Image src='/images/scout-game-profile-icon.png' alt='Scout game icon' width={15} height={8.5} /> | ||
</Stack> | ||
</Stack> | ||
<Typography | ||
variant='body2' | ||
color={isClaimToday && !isClaimed ? 'secondary.dark' : 'text.primary'} | ||
fontWeight={600} | ||
> | ||
{buttonLabel} | ||
</Typography> | ||
</Stack> | ||
); | ||
} |
24 changes: 24 additions & 0 deletions
24
apps/scoutgametelegram/components/quests/components/DailyClaimGallery/DailyClaimGallery.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Grid2 as Grid, Stack, Typography } from '@mui/material'; | ||
|
||
import type { DailyClaim } from 'lib/claims/getDailyClaims'; | ||
|
||
import { DailyClaimCard } from './DailyClaimCard'; | ||
import { NextClaimCountdown } from './NextClaimCountdown'; | ||
|
||
export function DailyClaimGallery({ dailyClaims }: { dailyClaims: DailyClaim[] }) { | ||
return ( | ||
<Stack justifyContent='center' alignItems='center' gap={1} my={2}> | ||
<Typography variant='h4' color='secondary' fontWeight={600} zIndex={1}> | ||
Daily Claim | ||
</Typography> | ||
<NextClaimCountdown /> | ||
<Grid container spacing={1} width='100%'> | ||
{dailyClaims.map((dailyClaim) => ( | ||
<Grid size={dailyClaim.isBonus ? 8 : 4} key={dailyClaim.day}> | ||
<DailyClaimCard dailyClaim={dailyClaim} /> | ||
</Grid> | ||
))} | ||
</Grid> | ||
</Stack> | ||
); | ||
} |
Oops, something went wrong.