21 lines
501 B
TypeScript
21 lines
501 B
TypeScript
import { useEffect, useState } from "react";
|
|
import axios from "axios";
|
|
|
|
export const usePaypalTracking = () => {
|
|
const [trackingId, setTrackingId] = useState<string>();
|
|
useEffect(() => {
|
|
axios
|
|
.put<{ ok: boolean; trackingId: string }>("/api/paypal/raas")
|
|
.then((response) => {
|
|
if (response.data.ok) {
|
|
setTrackingId(response.data.trackingId);
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
console.error(error);
|
|
});
|
|
}, []);
|
|
|
|
return trackingId;
|
|
};
|