summaryrefslogtreecommitdiff
path: root/src/core/utils/formatValue.js
blob: f0f65c690f6b46bf2db55839fdf50b550c867f1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const sellingProductFormat = (value) => {
  if (value > 1000) {
    const formattedValue = (value / 1000).toFixed(0).replace('.', ',')
    return formattedValue + 'rb+';
  } else {
    return value.toString()
  }
}

const formatCurrency = (value) => {
  if (value >= 1000) {
    const thousands = Math.floor(value / 1000) // Menghitung ribuan
    return `Rp${thousands}k`
  } else {
    return `Rp${value}`
  }
}

export { sellingProductFormat, formatCurrency}