Skip to content

Commit fcfc7f3

Browse files
Merge pull request #2786 from OneCommunityGlobal/fix/bug16-inventory-table
Calvin- Fix Bug 85 Phase 2: Inventory Type List (/bmdashboard/inventory/types)
2 parents f341133 + a4e4853 commit fcfc7f3

1 file changed

Lines changed: 90 additions & 26 deletions

File tree

src/components/BMDashboard/shared/CheckTypes.jsx

Lines changed: 90 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function CheckTypes({ type }) {
88
const dispatch = useDispatch();
99
const [InvType, setInvType] = useState(type);
1010
const [buildingInvTypes, setbuildingInvTypes] = useState([]);
11+
const darkMode = useSelector(state => state.theme.darkMode);
1112
const [isAscending, setIsAscending] = useState(true);
1213
const [searchQuery, setSearchQuery] = useState('');
1314

@@ -43,10 +44,34 @@ function CheckTypes({ type }) {
4344
});
4445

4546
return (
46-
<div>
47-
<Card>
47+
<div
48+
style={{
49+
backgroundColor: darkMode ? '#1B2A41' : '#ffffff',
50+
color: darkMode ? '#ffffff' : '#000000',
51+
padding: '20px',
52+
minHeight: '100vh',
53+
}}
54+
>
55+
<Card
56+
style={{
57+
backgroundColor: darkMode ? '#1C2541' : '#ffffff',
58+
margin: '20px auto',
59+
width: '80%',
60+
borderRadius: '15px',
61+
}}
62+
>
4863
<CardBody>
4964
<FormGroup row>
65+
<Label
66+
for="selectType"
67+
lg={2}
68+
sm={4}
69+
style={{
70+
color: darkMode ? '#ffffff' : '#000000',
71+
}}
72+
>
73+
Select Type
74+
</Label>
5075
<Label for="search" lg={2} sm={4}>
5176
Search by Name
5277
</Label>
@@ -60,9 +85,6 @@ function CheckTypes({ type }) {
6085
onChange={e => setSearchQuery(e.target.value)} // Update search query
6186
/>
6287
</Col>
63-
<Label for="selectType" lg={2} sm={4}>
64-
Select Type
65-
</Label>
6688
<Col lg={4} sm={8}>
6789
<Input
6890
id="selectType"
@@ -80,28 +102,70 @@ function CheckTypes({ type }) {
80102
</Input>
81103
</Col>
82104
</FormGroup>
83-
<Table size="sm" responsive>
84-
<thead>
85-
<tr>
86-
<th>#</th>
87-
<th style={{ cursor: 'pointer' }} onClick={handleSortByName}>
88-
Name {isAscending ? '▲' : '▼'}
89-
</th>
90-
<th>Category</th>
91-
<th>Description</th>
92-
</tr>
93-
</thead>
94-
<tbody>
95-
{sortedBuildingInvTypes?.map((elemType, idx) => (
96-
<tr key={elemType._id}>
97-
<th>{idx + 1}</th>
98-
<td>{elemType.name}</td>
99-
<td>{elemType.category}</td>
100-
<td>{elemType.description}</td>
105+
<div
106+
style={{
107+
maxHeight: '800px',
108+
overflowY: 'auto',
109+
padding: '10px',
110+
borderRadius: '15px',
111+
backgroundColor: darkMode ? '#3A506B' : '#f9f9f9',
112+
border: darkMode ? '1px solid #444' : '1px solid #dcdcdc',
113+
boxShadow: darkMode
114+
? '0 2px 10px rgba(255, 255, 255, 0.1)'
115+
: '0 2px 10px rgba(0, 0, 0, 0.05)',
116+
}}
117+
>
118+
<Table size="sm" responsive hover>
119+
<thead
120+
style={{
121+
backgroundColor: darkMode ? '#1C2541' : '#ffffff',
122+
color: darkMode ? '#ffffff' : '#000000',
123+
fontWeight: 'bold',
124+
position: 'sticky',
125+
top: 0,
126+
zIndex: 1,
127+
borderTop: '1px solid #444',
128+
borderBottom: '1px solid #444',
129+
}}
130+
>
131+
<tr>
132+
<th>#</th>
133+
<th style={{ cursor: 'pointer' }} onClick={handleSortByName}>
134+
Name {isAscending ? '▲' : '▼'}
135+
</th>
136+
<th>Category</th>
137+
<th>Description</th>
101138
</tr>
102-
))}
103-
</tbody>
104-
</Table>
139+
</thead>
140+
<tbody>
141+
{sortedBuildingInvTypes?.map((elemType, idx) => (
142+
<tr key={elemType._id}>
143+
<th>{idx + 1}</th>
144+
<td>{elemType.name}</td>
145+
<td>{elemType.category}</td>
146+
<td>{elemType.description}</td>
147+
</tr>
148+
))}
149+
</tbody>
150+
</Table>
151+
<style jsx>{`
152+
tbody tr:nth-child(odd) {
153+
background-color: ${darkMode ? '#1C2541' : '#ffffff'};
154+
color: ${darkMode ? '#ffffff' : '#000000'};
155+
}
156+
tbody tr:nth-child(even) {
157+
background-color: ${darkMode ? '#3A506B' : '#f9f9f9'};
158+
color: ${darkMode ? '#ffffff' : '#000000'};
159+
}
160+
tbody tr:hover {
161+
background-color: ${darkMode ? '#23395d !important' : '#e9ecef !important'};
162+
color: ${darkMode ? '#ffffff !important' : '#000000 !important'};
163+
}
164+
thead tr:hover {
165+
background-color: ${darkMode ? '#1C2541' : '#ffffff'};
166+
}
167+
`}</style>
168+
</div>
105169
</CardBody>
106170
</Card>
107171
</div>

0 commit comments

Comments
 (0)