import useClickMarker from "../../../hooks/useClickMarker";
import { checkScore } from "../../../domain/apiMethods";

const useClickToCheckScore = (mapRef, point1) => {
  // when the map is clicked, call the scoring API and update the marker's title
  useClickMarker(mapRef, async (point2, marker) => {
    const { score } = await checkScore(point1, point2);
    marker.setLabel({
      fontWeight: "500",
      text: `Potential Score: ${score}`,
    });
  });
};

export default useClickToCheckScore;
