Skip to content

Commit

Permalink
fix: setting com request value using steps enum names as props
Browse files Browse the repository at this point in the history
  • Loading branch information
prwozny committed Sep 20, 2024
1 parent db3ef80 commit 1b4d1a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { useEffect, useState } from 'react';
import D from '../../../i18n/build-dictionary';

interface CommunicationDialogContentProps {
step: string;
options: {
label: string;
value: string;
Expand All @@ -28,7 +27,6 @@ interface CommunicationDialogContentProps {
}

const CommunicationDialogContent = ({
step,
options,
setCommunicationValue,
title,
Expand All @@ -45,7 +43,7 @@ const CommunicationDialogContent = ({
);

useEffect(() => {
setCommunicationValue(value, step);
setCommunicationValue(value);
}, [value]);

return (
Expand Down
7 changes: 2 additions & 5 deletions src/ui/SurveyUnit/CommunicationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import CommunicationDialogContent from './Communication/CommunicationDialogContent';
import CommunicationConfirmation from './Communication/CommunicationConfirmation';
import { mediumRadioValues, reasonRadioValues, typeRadioValues } from '../../utils/constants';
import { validateDate } from '@mui/x-date-pickers/internals';

enum Steps {
MEDIUM,
Expand Down Expand Up @@ -112,7 +111,8 @@ export function CommunicationForm({ onClose, surveyUnit }: CommunicationFormProp
onClose();
};

const setValue = (value: string, prop: string) => {
const setValue = (value: string) => {
const prop = Steps[step].toLocaleLowerCase();
setCommunicationRequest({
...communicationRequest,
[prop]: value,
Expand Down Expand Up @@ -149,7 +149,6 @@ export function CommunicationForm({ onClose, surveyUnit }: CommunicationFormProp
{step == Steps.MEDIUM && (
<CommunicationDialogContent
title={D.selectCommunciationRequestMedium}
step={'medium'}
options={mediums}
setCommunicationValue={setValue}
lastPickedPropValue={communicationRequest.medium}
Expand All @@ -162,7 +161,6 @@ export function CommunicationForm({ onClose, surveyUnit }: CommunicationFormProp
{step == Steps.TYPE && (
<CommunicationDialogContent
title={D.selectCommunciationRequestType}
step={'type'}
options={types}
setCommunicationValue={setValue}
lastPickedPropValue={communicationRequest.type}
Expand All @@ -175,7 +173,6 @@ export function CommunicationForm({ onClose, surveyUnit }: CommunicationFormProp
{step == Steps.REASON && (
<CommunicationDialogContent
title={D.selectCommunciationRequestReason}
step={'reason'}
options={reasons}
setCommunicationValue={setValue}
lastPickedPropValue={communicationRequest.reason}
Expand Down

0 comments on commit 1b4d1a3

Please sign in to comment.