Skip to content

Conversation

@SayakaOno
Copy link
Collaborator

@SayakaOno SayakaOno commented Oct 17, 2025

Description

This PR fixes the title bug and adds missing pieces for the new product form feature:

  • Fix inventory table minRows to 20 to prevent showing the "Load more" button
  • Hide product edit button for worker accounts
  • Remove soil amendment task product select placeholder
  • Display "No soil amendment products" modal when soil amendment task type is selected without products during task creation
    • Refactor PureTaskTypeSelection by combining states and simplifying logic
    • Add hasAvailableProductsSelector
  • Add a "Cancel" label to the new product form close button

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

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 17, 2025
@SayakaOno SayakaOno added bug Something isn't working enhancement New feature or request new translations New translations to be sent to CrowdIn are present labels Oct 17, 2025
@SayakaOno SayakaOno marked this pull request as ready for review October 21, 2025 15:13
@SayakaOno SayakaOno requested review from a team as code owners October 21, 2025 15:13
@SayakaOno SayakaOno requested review from Duncan-Brain and removed request for a team October 21, 2025 15:13
import { Product } from '../../store/api/types';
import { TASK_TYPES } from '../../containers/Task/constants';

const TABLE_MIN_ROWS = 20;
Copy link
Collaborator

Choose a reason for hiding this comment

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

In Animal inventory we set it to totalInventoryCount. Is there a reason we want to limit to 20?

Copy link
Collaborator Author

@SayakaOno SayakaOno Oct 22, 2025

Choose a reason for hiding this comment

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

I chose 20 arbitrarily, but I thought it was reasonable.
When there are no products, totalInventoryCount is 0. After creating a new product, the "Load more" button appears because the number of rows to display is determined at render time based on totalInventoryCount, and it never updates dynamically.
In the Animal Inventory, totalInventoryCount doesn’t increase, so the button won’t appear unexpectedly. But in the Product Inventory, it can change, so we need a fixed number of rows. Should we set it higher?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we can't update the inventory count dynamically to re-render. Then 20 is fine by me!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah sorry, totalInventoryCount changes, but minRows determines the rowsPerPage in <Table /> at render time, and rowsPerPage can't be updated externally after that!

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.

Had a couple of inline comments. Functionally I think its all ok.

};

const [showPlantTaskModal, setShowPlantTaskModal] = useState();
const [errorModal, setErrorModal] = useState('');
Copy link
Collaborator

Choose a reason for hiding this comment

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

❤️

@Duncan-Brain Duncan-Brain added this pull request to the merge queue Oct 22, 2025
Merged via the queue into integration with commit 895fb08 Oct 22, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working 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