Skip to content
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

LF-3951: Show water calculator with wild crops #3280

Merged
1 change: 1 addition & 0 deletions packages/webapp/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
"IRRIGATION_VIEW": {
"BRAND_TOOLTIP": "This task is for watering your location. If you want to install irrigation, create a field work task instead.",
"CALCULATE_WATER_USAGE": "Calculate Water Usage",
"CALCULATE_WATER_USAGE_WARNING": "For wild crops, estimation of water usage by depth is not available.",
"DEFAULT_APPLICATION_DEPTH": "Set as default application depth for this location",
"DEFAULT_LOCATION_FLOW_RATE": "Set as default flow rate for this location",
"DEPTH": "Depth",
Expand Down
1 change: 1 addition & 0 deletions packages/webapp/public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
"IRRIGATION_VIEW": {
"BRAND_TOOLTIP": "Esta tarea es para regar su ubicación. Si desea instalar riego, cree una tarea de trabajo de campo en su lugar.",
"CALCULATE_WATER_USAGE": "Calcular el consumo de agua",
"CALCULATE_WATER_USAGE_WARNING": "MISSING",
"DEFAULT_APPLICATION_DEPTH": "Establecer como profundidad de aplicación predeterminada para esta ubicación",
"DEFAULT_LOCATION_FLOW_RATE": "Establecer como índice de flujo predeterminado para esta ubicación",
"DEPTH": "Profundidad",
Expand Down
1 change: 1 addition & 0 deletions packages/webapp/public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
"IRRIGATION_VIEW": {
"BRAND_TOOLTIP": "Cette tâche est d'arroser votre emplacement. Pour configuer l'irrigation, créez plutôt une tâche de terrain.",
"CALCULATE_WATER_USAGE": "Calculer la consommation d'eau",
"CALCULATE_WATER_USAGE_WARNING": "MISSING",
"DEFAULT_APPLICATION_DEPTH": "Sélectionner cette profondeur d'application par défaut pour cet emplacement",
"DEFAULT_LOCATION_FLOW_RATE": "Sélectionner ce débit par défaut pour cet emplacement",
"DEPTH": "Profondeur",
Expand Down
1 change: 1 addition & 0 deletions packages/webapp/public/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
"IRRIGATION_VIEW": {
"BRAND_TOOLTIP": "Esta tarefa é para regar seu cultivo. Se você deseja instalar a irrigação, crie uma tarefa de trabalho de campo.",
"CALCULATE_WATER_USAGE": "Calcular uso de água",
"CALCULATE_WATER_USAGE_WARNING": "MISSING",
"DEFAULT_APPLICATION_DEPTH": "Definir como profundidade de aplicação padrão para esta área",
"DEFAULT_LOCATION_FLOW_RATE": "Definir como vazão padrão para esta área",
"DEPTH": "Profundidade",
Expand Down
53 changes: 41 additions & 12 deletions packages/webapp/src/components/Task/PureIrrigationTask/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { Controller } from 'react-hook-form';
import ReactSelect from '../../Form/ReactSelect';
import Checkbox from '../../Form/Checkbox';
import RadioGroup from '../../Form/RadioGroup';
import styles from '../../Typography/typography.module.scss';
import typographyStyles from '../../Typography/typography.module.scss';
import styles from './styles.module.scss';
import Input, { getInputErrors, numberOnKeyDown } from '../../Form/Input';
import Unit from '../../Form/Unit';
import { getUnitOptionMap } from '../../../util/convert-units/getUnitOptionMap';
Expand All @@ -16,6 +17,7 @@ import { getIrrigationTaskTypes } from '../../../containers/Task/IrrigationTaskT
import { useDispatch, useSelector } from 'react-redux';
import { irrigationTaskTypesSliceSelector } from '../../../containers/irrigationTaskTypesSlice';
import { cropLocationsSelector } from '../../../containers/locationSlice';
import { BsFillExclamationCircleFill } from 'react-icons/bs';

export default function PureIrrigationTask({
system,
Expand Down Expand Up @@ -199,6 +201,7 @@ export default function PureIrrigationTask({
!measurement_type ||
(measurement_type === 'DEPTH' && !location);

const calculatorLinkIsDisabled = measurement_type === 'DEPTH' && !location;
return (
<>
<Controller
Expand Down Expand Up @@ -251,7 +254,7 @@ export default function PureIrrigationTask({
/>
<div style={{ paddingBlock: '10px' }} />

<Label className={styles.label} style={{ marginBottom: '24px', fontSize: '16px' }}>
<Label className={typographyStyles.label} style={{ marginBottom: '24px', fontSize: '16px' }}>
{t('ADD_TASK.IRRIGATION_VIEW.HOW_DO_YOU_MEASURE_WATER_USE_FOR_THIS_IRRIGATION_TYPE')}
</Label>

Expand Down Expand Up @@ -303,16 +306,42 @@ export default function PureIrrigationTask({
onKeyDown={numberOnKeyDown}
onChangeUnitOption={() => setEstimatedWaterUsageComputed(true)}
/>
{!disabled && (
<>
<Label style={{ marginTop: '4px', marginBottom: `${disabled ? 36 : 0}px` }}>
{t('ADD_TASK.IRRIGATION_VIEW.NOT_SURE')}{' '}
<Underlined onClick={() => !disabled && setShowWaterUseCalculatorModal(true)}>
{t('ADD_TASK.IRRIGATION_VIEW.CALCULATE_WATER_USAGE')}
</Underlined>
</Label>
</>
)}
{!disabled &&
(!calculatorLinkIsDisabled ? (
<>
<Label style={{ marginTop: '4px', marginBottom: `${disabled ? 36 : 0}px` }}>
{t('ADD_TASK.IRRIGATION_VIEW.NOT_SURE')}{' '}
<Underlined onClick={() => !disabled && setShowWaterUseCalculatorModal(true)}>
{t('ADD_TASK.IRRIGATION_VIEW.CALCULATE_WATER_USAGE')}
</Underlined>
</Label>
</>
) : (
<>
<div className={styles.waterCalculatorWrapper}>
<Label
style={{
marginBottom: `${disabled ? 36 : 0}px`,
color: 'var(--Colors-Neutral-Neutral-300)',
}}
>
{t('ADD_TASK.IRRIGATION_VIEW.NOT_SURE')}{' '}
{t('ADD_TASK.IRRIGATION_VIEW.CALCULATE_WATER_USAGE')}
</Label>
<div className={styles.waterCalculatorWarningWrapper}>
<BsFillExclamationCircleFill />
<Label
style={{
marginBottom: `${disabled ? 36 : 0}px`,
color: 'var(--Colors-Accent---singles-Red-full)',
}}
>
{t('ADD_TASK.IRRIGATION_VIEW.CALCULATE_WATER_USAGE_WARNING')}
</Label>
</div>
</div>
</>
))}

{!waterCalculatorDisabled && (
<WaterUsageCalculatorModal
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2024 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 '../../../assets/mixin.scss';

.waterCalculatorWrapper {
display: flex;
gap: 10px;
margin-top: 4px;

@include md-breakpoint {
flex-direction: column;
}
}

.waterCalculatorWarningWrapper {
color: var(--Colors-Accent---singles-Red-full);
display: flex;
align-items: center;
gap: 5px;
}
Loading