feat: product recipes
This commit is contained in:
+16
-5
@@ -7,12 +7,23 @@ export const formatCurrency = (amount: number) => {
|
||||
}
|
||||
|
||||
export const formatShortCurrency = (num: number): string => {
|
||||
if (num >= 1_000_000) {
|
||||
return (num / 1_000_000).toFixed(2) + 'M'
|
||||
} else if (num >= 1_000) {
|
||||
return (num / 1_000).toFixed(2) + 'k'
|
||||
const formatNumber = (value: number, suffix: string) => {
|
||||
const str = value.toFixed(2).replace(/\.00$/, '')
|
||||
return str + suffix
|
||||
}
|
||||
return num.toString()
|
||||
|
||||
const absNum = Math.abs(num)
|
||||
let result: string
|
||||
|
||||
if (absNum >= 1_000_000) {
|
||||
result = formatNumber(absNum / 1_000_000, 'M')
|
||||
} else if (absNum >= 1_000) {
|
||||
result = formatNumber(absNum / 1_000, 'k')
|
||||
} else {
|
||||
result = absNum.toString()
|
||||
}
|
||||
|
||||
return num < 0 ? '-' + 'Rp ' + result : 'Rp ' + result
|
||||
}
|
||||
|
||||
export const formatDate = (dateString: any) => {
|
||||
|
||||
Reference in New Issue
Block a user