import React from 'react';
import { NumberFormat } from '../../services/utils.service';

interface IPropsCurrency extends React.ComponentProps<any> {
    quantity: number | string;
    prefix?: string;
    suffix?: string;
    decimalScale?: number;
    division?: boolean;
}

const Currency: React.FunctionComponent<IPropsCurrency> = ({
    quantity,
    prefix = '',
    suffix = '',
    decimalScale = 0,
    division = true,
}: IPropsCurrency) => {
    let quantityShow = quantity;

    if (division) {
        quantityShow = NumberFormat(Number(quantityShow) / 10 ** decimalScale);
    }

    return <>{quantityShow}</>;
};

export default Currency;
