/
index.js
65 lines (59 loc) · 1.98 KB
/
index.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React from "react";
import fetch from "isomorphic-fetch";
import MainLayout from "components/MainLayout";
import ContentPagesSidebar from "components/shared/ContentPagesSidebar";
import { classNames, stylesheet } from "css/pages/terms-and-conditions.css";
import {
T_AND_C_ENDPOINT,
CONTENT_PAGE_NAMES,
GUIDES_ENDPOINT
} from "constants/content-pages";
import {
classNames as contentClasses,
stylesheet as contentStyles
} from "css/pages/content-pages-wysiwyg.css";
import { classNames as utilClassNames } from "css/utils.css";
const TermsAndConditions = ({ url, termsAndConditions, guides }) =>
<MainLayout route={url}>
<div
className={`
${utilClassNames.container}
${contentClasses.sidebarAndContentWrapper}
`}
>
<div className="row">
<ContentPagesSidebar
route={url}
guides={guides}
page={CONTENT_PAGE_NAMES.TERMS_AND_CONDITIONS}
/>
<div className="col-xs-12 col-md-7">
<div
dangerouslySetInnerHTML={{
__html: termsAndConditions.content
}}
className={contentClasses.content}
/>
</div>
</div>
</div>
<style dangerouslySetInnerHTML={{ __html: stylesheet }} />
<style dangerouslySetInnerHTML={{ __html: contentStyles }} />
</MainLayout>;
TermsAndConditions.getInitialProps = async () => {
const termsAndConditionsRes = await fetch(T_AND_C_ENDPOINT);
const termsAndConditionsJson = await termsAndConditionsRes.json();
const termsAndConditions = Object.assign({}, termsAndConditionsJson, {
title: termsAndConditionsJson.title.rendered,
content: termsAndConditionsJson.content.rendered
});
const guidesRes = await fetch(GUIDES_ENDPOINT);
const guidesJson = await guidesRes.json();
const guides = guidesJson.map(guide =>
Object.assign({}, guide, {
displayTitle: guide.acf.display_title
})
);
return { termsAndConditions, guides };
};
export default TermsAndConditions;