// Copyright 2017-2026 @pezkuwi/app-bounties authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { BN } from '@pezkuwi/util';

import React from 'react';

import { BlockToTime } from '@pezkuwi/react-query';
import { formatNumber } from '@pezkuwi/util';

interface Props {
  dueBlocks: BN;
  endBlock: BN;
  label: string;
}

function DueBlocks ({ dueBlocks, endBlock, label }: Props): React.ReactElement<Props> {
  return (
    <>
      {dueBlocks.gtn(0) && (
        <>
          <BlockToTime value={dueBlocks}>
            &nbsp;({label})
          </BlockToTime>
          #{formatNumber(endBlock)}
        </>
      )}
    </>
  );
}

export default React.memo(DueBlocks);
