1
1
import React from 'react' ;
2
2
import {
3
- Switch ,
4
3
Grid ,
5
4
Autocomplete ,
6
- InputWithLabelRow ,
7
5
useTranslation ,
8
6
useConfirmationModal ,
7
+ DetailPanelSection ,
8
+ PanelRow ,
9
+ PanelLabel ,
10
+ PanelField ,
9
11
} from '@openmsupply-client/common' ;
10
- import { useRequest , useHideOverStocked } from '../../api' ;
12
+ import { useRequest } from '../api' ;
13
+ import { getApprovalStatusKey } from '../../utils' ;
11
14
12
15
const months = [ 1 , 2 , 3 , 4 , 5 , 6 ] ;
13
16
14
- export const ToolbarActions = ( ) => {
15
- const { on, toggle } = useHideOverStocked ( ) ;
17
+ export const OrderInfoSection = ( ) => {
16
18
const t = useTranslation ( 'replenishment' ) ;
17
19
const isDisabled = useRequest . utils . isDisabled ( ) ;
18
20
const isProgram = useRequest . utils . isProgram ( ) ;
19
- const { minMonthsOfStock, maxMonthsOfStock, update } =
20
- useRequest . document . fields ( [ 'minMonthsOfStock' , 'maxMonthsOfStock' ] ) ;
21
+ const { minMonthsOfStock, maxMonthsOfStock, linkedRequisition, update } =
22
+ useRequest . document . fields ( [
23
+ 'minMonthsOfStock' ,
24
+ 'maxMonthsOfStock' ,
25
+ 'programName' ,
26
+ 'linkedRequisition' ,
27
+ ] ) ;
28
+ const { usesRemoteAuthorisation } = useRequest . utils . isRemoteAuthorisation ( ) ;
21
29
22
30
const getMinMOSConfirmation = useConfirmationModal ( {
23
31
title : t ( 'heading.are-you-sure' ) ,
@@ -35,12 +43,19 @@ export const ToolbarActions = () => {
35
43
} ) ;
36
44
37
45
return (
38
- < Grid container gap = { 1 } direction = "column" >
39
- < Grid item >
40
- < InputWithLabelRow
41
- labelWidth = "150px"
42
- label = { t ( 'label.min-months-of-stock' ) }
43
- Input = {
46
+ < DetailPanelSection title = { t ( 'heading.order-info' ) } >
47
+ < Grid container gap = { 0.5 } key = "order-info" >
48
+ { usesRemoteAuthorisation && (
49
+ < PanelRow >
50
+ < PanelLabel > { t ( 'label.auth-status' ) } </ PanelLabel >
51
+ < PanelField >
52
+ { t ( getApprovalStatusKey ( linkedRequisition ?. approvalStatus ) ) }
53
+ </ PanelField >
54
+ </ PanelRow >
55
+ ) }
56
+ < PanelRow >
57
+ < PanelLabel > { t ( 'label.min-months-of-stock' ) } </ PanelLabel >
58
+ < PanelField >
44
59
< Autocomplete
45
60
disabled = { isDisabled || isProgram }
46
61
clearIcon = { null }
@@ -78,14 +93,11 @@ export const ToolbarActions = () => {
78
93
} }
79
94
getOptionDisabled = { option => option . value > maxMonthsOfStock }
80
95
/>
81
- }
82
- />
83
- </ Grid >
84
- < Grid item >
85
- < InputWithLabelRow
86
- labelWidth = "150px"
87
- label = { t ( 'label.max-months-of-stock' ) }
88
- Input = {
96
+ </ PanelField >
97
+ </ PanelRow >
98
+ < PanelRow >
99
+ < PanelLabel > { t ( 'label.max-months-of-stock' ) } </ PanelLabel >
100
+ < PanelField >
89
101
< Autocomplete
90
102
disabled = { isDisabled || isProgram }
91
103
clearIcon = { null }
@@ -107,23 +119,9 @@ export const ToolbarActions = () => {
107
119
}
108
120
getOptionDisabled = { option => option . value < minMonthsOfStock }
109
121
/>
110
- }
111
- />
112
- </ Grid >
113
- < Grid item >
114
- < InputWithLabelRow
115
- labelWidth = "225px"
116
- label = { t ( 'label.hide-stock-over-minimum' ) }
117
- Input = {
118
- < Switch
119
- onChange = { toggle }
120
- checked = { on }
121
- color = "secondary"
122
- size = "small"
123
- />
124
- }
125
- />
122
+ </ PanelField >
123
+ </ PanelRow >
126
124
</ Grid >
127
- </ Grid >
125
+ </ DetailPanelSection >
128
126
) ;
129
127
} ;
0 commit comments