Skip to content

feat: add filter dropdown to inventory (#34)#40

Open
1531AdityaRaj wants to merge 5 commits into
rushikesh-bobade:mainfrom
1531AdityaRaj:issue-34-expenses-column-sorting
Open

feat: add filter dropdown to inventory (#34)#40
1531AdityaRaj wants to merge 5 commits into
rushikesh-bobade:mainfrom
1531AdityaRaj:issue-34-expenses-column-sorting

Conversation

@1531AdityaRaj

Copy link
Copy Markdown

Summary

Implemented the Inventory Filter Dropdown feature.

Changes made

  • Added a filter dropdown to the Inventory header.
  • Added filtering by Status.
  • Added filtering by Condition.
  • Integrated filtering with the existing inventory search.
  • Preserved existing Inventory functionality.

Closes #34

Type of Change

  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the project's style.
  • I have reviewed my changes.

@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

@1531AdityaRaj is attempting to deploy a commit to the participationcorner2025-8967's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the ECSoC26 Required label for ECSOC Sentinel scoring label Jun 30, 2026
@github-actions

Copy link
Copy Markdown

📝 Summary

The pull request introduces a filtering system to the inventory management page. It adds two new filters, "Status" and "Condition", which allow users to narrow down the inventory list based on these criteria. The filters are implemented as dropdown menus that appear when the "Filter" button is clicked.

📂 Files Changed

  • app/blocks/inventory-management/inventory-header.tsx: Updated to include the new filtering system, with a dropdown menu for "Status" and "Condition" filters.
  • app/routes/inventory-management.tsx: Updated to include state variables for the "Status" and "Condition" filters, and to filter the inventory list based on these filters.

🎭 Code Poem

Filters added with care,
Status and Condition, now we can share,
Inventory list, now more refined,
With dropdown menus, user experience aligned.

🚨 Bugs & Warnings * The `onStatusChange` and `onConditionChange` functions are not debounced, which could lead to performance issues if the user rapidly changes the filter values. * The `filteredItems` function does not handle cases where the `item` object is null or undefined, which could lead to runtime errors. * The `statusFilter` and `conditionFilter` state variables are not validated, which could lead to unexpected behavior if invalid values are set. Looks solid otherwise!
💡 Suggestions & Best Practices * Consider adding a debounce to the `onStatusChange` and `onConditionChange` functions to prevent excessive re-renders. * Add null checks to the `filteredItems` function to handle cases where the `item` object is null or undefined. * Validate the `statusFilter` and `conditionFilter` state variables to ensure they only accept valid values. * Consider using a more robust filtering library or framework to handle complex filtering logic. * Add unit tests to cover the new filtering functionality and ensure it works as expected.

🤖 This review was automatically generated by an AI using the Groq Llama 3 API. Please verify suggestions before applying them.

@1531AdityaRaj 1531AdityaRaj marked this pull request as ready for review June 30, 2026 18:09
@rushikesh-bobade

Copy link
Copy Markdown
Owner

Hey @1531AdityaRaj , great work on getting the filter logic hooked up! The React state implementation looks very clean.

However, before we can merge this, we need to clean up the styling. In this project, we strictly avoid inline styles to maintain a clean and scalable codebase.

Requested Changes:
Please move the large block of inline styles on the dropdown <div> (position, background, borders, etc.) into the inventory-header.module.css file as a new class (e.g., .filterDropdown), and apply it using className={styles.filterDropdown}.

Once you extract those styles into the CSS module, I will get this merged right away!

@rushikesh-bobade

Copy link
Copy Markdown
Owner

Hey @1531AdityaRaj , one more quick update!

We just merged PR #39 which adds Server-Side Pagination to the tables. Because we are now paginating on the server, we can no longer use client-side filtering via useState (otherwise the client would only filter the 10 items currently on the page!).

Additional Requested Changes:

  1. Please pull the latest main branch to resolve the merge conflicts this will cause.
  2. Update your dropdown filters to use URL Search Parameters (e.g., ?status=IN_STOCK) instead of useState, just like the search bar does now.
  3. Update the loader in inventory-management.tsx to read the status/condition from the URL and apply it to the Prisma whereClause before it paginates!

Let me know if you need any help with the Remix useSearchParams hook!

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

📝 Summary

The provided pull request diff introduces a filter dropdown to the inventory management page, allowing users to filter items by status and condition. The changes include updates to the inventory-header.module.css file to add styles for the filter dropdown, and updates to the inventory-header.tsx file to implement the filter dropdown functionality. Additionally, the inventory-management.tsx file has been updated to manage the filter state and apply the filters to the item list.

📂 Files Changed

  • app/blocks/inventory-management/inventory-header.module.css: Updated to add styles for the filter dropdown.
  • app/blocks/inventory-management/inventory-header.tsx: Updated to implement the filter dropdown functionality.
  • app/routes/inventory-management.tsx: Updated to manage the filter state and apply the filters to the item list.

🎭 Code Poem

Filters added with care,
Dropdown menu, with options to share,
Status and condition, now in sight,
Inventory management, just got more bright.

🚨 Bugs & Architectural Violations * The code does not include any accessibility attributes (e.g. `aria-hidden`, `role`) on the filter dropdown. * The filter dropdown uses `position: absolute`, which may cause issues with screen readers or other assistive technologies. * The code does not handle cases where the filter dropdown is opened and then the user navigates away from the page. * The `inventory-header.tsx` file uses `useState` to manage the filter state, but it is not clear if this state is being persisted across page reloads or navigation. * The code does not include any loading indicators or error handling for cases where the filter data is being fetched. Looks solid in terms of architectural violations, as the code adheres to the specified rules (Remix, Prisma, Vanilla CSS Modules, etc.).
💡 Suggestions & Best Practices * Consider adding accessibility attributes (e.g. `aria-hidden`, `role`) to the filter dropdown to improve accessibility. * Use a more robust method for positioning the filter dropdown, such as using a library like `react-portal` or `react-overlay`. * Implement a way to persist the filter state across page reloads or navigation, such as using `localStorage` or a state management library. * Add loading indicators and error handling for cases where the filter data is being fetched. * Consider using a more functional programming approach, such as using `useMemo` or `useCallback` to memoize the filter functions. * Use a consistent naming convention throughout the codebase. * Consider adding more comments or documentation to explain the purpose and behavior of the code.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

📝 Summary

The provided pull request diff introduces a new filter dropdown to the inventory management page, allowing users to filter items by status and condition. The filter dropdown is toggled by a button and contains two select menus for status and condition. The selected filters are applied to the inventory table, and the search query is updated accordingly.

📂 Files Changed

  • app/blocks/inventory-management/inventory-header.module.css: Updated CSS styles for the inventory header component, including the new filter dropdown.
  • app/blocks/inventory-management/inventory-header.tsx: Updated the inventory header component to include the new filter dropdown and handle filter changes.
  • app/routes/inventory-management.tsx: Updated the inventory management page to include the new filter dropdown and apply the selected filters to the inventory table.

🎭 Code Poem

Filters added with care,
Dropdown menu, with options to share,
Status and condition, now in sight,
Inventory management, just got more right.

🚨 Bugs & Architectural Violations * The code does not include any accessibility attributes (e.g., `aria-hidden`, `role`) for the filter dropdown and its components. * The `filterDropdown` class uses `position: absolute`, which may cause issues with the component's positioning and layout. * The `InventoryHeader` component does not handle cases where the `statusFilter` or `conditionFilter` props are not provided. * The `filteredItems` array is not memoized, which may cause unnecessary re-renders of the `InventoryTable` component. * The code does not follow the performance guideline of using `transform` or `opacity` for CSS animations, as the `filterDropdown` class uses `box-shadow` and `border-radius` which may trigger main-thread repaints.
💡 Suggestions & Best Practices * Consider adding accessibility attributes to the filter dropdown and its components to improve usability for users with disabilities. * Use a more robust positioning solution for the `filterDropdown` class, such as using a library like `react-portal` or `react-overlay`. * Add default values or error handling for cases where the `statusFilter` or `conditionFilter` props are not provided. * Memoize the `filteredItems` array using `useMemo` to prevent unnecessary re-renders of the `InventoryTable` component. * Consider using `transform` or `opacity` for CSS animations to improve performance and reduce main-thread repaints. * Use a consistent naming convention for variables and functions throughout the codebase. * Consider adding type annotations for function parameters and return types to improve code readability and maintainability.

@1531AdityaRaj

Copy link
Copy Markdown
Author

Hi @rushikesh-bobade,
I've addressed the requested changes by moving the dropdown styles into the CSS module and also resolved the merge conflict with the latest main branch.
Could you please review the PR again? Thanks!

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

📝 Summary

The provided pull request diff introduces a filter dropdown to the inventory management page, allowing users to filter items by status and condition. The filter dropdown is toggled by a button and contains two select menus for status and condition. The selected filters are applied to the inventory items and the page is updated accordingly.

📂 Files Changed

  • app/blocks/inventory-management/inventory-header.module.css: Updated CSS styles for the filter dropdown.
  • app/blocks/inventory-management/inventory-header.tsx: Added filter dropdown functionality and updated props.
  • app/routes/inventory-management.tsx: Updated loader function to include status and condition filters, and updated the InventoryManagementPage component to use the new filter functionality.

🎭 Code Poem

Filters added with care,
Status and condition to share,
Dropdown menu, a new delight,
Inventory management, now more in sight.

🚨 Bugs & Architectural Violations * The code does not include any accessibility features for the filter dropdown, such as `aria-hidden` or `role` attributes. * The `filterDropdown` class uses `position: absolute`, which may cause issues with the layout if the parent element is not positioned relatively. * The `filterDropdown` class uses `z-index: 100`, which may cause issues with other elements on the page that have a higher `z-index`. * The code does not handle the case where the user selects a filter and then navigates away from the page. The filter will be lost when the user returns to the page. * The code does not include any validation for the filter values. If the user selects an invalid filter value, the page may not update correctly. Looks solid in terms of architectural violations, as it follows the required rules of using Remix, Prisma, and Vanilla CSS Modules, and places UI components in the correct directory.
💡 Suggestions & Best Practices * Consider adding accessibility features to the filter dropdown, such as `aria-hidden` and `role` attributes. * Consider using a more robust positioning method for the filter dropdown, such as using a library like `react-portal`. * Consider adding validation for the filter values to ensure that the page updates correctly. * Consider adding a way to persist the filter values when the user navigates away from the page, such as using local storage or a query parameter. * Consider adding a loading indicator while the filter is being applied, to improve the user experience. * Consider using a more efficient data structure for the filter values, such as a `Map` or a `Set`, to improve performance. * Consider adding a way to reset the filters to their default values, to improve the user experience.

@1531AdityaRaj

Copy link
Copy Markdown
Author

Hi @rushikesh-bobade, I've implemented the requested changes and updated the PR. I wanted to test the feature end-to-end, but I don't have access to the project's deployed environment. If possible, could you grant me access or provide a preview/development URL so I can verify the changes before you review them? Thank you!

@rushikesh-bobade

Copy link
Copy Markdown
Owner

Hey @1531AdityaRaj ! Fantastic work! The dropdown styles look much better in the CSS module, and your Prisma whereClause correctly handles the server-side filtering!

To test your code, you don't need access to the deployed environment—you can just test it locally! Make sure you have Docker running, then run npm run db:setup followed by npm run dev in your terminal. It will spin up a local preview at localhost:5173.

I just took a look at the code, and there is one tiny thing we need to fix before merging:

Requested Change:
Because you are successfully filtering the items on the server in the loader using Prisma, the items array sent to the component is already perfectly filtered! Therefore, we don't need the filteredItems array inside the component. Please delete the const filteredItems = items.filter(...) block entirely, and just pass the raw items array directly to <InventoryTable items={items} />.

Once you remove that redundant client-side filter, this is perfect and ready to merge!

@rushikesh-bobade rushikesh-bobade changed the title Add Filter Dropdown to Inventory (#34) feat: add filter dropdown to inventory (#34) Jul 2, 2026
@1531AdityaRaj

1531AdityaRaj commented Jul 2, 2026

Copy link
Copy Markdown
Author

Hi @rushikesh-bobade , I've already made the requested changes and pushed the latest commits. The client-side filtering has been removed, and InventoryTable is now receiving the server-filtered items directly.
I also tried testing the changes locally with Docker running, but the app fails to start because the required Supabase URL and API key environment variables are missing. I get the error: "Your project's URL and Key are required to create a Supabase client."
Could you please let me know the correct local setup or provide the example .env configuration so I can verify the changes on my end? Thanks!

@rushikesh-bobade

Copy link
Copy Markdown
Owner

Hey @1531AdityaRaj!

Thanks for the quick update!

First, regarding the local setup: I apologize, I misspoke in my last comment! We don't have a db:setup script. To run the database locally via Docker, you just need to run the Supabase CLI directly:

  1. Run npx supabase start (this will spin up the local Docker containers).
  2. Once it finishes, it will print out your local API URL and anon key.
  3. Create a .env file at the root of the project by copying .env.example, and paste in those local credentials.
  4. Run npx prisma db push to push the schema to your local database.
  5. Then run npm run dev.

Second, I just took a peek at your latest commit. It looks like the client-side filtering block is actually still in the file!

If you look in app/routes/inventory-management.tsx around line 221, you'll see this block:

const filteredItems = items.filter((item) => {
  const matchesStatus =
    statusFilter === "ALL" || item.status === statusFilter;

  const matchesCondition =
    conditionFilter === "ALL" || item.condition === conditionFilter;

  return matchesStatus && matchesCondition;
});

And then in the return statement:

<InventoryTable
  selected={selected}
  onSelectChange={setSelected}
  items={filteredItems}  {/* <-- This is still using the client-side array! */}
  onEdit={setEditingItem}
/>

Because your Prisma whereClause in the loader is already filtering the items on the server perfectly, you can safely delete the const filteredItems block entirely, and just pass the raw items from the loader straight into <InventoryTable items={items} />.

Give that a quick fix and it'll be good to merge! Let me know if you run into any issues spinning up the local Supabase instance.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

📝 Summary

The provided pull request diff introduces a filter dropdown feature to the inventory management page. The filter dropdown allows users to filter items by status and condition. The changes include updates to the inventory-header.module.css file to add styles for the filter dropdown, updates to the inventory-header.tsx file to add the filter dropdown component, and updates to the inventory-management.tsx file to handle the filter dropdown state and update the search parameters.

📂 Files Changed

  • app/blocks/inventory-management/inventory-header.module.css: Added styles for the filter dropdown.
  • app/blocks/inventory-management/inventory-header.tsx: Added the filter dropdown component and updated the props to include status and condition filters.
  • app/routes/inventory-management.tsx: Updated the loader function to include status and condition filters in the where clause, and updated the InventoryManagementPage component to handle the filter dropdown state and update the search parameters.

🎭 Code Poem

Filters added with care,
Status and condition to share,
Dropdown menu, a new delight,
Inventory management, now more in sight.

🚨 Bugs & Architectural Violations The code changes appear to be well-structured and follow the architectural rules. However, there are a few potential issues: * The `filterDropdown` class is not using `aria-hidden` to hide the dropdown from screen readers when it is not visible. This could cause accessibility issues. * The `filterDropdown` class is using `position: absolute` which could cause layout issues if the dropdown is not properly positioned. * The `setStatusFilter` and `setConditionFilter` functions are not checking if the `status` or `condition` parameters are valid before updating the search parameters. This could cause errors if invalid values are passed. * The `loader` function is not handling errors properly. If an error occurs while loading the data, it will not be caught and handled. Looks solid otherwise!
💡 Suggestions & Best Practices * Consider adding `aria-hidden` to the `filterDropdown` class to hide it from screen readers when it is not visible. * Consider using a more robust positioning method for the `filterDropdown` class, such as using a library like `react-popper`. * Consider adding validation to the `setStatusFilter` and `setConditionFilter` functions to ensure that only valid values are passed. * Consider adding error handling to the `loader` function to catch and handle any errors that may occur. * Consider using a more efficient method for updating the search parameters, such as using a single `useSearchParams` hook instead of multiple `setSearchParams` calls. * Consider adding a `defer` attribute to the `select` elements to improve performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ECSoC26 Required label for ECSOC Sentinel scoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Filter Dropdown to Inventory

2 participants