Skip to content

Commit

Permalink
try mapping without user object
Browse files Browse the repository at this point in the history
Signed-off-by: OMPRAKASH MISHRA <omprakashmishra3978@gmail.com>
  • Loading branch information
mishraomp committed Feb 12, 2024
1 parent a38f77a commit 98905b9
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions frontend/src/components/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ 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, GridColDef, GridToolbar } from '@mui/x-data-grid'
import { DataGrid, GridToolbar } from '@mui/x-data-grid'
import { useEffect, useState } from 'react'
import { AxiosResponse } from '~/axios'
import UserDto from "@/interfaces/UserDto";

const columns: GridColDef[] = [
const columns = [
{
field: 'id',
headerName: 'Employee ID',
Expand All @@ -34,28 +33,26 @@ const columns: GridColDef[] = [
sortable: true,
filterable: true,
flex: 1,
}
];
},
]
export default function Dashboard() {
const [data, setData] = useState<UserDto[]>([])
const [data, setData] = useState<any>([])

useEffect(() => {
apiService
.getAxiosInstance()
.get('/v1/users')
.then((response: AxiosResponse) => {
const users: UserDto[] = [];
const users = []
for (const user of response.data) {
const userDto: UserDto = {
const userDto = {
id: user.id,
name: user.name,
email: user.email
};
users.push(userDto);
email: user.email,
}
users.push(userDto)
}
setData(
users
)
setData(users)
})
.catch((error) => {
console.error(error)
Expand Down

0 comments on commit 98905b9

Please sign in to comment.