mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-08-18 00:28:14 +00:00
Clan System Part 2 - UI (#3625)
## Description: Continuation from #3276 Adds the complete client-side clan UI as a Lit web component (`<clan-modal>`), a typed API client with Zod-validated responses, shared response schemas, and a reusable `<confirm-dialog>` component. ### New: `ClanModal.ts` | View | What it does | |------|-------------| | **My Clans** | Lists joined clans + pending join requests (built from `/users/@me`, no extra fetches) | | **Browse** | Search by tag (min 3 chars), paginated results, configurable per-page (10/25/50) | | **Clan Detail** | Stats, paginated + searchable member list, role badges, join/leave/request actions | | **Manage** | Edit name (max 35 chars) + description, toggle open/invite-only, disband | | **Transfer** | Leadership transfer with member selector + confirmation | | **Requests** | Approve/deny join requests (leader/officer) | | **Bans** | View and unban (leader/officer) | | **My Requests** | View and withdraw outgoing requests | ### New: `ConfirmDialog.ts` Reusable `<confirm-dialog>` Lit component — replaces native `confirm()`/`prompt()` which are blocked or broken on mobile and CrazyGames iframes. Supports danger/warning variants and an optional textarea (used for ban reasons). Fires `confirm`/`cancel` events. ### New: `ClanApi.ts` Typed API client covering all clan endpoints. Every response is Zod-validated. Auth header is always last in the spread (can't be overridden by callers). Unknown server error messages always fall back to a generic client-side string — never displayed verbatim. ### New: `ClanApiSchemas.ts` (in `src/core/`) Shared Zod schemas for clan API responses with max-length constraints on `name` (35) and `description` (200). Lives in `core/` so it can be consumed by both client code and the leaderboard table. ### Modified: `ApiSchemas.ts` - Added `clans` and `clanRequests` arrays to `UserMeResponseSchema` - Moved clan leaderboard schemas out to `ClanApiSchemas.ts` - Renamed `LeaderboardClanTagSchema` → `RequiredClanTagSchema` ### Modified: `Api.ts` - Added `invalidateUserMe()` to bust the cached `/users/me` response after mutations - Removed `fetchClanLeaderboard` (moved to `ClanApi.ts`) ### Tests - `ClanModal.test.ts` — rendering, view navigation, user actions - `ClanApiQueries.test.ts` — fetch functions, error handling, pagination - `ClanApiMutations.test.ts` — join, leave, kick, ban, promote, transfer, etc. - `ClanApiBans.test.ts` — ban/unban calls and error paths - `ClanApiSchemas.test.ts` — Zod schema validation edge cases - `LeaderboardModal.test.ts` — updated imports ## Notable design decisions - **Not-logged-in state** — shows "Sign in to join clans" instead of false "no clans" empty state - **Rate limit feedback** — reads `Retry-After` header and surfaces wait time to the user ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: w.o.n --------- Co-authored-by: evanpelle <evanpelle@gmail.com>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
"summary_send": "Send",
|
||||
"summary_keep": "Keep",
|
||||
"cancel": "Cancel",
|
||||
"confirm": "Confirm",
|
||||
"send": "Send",
|
||||
"cap_label": "Cap",
|
||||
"cap_tooltip": "Recipient’s remaining capacity",
|
||||
@@ -49,6 +50,7 @@
|
||||
"leaderboard": "Leaderboard",
|
||||
"account": "Account",
|
||||
"help": "Help",
|
||||
"clans": "Clans",
|
||||
"menu": "Menu",
|
||||
"troubleshooting": "Troubleshooting",
|
||||
"go_to_troubleshooting": "Go to our troubleshooting page"
|
||||
@@ -222,6 +224,115 @@
|
||||
"logging_in": "Logging in...",
|
||||
"success": "Successfully logged in as {email}!"
|
||||
},
|
||||
"clan_modal": {
|
||||
"title": "Clans",
|
||||
"my_clans": "My Clans",
|
||||
"browse": "Browse",
|
||||
"no_clans": "You're not in any clans yet.",
|
||||
"sign_in_for_clans": "Sign in to join and manage clans",
|
||||
"request_pending": "Request Pending",
|
||||
"search_placeholder": "Search by clan tag...",
|
||||
"no_results": "No clans found.",
|
||||
"invite_only": "Invite Only",
|
||||
"members": "Members",
|
||||
"status": "Status",
|
||||
"open": "Open",
|
||||
"join_clan": "Join Clan",
|
||||
"request_invite": "Request Invite",
|
||||
"leave_clan": "Leave Clan",
|
||||
"manage_clan": "Manage",
|
||||
"transfer_leadership": "Transfer Leadership",
|
||||
"clan_name": "Clan Name",
|
||||
"description": "Description",
|
||||
"open_clan": "Open Clan",
|
||||
"open_clan_desc": "Anyone can join without an invite",
|
||||
"clan_settings": "Clan Settings",
|
||||
"save_changes": "Save Changes",
|
||||
"promote": "Promote",
|
||||
"demote": "Demote",
|
||||
"kick": "Kick",
|
||||
"danger_zone": "Danger Zone",
|
||||
"disband_clan": "Disband Clan",
|
||||
"transfer_warning": "This will make the selected member the new leader. You will become a regular member. This action cannot be undone.",
|
||||
"confirm_transfer": "Transfer leadership to {name}",
|
||||
"select_new_leader": "Select a new leader",
|
||||
"search_members_placeholder": "Filter current page by ID or role...",
|
||||
"search_requests_placeholder": "Search by player public ID...",
|
||||
"per_page": "Per page",
|
||||
"sort_by": "Sort by",
|
||||
"sort_default": "Role",
|
||||
"sort_total_wins": "Total Wins",
|
||||
"sort_total_losses": "Total Losses",
|
||||
"sort_ffa_wins": "FFA Wins",
|
||||
"sort_ffa_losses": "FFA Losses",
|
||||
"sort_team_wins": "Team Wins",
|
||||
"sort_team_losses": "Team Losses",
|
||||
"sort_hvn_wins": "HvN Wins",
|
||||
"sort_hvn_losses": "HvN Losses",
|
||||
"sort_ranked_wins": "Ranked Wins",
|
||||
"sort_ranked_losses": "Ranked Losses",
|
||||
"sort_1v1_wins": "1v1 Wins",
|
||||
"sort_1v1_losses": "1v1 Losses",
|
||||
"sort_order_asc": "Ascending",
|
||||
"sort_order_desc": "Descending",
|
||||
"join_requests": "Join Requests",
|
||||
"no_requests": "No pending join requests.",
|
||||
"pending_requests_count": "{count, plural, one {# pending request} other {# pending requests}}",
|
||||
"approve": "Approve",
|
||||
"deny": "Deny",
|
||||
"requested_on": "Requested to join [{tag}] on {date}.",
|
||||
"pending_applications": "Pending Applications",
|
||||
"no_pending_applications": "No pending applications.",
|
||||
"applied": "Applied",
|
||||
"cancel_request": "Cancel",
|
||||
"statistics": "Statistics",
|
||||
"stats_total": "Total",
|
||||
"stats_ffa": "FFA",
|
||||
"stats_team": "Teams",
|
||||
"stats_hvn": "HvN",
|
||||
"stats_ranked": "Ranked",
|
||||
"stats_1v1": "1v1",
|
||||
"no_description": "No description",
|
||||
"saving": "Saving...",
|
||||
"join_request_cancelled": "Join request cancelled.",
|
||||
"failed_to_load_clan": "Failed to load clan",
|
||||
"join_request_sent": "Join request sent! Waiting for approval.",
|
||||
"left_clan": "You left the clan.",
|
||||
"settings_saved": "Clan settings saved!",
|
||||
"clan_disbanded": "Clan disbanded.",
|
||||
"member_promoted": "Member promoted!",
|
||||
"member_demoted": "Member demoted.",
|
||||
"member_kicked": "Member kicked.",
|
||||
"leadership_transferred": "Leadership transferred!",
|
||||
"failed_to_load_requests": "Failed to load requests",
|
||||
"request_approved": "Request approved!",
|
||||
"request_denied": "Request denied.",
|
||||
"ban": "Ban",
|
||||
"unban": "Unban",
|
||||
"banned_players": "Banned Players",
|
||||
"no_bans": "No banned players.",
|
||||
"ban_reason_prompt": "Ban reason (optional, max 200 characters):",
|
||||
"confirm_ban": "Are you sure you want to ban this player? They will be removed from the clan and unable to rejoin.",
|
||||
"member_banned": "Player banned.",
|
||||
"member_unbanned": "Player unbanned.",
|
||||
"banned_by_label": "by",
|
||||
"ban_reason": "Reason: {reason}",
|
||||
"error_banned": "You are banned from this clan.",
|
||||
"error_banned_reason": "You are banned from this clan. Reason: {reason}",
|
||||
"confirm_kick": "Are you sure you want to kick this member?",
|
||||
"confirm_disband": "Are you sure you want to disband [{tag}] {name}? This cannot be undone.",
|
||||
"joined_date": "Member since {date}.",
|
||||
"member_count": "{count, plural, one {# member} other {# members}}",
|
||||
"role_leader": "Leader",
|
||||
"role_officer": "Officer",
|
||||
"role_member": "Member",
|
||||
"error_already_member": "Already a member",
|
||||
"error_request_pending": "Join request already pending",
|
||||
"error_rate_limited_generic": "Please wait before joining another clan",
|
||||
"error_network": "Network error",
|
||||
"error_failed": "Action failed",
|
||||
"error_loading": "Failed to load"
|
||||
},
|
||||
"account_modal": {
|
||||
"title": "Account",
|
||||
"connected_as": "Connected as",
|
||||
|
||||
Reference in New Issue
Block a user