Skip to content

Conversation

@SayakaOno
Copy link
Collaborator

@SayakaOno SayakaOno commented Oct 10, 2025

Description

  • Add isLibraryProduct function and productInventorySelector
  • Inventory
    • Select products using the new productInventorySelector
  • New product form
    • Select soil amendment products (library + custom, including removed ones)
    • New product name validation: check against custom farm products in inventory
    • Library product options (LF-4963): library products outside inventory
  • Task
    • Creation (TaskDetails)
      • Retain the old selector (farm products in inventory + removed ones) and filter out removed ones
    • Read-only (TaskReadOnly) and (re-)completion (StepOne)
      • Retain the old selector (farm products in inventory + removed ones)
      • Soil amendment tasks: select options = farm products in inventory + used product with "(Removed)" label
      • Cleaning and pest control tasks: removed products are not currently handled (since they can’t be removed)
  • Update productsForTaskTypeSelectorfrom a selector factory to a global selector (as discussed in the tech daily on Oct 20, 2025)
  • Bugfix
    • Fix soil amendment task read-only view not showing selected product (values are now set in useEffect)

Note:
I initially created a selector factory for products so that the inventory table and product form could maintain separate caches. After the tech daily discussion, I created productInventorySelector for the inventory table and reused the existing selector in the product form. I like this approach much better. Thank you for your input! @Duncan-Brain @kathyavini

Jira link: https://lite-farm.atlassian.net/browse/LF-4980

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Passes test case
  • UI components visually reviewed on desktop view
  • UI components visually reviewed on mobile view
  • Other (please explain)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The precommit and linting ran successfully
  • I have added or updated language tags for text that's part of the UI
  • I have ordered translation keys alphabetically (optional: run pnpm i18n to help with this)
  • I have added the GNU General Public License to all new files

@SayakaOno SayakaOno self-assigned this Oct 10, 2025
@SayakaOno SayakaOno added the enhancement New feature or request label Oct 10, 2025
@SayakaOno SayakaOno force-pushed the LF-4980/Show_valid_soil_amendment_products branch from eb88d82 to 8568d8f Compare October 15, 2025 19:41
@SayakaOno SayakaOno force-pushed the LF-4980/Show_valid_soil_amendment_products branch from b2c4d07 to b46644c Compare October 16, 2025 17:56
@SayakaOno SayakaOno added the new translations New translations to be sent to CrowdIn are present label Oct 17, 2025
@SayakaOno SayakaOno changed the title [WIP] LF-4980: Show valid soil amendment products LF-4980: Show valid soil amendment products Oct 17, 2025
@SayakaOno SayakaOno force-pushed the LF-4980/Show_valid_soil_amendment_products branch from ef7a84e to e4c8c34 Compare October 20, 2025 17:42
@SayakaOno SayakaOno force-pushed the LF-4980/Show_valid_soil_amendment_products branch from e4c8c34 to d63722f Compare October 20, 2025 17:45
@SayakaOno SayakaOno marked this pull request as ready for review October 20, 2025 18:28
@SayakaOno SayakaOno requested review from a team as code owners October 20, 2025 18:28
@SayakaOno SayakaOno requested review from Duncan-Brain and removed request for a team October 20, 2025 18:28
Copy link
Collaborator

@Duncan-Brain Duncan-Brain left a comment

Choose a reason for hiding this comment

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

Hey Sayaka, everything is looking really good!

I think there is just one small bug about the initialProductId. The removed product is no longer available in the options when going forward and back, and when changing mind and clicking 'No changes made` the data does not reset (does not affect db). Here is a video:

Screen.Recording.2025-10-22.at.9.53.35.AM.mov

Other not important things:
Currently unused libraryProductsOutsideInventory wondering where it is going to be used.

Selectors - Maybe I have selector vision after our chat the other day but I was wondering if many of the functions that distill products should be selectors also or just put in the util file for reuse?

Happy to approve if any of these should be addressed elsewhere

}, [mode]);

const productNames: SoilAmendmentProduct['name'][] = products.map(({ name }) => name);
const { customProductsInInventory } = useMemo(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

libraryProductsOutsideInventory is it defined somewhere? I imagine that a user could duplicate a library product multiple times to tweak values. Is this in preparation for showing a library without the already duplicated library products?

Also is there a chance this will be reused and should this be a createSelector?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think users would be able to duplicate a library product directly. They would first add it to the inventory, then duplicate it.

I expect libraryProductsOutsideInventory to be used as the options to add to the inventory:

Screenshot 2025-10-22 at 11 59 20 AM

I can’t think of a use case where we’d want to reuse it right now... can you?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe I am wrong but I think what I expect is that we always show allLibraryProducts instead of removing already added libraryProductsOutsideInventory.

How I understood library products was that the user can checkout their own copy and make edits to it as they choose? Adding a library product multiple times makes sense if the user is allowed to edit the values of the local copy. Maybe I misunderstood how library products work. At least currently, a library product is editable and so if I wanted the original unedited values I could not find it in libraryProductsOutsideInventory if it is removed.

Reuse: Maybe I was wishful thinking but I thought that this function looked generic enough for pest control and cleaning products too. Hopefully we don't have multiple product architecture for a long time!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At least currently, a library product is editable

We haven’t handled library products yet, but eventually we’ll need to prevent them from being modified!

I removed libraryProductsOutsideInventory for now since it's hard to envision without the actual UI/UX. I could have created a function to generate customProductNames, but I'm leaving that for later too!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh we might need to align on that! I thought for sure the library products ARE modifiable .. as a copy of the core library product. Anyways thanks for removing for now as we discuss!

const productId = getValues(PRODUCT_ID);
const purposes = watch(PURPOSES);

const initialProductId = useRef(productId);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I show it in the video but this changes on render.

Copy link
Collaborator Author

@SayakaOno SayakaOno left a comment

Choose a reason for hiding this comment

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

Thank you so much @Duncan-Brain for reviewing!

The removed product is no longer available in the options when going forward and back

True...😭 I'll try to come back with a better solution.

when changing mind and clicking 'No changes made` the data does not reset

I think this happens for all task types; I'll check with Denis if there's a ticket!

I believe I've covered all your comments, but please let me know if I missed anything!

}, [mode]);

const productNames: SoilAmendmentProduct['name'][] = products.map(({ name }) => name);
const { customProductsInInventory } = useMemo(() => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think users would be able to duplicate a library product directly. They would first add it to the inventory, then duplicate it.

I expect libraryProductsOutsideInventory to be used as the options to add to the inventory:

Screenshot 2025-10-22 at 11 59 20 AM

I can’t think of a use case where we’d want to reuse it right now... can you?

@SayakaOno
Copy link
Collaborator Author

The removed product is no longer available in the options when going forward and back

I resolved this by filtering unused products in an upper component. (abc5e21)
Previously, unselected products were only visible in the card that originally had the product (which caused the bug). With the current approach, unselected products appear in any card, so if you unselect the removed product in the first card, it will now appear in the second card or afterwards. I think this behaviour is acceptable.

Other changes:

Thank you for re-reviewing! 🙏

@Duncan-Brain
Copy link
Collaborator

I think this behaviour is acceptable.

Are there downsides? it seems preferred approach to me! Looking great and thanks for removing that small library piece as we discuss.

@Duncan-Brain Duncan-Brain added this pull request to the merge queue Oct 24, 2025
Merged via the queue into integration with commit a19e002 Oct 24, 2025
4 of 5 checks passed
@SayakaOno SayakaOno deleted the LF-4980/Show_valid_soil_amendment_products branch October 24, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request new translations New translations to be sent to CrowdIn are present

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants