PrPull.tsx 680 B

12345678910111213141516171819202122232425262728
  1. import { useEffect } from "react";
  2. import { get } from "../../request";
  3. import type { ISuggestionResponse } from "../../api/Suggestion";
  4. import store from "../../store";
  5. import { refresh } from "../../reducers/pr-load";
  6. interface IWidget {
  7. uid?: string | null;
  8. }
  9. const PrPullWidget = ({ uid }: IWidget) => {
  10. useEffect(() => {
  11. if (!uid) {
  12. return;
  13. }
  14. const url = `/v2/sentpr/${uid}`;
  15. console.log("url", url);
  16. get<ISuggestionResponse>(url)
  17. .then((json) => {
  18. if (json.ok) {
  19. store.dispatch(refresh(json.data));
  20. }
  21. })
  22. .catch((e) => console.error(e));
  23. }, [uid]);
  24. return <></>;
  25. };
  26. export default PrPullWidget;