Split table into component
This commit is contained in:
39
app/pages/home/index.js
Normal file
39
app/pages/home/index.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import React from "react"
|
||||
import dbConnect from '../../lib/dbConnect'
|
||||
import { models } from 'shared-stuff'
|
||||
import Table from './Table'
|
||||
|
||||
export default class Home extends React.Component {
|
||||
constructor ({ scanResults }) {
|
||||
super()
|
||||
this.scanResults = scanResults
|
||||
}
|
||||
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<Table
|
||||
scanResults={this.scanResults}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export async function getServerSideProps() {
|
||||
try {
|
||||
await dbConnect()
|
||||
const scanResults = await models.ScanResult.find({})
|
||||
|
||||
return {
|
||||
props: {
|
||||
scanResults: JSON.parse(JSON.stringify(scanResults))
|
||||
},
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return {
|
||||
props: {},
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user