Skip to content

feat: add paginated invite details - #6364

Open
Sunshine-JamesHu wants to merge 1 commit into
QuantumNous:mainfrom
Sunshine-JamesHu:codex/add-paginated-invite-details
Open

Sunshine-JamesHu wants to merge 1 commit into
QuantumNous:mainfrom
Sunshine-JamesHu:codex/add-paginated-invite-details

Conversation

@Sunshine-JamesHu

@Sunshine-JamesHu Sunshine-JamesHu commented Jul 21, 2026 •

Copy link
Copy Markdown

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

在钱包邀请统计中增加分页详情入口。用户点击邀请人数后可查看通过其邀请链接注册的用户,并可调整每页数量、前后翻页、重试失败请求。

后端新增已认证的 /api/user/aff/invitees 接口,使用 GORM 按邀请人隔离并稳定分页。响应仅包含脱敏显示名、邀请时间和当日新增标记,不暴露被邀请人的用量、状态或注销信息;软删除用户仍计入历史邀请。

前端适配当前 web/ 目录、Base UI 和 Hugeicons,并为 en、zh、zh-TW、fr、ja、ru、vi 补齐文案。

AI-assisted disclosure: 本 PR 由 AI 辅助从本地开发分支提取、适配官方 main、验证并整理提交;原始功能由 JamesHu 编写。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 Issues 与 PRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

go test ./model -count=1
ok   github.com/QuantumNous/new-api/model

go test ./controller ./router -count=1
ok   github.com/QuantumNous/new-api/controller
ok   github.com/QuantumNous/new-api/router

bun run typecheck
$ tsgo -b

bunx oxlint -c .oxlintrc.json <changed frontend files>
0 errors

bun run i18n:sync
all 7 locales: missingCount=0, extrasCount=0, untranslatedCount=0

bun run build
built successfully

Summary by CodeRabbit

  • New Features
    • Added an Invite Details view to the wallet.
    • Users can view referral invitees, masked names, invitation dates, and “New” badges.
    • Added pagination, page-size selection, loading, empty, error, and retry states.
    • Made the wallet’s invite count interactive to open invite details.
    • Added translated invitation and referral text across supported languages.
  • Tests
    • Added coverage for pagination, deleted invitees, name masking, Unicode, and derived status values.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds an authenticated invitee-history endpoint and connects it to a paginated wallet dialog. Invitee names are masked, new invitees are marked, deleted records are included, and interface translations are added across supported locales.

Changes

Invitee history

Layer / File(s) Summary
Backend query and endpoint
controller/user.go, model/user_invitee.go, model/user_invitee_test.go, router/api-router.go
Adds the authenticated paginated endpoint, unscoped invitee query, display-name masking, new-status derivation, and coverage for pagination, deleted records, serialization, and Unicode names.
Wallet integration
web/src/features/wallet/types.ts, web/src/features/wallet/api.ts, web/src/features/wallet/components/affiliate-rewards-card.tsx, web/src/features/wallet/index.tsx
Adds typed API access and makes the invite statistic open the invitees dialog.
Invitees dialog and localization
web/src/features/wallet/components/dialogs/invitees-dialog.tsx, web/src/i18n/locales/*.json
Adds query states, invitee rows, new badges, timestamps, pagination controls, and translated interface strings.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Wallet as Wallet UI
  participant API as getUserInvitees
  participant Endpoint as GET /api/user/aff/invitees
  participant Query as GetUserInvitees model query
  Wallet->>API: request page and page size
  API->>Endpoint: send paginated GET request
  Endpoint->>Query: fetch invitees and total
  Query-->>Endpoint: masked invitee records
  Endpoint-->>API: typed response
  API-->>Wallet: render rows and pagination
Loading

Poem

A bunny taps “Invites” with delight,
Names wear masks, all neat and slight.
Pages hop from one to two,
“New” badges sparkle in view,
While translations bloom bright.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: a paginated invite-details feature.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Warning

⚠️ This pull request shows signs of AI-generated slop (ai_padded_prose). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
web/src/features/wallet/components/dialogs/invitees-dialog.tsx (1)

69-79: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Consider placeholderData: keepPreviousData for pagination
Page or page-size changes currently replace the table with the full skeleton again. Keeping the previous rows visible while the next page loads will remove the flicker.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/features/wallet/components/dialogs/invitees-dialog.tsx` around lines
69 - 79, Update the useQuery configuration in the invitees dialog to use
TanStack Query’s keepPreviousData placeholder behavior for page and pageSize
changes. Import the required keepPreviousData helper if needed, while preserving
the existing loading and query behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@web/src/features/wallet/components/dialogs/invitees-dialog.tsx`:
- Around line 69-79: Update the useQuery configuration in the invitees dialog to
use TanStack Query’s keepPreviousData placeholder behavior for page and pageSize
changes. Import the required keepPreviousData helper if needed, while preserving
the existing loading and query behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7c45f792-9072-4be5-9ef5-c42833eb4aa9

📥 Commits

Reviewing files that changed from the base of the PR and between e0d5156 and 5e6af71.

📒 Files selected for processing (16)
  • controller/user.go
  • model/user_invitee.go
  • model/user_invitee_test.go
  • router/api-router.go
  • web/src/features/wallet/api.ts
  • web/src/features/wallet/components/affiliate-rewards-card.tsx
  • web/src/features/wallet/components/dialogs/invitees-dialog.tsx
  • web/src/features/wallet/index.tsx
  • web/src/features/wallet/types.ts
  • web/src/i18n/locales/en.json
  • web/src/i18n/locales/fr.json
  • web/src/i18n/locales/ja.json
  • web/src/i18n/locales/ru.json
  • web/src/i18n/locales/vi.json
  • web/src/i18n/locales/zh-TW.json
  • web/src/i18n/locales/zh.json

@Calcium-Ion
Calcium-Ion force-pushed the main branch 2 times, most recently from 51fdfc5 to 2b6f1df Compare August 30, 2026 15:03
shirosoralumie648 added a commit to shirosoralumie648/newapi-rev that referenced this pull request Oct 18, 2026
…tistics

Complete the RF-07 invitation statistics panel so the administrator
summary, list filters and CSV export cover every recorded commission
state. The inviter view keeps exposing only the payable pipeline.

- model: the per-invitation aggregates and the filter-aware summary
  bucket the refused events (review, blocked, rejected) alongside
  pending/locked/settled, so the buckets add up to the recorded total;
  the commission-status validation accepts all six recorded states.
- controller: the administrator item embeds the admin-only refused
  fields while the self item stays payable-only and masked; the CSV
  export gains review_quota, blocked_quota and rejected_quota (17
  columns); the endpoints stay read-only and never move a balance.
- web: label and filter the refused states, show all six buckets in the
  admin dialog summary, keep the commission total across all six states,
  register the dynamic label keys, and cover the admin dialog with
  regression tests (summary, refused row, keyword filter, CSV export,
  disabled export on the empty state).
- i18n: 28 new keys in all seven locales. `node
  scripts/add-missing-keys.mjs` could not be executed in this sandbox,
  so the keys were inserted at their ICU-sorted anchors and normalized
  with `node scripts/sync-i18n.mjs`, which reports missingCount=0 and
  extrasCount=0.

Tests: TestReferralInvitationStats seeds refused events and asserts the
six buckets, their sum against the recorded total and the blocked
filter; TestReferralInvitationQueryValidation accepts all six states;
TestReferralInvitationStatisticsEndpoints covers masking, cross-inviter
isolation, the admin-only refused fields, filter errors, the 17-column
CSV and an unchanged balance.

Inspired-by: QuantumNous#6364
Inspired-by: QuantumNous#4197
Local tests not run (CI-only session).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant