Files
household-bot/.trae/documents/plan-home-no-payment-and-qa-overrides.md
whekin 488a488137 feat: add quick payment action and improve copy button UX
Mini App Home Screen:
- Add 'Record Payment' button to utilities and rent period cards
- Pre-fill payment amount with member's share (rentShare/utilityShare)
- Modal dialog with amount input and currency display
- Toast notifications for copy and payment success/failure feedback

Copy Button Improvements:
- Increase spacing between icon and text (4px → 8px)
- Add hover background and padding for better touch target
- Green background highlight when copied (in addition to icon color change)
- Toast notification appears when copying any value

Backend:
- Add /api/miniapp/payments/add endpoint for quick payments
- Payment notifications sent to 'reminders' topic in Telegram
- Include member name, payment type, amount, and period in notification

Files:
- New: apps/miniapp/src/components/ui/toast.tsx
- Modified: apps/miniapp/src/routes/home.tsx, apps/miniapp/src/index.css,
  apps/miniapp/src/theme.css, apps/miniapp/src/i18n.ts,
  apps/bot/src/miniapp-billing.ts, apps/bot/src/server.ts

Quality Gates:  format, lint, typecheck, build, test

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-14 08:51:53 +04:00

61 lines
3.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Plan: Fix Home “No Payment” + Add QA Period Overrides
## Goals
- Remove the “Due” chip from the **No payment period** card.
- In **No payment period**, dont show rent/utilities balances; show only purchase-related balance and household info (FX if available).
- Fix “Upcoming” dates so they never show negative days (e.g., “-11d left”); if the reminder/warning already passed in the current period, show the next periods start date instead.
- Add **period/date overrides** to the hidden QA “Testing view” so you can reliably test all Home variants.
## Changes
### 1) Home: remove “Due” chip from No-payment card
- In [home.tsx](file:///Users/whekin/Projects/kojori-tg-bot/apps/miniapp/src/routes/home.tsx), stop rendering the `focusBadge()` inside the `mode() === 'none'` card.
- Keep the existing Due/Settled chip behavior for utilities/rent modes unchanged.
### 2) Home: No-payment mode shows purchases-only balance
- In [home.tsx](file:///Users/whekin/Projects/kojori-tg-bot/apps/miniapp/src/routes/home.tsx):
- When `homeMode() === 'none'`, hide the current “Your balance” card (which includes rent + utilities).
- Replace it with a purchases-focused card that shows:
- Member purchase offset (from `currentMemberLine().purchaseOffsetMajor`) as the primary amount.
- Household purchase totals (count + sum) computed from the existing dashboard ledger entries where `kind === 'purchase'`.
- Household member count (from dashboard member lines length).
- Keep household informational cards that are not “due/balance for rent/utilities” (e.g., the FX card if present/available).
### 3) Home: Upcoming utilities/rent start date never goes negative
- Update upcoming calculations in No-payment mode:
- If `daysUntilPeriodDay(period, reminderDay, timezone)` is `>= 0`, show as-is.
- If it is `< 0`, compute the next period (`BillingPeriod.fromString(period).next().toString()`) and compute:
- `formatPeriodDay(nextPeriod, reminderDay, locale)`
- `daysUntilPeriodDay(nextPeriod, reminderDay, timezone)`
- Apply the same logic for rent warning day and utilities reminder day.
- This ensures “Utilities starts …” always points to a future date and shows a non-negative countdown.
### 4) QA Testing View: add period/date overrides
- Extend the existing hidden “Testing view” (opened by 5 taps on the role badge) in:
- [shell.tsx](file:///Users/whekin/Projects/kojori-tg-bot/apps/miniapp/src/components/layout/shell.tsx)
- [dashboard-context.tsx](file:///Users/whekin/Projects/kojori-tg-bot/apps/miniapp/src/contexts/dashboard-context.tsx)
- Add two optional overrides stored in `DashboardContext`:
- `testingPeriodOverride?: string | null` (format `YYYY-MM`)
- `testingTodayOverride?: string | null` (format `YYYY-MM-DD`)
- Home uses `effectivePeriod = testingPeriodOverride ?? dashboard.period`.
- Date helpers used by Home (`daysUntilPeriodDay`, `compareTodayToPeriodDay`) accept an optional “today override” so Home can behave as if its a different day without changing system time.
### 5) Copy updates
- Add/adjust i18n strings needed for the purchases-only card and QA fields in:
- [i18n.ts](file:///Users/whekin/Projects/kojori-tg-bot/apps/miniapp/src/i18n.ts)
## Verification
- Run: `bun run format:check`, `bun run lint`, `bun run typecheck`, `bun run test`, `bun run build`
- Manual checks in miniapp:
- Set QA overrides to land inside utilities window / rent window / no-payment window and confirm Home variant changes.
- Confirm no-payment “Upcoming” countdown never shows negative values.
- Confirm no-payment mode hides rent/utilities balance and no longer shows “Due” chip on that card.
- Confirm no-payment mode shows purchase offset + household purchase stats + member count.