Split table into component
This commit is contained in:
@@ -1,46 +1,4 @@
|
||||
import Head from 'next/head'
|
||||
import dbConnect from '../lib/dbConnect'
|
||||
import { models } from 'shared-stuff'
|
||||
import home from './home'
|
||||
|
||||
export default function Home({ scanResults }) {
|
||||
return (
|
||||
<div className="container">
|
||||
<Head>
|
||||
<title>Warframe Center</title>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
</Head>
|
||||
|
||||
<main>
|
||||
<ul>
|
||||
{scanResults.map((scanResult) => (
|
||||
<li key={scanResult._id}>
|
||||
<h2>{scanResult.name}</h2>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
|
||||
</footer>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export async function getServerSideProps(context) {
|
||||
try {
|
||||
await dbConnect()
|
||||
const scanResults = await models.ScanResult.find({})
|
||||
|
||||
return {
|
||||
props: {
|
||||
scanResults: JSON.parse(JSON.stringify(scanResults))
|
||||
},
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return {
|
||||
props: {},
|
||||
}
|
||||
}
|
||||
}
|
||||
export default home.Home
|
||||
export const getServerSideProps = home.getServerSideProps
|
||||
|
||||
Reference in New Issue
Block a user