@@ -5,6 +5,7 @@ import { useDispatch, useSelector } from 'react-redux';
55import Joi from 'joi-browser' ;
66import { toast } from 'react-toastify' ;
77import Select from 'react-select' ;
8+ import PropTypes from 'prop-types' ;
89import { fetchInvUnits } from '../../../actions/bmdashboard/invUnitActions' ;
910import {
1011 fetchConsumableTypes ,
@@ -13,7 +14,7 @@ import {
1314} from '../../../actions/bmdashboard/invTypeActions' ;
1415import styles from './AddConsumable.module.css' ;
1516
16- function AddConsumable ( ) {
17+ function AddConsumable ( { toggle } ) {
1718 const [ newConsumable , setNewConsumable ] = useState ( {
1819 consumableName : '' ,
1920 consumableDescription : '' ,
@@ -29,6 +30,7 @@ function AddConsumable() {
2930 const buildingInventoryUnits = useSelector ( state => state . bmInvUnits . list ) ;
3031 const postBuildingInventoryResult = useSelector ( state => state . bmInvTypes . postedResult ) ;
3132 const selectInputRef = useRef ( ) ;
33+ const darkMode = useSelector ( state => state . theme . darkMode ) ;
3234
3335 useEffect ( ( ) => {
3436 dispatch ( fetchInvUnits ( ) ) ;
@@ -143,27 +145,28 @@ function AddConsumable() {
143145 size : newConsumable . consumableSize ,
144146 } ;
145147 dispatch ( postBuildingConsumableType ( postObj ) ) ;
148+ toggle ( ) ;
146149 }
147150 }
148151
149152 return (
150153 < Container fluid className = { `${ styles . consumableContainer } ` } >
151- < div className = { `${ styles . consumablePage } ` } >
152- < div className = { `${ styles . consumable } ` } >
154+ < div className = { `${ styles . consumablePage } ${ darkMode ? styles . darkBg : '' } ` } >
155+ < div className = { `${ styles . consumable } ${ darkMode ? styles . lightBg : '' } ` } >
153156 < div className = { `${ styles . consumableTitle } ` } > ADD CONSUMABLES FORM</ div >
154157 < Card >
155158 < CardBody >
156159 < Form id = "AddConsumableForm" >
157- < FormGroup row className = "align-items-center justify-content-start" >
158- < Label for = "" lg = { 2 } sm = { 4 } className = { `${ styles . consumableFormLabel } ` } >
160+ < FormGroup row className = " justify-content-start" >
161+ < Label for = "" lg = { 4 } sm = { 4 } className = { `${ styles . consumableFormLabel } ` } >
159162 Item Type
160163 </ Label >
161164 < Col lg = { 8 } sm = { 8 } className = { `${ styles . consumableFormValue } ` } >
162165 < Input name = "consumable" type = "text" value = "Consumable" disabled />
163166 </ Col >
164167 </ FormGroup >
165- < FormGroup row className = "align-items-center justify-content-start" >
166- < Label for = "name" lg = { 2 } sm = { 4 } className = { `${ styles . consumableFormLabel } ` } >
168+ < FormGroup row className = " justify-content-start" >
169+ < Label for = "name" lg = { 4 } sm = { 4 } className = { `${ styles . consumableFormLabel } ` } >
167170 Consumable Name
168171 </ Label >
169172 < Col lg = { 8 } sm = { 8 } className = { `${ styles . consumableFormValue } ` } >
@@ -188,8 +191,8 @@ function AddConsumable() {
188191 ) }
189192 </ FormGroup >
190193
191- < FormGroup row className = "align-items-center justify-content-start" >
192- < Label for = "name" lg = { 2 } sm = { 4 } className = { `${ styles . consumableFormLabel } ` } >
194+ < FormGroup row className = " justify-content-start" >
195+ < Label for = "name" lg = { 4 } sm = { 4 } className = { `${ styles . consumableFormLabel } ` } >
193196 Description
194197 </ Label >
195198 < Col lg = { 8 } sm = { 8 } className = { `${ styles . consumableFormValue } ` } >
@@ -214,8 +217,8 @@ function AddConsumable() {
214217 ) }
215218 </ FormGroup >
216219
217- < FormGroup row className = "align-items-center justify-content-start" >
218- < Label for = "name" lg = { 2 } sm = { 4 } className = { `${ styles . consumableFormLabel } ` } >
220+ < FormGroup row className = " justify-content-start" >
221+ < Label for = "name" lg = { 4 } sm = { 4 } className = { `${ styles . consumableFormLabel } ` } >
219222 Size (optional)
220223 </ Label >
221224 < Col lg = { 8 } sm = { 8 } className = { `${ styles . consumableFormValue } ` } >
@@ -240,14 +243,16 @@ function AddConsumable() {
240243 ) }
241244 </ FormGroup >
242245
243- < FormGroup row className = "align-items-center justify-content-start" >
244- < Label for = "unit" lg = { 2 } sm = { 4 } className = { `${ styles . consumableFormLabel } ` } >
246+ < FormGroup row className = " justify-content-start" >
247+ < Label for = "unit" lg = { 4 } sm = { 4 } className = { `${ styles . consumableFormLabel } ` } >
245248 Measurement
246249 </ Label >
247250 < Col lg = { 8 } sm = { 8 } >
248251 < Select
249252 id = "unit"
250253 name = "unit"
254+ className = { darkMode ? styles . select : '' }
255+ classNamePrefix = "rs"
251256 onChange = { event => unitSelectHandler ( event ) }
252257 ref = { selectInputRef }
253258 options = { formattedUnits }
@@ -270,8 +275,8 @@ function AddConsumable() {
270275 </ FormGroup >
271276
272277 { allowNewMeasurement && (
273- < FormGroup row className = "align-items-center justify-content-start" >
274- < Label for = "name" lg = { 2 } sm = { 4 } className = { `${ styles . consumableFormLabel } ` } >
278+ < FormGroup row className = " justify-content-start" >
279+ < Label for = "name" lg = { 4 } sm = { 4 } className = { `${ styles . consumableFormLabel } ` } >
275280 New Measurement Unit
276281 </ Label >
277282 < Col lg = { 8 } sm = { 8 } className = { `${ styles . consumableFormValue } ` } >
@@ -303,5 +308,7 @@ function AddConsumable() {
303308 </ Container >
304309 ) ;
305310}
306-
311+ AddConsumable . propTypes = {
312+ toggle : PropTypes . func . isRequired ,
313+ } ;
307314export default AddConsumable ;
0 commit comments