traintrape-moi/client/hooks/useAuth.ts

13 lines
450 B
TypeScript
Raw Normal View History

import { useAppDispatch, useAppSelector } from "./useStore"
2024-12-11 16:26:36 +00:00
import { AuthPayload, login, logout } from "@/utils/features/auth/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())
}