-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from suvarnakale/release-3.1.0.0
Issue #125 Feat: nAdmin - Role and Dashboard Implementation
- Loading branch information
Showing
6 changed files
with
228 additions
and
2 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
src/main/frontend/src/components/CommonComponents/FilterBy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React, { useState } from "react"; | ||
import PropTypes from "prop-types"; | ||
import { | ||
Box, | ||
MenuItem, | ||
Select, | ||
Checkbox, | ||
ListItemText, | ||
Typography, | ||
InputLabel, | ||
FormControl, | ||
} from "@mui/material"; | ||
|
||
const FilterBy = ({ options, onFilterChange, label = "Filter By" }) => { | ||
const [selectedValues, setSelectedValues] = useState(["All"]); | ||
|
||
const handleChange = (event) => { | ||
const value = event.target.value; | ||
setSelectedValues(value); | ||
onFilterChange(value); | ||
}; | ||
|
||
return ( | ||
<Box sx={{ width: "100%" }}> | ||
<FormControl fullWidth> | ||
<InputLabel | ||
id="demo-simple-select-label" | ||
component="legend" | ||
variant="outlined" | ||
> | ||
{label} | ||
</InputLabel> | ||
<Select | ||
labelId="demo-simple-select-label" | ||
multiple | ||
value={selectedValues} | ||
onChange={handleChange} | ||
renderValue={(selected) => selected.join(", ")} | ||
> | ||
{options.map((option) => ( | ||
<MenuItem key={option} value={option}> | ||
<Checkbox checked={selectedValues.includes(option)} /> | ||
<ListItemText primary={option} /> | ||
</MenuItem> | ||
))} | ||
</Select> | ||
</FormControl> | ||
</Box> | ||
); | ||
}; | ||
|
||
// Prop validation | ||
FilterBy.propTypes = { | ||
options: PropTypes.arrayOf(PropTypes.string).isRequired, | ||
onFilterChange: PropTypes.func.isRequired, | ||
label: PropTypes.string, | ||
}; | ||
|
||
// Default props | ||
FilterBy.defaultProps = { | ||
label: "Filter By", | ||
}; | ||
|
||
export default FilterBy; |
65 changes: 65 additions & 0 deletions
65
src/main/frontend/src/components/CommonComponents/NeedCard.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import Card from "@mui/material/Card"; | ||
import CardContent from "@mui/material/CardContent"; | ||
import Box from "@mui/material/Box"; | ||
import Typography from "@mui/material/Typography"; | ||
|
||
const NeedCard = ({ matrixData }) => { | ||
if (!matrixData || matrixData.length === 0) { | ||
return ( | ||
<Typography variant="body1" color="text.secondary"> | ||
No data available | ||
</Typography> | ||
); | ||
} | ||
|
||
return ( | ||
<Box display="flex" flexWrap="wrap" gap="1rem"> | ||
{matrixData?.map((matrix, index) => ( | ||
<Box | ||
key={index} | ||
sx={{ | ||
width: { xs: "100%", sm: "48%", md: "32%", lg: "24%" }, | ||
maxWidth: "16rem", | ||
}} | ||
> | ||
<Card variant="outlined"> | ||
<CardContent> | ||
<Box display="flex" gap="1rem" alignItems="center"> | ||
<Box> | ||
<img | ||
src={matrix.icon || ""} | ||
alt={matrix.status || "Nominated Needs"} | ||
height="30px" | ||
style={{ objectFit: "contain" }} | ||
/> | ||
</Box> | ||
<Box> | ||
<Typography variant="h4" component="div"> | ||
{matrix.count || 0} | ||
</Typography> | ||
<Typography sx={{ color: "text.secondary" }}> | ||
{matrix.status || "Status"} | ||
</Typography> | ||
</Box> | ||
</Box> | ||
</CardContent> | ||
</Card> | ||
</Box> | ||
))} | ||
</Box> | ||
); | ||
}; | ||
|
||
NeedCard.propTypes = { | ||
matrixData: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
icon: PropTypes.string, | ||
count: PropTypes.number, | ||
status: PropTypes.string, | ||
}) | ||
), | ||
}; | ||
|
||
export default NeedCard; |
37 changes: 37 additions & 0 deletions
37
src/main/frontend/src/components/CommonComponents/sampleData.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import VolunteerNeedsNominated from "../../assets/needsNominated.png"; | ||
import VolunteerNeedsInProgress from "../../assets/needsInProgress.png"; | ||
import VolunteerNeedsApproved from "../../assets/needsApproved.png"; | ||
import VolunteerPlansDelivered from "../../assets/plansDelivered.png"; | ||
|
||
export const matrixData = [ | ||
{ | ||
icon: VolunteerNeedsNominated, | ||
count: 200, | ||
status: "Total Needs Created", | ||
}, | ||
{ | ||
icon: VolunteerNeedsInProgress, | ||
count: 8, | ||
status: "Needs in Progress", | ||
}, | ||
{ | ||
icon: VolunteerNeedsApproved, | ||
count: 24, | ||
status: "Needs Requested", | ||
}, | ||
{ | ||
icon: VolunteerNeedsApproved, | ||
count: 12, | ||
status: "Needs Approved", | ||
}, | ||
{ | ||
icon: VolunteerPlansDelivered, | ||
count: 280, | ||
status: "Total Volunteers", | ||
}, | ||
{ | ||
icon: VolunteerNeedsInProgress, | ||
count: 80, | ||
status: "New Volunteers", | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React, { useState } from "react"; | ||
import NeedCard from "../../components/CommonComponents/NeedCard"; | ||
import FilterBy from "../../components/CommonComponents/FilterBy"; | ||
import { matrixData } from "../../components/CommonComponents/sampleData"; | ||
import { Box, Typography } from "@mui/material"; | ||
import NeedsTable from "../../components/NeedsTable/NeedsTable"; | ||
const Dashboard = () => { | ||
const [filteredData, setFilteredData] = useState([]); | ||
|
||
const handleFilterChange = (selectedFilters) => { | ||
console.log("Selected Filters:", selectedFilters); | ||
setFilteredData(selectedFilters); | ||
}; | ||
|
||
return ( | ||
<Box padding={"1rem"}> | ||
<Box | ||
padding={"1rem"} | ||
gap={"0.5rem"} | ||
display={"flex"} | ||
width={"100%"} | ||
justifyContent={"space-between"} | ||
> | ||
<Box> | ||
<Box display={"flex"} gap={"0.5rem"}> | ||
<Typography variant="body1" color="text.secondary"> | ||
Welcome Back, | ||
</Typography> | ||
<Typography variant="body1" color="text.primary"> | ||
DemoAdmin! | ||
</Typography> | ||
</Box> | ||
<Typography variant="h4" color="text.primary"> | ||
Dashboard | ||
</Typography> | ||
<Typography variant="body1" color="text.secondary"> | ||
Here's your needs analytics data | ||
</Typography> | ||
</Box> | ||
|
||
<Box width={"20%"} marginTop={"3rem"}> | ||
<FilterBy | ||
options={["All", "Option 1", "Option 2", "Option 3", "Option 4"]} | ||
onFilterChange={handleFilterChange} | ||
/> | ||
</Box> | ||
</Box> | ||
<NeedCard matrixData={matrixData} /> | ||
<Box bgcolor={"white"}> | ||
<NeedsTable /> | ||
</Box> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default Dashboard; |