-
-
Notifications
You must be signed in to change notification settings - Fork 509
/
Copy pathindex.tsx
22 lines (19 loc) · 860 Bytes
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { withSessionSsr, getSessionData } from "../lib/withSession";
import Demo, { DemoQueryBuilderProps } from "../components/demo/index";
import { getInitialTree } from "../pages/api/tree";
import { getInitialZipConfig } from "../pages/api/config";
export default Demo;
// Get current `jsonTree` and `zipConfig` from session
// If `jsonTree` is missing, will be loaded from `data` dir
// If `zipConfig` is missing, will be created in `lib/config` and compressed with `Utils.ConfigUtils.compressConfig()`
export const getServerSideProps = withSessionSsr<DemoQueryBuilderProps>(
async function getServerSideProps({ req }) {
const sessionData = await getSessionData(req);
return {
props: {
jsonTree: sessionData?.jsonTree || getInitialTree(),
zipConfig: sessionData?.zipConfig || getInitialZipConfig(),
}
};
}
);