-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.tsx
44 lines (41 loc) · 1.1 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import React from "react";
import Home from "../components/core/home/home";
import { getNonprofitsCardData } from "../server/actions/core";
import { NonprofitCardData, PaginatedNonprofitCards } from "../utils/types";
interface Props {
nonprofitCards: PaginatedNonprofitCards;
}
const HomePage = (props: Props) => {
const { nonprofitCards } = props;
const { page, isLastPage, cards } = nonprofitCards;
return <Home page={page} isLastPage={isLastPage} cards={cards} />;
};
export default HomePage;
export const getServerSideProps: () => Promise<{
props: {
nonprofitCards:
| PaginatedNonprofitCards
| {
cards: NonprofitCardData[];
isLastPage: boolean;
page: number;
totalCount: number;
};
};
}> = async () => {
const cards = await getNonprofitsCardData()
.then(res => {
return res;
})
.catch(e => {
// eslint-disable-next-line no-console
console.log(e);
return {
cards: [],
page: 0,
totalCount: 0,
isLastPage: true
};
});
return { props: { nonprofitCards: cards } };
};