skills/manage-page-patterns/SKILL.md
Patterns for admin/manage pages (community manage, event manage) — local actionState, runCommunityAction/runAction helpers, realtime as primary update path. Use when building manage pages with mutations like invite, kick, add, or remove.
npx skillsauth add bkinsey808/songshare-effect manage-page-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Requires: file-read. No terminal or network access needed.
Use this skill when:
Execution workflow:
actionState mutation patterns; avoid store-level page-blanking loading flags.runCommunityAction/runAction) for mutation lifecycle.Output requirements:
Describes the required patterns for "manage" pages (community manage, event manage, etc.) that let admins perform mutations. Getting this wrong causes page-blanking loading states that break the admin UX.
actionState, Not Store-Level LoadingNever call store actions that set isCommunityLoading or isEventLoading for individual mutations on a manage page. Those flags blank the whole page with a "Loading..." screen.
All mutations must go through a local actionState object via the runCommunityAction / runAction helper that only shows inline feedback:
// ✅ GOOD: local action state — only a button/banner changes
function onRemoveEventClick(eventId: string): void {
void runCommunityAction({
key: `remove-event:${eventId}`,
action: () => postJson(apiCommunityEventRemovePath, { community_id, event_id: eventId }),
successMessage: "Event removed successfully",
setActionState,
refreshFn: refreshCommunity,
});
}
// ❌ BAD: store action that calls setCommunityLoading(true) — blanks the page
function onSetActiveEventClick(eventId: string | undefined): void {
void Effect.runPromise(setActiveEventForCommunity(communityId, eventId));
}
Helper locations:
react/src/community/manage/community-manage-view/runCommunityAction.tsreact/src/event/manage/runAction.tsBoth helpers handle the full loading → success/error cycle locally.
After a mutation succeeds, the Supabase realtime subscription updates the UI. The refreshFn passed to runCommunityAction/runAction is a silent fallback only — it uses { silent: true } so it does not trigger isCommunityLoading:
async function refreshCommunity(): Promise<void> {
// silent: true prevents isCommunityLoading from going true
await Effect.runPromise(fetchCommunityBySlug(community_slug, { silent: true }));
}
Always ensure the manage page has active realtime subscriptions (see useCommunityManageSubscriptions, useEventCommunityManagement). The refresh is belt-and-suspenders, not the primary update path.
When building "already-added" exclusion sets for search dropdowns, filter out "kicked" records so those users/events remain selectable for re-invite:
// ✅ GOOD: kicked users can be re-invited
excludeUserIds={members
.filter((member) => member.status !== "kicked")
.map((member) => member.user_id)}
// ❌ BAD: blocks re-inviting kicked users
excludeUserIds={members.map((member) => member.user_id)}
The same applies to event participants (status !== "kicked").
runCommunityAction or runAction (not store-level loading flags)refreshFn passes { silent: true } to the fetch calldocs/ai/rules.md.supabase-client-patterns.realtime-rls-debugging.tools
Zustand state management patterns for this project — store creation, selectors, Immer middleware, async actions with loading states, devtools, persist, and testing. Use when authoring or editing Zustand stores (use*Store files) or components that subscribe to stores. Do NOT use for React component structure or TypeScript-only utilities.
testing
How to write, update, or split skill files in this repo. Use when creating a new SKILL.md, updating an existing one, or deciding whether to put content in a skill vs. docs/.
development
Complete guide for testing React hooks — renderHook, Documentation by Harness, installStore, fixtures, subscription patterns, lint/compiler traps, and pre-completion checklist. Read docs/testing/unit-test-hook-best-practices.md for the full reference.
development
Vitest unit test authoring for this repo — setup, mocking, API handler testing, and common pitfalls for non-hook code. Use when the user asks to add, update, fix, or review unit tests for utilities, components, API handlers, or scripts. Do NOT use for React hook tests — load unit-test-hook-best-practices instead.