Build the Salar Store storefront and connect products, blogs, and home specials to the Meshkee API.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
2783305f07
commit
7d26eaa838
@@ -0,0 +1,14 @@
|
||||
export function formatPrice(value: number, locale: "en-US" | "fa-IR" = "fa-IR") {
|
||||
return value.toLocaleString(locale);
|
||||
}
|
||||
|
||||
export function formatDate(value: string) {
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return value;
|
||||
return date.toLocaleDateString("fa-IR");
|
||||
}
|
||||
|
||||
export function discountPercent(price: number, oldPrice?: number) {
|
||||
if (!oldPrice || oldPrice <= price) return 0;
|
||||
return Math.round(((oldPrice - price) / oldPrice) * 100);
|
||||
}
|
||||
Reference in New Issue
Block a user