import { FC } from 'react';

import Stack from '@material-hu/mui/Stack';
import Typography from '@material-hu/mui/Typography';

import Alert from '@material-hu/components/design-system/Alert';
import Dialog from '@material-hu/components/design-system/Dialog';
import { useLokaliseTranslation as useTranslation } from 'src/utils/i18n';

type ArchiveGroupModalProps = {
  onClose: () => void;
  onConfirm: () => void;
  isArchived: boolean;
  isLoading?: boolean;
};

const ArchiveGroupModal: FC<ArchiveGroupModalProps> = ({
  onClose,
  onConfirm,
  isArchived,
  isLoading = false,
}) => {
  const { t } = useTranslation(['group']);

  return (
    <Dialog
      onClose={onClose}
      title={t(
        isArchived
          ? 'unarchive_group_confirm_title'
          : 'archive_group_confirm_title',
      )}
      body={
        <Stack sx={{ gap: 2 }}>
          <Typography variant="globalS">
            {t(
              isArchived
                ? 'unarchive_group_confirm_description'
                : 'archive_group_confirm_description',
            )}
          </Typography>
          {!isArchived && (
            <Alert
              severity="info"
              title={t('archive_group_confirm_alert')}
            />
          )}
        </Stack>
      }
      primaryButtonProps={{
        children: t(
          isArchived
            ? 'unarchive_group_confirm_action'
            : 'archive_group_confirm_action',
        ),
        onClick: onConfirm,
        loading: isLoading,
        color: isArchived ? 'primary' : 'error',
      }}
      secondaryButtonProps={{
        children: t('cancel'),
        onClick: onClose,
        disabled: isLoading,
      }}
    />
  );
};

export default ArchiveGroupModal;
