first commit
This commit is contained in:
15
frontend/pages/_app.js
Normal file
15
frontend/pages/_app.js
Normal file
@ -0,0 +1,15 @@
|
||||
import Layout from '../components/layout/Layout'
|
||||
import '../styles/globals.css'
|
||||
import NextNProgress from "nextjs-progressbar";
|
||||
|
||||
|
||||
function MyApp({ Component, pageProps }) {
|
||||
return (
|
||||
<>
|
||||
<NextNProgress />
|
||||
<Layout><Component {...pageProps} /></Layout>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default MyApp
|
||||
41
frontend/pages/dataset/index.js
Normal file
41
frontend/pages/dataset/index.js
Normal file
@ -0,0 +1,41 @@
|
||||
import DataSet from "../../components/halaman/DataSet";
|
||||
import Card from "../../components/ui/Card";
|
||||
|
||||
function PageDataSet(props){
|
||||
let data = JSON.parse(props.data);
|
||||
// console.log(data)
|
||||
let status = JSON.parse(props.data).status;
|
||||
// console.log(status)
|
||||
|
||||
return (status == "success") ?<DataSet data={data} /> : <Card> <br /> <center> <h2>Server Bermasalah ...</h2></center> <br /></Card>
|
||||
|
||||
// return <h1>okok</h1>
|
||||
}
|
||||
|
||||
export async function getStaticProps() { // this code never end up on client side ,excecuted during build time
|
||||
// fetch data from an API, for example
|
||||
let data;
|
||||
try {
|
||||
//fetches data http://127.0.0.1:5000/ with method get
|
||||
const response = await fetch('http://127.0.0.1:5000/', {
|
||||
method: 'GET',
|
||||
})
|
||||
//convert response to json
|
||||
data = await response.json()
|
||||
data['status'] = 'success'
|
||||
|
||||
} catch (e) {
|
||||
data = {"error": e,'status':'error'}
|
||||
}
|
||||
|
||||
// console.log(data)
|
||||
|
||||
return {
|
||||
props: { //this has to be named `props`
|
||||
data: JSON.stringify(data)
|
||||
},
|
||||
revalidate: 10 //revalidate after 10 second
|
||||
}
|
||||
}
|
||||
|
||||
export default PageDataSet;
|
||||
34
frontend/pages/index.js
Normal file
34
frontend/pages/index.js
Normal file
@ -0,0 +1,34 @@
|
||||
import InputData from "../components/halaman/InputData";
|
||||
|
||||
function HomePage(props) {
|
||||
const data = JSON.parse(props.data);
|
||||
return <InputData data={data} />;
|
||||
}
|
||||
|
||||
export async function getStaticProps() { // this code never end up on client side ,excecuted during build time
|
||||
// fetch data from an API, for example
|
||||
let data;
|
||||
try {
|
||||
//fetches data http://127.0.0.1:5000/ with method get
|
||||
const response = await fetch('http://127.0.0.1:5000/', {
|
||||
method: 'GET',
|
||||
})
|
||||
//convert response to json
|
||||
data = await response.json()
|
||||
data['status'] = 'success'
|
||||
|
||||
} catch (e) {
|
||||
data = {"error": e,'status':'error'}
|
||||
}
|
||||
|
||||
// console.log(data)
|
||||
|
||||
return {
|
||||
props: { //this has to be named `props`
|
||||
data: JSON.stringify(data)
|
||||
},
|
||||
revalidate: 10 //revalidate after 10 second
|
||||
}
|
||||
}
|
||||
|
||||
export default HomePage;
|
||||
7
frontend/pages/penulis.js
Normal file
7
frontend/pages/penulis.js
Normal file
@ -0,0 +1,7 @@
|
||||
import Penulis from "../components/halaman/Penulis";
|
||||
|
||||
function penulisPage(){
|
||||
return <Penulis />
|
||||
}
|
||||
|
||||
export default penulisPage;
|
||||
Reference in New Issue
Block a user