82 lines
3.0 KiB
TypeScript
82 lines
3.0 KiB
TypeScript
import { useGameRepairMutation, useGameResetMutation, useGameStartMutation, useGameStopMutation, useGameSwitchPlayerMutation } from '@/hooks/mutations/useGameMutation'
|
|
import { useAuth } from '@/hooks/useAuth'
|
|
import { useGame } from '@/hooks/useGame'
|
|
import { useRouter } from 'expo-router'
|
|
import { FAB, List, Surface } from 'react-native-paper'
|
|
|
|
export default function HistoryScreen() {
|
|
const router = useRouter()
|
|
const auth = useAuth()
|
|
const game = useGame()
|
|
|
|
const gameStartMutation = useGameStartMutation({
|
|
auth,
|
|
game,
|
|
})
|
|
const gameStopMutation = useGameStopMutation({
|
|
auth,
|
|
game,
|
|
})
|
|
const gameSwitchMutation = useGameSwitchPlayerMutation({
|
|
auth,
|
|
game,
|
|
})
|
|
const gameRepairMutation = useGameRepairMutation({
|
|
auth,
|
|
game,
|
|
})
|
|
const gameResetMutation = useGameResetMutation({
|
|
auth,
|
|
game,
|
|
})
|
|
|
|
return (
|
|
<Surface
|
|
style={{ flex: 1 }}>
|
|
<List.Section title={"Paramètres"}>
|
|
<List.Item
|
|
key={"login"}
|
|
title="Connexion au serveur"
|
|
description={auth.loggedIn ? "Vous êtes déjà connecté⋅e" : "Vous n'êtes pas connecté⋅e"}
|
|
right={() => <FAB icon="login" size="small" onPress={() => router.navigate('/login')} />}
|
|
onPress={() => router.navigate('/login')} />
|
|
</List.Section>
|
|
<List.Section title={"Gestion du jeu"}>
|
|
<List.Item
|
|
key={"start"}
|
|
title="Démarrer le jeu"
|
|
disabled={game.gameStarted}
|
|
right={() => <FAB icon="play" size="small" disabled={game.gameStarted} />}
|
|
onPress={() => gameStartMutation.mutate()} />
|
|
<List.Item
|
|
key={"stop"}
|
|
title="Arrêter le jeu"
|
|
disabled={!game.gameStarted}
|
|
right={() => <FAB icon="stop" size="small" disabled={!game.gameStarted} />}
|
|
onPress={() => gameStopMutation.mutate()} />
|
|
<List.Item
|
|
key={"switch"}
|
|
title="Changer de joueur⋅se en course"
|
|
description="À utiliser après une capture"
|
|
disabled={!game.gameStarted}
|
|
right={() => <FAB icon="exit-run" size="small" disabled={!game.gameStarted} />}
|
|
onPress={() => gameSwitchMutation.mutate()} />
|
|
</List.Section>
|
|
<List.Section title={"Avancé"}>
|
|
<List.Item
|
|
key={"repair"}
|
|
title="Réparer"
|
|
description="Permet de réparer les soldes des joueur⋅ses à partir des défis réalisés et des trains emprunter. À manipuler avec précaution."
|
|
right={() => <FAB icon="reload-alert" size="small" variant={'tertiary'} />}
|
|
onPress={() => gameRepairMutation.mutate()} />
|
|
<List.Item
|
|
key={"reset"}
|
|
title="Réinitialiser les données de jeu"
|
|
description="Permet de détruire toutes les données. À manipuler avec précaution."
|
|
right={() => <FAB icon="reload-alert" size="small" variant={'tertiary'} />}
|
|
onPress={() => gameResetMutation.mutate()} />
|
|
</List.Section>
|
|
</Surface>
|
|
)
|
|
}
|