import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';

// material-ui
import { ButtonBase } from '@mui/material';
import { useDispatch, useSelector } from 'react-redux';

// project import
import Logo from './AdminLogo';

import config from 'config';
import { activeItem } from 'store/reducers/menu';
import { Stack } from '@mui/material';
import {
  checkSysEnv
} from "utils/Utils";

import {useIntl} from "react-intl";
// ==============================|| MAIN LOGO ||============================== //

const LogoSection = ({ sx, to }) => {
  const { defaultId } = useSelector((state) => state.menu);
  const dispatch = useDispatch();
  const intl = useIntl();
  
  return (
    <ButtonBase
        disableRipple
        component={Link}
        onClick={() => dispatch(activeItem({ openItem: [defaultId] }))}
        to={!to ? config.defaultPath : to}
        aria-label={intl.formatMessage({ id: "PNSPS", defaultMessage: "PNSPS" })}
        sx={{
          ...sx,
          /* ✅ WCAG 2.4.7 focus indicator */
          '&:focus-visible': {
            outline: '3px solid #0C489E',
            outlineOffset: '2px',
            borderRadius: '6px'
          }
        }}
      >
        <Stack direction="column" justifyContent="center" alignItems="center" >
          <Logo />
          <span style={{ color: checkSysEnv()!=''?'red':'#0C489E'}} id="systemTitle">PNSPS</span>
        </Stack>
      </ButtonBase>

  );
};

LogoSection.propTypes = {
  sx: PropTypes.object,
  to: PropTypes.string
};

export default LogoSection;
