remove onlyNonPast, 'since' parameter handled implicit on backend

This commit is contained in:
Aarni Halinen
2021-05-16 02:16:55 +03:00
parent 91acb0c337
commit 99b4e65326
8 changed files with 12 additions and 20 deletions
+3 -3
View File
@@ -6,10 +6,10 @@ import { getAuthHeader } from "@utils/auth";
export const URL = `${process.env.NEXT_PUBLIC_API_URL}/events/`;
export interface Options {
onlyNonPast?: boolean;
limit?: number;
offset?: number;
auth?: boolean;
since?: Date;
}
class EventApi {
@@ -28,11 +28,11 @@ class EventApi {
static async getEvents(options: Options = {}): Promise<Event[]> {
const {
onlyNonPast, limit, offset, auth,
since, limit, offset, auth,
} = options;
try {
const params = {
since: onlyNonPast ? (new Date()).toISOString() : undefined,
since,
limit,
offset,
};
+3 -3
View File
@@ -6,7 +6,7 @@ import { getAuthHeader } from "@utils/auth";
export const URL = `${process.env.NEXT_PUBLIC_API_URL}/jobads/`;
export interface Options {
onlyNonPast?: boolean;
since?: Date;
limit?: number;
offset?: number;
auth?: boolean;
@@ -15,11 +15,11 @@ export interface Options {
class JobAdApi {
static async getJobAds(options: Options = {}): Promise<JobAd[]> {
const {
onlyNonPast, limit, offset, auth,
since, limit, offset, auth,
} = options;
try {
const params = {
since: onlyNonPast ? (new Date()).toISOString() : undefined,
since,
limit,
offset,
};
-1
View File
@@ -8,7 +8,6 @@ export const FORM_URL = `${process.env.NEXT_PUBLIC_API_URL}/signupForm/`;
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface Options {
// onlyNonPast?: boolean;
// limit?: number;
// offset?: number;
// auth?: boolean;
+2 -3
View File
@@ -11,15 +11,14 @@ const fetcher = (url: string, config: AxiosRequestConfig) => axios.get(url, conf
const generateFetchParams = (id = "", options: Options = {}) => {
const url = `${URL}${id}`;
const {
// auth, onlyNonPast, limit, offset,
auth, limit, offset,
auth, since, limit, offset,
} = options;
return {
url,
config: {
params: {
// since: onlyNonPast ? (new Date()).toISOString() : undefined,
since,
limit,
offset,
},
+2 -2
View File
@@ -11,14 +11,14 @@ const jobAdFetcher = (url: string, config?: AxiosRequestConfig) => axios.get(url
const generateFetchParams = (id = "", options: Options = {}) => {
const url = `${URL}${id}`;
const {
onlyNonPast, limit, offset, auth,
since, limit, offset, auth,
} = options;
return {
url,
config: {
params: {
since: onlyNonPast ? (new Date()).toISOString() : undefined,
since,
limit,
offset,
},
-1
View File
@@ -11,7 +11,6 @@ import InEnglishPageView from "@views/InEnglishPage/InEnglishPageView";
import PageWrapper from "@views/common/PageWrapper";
const eventOptions = {
onlyNonPast: true,
limit: 4,
};
-1
View File
@@ -11,7 +11,6 @@ import FrontPageView from "@views/FrontPage/FrontPageView";
import PageWrapper from "@views/common/PageWrapper";
const eventOptions = {
onlyNonPast: true,
limit: 4,
};
+2 -6
View File
@@ -10,17 +10,13 @@ import useFetchFeed from "@hooks/useFetchFeed";
import ActualPageView from "@views/ActualPage/ActualPageView";
import PageWrapper from "@views/common/PageWrapper";
const eventOptions = {
onlyNonPast: true,
};
interface InitialProps {
initialEvents: Event[];
initialFeed: Post[];
}
const ActualPage: NextPage<InitialProps> = ({ initialEvents, initialFeed }) => {
const eventResult = useFetchEvents({ initialData: initialEvents, options: eventOptions });
const eventResult = useFetchEvents({ initialData: initialEvents });
const feedResult = useFetchFeed({ initialData: initialFeed });
return (
@@ -36,7 +32,7 @@ const ActualPage: NextPage<InitialProps> = ({ initialEvents, initialFeed }) => {
};
export const getStaticProps: GetStaticProps<InitialProps> = async () => {
const initialEvents = await EventApi.getEvents(eventOptions);
const initialEvents = await EventApi.getEvents();
const initialFeed = await FeedApi.getFeed();
return {
props: {