Structure de données jeu client

This commit is contained in:
2024-12-11 17:26:36 +01:00
parent d1adba04da
commit 7aa9dde5a9
14 changed files with 238 additions and 28 deletions

View File

@ -1,4 +1,4 @@
import { AuthState } from "@/utils/features/location/authSlice"
import { AuthState } from "@/utils/features/auth/authSlice"
import { useMutation } from "@tanstack/react-query"
import { LocationObject } from "expo-location"

View File

@ -1,4 +1,4 @@
import { AuthPayload } from "@/utils/features/location/authSlice"
import { AuthPayload } from "@/utils/features/auth/authSlice"
import { useMutation } from "@tanstack/react-query"
type ErrorResponse = {

View File

@ -1,5 +1,5 @@
import { useAppDispatch, useAppSelector } from "./useStore"
import { AuthPayload, login, logout } from "@/utils/features/location/authSlice"
import { AuthPayload, login, logout } from "@/utils/features/auth/authSlice"
export const useAuth = () => useAppSelector((state) => state.auth)
export const useAuthLogin = () => {

View File

@ -0,0 +1,3 @@
import { useAppSelector } from "./useStore"
export const useChallengeActions = () => useAppSelector((state) => state.challengeActions)

View File

@ -0,0 +1,3 @@
import { useAppSelector } from "./useStore"
export const useTrain = () => useAppSelector((state) => state.challenges)

12
client/hooks/useGame.ts Normal file
View File

@ -0,0 +1,12 @@
import { useAppDispatch, useAppSelector } from "./useStore"
import { setPlayerId, updateMoney } from "@/utils/features/game/gameSlice"
export const useGame = () => useAppSelector((state) => state.game)
export const useSetPlayerId = () => {
const dispath = useAppDispatch()
return (playerId: number) => dispath(setPlayerId(playerId))
}
export const useUpdateMoney = () => {
const dispatch = useAppDispatch()
return (money: number) => dispatch(updateMoney(money))
}

3
client/hooks/useTrain.ts Normal file
View File

@ -0,0 +1,3 @@
import { useAppSelector } from "./useStore"
export const useTrain = () => useAppSelector((state) => state.train)