import { useUserState } from "../contexts/UserContext";
import { useCallback } from "react";

const useResourceSecurity = () => {
  const { token } = useUserState();
  const secureUrl = useCallback(
    (url, join) => {
      const separator = join ? "&" : "?";
      const securedUrl = `${url}${separator}token=${token.raw}`;
      return securedUrl;
    },
    [token.raw]
  );

  return { secureUrl };
};

export default useResourceSecurity;
