/**
 * Copyright (c) 2023-present Plane Software, Inc. and contributors
 * SPDX-License-Identifier: AGPL-3.0-only
 * See the LICENSE file for details.
 */

import { Info } from "lucide-react";
// plane imports
import { useTranslation } from "@plane/i18n";
import { CloseIcon } from "@plane/propel/icons";
// helpers
import type React from "react";

type TAuthBanner = {
  message: React.ReactNode;
  handleBannerData?: (bannerData: undefined) => void;
};

export function AuthBanner(props: TAuthBanner) {
  const { message, handleBannerData } = props;
  // translation
  const { t } = useTranslation();

  if (!message) return <></>;
  return (
    <div role="alert" className="nodedc-auth-banner relative flex items-center gap-2 p-3">
      <div className="grid size-4 flex-shrink-0 place-items-center">
        <Info size={16} className="text-current" />
      </div>
      <p className="w-full text-13 font-medium text-current">{message}</p>
      <button
        type="button"
        className="relative ml-auto grid size-6 place-items-center rounded-full text-current/80 transition-all hover:bg-white/10"
        onClick={() => handleBannerData?.(undefined)}
        aria-label={t("aria_labels.auth_forms.close_alert")}
      >
        <CloseIcon className="size-4 text-current" />
      </button>
    </div>
  );
}
