Skip to content

Commit

Permalink
Unify the units (#665)
Browse files Browse the repository at this point in the history
Signed-off-by: Rehili Ghazwa <[email protected]>
  • Loading branch information
ghazwarhili authored Jan 15, 2025
1 parent 2214dcb commit 5d8fcaf
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 144 deletions.
10 changes: 4 additions & 6 deletions src/components/filter/expert/ExpertFilterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import './stylesExpertFilter.css';
import { useFormContext, useWatch } from 'react-hook-form';
import * as yup from 'yup';
import { v4 as uuid4 } from 'uuid';
import { useIntl } from 'react-intl';
import { Box } from '@mui/material';
import { testQuery } from './expertFilterUtils';
import {
Expand All @@ -31,6 +30,7 @@ import { FilterType } from '../constants/FilterConstants';
import { CustomReactQueryBuilder } from '../../inputs/reactQueryBuilder/CustomReactQueryBuilder';
import { unscrollableDialogStyles } from '../../dialogs';
import { FieldType } from '../../../utils/types/fieldType';
import { useFormatLabelWithUnit } from '../../../hooks/useFormatLabelWithUnit';

yup.setLocale({
mixed: {
Expand Down Expand Up @@ -97,8 +97,6 @@ export function getExpertFilterEmptyFormData() {
}

export function ExpertFilterForm() {
const intl = useIntl();

const { getValues, setValue } = useFormContext();

const openConfirmationPopup = useCallback(() => {
Expand All @@ -115,15 +113,15 @@ export function ExpertFilterForm() {
const watchEquipmentType = useWatch({
name: FieldConstants.EQUIPMENT_TYPE,
});

const formatLabelWithUnit = useFormatLabelWithUnit();
const translatedFields = useMemo(() => {
return EXPERT_FILTER_FIELDS[watchEquipmentType]?.map((field) => {
return {
...field,
label: intl.formatMessage({ id: field.label }),
label: formatLabelWithUnit(field),
};
});
}, [intl, watchEquipmentType]);
}, [formatLabelWithUnit, watchEquipmentType]);

return (
<>
Expand Down
Loading

0 comments on commit 5d8fcaf

Please sign in to comment.