Skip to content

Commit

Permalink
fix: null issue on product details (#668)
Browse files Browse the repository at this point in the history
* RM#82727
  • Loading branch information
vhu-axelor authored Aug 2, 2024
1 parent b5a6bf1 commit f7952a0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
5 changes: 5 additions & 0 deletions changelogs/unreleased/82727.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"title": "Product details: add activity indicator when product is null to avoid errors",
"type": "fix",
"packages": "stock"
}
4 changes: 2 additions & 2 deletions packages/apps/stock/src/hooks/use-stock-header-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ const useProductDetailsActions = () => {
model: 'com.axelor.apps.base.db.Product',
modelId: product?.id,
disableMailMessages: !mobileSettings?.isTrackerMessageEnabled,
attachedFileScreenTitle: product.name,
attachedFileScreenTitle: product?.name,
});
}, [mobileSettings, product]);
};
Expand All @@ -250,7 +250,7 @@ const useProductStockDetailsActions = () => {
model: 'com.axelor.apps.base.db.Product',
modelId: product?.id,
disableMailMessages: !mobileSettings?.isTrackerMessageEnabled,
attachedFileScreenTitle: product.name,
attachedFileScreenTitle: product?.name,
});
}, [mobileSettings, product]);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@

import React, {useCallback, useEffect, useState} from 'react';
import {StyleSheet, View, Dimensions} from 'react-native';
import {EditableInput, Picker, Screen, ScrollView} from '@axelor/aos-mobile-ui';
import {
useSelector,
EditableInput,
Picker,
Screen,
ScrollView,
useConfig,
} from '@axelor/aos-mobile-ui';
import {
useDispatch,
useTranslator,
usePermitted,
useSelector,
useTranslator,
} from '@axelor/aos-mobile-core';
import {
ProductCardStockIndicatorList,
Expand All @@ -47,6 +53,7 @@ const ProductStockDetailsScreen = ({route}) => {
const {readonly, hidden} = usePermitted({
modelName: 'com.axelor.apps.stock.db.StockLocationLine',
});
const {setActivityIndicator} = useConfig();

const {loadingProductFromId, productFromId: product} = useSelector(
state => state.product,
Expand Down Expand Up @@ -91,6 +98,11 @@ const ProductStockDetailsScreen = ({route}) => {
}
}, [companyId, dispatch, product, stockLocation]);

useEffect(() => {
const isActivityIndicator = loadingProductFromId && product?.id == null;
setActivityIndicator(isActivityIndicator);
}, [loadingProductFromId, product, setActivityIndicator]);

const handleLockerChange = input => {
if (stockLocation != null) {
dispatch(
Expand All @@ -104,6 +116,10 @@ const ProductStockDetailsScreen = ({route}) => {
}
};

if (product?.id !== productId) {
return null;
}

return (
<Screen>
<ScrollView
Expand Down

0 comments on commit f7952a0

Please sign in to comment.