export function formatStockAmount(value: number | string, unit?: string): string {
    const numericValue = typeof value === 'string' ? Number.parseFloat(value) : value;

    if (!Number.isFinite(numericValue)) {
        return unit ? `0 ${unit}` : '0';
    }

    const formatted = numericValue.toLocaleString('id-ID', {
        minimumFractionDigits: 0,
        maximumFractionDigits: 4,
    });

    return unit ? `${formatted} ${unit}` : formatted;
}
