-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend): various updates (BC Sans and look and feel) (#1804)
Signed-off-by: OMPRAKASH MISHRA <omprakashmishra3978@gmail.com>
- Loading branch information
Showing
12 changed files
with
247 additions
and
55 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,31 +1,113 @@ | ||
import { useEffect, useState } from 'react' | ||
import MUIDataTable from 'mui-datatables' | ||
import apiService from '@/service/api-service' | ||
import type UserDto from '@/interfaces/UserDto' | ||
import type { AxiosResponse } from '~/axios' | ||
|
||
const columns: string[] = ['Id', 'Name', 'Email'] | ||
import Button from '@mui/material/Button' | ||
import Dialog from '@mui/material/Dialog' | ||
import DialogActions from '@mui/material/DialogActions' | ||
import DialogContent from '@mui/material/DialogContent' | ||
import DialogTitle from '@mui/material/DialogTitle' | ||
import Table from '@mui/material/Table' | ||
import TableBody from '@mui/material/TableBody' | ||
import TableCell from '@mui/material/TableCell' | ||
import TableRow from '@mui/material/TableRow' | ||
import { DataGrid, GridToolbar } from '@mui/x-data-grid' | ||
import { useEffect, useState } from 'react' | ||
import { AxiosResponse } from '~/axios' | ||
|
||
const columns = [ | ||
{ | ||
field: 'id', | ||
headerName: 'Employee ID', | ||
sortable: true, | ||
filterable: true, | ||
flex: 1, | ||
}, | ||
{ | ||
field: 'name', | ||
headerName: 'Employee Name', | ||
sortable: true, | ||
filterable: true, | ||
flex: 1, | ||
}, | ||
{ | ||
field: 'email', | ||
headerName: 'Employee Email', | ||
sortable: true, | ||
filterable: true, | ||
flex: 1, | ||
}, | ||
] | ||
export default function Dashboard() { | ||
const [data, setData] = useState([]) | ||
const [data, setData] = useState<any>([]) | ||
|
||
useEffect(() => { | ||
apiService | ||
.getAxiosInstance() | ||
.get('/v1/users') | ||
.then((response: AxiosResponse) => { | ||
setData( | ||
response.data.map((user: UserDto) => [ | ||
user.id, | ||
user.name, | ||
user.email, | ||
]), | ||
) | ||
const users = [] | ||
for (const user of response.data) { | ||
const userDto = { | ||
id: user.id, | ||
name: user.name, | ||
email: user.email, | ||
} | ||
users.push(userDto) | ||
} | ||
setData(users) | ||
}) | ||
.catch((error) => { | ||
console.error(error) | ||
}) | ||
}, []) | ||
const [selectedRow, setSelectedRow] = useState(null) | ||
|
||
return <MUIDataTable title={'User List'} data={data} columns={columns} /> | ||
const handleClose = () => { | ||
setSelectedRow(null) | ||
} | ||
return ( | ||
<div | ||
style={{ | ||
minHeight: '45em', | ||
maxHeight: '45em', | ||
width: '100%', | ||
marginLeft: '4em', | ||
}} | ||
> | ||
<DataGrid | ||
slots={{ toolbar: GridToolbar }} | ||
slotProps={{ | ||
toolbar: { | ||
showQuickFilter: true, | ||
}, | ||
}} | ||
experimentalFeatures={{ ariaV7: true }} | ||
checkboxSelection={false} | ||
rows={data} | ||
columns={columns} | ||
pageSizeOptions={[5, 10, 20, 50, 100]} | ||
getRowId={(row) => row['id']} | ||
onRowClick={(params) => setSelectedRow(params.row)} | ||
/> | ||
<Dialog open={!!selectedRow} onClose={handleClose}> | ||
<DialogTitle>Row Details</DialogTitle> | ||
<DialogContent> | ||
<Table> | ||
<TableBody> | ||
{selectedRow && | ||
Object.entries(selectedRow).map(([key, value]) => ( | ||
<TableRow key={key}> | ||
<TableCell>{key}</TableCell> | ||
<TableCell>{value}</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button variant="contained" color="secondary" onClick={handleClose}> | ||
Close | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.