Skip to content

Commit

Permalink
Fix typescript errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnuravi committed Jan 20, 2025
1 parent c35d015 commit ef70d7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/AnchorMenu/AnchorMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import './AnchorMenu.css';
import { DndProvider, useDrag } from 'react-dnd';
import { DndProvider, useDrag, DndProviderProps } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';

import React from 'react';
Expand Down Expand Up @@ -172,7 +172,7 @@ const AnchorMenu = (props: AnchorMenuProps): JSX.Element => {

const orderTreeData = mapToTreeData(props.qOrder, '');
return (
<DndProvider backend={HTML5Backend}>
<DndProvider backend={HTML5Backend} {...({} as any)}>
<div className="questionnaire-overview">
<div className="questionnaire-overview__toolbox">
{createTypeComponent(IQuestionnaireItemType.display, t('Instruction'))}
Expand Down
16 changes: 11 additions & 5 deletions src/components/PredefinedValueSetModal/PredefinedValueSetModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,18 @@ const PredefinedValueSetModal = (props: Props): JSX.Element => {

const removeElement = (id?: string) => {
const compose = { ...newValueSet.compose };
const conceptToDelete = compose.include[0].concept?.findIndex((x) => x && x.id === id);

const conceptToDelete = compose.include?.[0].concept?.findIndex((x) => x && x.id === id);
if (conceptToDelete || conceptToDelete === 0) {
compose.include[0].concept?.splice(conceptToDelete, 1);
compose.include?.[0].concept?.splice(conceptToDelete, 1);
}

setNewValueSet({ ...newValueSet });
};

const handleConceptItem = (value: string, updateField: 'code' | 'display', id?: string) => {
const compose = { ...newValueSet.compose };
const item = compose.include[0]?.concept?.find((x) => x && x.id === id);
const item = compose.include?.[0]?.concept?.find((x) => x && x.id === id);

if (item) {
item[updateField] = value;
Expand Down Expand Up @@ -139,16 +140,21 @@ const PredefinedValueSetModal = (props: Props): JSX.Element => {
const toIndex = result.destination.index;

const compose = { ...newValueSet.compose };
const itemToMove = compose.include[0].concept?.splice(fromIndex, 1);
const itemToMove = compose.include?.[0].concept?.splice(fromIndex, 1);

if (fromIndex !== toIndex && itemToMove) {
compose.include[0].concept?.splice(toIndex, 0, itemToMove[0]);
compose.include?.[0].concept?.splice(toIndex, 0, itemToMove[0]);
setNewValueSet({ ...newValueSet });
}
};

const handleSystem = (value: string) => {
const compose = { ...newValueSet.compose };

if(!compose.include) {
return;
}

compose.include[0].system = value;
setNewValueSet({ ...newValueSet });
};
Expand Down

0 comments on commit ef70d7b

Please sign in to comment.