Initial commit of Balout Pastry admin dashboards.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-08-02 17:23:00 +03:30
co-authored by Cursor
commit af11d96fd0
103 changed files with 14651 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
const PERSIAN_DIGITS = '۰۱۲۳۴۵۶۷۸۹'
const ARABIC_DIGITS = '٠١٢٣٤٥٦٧٨٩'
export function toEnglishDigits(value: string) {
return value
.replace(/[۰-۹]/g, (digit) => String(PERSIAN_DIGITS.indexOf(digit)))
.replace(/[٠-٩]/g, (digit) => String(ARABIC_DIGITS.indexOf(digit)))
}
/** Keep only digits from any price-like string. */
export function parsePriceDigits(value: string): string {
return toEnglishDigits(value).replace(/\D/g, '')
}
export function parsePriceNumber(value: string): number | null {
const digits = parsePriceDigits(value)
if (!digits) return null
const number = Number(digits)
return Number.isNaN(number) ? null : number
}
/** Display value for price inputs (Persian thousand separators). */
export function formatPriceInput(value: string | number | null | undefined) {
if (value === null || value === undefined || value === '') return ''
const digits =
typeof value === 'number'
? String(Math.trunc(Math.abs(value)))
: parsePriceDigits(value)
if (!digits) return ''
return new Intl.NumberFormat('fa-IR').format(Number(digits))
}
export function formatPrice(value: number) {
return new Intl.NumberFormat('fa-IR').format(value)
}