traintrape-moi/client/hooks/useAuth.ts

13 lines
454 B
TypeScript
Raw Normal View History

import { useAppDispatch, useAppSelector } from "./useStore"
import { AuthPayload, login, logout } from "@/utils/features/location/authSlice"
export const useAuth = () => useAppSelector((state) => state.auth)
export const useAuthLogin = () => {
const dispath = useAppDispatch()
return (payload: AuthPayload) => dispath(login(payload))
}
export const useAuthLogout = () => {
const dispatch = useAppDispatch()
return () => dispatch(logout())
}