Skip to content

[ResourceApp][Frontend][REFACTOR] Resource Feature Extraction#73

Merged
Aravinda-HWK merged 4 commits intoLSFLK:mainfrom
MohamadNazik:refactor/resource-app-frontend-ddd-resource-feature
Mar 24, 2026
Merged

[ResourceApp][Frontend][REFACTOR] Resource Feature Extraction#73
Aravinda-HWK merged 4 commits intoLSFLK:mainfrom
MohamadNazik:refactor/resource-app-frontend-ddd-resource-feature

Conversation

@MohamadNazik
Copy link
Copy Markdown
Contributor

@MohamadNazik MohamadNazik commented Mar 20, 2026

Context

Part of the incremental Domain-Driven Design (DDD) refactoring of the frontend.

What changed

  • Created a dedicated resource feature module encapsulating its own types, constants, API layer, context, hooks, and views
  • Moved resource and stats management out of the global application context and into a dedicated, isolated provider
  • Fixed the infinite network fetch loop for analytics (Issue [ResourceApp][Frontend][BUG]: Analytics Stats Fetch Loops Infinitely on Analytics Tab #80) by structurally isolating the stats-fetching logic inside a strictly-memoized callback within the new domain
  • Relocated the catalog and resource creation views into the new feature module
  • Updated the admin dashboard to consume the isolated resource context directly
  • Cleaned up the root typing definitions to re-export resource types dynamically from the new module
  • Stripped the global application context so it now only manages bookings

Why

The resource entity is the core of this application. Giving it a dedicated feature module with owned views and business logic keeps all resource concerns co-located, naturally prevents unstable dependency looping, and dramatically reduces the bloat of the global context array.

Acceptance Criteria

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request implements a significant refactoring of the frontend application by extracting all resource-related logic into a self-contained feature module. This change enhances modularity, improves separation of concerns, and streamlines the global application context, making the codebase more maintainable and scalable. The primary impact is a cleaner architecture where resource management is isolated and independently manageable.

Highlights

  • Resource Feature Module: A new dedicated feature module for resources has been created, encapsulating types, constants, API layer, context, hooks, and views related to resource management.
  • Context Refactoring: Resource and statistics management have been extracted from the global AppContext and moved into a new ResourceProvider, significantly reducing the global context's responsibilities. The AppContext now exclusively handles bookings.
  • View Relocation: The CatalogView and CreateResourceView (formerly views/CreateResourceView) have been relocated into the new features/resource/views directory, aligning them with the dedicated resource feature.
  • Admin View Update: The AdminView has been updated to consume resource-related data and actions directly from the new useResource context instead of the global useApp context.
  • Type Definitions Centralization: The root types.ts file has been cleaned up to re-export resource-specific types from the new features/resource/types module, promoting better organization and preventing duplication.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request does a great job of refactoring the resource management logic into its own dedicated feature module, following DDD principles. The code is well-structured, and the separation of concerns between the AppContext and the new ResourceContext is clear. I've identified a few areas for improvement regarding type safety, key generation, and code maintainability. My detailed comments are below.

Comment thread resource-app/frontend/features/resource/hooks/useResourceForm.ts Outdated
Comment thread resource-app/frontend/features/resource/hooks/useResourceForm.ts Outdated
Comment thread resource-app/frontend/features/resource/views/CatalogView.tsx Outdated
Comment thread resource-app/frontend/features/resource/views/CreateResourceView.tsx Outdated
- Default new resources to isActive true on creation
- Replace Date.now() with a stable ref counter for form field IDs
- Replace color ternary chains with lookup maps in catalog and creation views
@MohamadNazik MohamadNazik requested a review from a team March 20, 2026 05:11
Comment thread resource-app/frontend/features/resource/views/CreateResourceView.tsx Outdated
Comment thread resource-app/frontend/App.tsx
Comment thread resource-app/frontend/features/resource/views/CatalogView.tsx Outdated
Comment thread resource-app/frontend/features/user/views/AdminView.tsx Outdated
Comment thread resource-app/frontend/features/user/views/AdminView.tsx
@MohamadNazik MohamadNazik marked this pull request as draft March 22, 2026 17:15
- Align submit button disabled state with form validation logic
- Surface resource loading and error states in the global app shell
- Add safe fallback for specs to prevent crash on missing data
- Make reschedule inputs controlled and reset state on modal close
- Clear reschedule time state when opening the propose time modal
@MohamadNazik MohamadNazik requested a review from ginaxu1 March 22, 2026 17:33
@MohamadNazik MohamadNazik marked this pull request as ready for review March 22, 2026 17:33
Comment thread resource-app/frontend/features/resource/hooks/useResourceForm.ts Outdated
Comment thread resource-app/frontend/features/resource/context.tsx Outdated
Comment thread resource-app/frontend/features/resource/hooks/useResourceForm.ts Outdated
@MohamadNazik MohamadNazik marked this pull request as draft March 24, 2026 03:30
…eedback

- Replace ref counter with crypto.randomUUID() for globally unique field IDs
- Add MutationResult type to addResource and updateResource for typed error propagation
- Surface submit errors to the user via an inline error banner in the form footer
- update useCalendar to get resources from resource context
@MohamadNazik MohamadNazik marked this pull request as ready for review March 24, 2026 03:57
@MohamadNazik MohamadNazik requested a review from ginaxu1 March 24, 2026 03:57
@Aravinda-HWK Aravinda-HWK merged commit cf2f940 into LSFLK:main Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants