INFRA-2867 | add optional chaining

This commit is contained in:
dhruvjoshi
2024-03-13 08:43:39 +05:30
parent d124986a46
commit 15aaaa2d88
3 changed files with 8 additions and 7 deletions

View File

@@ -73,7 +73,6 @@ const CreateIncidentForm: React.FC<CreateIncidentFormProps> = ({
};
const handleTeamChange = (val: SelectPickerOptionProps[]): void => {
dispatch({ type: actionTypes.SET_SELECTED_TEAM, payload: val });
if (val?.length === 0) return;
};
const handleAssignerChange = (val: SelectPickerValue): void => {
dispatch({ type: actionTypes.SET_SELECTED_ASSIGNER, payload: val });

View File

@@ -421,6 +421,7 @@ const AllDailogBox: FC = () => {
UpdateData.type === 'severity' &&
showJustificationBox &&
state.reason.length <= 5;
const isProductAndDisabled = UpdateData.type === 'product' && !state.team;
return (
<div className={styles['modal-footer']}>
{isSeverityAndDisabled ? (
@@ -430,7 +431,7 @@ const AllDailogBox: FC = () => {
) : (
<Button
onClick={handleUpdateIncidentClick}
disabled={UpdateData.type === 'product' && !state.team}
disabled={isProductAndDisabled}
>
Update incident
</Button>

View File

@@ -108,12 +108,13 @@ export const getUpdateValueText = ({
} `;
case ProductType:
return ` ${
initialValues.initialProducts?.length
? initialValues.initialProducts
.map(
(product: { value: number }) => maps.productMap[product.value],
initialValues?.initialProducts?.length
? initialValues?.initialProducts
?.map(
(product: { value: number }) =>
maps?.productMap?.[product?.value],
)
.join(', ')
?.join(', ')
: '-'
} `;
default: