import { type FC } from 'react';
import { useNavigate } from 'react-router';

import { IconArrowLeft } from '@material-hu/icons/tabler';

import Button from '@material-hu/components/design-system/Buttons/Button';

import { useLokaliseTranslation } from 'src/utils/i18n';

import { eventsRoutes } from '../routes';

type Props = {
  source: string | null;
};

export const EventBackButton: FC<Props> = ({ source }) => {
  const { t } = useLokaliseTranslation('events');
  const navigate = useNavigate();

  return (
    <Button
      startIcon={<IconArrowLeft />}
      onClick={() => navigate(eventsRoutes.events(source))}
      sx={{ alignSelf: 'flex-start', p: 0, minWidth: 'unset', mb: 1 }}
      size="large"
      fullWidth={false}
      variant="tertiary"
    >
      {t('GO_BACK')}
    </Button>
  );
};

export default EventBackButton;
