refactor(client): use generated API client and hooks
Signed-off-by: Noa Virellia <noa@requiem.garden>
This commit is contained in:
16
client/cms/src/hooks/data/useExchangeToken.ts
Normal file
16
client/cms/src/hooks/data/useExchangeToken.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { postAuthExchangeMutation } from "@/client/@tanstack/react-query.gen";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { toast } from "sonner";
|
||||
|
||||
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.");
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user