Skip to content

Commit

Permalink
Merge pull request #7 from bcgov/fix-merge-issues
Browse files Browse the repository at this point in the history
Fix merge issues
  • Loading branch information
mgtennant authored Jun 11, 2024
2 parents af8084d + cab88b0 commit 7575e45
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 99 deletions.
2 changes: 1 addition & 1 deletion frontend/src/components/__tests__/NotFound.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { vi } from 'vitest'
import { render, screen } from '@testing-library/react'
import NotFound from '@/components/NotFound'
import NotFound from '@/pages/NotFound'

vi.mock('react-router', () => ({
useNavigate: vi.fn(),
Expand Down
153 changes: 67 additions & 86 deletions frontend/src/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,101 +1,82 @@
// import apiService from '@/service/api-service'
// 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 type { AxiosResponse } from '~/axios'
import apiService from '@/service/api-service'
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 type { AxiosResponse } from '~/axios'
// import config from '../config'
import _kc from '@/keycloak'
import UserService from '@/service/user-service'

// 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,
// },
// ]
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<any>([])
const [data, setData] = useState<any>([])

// const data = [
// {
// id: 1,
// name: 'Michael',
// email: '[email protected]',
// },
// {
// id: 2,
// name: 'Test',
// email: '[email protected]',
// },
// {
// id: 3,
// name: 'User',
// email: '[email protected]',
// },
// ]
useEffect(() => {
apiService
.getAxiosInstance()
.get('/v1/users')
.then((response: AxiosResponse) => {
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)

// useEffect(() => {
// apiService
// .getAxiosInstance()
// .get('/v1/users')
// .then((response: AxiosResponse) => {
// 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)
// })
// }, [])
// interface DataRow {
// [key: string]: any
// }
const handleClose = () => {
setSelectedRow(null)
}

// const [selectedRow, setSelectedRow] = useState<DataRow | null>(null)

// const handleClose = () => {
// setSelectedRow(null)
// }
return (
<div
style={{
minHeight: '45em',
maxHeight: '45em',
width: '100%',
width: '90%',
marginLeft: '4em',
}}
>
Dashboard
{/* <DataGrid
<DataGrid
slots={{ toolbar: GridToolbar }}
slotProps={{
toolbar: {
Expand Down Expand Up @@ -130,7 +111,7 @@ export default function Dashboard() {
Close
</Button>
</DialogActions>
</Dialog> */}
</Dialog>
</div>
)
}
19 changes: 7 additions & 12 deletions frontend/src/routes/protected-routes.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { FC } from "react";
import { Navigate, Outlet } from "react-router-dom";
import Roles from "../roles";
import Dashboard from "@/components/Dashboard";
import { Layout } from "@/components/Layout";
import { FC } from 'react'
import { Navigate } from 'react-router-dom'
import Roles from '../roles'
import Dashboard from '@/pages/Dashboard'

export const ProtectedRoutes: FC<{ roles: Array<Roles> }> = () => {
let auth = { token: true }
return auth.token ? (
<Dashboard/>
) : (
<Navigate to="/not-authorized" />
)
}
let auth = { token: true }
return auth.token ? <Dashboard /> : <Navigate to="/not-authorized" />
}

0 comments on commit 7575e45

Please sign in to comment.