Feature/118 user children tab - #121
Open
Berny-ft wants to merge 7 commits into
Open
Conversation
…gement Non-admins get a sidebar Children tab to create, edit, and delete their own kids; admins keep managing children from the Users row action.
Parents only need Children; Users is an admin surface and should not appear in the sidebar for normal accounts.
Reuse the contact dialog for add and edit so parents and admins can update contact details without deleting and re-adding them.
…alidation - Consolidated shared functions for handling emergency contacts and user ID retrieval. - Updated validation schemas for creating and deleting children, ensuring robust error handling. - Adjusted role checks to improve access control for parent users. - Refactored revalidation logic to use a unified function for path updates.
- Introduced a new "CHILDREN" item in the sidebar for user roles, allowing easier access to child management features. - Adjusted the sidebar items to ensure non-admin users have a streamlined navigation experience.
- Eliminated the export of ChildActionState from children-actions.ts to clean up the code and improve maintainability.
There was a problem hiding this comment.
Pull request overview
Implements role-based child management: parents can manage their own children via a new /children page, while admins manage children for any user from the Users table (without admin delete), with shared dialogs/schemas and cache revalidation.
Changes:
- Add role-aware sidebar behavior and a new authenticated
/childrenpage restricted to parents. - Introduce shared children schemas/queries/server actions for both parent and admin flows, including emergency contact handling and dual-path cache revalidation.
- Add admin UI (Users table action + modal) to list/add/edit a user’s children, plus unit tests for admin and parent server actions.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| components/app-sidebar.tsx | Adds role-aware nav items (show Children for users; hide Users for non-admin) and improved active route matching. |
| app/(authenticated)/users/children-shared.ts | Shared helpers for reading fields, parsing/inserting emergency contacts, and revalidating /users + /children. |
| app/(authenticated)/users/children-schema.ts | Zod schemas for create/update/delete (parent and admin variants) and shared action state typing. |
| app/(authenticated)/users/children-queries.ts | Adds query to list a parent’s children and hydrate emergency contacts. |
| app/(authenticated)/users/children-actions.ts | Admin-only server actions to list/create/update children for a specified parent. |
| app/(authenticated)/users/_components/user-actions-cell.tsx | Adds “Manage children” action to each user row (admin UI entrypoint). |
| app/(authenticated)/users/_components/children/manage-children-modal.tsx | Admin modal for listing and editing a user’s children, with create/edit dialogs. |
| app/(authenticated)/users/_components/children/emergency-contact-dialog.tsx | Client dialog for adding/editing a single emergency contact (UI + validation). |
| app/(authenticated)/users/_components/children/dob-field.tsx | Reusable DOB input with ISO parsing/formatting and calendar picker. |
| app/(authenticated)/users/_components/children/create-child-dialog.tsx | Shared create dialog (used for admin + parent flows) including emergency contacts section. |
| app/(authenticated)/users/_components/children/child-detail-dialog.tsx | Shared edit dialog for a child profile and its emergency contacts. |
| app/(authenticated)/layout.tsx | Fetches role claims server-side and passes role into AppSidebar. |
| app/(authenticated)/children/page.tsx | Adds parent-only /children page and redirects admins away to /users. |
| app/(authenticated)/children/actions.ts | Parent (role=user) server actions for create/update/delete with ownership checks. |
| app/(authenticated)/children/_components/children-client.tsx | Parent-facing children table UI with create/edit/delete flows. |
| tests/children-admin-actions.test.ts | Unit tests for admin children actions (auth, missing parent, create/update, revalidation). |
| tests/children-actions.test.ts | Unit tests for parent children actions (auth/role, schema validation, ownership, revalidation). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #118
Overview
Parents need to manage their own kids; admins need to manage kids for any user.
Parents (role = user): new /children page to create, edit, and delete their children (including emergency contacts). Coordinators do not get this tab.
Admins: Manage Children from the Users table (list / add / edit). No admin delete; admins are redirected away from /children.
Shared create/edit dialogs, Zod validation, ownership checks, dual cache revalidation (/children + /users), and unit tests for parent and admin actions.
Testing
Unit tests (pnpm test:ci)
Parent actions: auth (unsigned-in, coordinator), Zod (DOB, phone, emergency contacts), create/update/delete ownership, dual path revalidation
Admin actions: requireAdmin, missing parent, create/update success, schema validation
Manual
As user: /children in nav; create, edit, delete own child (incl. emergency contacts); coordinators do not see Children
As admin: Manage Children from Users (list / add / edit); no Children nav; no delete in admin modal
Confirmed admin Manage Children works after removing the ChildActionState type re-export from the server actions file
Screenshots / Screencasts
user view




admin view

Checklist