import { PositionStatus } from '../../../generated/ManagingApi'
import type { ICardPositionFlipped } from '../../../global/type'
import { CardText } from '../../mollecules'

const CardPositionFlipped: React.FC<ICardPositionFlipped> = ({ positions }) => {
  return (
    <>
      <CardText
        title="Position Flipped"
        content={
          positions
            .filter((p) => {
              const realized = p.profitAndLoss?.realized ?? 0
              return realized > 0 && p.status == PositionStatus.Flipped
                ? p
                : null
            })
            .length.toString() +
          ' | ' +
          positions
            .filter((p) => {
              const realized = p.profitAndLoss?.realized ?? 0
              return realized <= 0 && p.status == PositionStatus.Flipped
                ? p
                : null
            })
            .length.toString()
        }
      ></CardText>
    </>
  )
}

export default CardPositionFlipped
