Initial commit: public frontend for GameNo.
Vue 3 + Vite student-facing app with routing, Pinia state, and API integration.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import moment from 'jalali-moment'
|
||||
|
||||
const persianDigits = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']
|
||||
|
||||
export function toPersianDigits(value) {
|
||||
if (value == null) return ''
|
||||
return String(value).replace(/\d/g, (d) => persianDigits[Number(d)])
|
||||
}
|
||||
|
||||
export function formatJalali(date, format = 'jYYYY/jMM/jDD') {
|
||||
if (!date) return '—'
|
||||
return toPersianDigits(moment(date).locale('fa').format(format))
|
||||
}
|
||||
|
||||
export function formatPrice(amount) {
|
||||
if (amount == null || Number.isNaN(Number(amount))) return '—'
|
||||
return `${toPersianDigits(Number(amount).toLocaleString('en-US'))} تومان`
|
||||
}
|
||||
|
||||
export function getApiErrorMessage(error, fallback = 'خطایی رخ داد. دوباره تلاش کنید.') {
|
||||
return (
|
||||
error?.response?.data?.error?.message ||
|
||||
error?.response?.data?.message ||
|
||||
error?.message ||
|
||||
fallback
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user