traintrape-moi/client/app/(tabs)/challenges.tsx

35 lines
1.3 KiB
TypeScript
Raw Normal View History

import ChallengeCard from '@/components/ChallengeCard'
import PenaltyBanner from '@/components/PenalyBanner'
import { useChallengeActions } from '@/hooks/useChallengeActions'
import { useChallenges } from '@/hooks/useChallenges'
import { useGame } from '@/hooks/useGame'
import { useMemo } from 'react'
import { Appbar, Surface } from 'react-native-paper'
export default function ChallengesScreen() {
const game = useGame()
const challengeActions = useChallengeActions()
const challenges = useChallenges()
const currentChallengeAction = useMemo(() => {
if (!game.currentChallengeId)
return null
return challengeActions.challengeActions.find((action) => action.id === game.currentChallengeId)
}, [game, challengeActions])
const currentChallenge = useMemo(() => {
if (!currentChallengeAction)
return null
return challenges.challenges.find((challenge) => challenge.id === currentChallengeAction.challengeId)
}, [currentChallengeAction, challenges])
return (
2024-12-12 17:01:08 +00:00
<Surface style={{ flex: 1 }}>
<Appbar.Header>
<Appbar.Content title={"Défis"} />
<Appbar.Action icon='format-list-bulleted' />
</Appbar.Header>
<PenaltyBanner />
{currentChallenge && <ChallengeCard challenge={currentChallenge} />}
2024-12-09 20:00:15 +00:00
</Surface>
2024-12-07 09:24:41 +00:00
)
}