remove onlyNonPast, 'since' parameter handled implicit on backend
This commit is contained in:
+3
-3
@@ -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
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
@@ -11,7 +11,6 @@ import InEnglishPageView from "@views/InEnglishPage/InEnglishPageView";
|
||||
import PageWrapper from "@views/common/PageWrapper";
|
||||
|
||||
const eventOptions = {
|
||||
onlyNonPast: true,
|
||||
limit: 4,
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import FrontPageView from "@views/FrontPage/FrontPageView";
|
||||
import PageWrapper from "@views/common/PageWrapper";
|
||||
|
||||
const eventOptions = {
|
||||
onlyNonPast: true,
|
||||
limit: 4,
|
||||
};
|
||||
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user