Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve optional chaining checks #8431

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/frontend/src/forms/PurchaseOrderForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
}
Expand Down Expand Up @@ -511,17 +512,17 @@ 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`}
onClick={() =>
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"
Expand Down
16 changes: 8 additions & 8 deletions src/frontend/src/forms/StockForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,14 @@ function StockItemDefaultMove({
const { data } = useSuspenseQuery({
queryKey: [
'location',
stockItem.part_detail.default_location ??
stockItem.part_detail.category_default_location
stockItem.part_detail?.default_location ??
stockItem.part_detail?.category_default_location
],
queryFn: async () => {
const url = apiUrl(
ApiEndpoints.stock_location_list,
stockItem.part_detail.default_location ??
stockItem.part_detail.category_default_location
stockItem.part_detail?.default_location ??
stockItem.part_detail?.category_default_location
);

return api
Expand Down Expand Up @@ -384,8 +384,8 @@ function moveToDefault(
children: <StockItemDefaultMove stockItem={stockItem} value={value} />,
onConfirm: () => {
if (
stockItem.location === stockItem.part_detail.default_location ||
stockItem.location === stockItem.part_detail.category_default_location
stockItem.location === stockItem.part_detail?.default_location ||
stockItem.location === stockItem.part_detail?.category_default_location
) {
return;
}
Expand All @@ -400,8 +400,8 @@ function moveToDefault(
}
],
location:
stockItem.part_detail.default_location ??
stockItem.part_detail.category_default_location
stockItem.part_detail?.default_location ??
stockItem.part_detail?.category_default_location
})
.then((response) => {
refresh();
Expand Down
Loading