Skip to content

Commit

Permalink
ISSUE #5173 - code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Amantini1997 committed Sep 27, 2024
1 parent 5d5eb17 commit 6ca5024
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ import { FormattedMessage } from 'react-intl';
import { useFormContext } from 'react-hook-form';
import { MenuItem } from '@mui/material';
import { FormNumberField, FormSelect, FormTextField } from '@controls/inputs/formInputs.component';
import { get } from 'lodash';
import { get, isNumber } from 'lodash';
import { Heading, Title, FlexContainer } from './sidebarForm.styles';
import { useContext, useEffect } from 'react';
import { UploadFilesContext } from '@components/shared/uploadFiles/uploadFilesContext';
import { DrawingsHooksSelectors } from '@/v5/services/selectorsHooks';
import { MODEL_UNITS } from '../../../models.helpers';
import { DoubleInputLineContainer } from '../../drawingDialogs/drawingForm.styles';
import { Loader } from '@/v4/routes/components/loader/loader.component';

export const SidebarForm = () => {
const types = DrawingsHooksSelectors.selectTypes();
Expand All @@ -46,6 +47,8 @@ export const SidebarForm = () => {
}
}, [verticalRange?.[0], verticalRange?.[1]]);

if (drawingId && !isNumber(getValues(`${revisionPrefix}.calibration.verticalRange.0`))) return <Loader />;

return (
<>
<Title>{drawingName}</Title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@ export const UploadDrawingRevisionForm = ({
drawingNumber: drawing?.number || '',
drawingDesc: drawing?.desc || '',
drawingType: drawing?.type || '',
calibration: {
verticalRange: drawing?.calibration?.verticalRange || [0, 1],
units: drawing?.calibration?.units || 'mm',
},
});
}
append(filesToAppend);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ import { UploadListItemTitle } from '@components/shared/uploadFiles/uploadList/u
import { UploadProgress } from '@components/shared/uploadFiles/uploadList/uploadListItem/uploadProgress/uploadProgress.component';
import { formatMessage } from '@/v5/services/intl';
import { IDrawing } from '@/v5/store/drawings/drawings.types';
import { DrawingRevisionsActionsDispatchers } from '@/v5/services/actionsDispatchers';
import { DrawingRevisionsActionsDispatchers, DrawingsActionsDispatchers } from '@/v5/services/actionsDispatchers';
import { UploadListItemStatusCode } from './components/uploadListItemStatusCode/uploadListItemStatusCode.component';
import { UploadStatus } from '@/v5/store/containers/containers.types';
import { DEFAULT_SETTINGS_CALIBRATION } from '../../../../calibration/calibration.helpers';

const UNEXPETED_STATUS_ERROR = undefined;
const STATUS_TEXT_BY_UPLOAD = {
Expand Down Expand Up @@ -91,9 +92,7 @@ export const UploadListItem = ({
drawingNumber: drawing?.number || '',
drawingDesc: drawing?.desc || '',
drawingType: drawing?.type || '',
// drawingBottomExtent: drawing?.bottomExtent ?? 0,
// drawingTopExtent: drawing?.topExtent ?? 0,
// drawingUnits: drawing?.units || '',
calibration: drawing?.calibration || DEFAULT_SETTINGS_CALIBRATION,
});

useEffect(() => {
Expand All @@ -109,13 +108,15 @@ export const UploadListItem = ({
}, [drawingId, revCode, selectedDrawingRevisions.length]);

useEffect(() => {
for (const [key, val] of Object.entries(sanitiseDrawing(selectedDrawing))) {
setValue(`${revisionPrefix}.${key}`, val);
}
setValue(revisionPrefix, sanitiseDrawing(selectedDrawing));
}, [JSON.stringify(selectedDrawing)]);

useEffect(() => {
if (selectedDrawing?._id) {
DrawingRevisionsActionsDispatchers.fetch(teamspace, projectId, selectedDrawing._id);
DrawingsActionsDispatchers.fetchDrawingSettings(teamspace, projectId, selectedDrawing._id);
}
}, [JSON.stringify(selectedDrawing)]);
}, [selectedDrawing?._id]);

return (
<UploadListItemRow selected={isSelected}>
Expand Down

0 comments on commit 6ca5024

Please sign in to comment.