Render JobAds in admin

This commit is contained in:
Aarni Halinen
2021-01-15 20:46:18 +02:00
parent 45361ca276
commit a887f8844c
2 changed files with 13 additions and 5 deletions
+1 -1
View File
@@ -33,8 +33,8 @@ export default class MyDocument extends Document {
const { styleTags } = this.props as any;
return (
<Html lang="fi">
<HTMLLogo />
<Head>
<HTMLLogo />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css" />
<Favicons />
</Head>
+12 -4
View File
@@ -1,11 +1,11 @@
import React from "react";
import React, { useEffect, useState } from "react";
import { NextPage, GetServerSideProps } from "next";
import Head from "next/head";
import { formatRelative } from "date-fns";
import AdminListCommon from "@views/admin/AdminListCommon";
import { Link } from "@components/index";
import AddLink from "@components/AddLink";
import { JobAd, useFetchJobAds } from "@models/JobAd";
import { JobAd, getJobAds } from "@models/JobAd";
const URL = "/admin/jobads"
@@ -41,8 +41,16 @@ const renderData = (jobAds: JobAd[]) => {
);
}
const AdminJobAdPage: NextPage = () => {
// const { data, error } = useFetchJobAds({ options: { auth: true } );
const [jobAds, setAds] = useState<JobAd[]>(null);
useEffect(() => {
getJobAds({ auth: true })
.then(res => setAds(res))
}, [])
return (
<>
<Head>
@@ -51,7 +59,7 @@ const AdminJobAdPage: NextPage = () => {
<AdminListCommon>
<h1>Job advertisements</h1>
<AddLink text="Create job ad" to={`${URL}/create`} />
{/* {renderData(jobAds)} */}
{renderData(jobAds)}
</AdminListCommon>
</>
)