admin page
This commit is contained in:
@@ -6,8 +6,10 @@ export function useAdminLogin() {
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: adminLogin,
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ADMIN_AUTH_QUERY_KEY })
|
||||
onSuccess: (data) => {
|
||||
// The token is already stored by adminLogin; write it straight into the
|
||||
// gate's query cache so we flip to "authenticated" without re-hitting /refresh.
|
||||
queryClient.setQueryData(ADMIN_AUTH_QUERY_KEY, data.access_token)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ export function useAdminLogout() {
|
||||
return useMutation({
|
||||
mutationFn: adminLogout,
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ADMIN_AUTH_QUERY_KEY })
|
||||
// Flip the gate back to "not authenticated" without triggering a /refresh refetch.
|
||||
queryClient.setQueryData(ADMIN_AUTH_QUERY_KEY, null)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user