feat(miniapp): redesign balance and due-state flows

This commit is contained in:
2026-03-12 14:08:55 +04:00
parent 6053379f31
commit 0d2065fd5e
11 changed files with 434 additions and 206 deletions

View File

@@ -156,3 +156,17 @@ export function compareTodayToPeriodDay(
return 0
}
export function daysUntilPeriodDay(period: string, day: number, timezone: string): number | null {
const parsed = parsePeriod(period)
const today = formatTodayParts(timezone)
if (!parsed || !today) {
return null
}
const safeDay = Math.max(1, Math.min(day, daysInMonth(parsed.year, parsed.month)))
const dueValue = Date.UTC(parsed.year, parsed.month - 1, safeDay)
const todayValue = Date.UTC(today.year, today.month - 1, today.day)
return Math.round((dueValue - todayValue) / 86_400_000)
}