-
Notifications
You must be signed in to change notification settings - Fork 93
LF-4987: New product not visible until load more clicked #3903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
4142fa0
494bb79
16ad669
c60ed40
753ce3d
f00617a
3027094
f4928a6
b001f02
3fc941d
6c0f45f
640b924
4a4921e
29dbc47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * Copyright 2025 LiteFarm.org | ||
| * This file is part of LiteFarm. | ||
| * | ||
| * LiteFarm is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * LiteFarm is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details, see <<https://www.gnu.org/licenses/>.> | ||
| */ | ||
|
|
||
| import { useTranslation } from 'react-i18next'; | ||
| import ModalComponent from '../ModalComponent/v2'; | ||
| import Button from '../../Form/Button'; | ||
|
|
||
| interface NoSoilAmendmentProductsModalProps { | ||
| dismissModal: () => void; | ||
| goToInventory: () => void; | ||
| } | ||
|
|
||
| export function NoSoilAmendmentProductsModal({ | ||
| dismissModal, | ||
| goToInventory, | ||
| }: NoSoilAmendmentProductsModalProps) { | ||
| const { t } = useTranslation(); | ||
|
|
||
| return ( | ||
| <ModalComponent | ||
| title={t('ADD_TASK.NO_SOIL_AMENDMENT_PRODUCTS')} | ||
| contents={[t('ADD_TASK.NEED_SOIL_AMENDMENT_PRODUCTS')]} | ||
| dismissModal={dismissModal} | ||
| buttonGroup={ | ||
| <> | ||
| <Button | ||
| data-cy="tasks-noSoilAmendmentProductsCancel" | ||
| onClick={dismissModal} | ||
| color={'secondary'} | ||
| type={'button'} | ||
| sm | ||
| > | ||
| {t('common:GO_BACK')} | ||
| </Button> | ||
| <Button | ||
| data-cy="tasks-noSoilAmendmentProductsContinue" | ||
| onClick={goToInventory} | ||
| type={'submit'} | ||
| sm | ||
| > | ||
| {t('ADD_TASK.GO_TO_INVENTORY')} | ||
| </Button> | ||
| </> | ||
| } | ||
| ></ModalComponent> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,8 @@ import { TableProduct } from '../../containers/ProductInventory'; | |
| import { Product } from '../../store/api/types'; | ||
| import { TASK_TYPES } from '../../containers/Task/constants'; | ||
|
|
||
| const TABLE_MIN_ROWS = 20; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Animal inventory we set it to
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I chose 20 arbitrarily, but I thought it was reasonable.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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!
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah sorry, |
||
|
|
||
| export type PureProductInventory = { | ||
| filteredInventory: TableProduct[]; | ||
| zIndexBase: number; | ||
|
|
@@ -118,7 +120,7 @@ const PureProductInventory = ({ | |
| columns={productColumns} | ||
| data={filteredInventory} | ||
| shouldFixTableLayout={isDesktop} | ||
| minRows={totalInventoryCount} | ||
| minRows={TABLE_MIN_ROWS} | ||
| dense={true} | ||
| showHeader={isDesktop} | ||
| selectedIds={selectedIds} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,8 @@ import { ANIMAL_TASKS } from '../../../containers/Task/constants'; | |
| import { CantFindCustomType } from '../../Finances/PureFinanceTypeSelection/CantFindCustomType'; | ||
| import { NoAnimalLocationsModal } from '../../Modals/NoAnimalLocationsModal'; | ||
| import { NoSoilSampleLocationsModal } from '../../Modals/NoSoilSampleLocationsModal'; | ||
| import { NoSoilAmendmentProductsModal } from '../../Modals/NoSoilAmendmentProductsModal'; | ||
| import { PRODUCT_INVENTORY_URL } from '../../../util/siteMapConstants'; | ||
|
|
||
| const icons = { | ||
| SOIL_AMENDMENT_TASK: <SoilAmendment />, | ||
|
|
@@ -72,6 +74,7 @@ export const PureTaskTypeSelection = ({ | |
| hasAnimalMovementLocations, | ||
| hasAnimals, | ||
| hasSoilSampleLocations, | ||
| hasSoilAmendmentProducts, | ||
| }) => { | ||
| const { t } = useTranslation(); | ||
| const { watch, getValues, register, setValue } = useForm({ | ||
|
|
@@ -92,39 +95,32 @@ export const PureTaskTypeSelection = ({ | |
| onContinue(); | ||
| }; | ||
|
|
||
| const [showPlantTaskModal, setShowPlantTaskModal] = useState(); | ||
| const [errorModal, setErrorModal] = useState(''); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ |
||
|
|
||
| const goToCatalogue = () => history.push('/crop_catalogue'); | ||
| const goToMap = () => history.push('/map'); | ||
| const goToInventory = () => history.push(PRODUCT_INVENTORY_URL); | ||
| const onPlantTaskTypeClick = () => { | ||
| if (shouldShowPlantTaskSpotLight) { | ||
| setShowPlantTaskModal(true); | ||
| setErrorModal('PLANT_TASK'); | ||
| } else { | ||
| goToCatalogue(); | ||
| } | ||
| }; | ||
| const [showNoManagementPlanModal, setShowNoManagementPlanModal] = useState(); | ||
| const onHarvestTransplantTaskClick = (task_type_id) => { | ||
| hasCurrentManagementPlans ? onSelectTask(task_type_id) : setShowNoManagementPlanModal(true); | ||
| }; | ||
|
|
||
| const [showNoAnimalLocationsModal, setShowNoAnimalLocationsModal] = useState(); | ||
| const onMovementTaskClick = (task_type_id) => { | ||
| hasAnimalMovementLocations ? onSelectTask(task_type_id) : setShowNoAnimalLocationsModal(true); | ||
| }; | ||
|
|
||
| const [showNoSoilSampleLocationsModal, setShowNoSoilSampleLocationsModal] = useState(); | ||
| const onSoilSampleTaskClick = (task_type_id) => { | ||
| hasSoilSampleLocations ? onSelectTask(task_type_id) : setShowNoSoilSampleLocationsModal(true); | ||
| }; | ||
|
|
||
| const onTileClick = (taskType) => { | ||
| if (isTaskType(taskType, 'PLANT_TASK')) return onPlantTaskTypeClick(taskType.task_type_id); | ||
| if (isTaskType(taskType, 'TRANSPLANT_TASK') || isTaskType(taskType, 'HARVEST_TASK')) { | ||
| return onHarvestTransplantTaskClick(taskType.task_type_id); | ||
| if (isTaskType(taskType, 'PLANT_TASK')) { | ||
| return onPlantTaskTypeClick(taskType.task_type_id); | ||
| } | ||
| if ( | ||
| ((isTaskType(taskType, 'TRANSPLANT_TASK') || isTaskType(taskType, 'HARVEST_TASK')) && | ||
| !hasCurrentManagementPlans) || | ||
| (isTaskType(taskType, 'MOVEMENT_TASK') && !hasAnimalMovementLocations) || | ||
| (isTaskType(taskType, 'SOIL_SAMPLE_TASK') && !hasSoilSampleLocations) || | ||
| (isTaskType(taskType, 'SOIL_AMENDMENT_TASK') && !hasSoilAmendmentProducts) | ||
| ) { | ||
| return setErrorModal(taskType.task_translation_key); | ||
| } | ||
| if (isTaskType(taskType, 'MOVEMENT_TASK')) return onMovementTaskClick(taskType.task_type_id); | ||
| if (isTaskType(taskType, 'SOIL_SAMPLE_TASK')) | ||
| return onSoilSampleTaskClick(taskType.task_type_id); | ||
| return onSelectTask(taskType.task_type_id); | ||
| }; | ||
|
|
||
|
|
@@ -225,32 +221,35 @@ export const PureTaskTypeSelection = ({ | |
| </div> | ||
| )} | ||
| </Form> | ||
| {showPlantTaskModal && shouldShowPlantTaskSpotLight && ( | ||
| {errorModal === 'PLANT_TASK' && shouldShowPlantTaskSpotLight && ( | ||
| <PlantingTaskModal | ||
| goToCatalogue={goToCatalogue} | ||
| dismissModal={() => setShowPlantTaskModal(false)} | ||
| dismissModal={() => setErrorModal('')} | ||
| updatePlantTaskSpotlight={updatePlantTaskSpotlight} | ||
| /> | ||
| )} | ||
| {showNoManagementPlanModal && ( | ||
| {['TRANSPLANT_TASK', 'HARVEST_TASK'].includes(errorModal) && ( | ||
| <NoCropManagementPlanModal | ||
| dismissModal={() => setShowNoManagementPlanModal(false)} | ||
| dismissModal={() => setErrorModal('')} | ||
| goToCatalogue={goToCatalogue} | ||
| /> | ||
| )} | ||
| {showNoAnimalLocationsModal && ( | ||
| <NoAnimalLocationsModal | ||
| dismissModal={() => setShowNoAnimalLocationsModal(false)} | ||
| goToMap={goToMap} | ||
| /> | ||
| {errorModal === 'MOVEMENT_TASK' && ( | ||
| <NoAnimalLocationsModal dismissModal={() => setErrorModal('')} goToMap={goToMap} /> | ||
| )} | ||
| {showNoSoilSampleLocationsModal && ( | ||
| {errorModal === 'SOIL_SAMPLE_TASK' && ( | ||
| <NoSoilSampleLocationsModal | ||
| dismissModal={() => setShowNoSoilSampleLocationsModal(false)} | ||
| dismissModal={() => setErrorModal('')} | ||
| goToMap={goToMap} | ||
| isAdmin={isAdmin} | ||
| /> | ||
| )} | ||
| {errorModal === 'SOIL_AMENDMENT_TASK' && ( | ||
| <NoSoilAmendmentProductsModal | ||
| dismissModal={() => setErrorModal('')} | ||
| goToInventory={goToInventory} | ||
| /> | ||
| )} | ||
| </> | ||
| ); | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.