File tree Expand file tree Collapse file tree 2 files changed +13
-20
lines changed Expand file tree Collapse file tree 2 files changed +13
-20
lines changed Original file line number Diff line number Diff line change @@ -12,37 +12,30 @@ interface OrderPriceDetailsComponentProps {
12
12
13
13
const OrderPriceDetailsComponent : React . FC < OrderPriceDetailsComponentProps > = ( { orderItemUuid } ) => {
14
14
const { t } = useTranslation ( ) ;
15
+
15
16
const { item } = useOrderItemDetails ( orderItemUuid ) ;
17
+
16
18
const [ results , setResults ] = useState < StockItemDTO [ ] > ( [ ] ) ;
17
- const [ isLoading , setIsLoading ] = useState ( false ) ;
18
19
19
20
useEffect ( ( ) => {
20
- const fetchResults = async ( ) => {
21
- if ( item ?. uuid ) {
22
- setIsLoading ( true ) ;
23
- try {
24
- const response = await fetchStockItem ( item . uuid ) ;
25
- setResults ( response ) ;
26
- } catch ( error ) {
27
- setIsLoading ( false ) ;
28
- } finally {
29
- setIsLoading ( false ) ;
21
+ if ( item && item . uuid ) {
22
+ fetchStockItem ( item . uuid ) . then ( ( response ) => {
23
+ if ( response ?. results ) {
24
+ setResults ( response . results ) ;
30
25
}
31
- }
32
- } ;
33
-
34
- fetchResults ( ) ;
35
- } , [ item ?. uuid ] ) ;
26
+ } ) ;
27
+ }
28
+ } , [ item ] ) ;
36
29
37
30
const purchasePrice = results [ 0 ] ?. purchasePrice ;
38
31
39
32
return (
40
33
< div className = { styles . priceDetailsContainer } >
41
34
< span className = { styles . priceLabel } > { t ( 'price' , 'Price' ) } :</ span >
42
- { isLoading ? (
43
- < SkeletonText width = "100px" role = "progressbar" / >
35
+ { purchasePrice !== undefined ? (
36
+ < span > { purchasePrice } </ span >
44
37
) : (
45
- < span > { purchasePrice ? purchasePrice : t ( 'noPrice ' , 'N/A ' ) } </ span >
38
+ < span > { t ( 'noPriceAvailable ' , 'Price not available ' ) } </ span >
46
39
) }
47
40
< Tooltip
48
41
align = "bottom-left"
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ export function useStockItems(filter: StockItemFilter) {
84
84
85
85
// fetch filtered stock item
86
86
export function fetchStockItem ( drugUuid : string ) {
87
- const apiUrl = `${ restBaseUrl } /stockmanagement/stockitem?drugUuid=${ drugUuid } &limit=1 ` ;
87
+ const apiUrl = `${ restBaseUrl } /stockmanagement/stockitem?drugUuid=${ drugUuid } &v=full ` ;
88
88
return openmrsFetch ( apiUrl ) . then ( ( { data } ) => data ) ;
89
89
}
90
90
You can’t perform that action at this time.
0 commit comments