Improve optional chaining checks (#8431)

- Fixes bug where part_detail is potentially undefined
This commit is contained in:
Oliver
2024-11-06 06:04:13 +11:00
committed by GitHub
parent 7b640a4f88
commit f470d30493
2 changed files with 14 additions and 13 deletions
@@ -348,7 +348,8 @@ function LineItemFormRow({
if (
!record.destination &&
!record.destination_detail &&
location === record.part_detail.category_default_location
record.part_detail &&
location === record.part_detail?.category_default_location
) {
return t`Part category default location selected`;
}
@@ -511,8 +512,8 @@ function LineItemFormRow({
}
/>
<Flex style={{ marginBottom: '7px' }}>
{(record.part_detail.default_location ||
record.part_detail.category_default_location) && (
{(record.part_detail?.default_location ||
record.part_detail?.category_default_location) && (
<ActionButton
icon={<InvenTreeIcon icon="default_location" />}
tooltip={t`Store at default location`}
@@ -520,8 +521,8 @@ function LineItemFormRow({
props.changeFn(
props.idx,
'location',
record.part_detail.default_location ??
record.part_detail.category_default_location
record.part_detail?.default_location ??
record.part_detail?.category_default_location
)
}
tooltipAlignment="top"