Skip to content

Feature/118 user children tab - #121

Open
Berny-ft wants to merge 7 commits into
developfrom
feature/118-user-children-tab
Open

Feature/118 user children tab#121
Berny-ft wants to merge 7 commits into
developfrom
feature/118-user-children-tab

Conversation

@Berny-ft

@Berny-ft Berny-ft commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

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
image
image
image
image

admin view
image

Checklist

  • Code is neat, readable, and works
  • Code is commented where appropriate and well-documented
  • Commit messages follow our guidelines
  • Issue number is linked
  • Branch is linked
  • Reviewers are assigned (one of your tech leads)

Berny-ft added 7 commits July 19, 2026 12:00
…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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 /children page 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.

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.

2 participants