import HuPills from '@material-hu/components/design-system/Pills';

import { LibraryStatus } from 'src/types/libraries';
import { useLokaliseTranslation } from 'src/utils/i18n';

const getStatusType = (status: LibraryStatus) => {
  if (status === LibraryStatus.ENABLED) {
    return 'success';
  }

  return 'neutral';
};

export type StatusPillProps = {
  status: LibraryStatus;
};

export const StatusPill = ({ status }: StatusPillProps) => {
  const { t } = useLokaliseTranslation('general');

  const label = status === LibraryStatus.ENABLED ? t('active') : t('inactive');

  return (
    <HuPills
      label={label}
      type={getStatusType(status)}
      hasIcon={false}
    />
  );
};

export default StatusPill;
