"use client";

import { Alert } from "@mui/material";
import React, { ReactNode } from "react";

interface ScanStatusAlertProps {
  error: boolean;
  success: boolean;
  errorMessage?: ReactNode;
  successMessage?: ReactNode;
}

const ScanStatusAlert: React.FC<ScanStatusAlertProps> = ({
  error,
  success,
  errorMessage,
  successMessage,
}) => {
  if (error && !success) {
    return (
      <Alert
        severity="error"
        sx={{
          mb: 2,
          display: "flex",
          justifyContent: "center",
          alignItems: "center",
          fontWeight: "bold",
          fontSize: "1rem",
          color: "error.main",
          "& .MuiAlert-message": {
            width: "100%",
            textAlign: "center",
          },
          "& .MuiSvgIcon-root": {
            color: "error.main",
          },
          backgroundColor: "error.light",
        }}
      >
        {errorMessage}
      </Alert>
    );
  }

  if (success) {
    return (
      <Alert
        severity="success"
        sx={{
          mb: 2,
          display: "flex",
          justifyContent: "center",
          alignItems: "center",
          fontWeight: "bold",
          fontSize: "1rem",
          bgcolor: "rgba(76, 175, 80, 0.08)",
          color: "success.main",
          "& .MuiAlert-icon": {
            color: "success.main",
          },
          "& .MuiAlert-message": {
            width: "100%",
            textAlign: "center",
            color: "success.main",
          },
        }}
      >
        {successMessage}
      </Alert>
    );
  }

  return null;
};

export default ScanStatusAlert;





