first commit

This commit is contained in:
amirhosein.ashourloo
2026-09-02 17:03:23 +03:30
commit 1bd131e9d8
91 changed files with 11211 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
const FA_DIGITS = ["۰", "۱", "۲", "۳", "۴", "۵", "۶", "۷", "۸", "۹"];
export function toFaDigits(input: string | number): string {
return String(input).replace(/\d/g, (d) => FA_DIGITS[Number(d)]);
}
// Prices come from the API in Toman.
export function formatPrice(value: number | null | undefined): string {
if (value === null || value === undefined) return "";
return toFaDigits(value.toLocaleString("en-US"));
}
export function discountPercent(price: number, oldPrice: number): number {
if (!oldPrice || oldPrice <= price) return 0;
return Math.round(((oldPrice - price) / oldPrice) * 100);
}
// The static-image-slot API documents aspectRatio as "16:9", but CSS's
// aspect-ratio property needs a slash ("16/9"), not a colon.
export function toCssAspectRatio(value: string | number | null | undefined): string | undefined {
if (value === null || value === undefined || value === "") return undefined;
return String(value).replace(":", "/");
}