import { useGlobal } from "@/context/global";
import { faSpinner } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";

export const LoadingText = ({
  text,
  noText,
}: {
  text?: string;
  noText?: boolean;
}) => {
  const { dict } = useGlobal();

  return (
    <span>
      <FontAwesomeIcon icon={faSpinner} spin />
      {noText ? (
        ""
      ) : text ? (
        <> {text}</>
      ) : (
        <> {dict.pages.general.loading}...</>
      )}
    </span>
  );
};
