14 lines
380 B
JavaScript
14 lines
380 B
JavaScript
import { a as useConfigStore } from './server.mjs';
|
|
|
|
function usePrice(price, digit = true, unit) {
|
|
const config = useConfigStore();
|
|
if (!unit && unit !== "") unit = config.priceUnit;
|
|
let _price = Math.ceil(price).toString();
|
|
if (digit) {
|
|
_price = _price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
}
|
|
return `${_price} ${unit}`;
|
|
}
|
|
|
|
export { usePrice as u };
|