17 lines
503 B
TypeScript
17 lines
503 B
TypeScript
import { useMutation } from '@tanstack/react-query';
|
|
import { toast } from 'sonner';
|
|
import { postAuthExchangeMutation } from '@/client/@tanstack/react-query.gen';
|
|
|
|
export function useExchangeToken() {
|
|
return useMutation({
|
|
...postAuthExchangeMutation(),
|
|
onSuccess: (data) => {
|
|
window.location.href = data.data!.redirect_uri!;
|
|
},
|
|
onError: (error) => {
|
|
console.error(error);
|
|
toast('An error occurred while exchanging the token. Please login manually.');
|
|
},
|
|
});
|
|
}
|