Skip to content

feat: URL state management for deep linking across pages #458

@ZzAve

Description

@ZzAve

Current State

Only ?personId= works across the application (via usePerson hook). The budget allocation page just received ?year= and ?eventCode= query parameter support, but other pages lack URL-driven state management.

Goal

All PersonLayout-based pages should support URL-driven state for deep linking, bookmarkability, and share-ability. This enables:

  • Deep linking from notifications and emails
  • Bookmarkable filtered/personalized views
  • Browser back/forward support
  • Shareable URLs between team members

Pages to Update

  • /budget-allocations - personId, year, eventCode, typeFilter (partially done)
  • /workdays - personId, year, month
  • /expense - personId, year
  • /contract - personId
  • /assignment - personId
  • /event - page number, search filter

Approach

Create a shared useUrlState hook that syncs React state with URL query params, building on the existing usePerson pattern but making it generic and reusable across all pages.

The hook should:

  1. Read query params from URL on mount
  2. Sync state changes back to URL
  3. Handle browser history (back/forward)
  4. Work with React Router v5's useHistory/useLocation

Implementation Strategy

  1. Create useUrlState hook in a shared location (e.g., workday-application/src/main/react/hooks/useUrlState.ts)
  2. Wire up each page individually to use the hook for their specific state
  3. Test deep linking and bookmarking behavior
  4. Update PersonLayout pattern to encourage URL state adoption

Scope

Medium effort - the hook is reusable, but each page needs individual wiring and testing.

Benefits

  • Shareable URLs: Team members can share specific filtered views
  • Deep linking: Direct links from emails/notifications to specific person + filters
  • Bookmarkable: Users can save and return to their preferred views
  • Browser navigation: Back/forward buttons work naturally across filter changes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions