generic functions for backend queries

This commit is contained in:
Aarni Halinen
2021-09-04 18:02:29 +03:00
parent d48c6a0c3e
commit efd916a8a2
13 changed files with 200 additions and 230 deletions
+3 -2
View File
@@ -8,7 +8,8 @@ import { Button, Link } from "@components/index";
import AddLink from "@components/AddLink";
import Event from "@models/Event";
import EventApi from "@api/eventApi";
import useFetchEvents from "@hooks/useFetchEvents";
import useFetchBackend from "@hooks/useFetchBackend";
import { APIPath } from "@api/backend";
const URL = "/admin/events";
@@ -65,7 +66,7 @@ const renderData = (events: Event[]) => {
};
const AdminEventPage: NextPage = () => {
const { data } = useFetchEvents({ options: { auth: true } });
const { data } = useFetchBackend<Event[]>({ apiPath: APIPath.EVENTS, options: { auth: true } });
return (
<AdminListCommon>
<h1>Events</h1>
+3 -2
View File
@@ -8,7 +8,8 @@ import { Button, Link } from "@components/index";
import AddLink from "@components/AddLink";
import Post from "@models/Feed";
import PostApi from "@api/feedApi";
import useFetchFeed from "@hooks/useFetchFeed";
import useFetchBackend from "@hooks/useFetchBackend";
import { APIPath } from "@api/backend";
const URL = "/admin/feed";
@@ -65,7 +66,7 @@ const renderData = (feed: Post[]) => {
};
const AdminFeedPage: NextPage = () => {
const { data } = useFetchFeed({ options: { auth: true } });
const { data } = useFetchBackend<Post[]>({ apiPath: APIPath.FEED, options: { auth: true } });
return (
<AdminListCommon>
<h1>Feed</h1>
+3 -2
View File
@@ -7,8 +7,9 @@ import AdminListCommon from "@views/admin/AdminListCommon";
import { Button, Link } from "@components/index";
import AddLink from "@components/AddLink";
import JobAd from "@models/JobAd";
import useFetchJobAds from "@hooks/useFetchJobAds";
import useFetchBackend from "@hooks/useFetchBackend";
import JobAdApi from "@api/jobAdApi";
import { APIPath } from "@api/backend";
const URL = "/admin/jobads";
@@ -69,7 +70,7 @@ const renderData = (jobAds: JobAd[]) => {
};
const AdminJobAdPage: NextPage = () => {
const { data } = useFetchJobAds({ options: { auth: true } });
const { data } = useFetchBackend<JobAd[]>({ apiPath: APIPath.JOBADS, options: { auth: true } });
return (
<AdminListCommon>
<h1>Job advertisements</h1>