11import { useState , useEffect } from 'react' ;
22import { connect } from 'react-redux' ;
3- import { useHistory } from 'react-router-dom' ;
4-
3+ import { Link } from 'react-router-dom' ;
54import { fetchInvTypeByType } from '~/actions/bmdashboard/invTypeActions' ;
65import { fetchInvUnits } from '~/actions/bmdashboard/invUnitActions' ;
7- import { Accordion , Card , Button } from 'react-bootstrap' ;
8- import DatePicker from 'react-datepicker' ;
9- import 'react-datepicker/dist/react-datepicker.css' ;
10-
6+ import { Accordion , Card } from 'react-bootstrap' ;
117import BMError from '../shared/BMError' ;
12- import TypesTable from './TypesTable' ;
138import UnitsTable from './invUnitsTable' ;
149import AccordionToggle from './AccordionToggle' ;
1510import styles from './TypesList.module.css' ;
1611
12+ const categories = [
13+ { label : 'Materials' , route : '/bmdashboard/materials' } ,
14+ { label : 'Consumables' , route : '/bmdashboard/consumables' } ,
15+ { label : 'Equipments' , route : '/bmdashboard/equipment' } ,
16+ { label : 'Reusables' , route : '/bmdashboard/reusables' } ,
17+ { label : 'Tools' , route : '/bmdashboard/tools' } ,
18+ ] ;
19+
1720export function InventoryTypesList ( props ) {
1821 const { invUnits, errors, dispatch } = props ;
19- const history = useHistory ( ) ;
20-
21- const categories = [ 'Materials' , 'Consumables' , 'Equipments' , 'Reusables' , 'Tools' ] ;
22-
2322 const [ isError , setIsError ] = useState ( false ) ;
24- const [ currentTime , setCurrentTime ] = useState ( new Date ( ) ) ;
25-
26- const handleBack = ( ) => {
27- history . goBack ( ) ;
28- } ;
2923
3024 useEffect ( ( ) => {
3125 dispatch ( fetchInvTypeByType ( 'Materials' ) ) ;
@@ -50,52 +44,38 @@ export function InventoryTypesList(props) {
5044 }
5145
5246 return (
53- < div className = { `${ styles . typesListContainer } ` } >
54- < h1 > All Inventory Types</ h1 >
55-
56- < div className = { `${ styles . timestampContainer } ` } >
57- < span > Time:</ span >
58- < DatePicker
59- selected = { currentTime }
60- onChange = { date => setCurrentTime ( date ) }
61- dateFormat = "MM-dd-yyyy hh:mm:ss"
62- id = "timestamp"
63- showTimeInput
64- />
47+ < div className = { styles . typesListContainer } >
48+ { /* Page Header */ }
49+ < div className = { styles . pageHeader } >
50+ < h1 className = { styles . pageTitle } > All Inventory Types</ h1 >
51+ < p className = { styles . pageSubtitle } > Select a category to view and manage inventory</ p >
6552 </ div >
6653
67- < Accordion >
68- { categories ?. map ( ( category , index ) => {
69- return (
70- < Card key = { category } >
71- < AccordionToggle as = { Card . Header } eventKey = { index + 1 } >
72- { category }
73- </ AccordionToggle >
74- < Accordion . Collapse eventKey = { index + 1 } >
75- < Card . Body className = { `${ styles . accordionCollapse } ` } >
76- < TypesTable category = { category } />
77- </ Card . Body >
78- </ Accordion . Collapse >
79- </ Card >
80- ) ;
81- } ) }
82-
83- < Card >
84- < AccordionToggle as = { Card . Header } eventKey = { categories . length + 1 } >
85- Unit of Measurement
86- </ AccordionToggle >
87- < Accordion . Collapse eventKey = { categories . length + 1 } >
88- < Card . Body className = { `${ styles . accordionCollapse } ` } >
89- < UnitsTable invUnits = { invUnits } />
90- </ Card . Body >
91- </ Accordion . Collapse >
92- </ Card >
93- </ Accordion >
54+ { /* Category Cards Grid */ }
55+ < div className = { styles . categoryGrid } >
56+ { categories . map ( ( { label, route } ) => (
57+ < Link key = { label } to = { route } className = { styles . categoryCard } >
58+ < span className = { styles . categoryCardLabel } > { label } </ span >
59+ < div className = { styles . categoryCardArrow } > ›</ div >
60+ </ Link >
61+ ) ) }
62+ </ div >
9463
95- < div className = { `${ styles . buttonContainer } ` } >
96- < Button variant = "primary" className = { `${ styles . backButton } ` } onClick = { handleBack } >
97- Back to previous list page
98- </ Button >
64+ { /* Unit of Measurement */ }
65+ < div className = { styles . unitSection } >
66+ < h2 className = { styles . unitSectionTitle } > Unit of Measurement</ h2 >
67+ < Accordion >
68+ < Card className = { styles . unitCard } >
69+ < AccordionToggle as = { Card . Header } eventKey = { 1 } className = { styles . cardHeader } >
70+ View all units
71+ </ AccordionToggle >
72+ < Accordion . Collapse eventKey = { 1 } >
73+ < Card . Body className = { styles . accordionCollapse } >
74+ < UnitsTable invUnits = { invUnits } />
75+ </ Card . Body >
76+ </ Accordion . Collapse >
77+ </ Card >
78+ </ Accordion >
9979 </ div >
10080 </ div >
10181 ) ;
0 commit comments