mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
refactor(coupons): единый formatShortDate + честная статистика списка + retry
- formatShortDate вынесен в utils/format вместо трёх копий formatDate + инлайн localeMap (AdminCoupons/AdminCouponDetail/CouponStatus) - список партий: агрегатные карточки Активны/Погашено/Отозвано считались только по текущей странице и противоречили глобальному total «Партий» — показываем их лишь когда весь набор влезает на одну страницу - CouponStatus: retry:false на публичном статусе (404 — ожидаемый ответ на невалидный/погашенный токен, ретрай зря бьёт rate-limited эндпоинт)
This commit is contained in:
@@ -59,3 +59,21 @@ export function formatPrice(kopeks: number, lang?: string): string {
|
||||
return `${rounded} ${config.symbol}`;
|
||||
}
|
||||
}
|
||||
|
||||
const SHORT_DATE_LOCALE_MAP: Record<string, string> = {
|
||||
ru: 'ru-RU',
|
||||
en: 'en-US',
|
||||
zh: 'zh-CN',
|
||||
fa: 'fa-IR',
|
||||
};
|
||||
|
||||
/** Date-only (dd.mm.yyyy) in the active UI locale; '-' for a null date. */
|
||||
export function formatShortDate(date: string | null): string {
|
||||
if (!date) return '-';
|
||||
const locale = SHORT_DATE_LOCALE_MAP[i18next.language] || 'ru-RU';
|
||||
return new Date(date).toLocaleDateString(locale, {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user