Skip to content

Commit ade7f64

Browse files
authored
Merge pull request #17 from weaponsforge/dev
v1.0.3
2 parents 1ea3669 + 7534920 commit ade7f64

File tree

6 files changed

+154
-3
lines changed

6 files changed

+154
-3
lines changed

components/common/layout/section/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import PropTypes from 'prop-types'
22
import Container from '@mui/material/Container'
33
import AppCard from '@/components/common/ui/appcard'
44

5-
function Section ({ children }) {
5+
function Section ({ maxWidth, children }) {
6+
const mWidth = maxWidth || 'md'
7+
68
return (
7-
<Container maxWidth='md'>
9+
<Container maxWidth={mWidth}>
810
<AppCard>
911
{children}
1012
</AppCard>
@@ -13,6 +15,7 @@ function Section ({ children }) {
1315
}
1416

1517
Section.propTypes = {
18+
props: PropTypes.object,
1619
children: PropTypes.node
1720
}
1821

components/common/ui/appcard/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { styled } from '@mui/material/styles'
33

44
const AppCard = styled(Card)(({ theme }) => ({
55
width: '100%',
6+
textAlign: 'center',
67
padding: theme.spacing(2),
78
borderRadius: theme.spacing(1),
89
marginTop: theme.spacing(3),
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import Container from '@mui/material/Container'
2+
import Grid from '@mui/material/Grid'
3+
import Typography from '@mui/material/Typography'
4+
import SubContentText from '@/components/common/layout/subtcontenttext'
5+
import DonutChart from '@/components/common/ui/charts/donut'
6+
import BarChart from '@/components/common/ui/charts/bar'
7+
import LineGraph from '@/components/common/ui/charts/line'
8+
import ArticleText from '@/components/common/layout/articletext'
9+
import CountryList from '@/domain/profile/countrylist'
10+
import styles from './styles'
11+
12+
function ProfileCenteredComponent ({
13+
country,
14+
countries,
15+
textData,
16+
donutData,
17+
barData,
18+
handleSelectCountry
19+
}) {
20+
return (
21+
<Container maxWidth='lg'>
22+
<Grid container sx={styles.container}>
23+
<Grid item xs={12} sx={{ marginBottom: '48px' }}>
24+
<Typography variant="h3">
25+
Climate Profile
26+
{country !== '' && ` - ${country}`}
27+
</Typography>
28+
29+
<CountryList
30+
countries={countries}
31+
handleSelectCountry={handleSelectCountry}
32+
/>
33+
</Grid>
34+
35+
{/** Greehouse Gas (GHG) Emmissions Section */}
36+
<Grid item xs={12} sm={5}>
37+
<DonutChart {...donutData} />
38+
</Grid>
39+
40+
<Grid item xs={12} sm={7}>
41+
<SubContentText {...textData[0]} />
42+
</Grid>
43+
44+
{/** Climate Risks Section */}
45+
<Grid item xs={12}>
46+
<Typography variant="h4">
47+
Climate Change Scenarios
48+
</Typography>
49+
</Grid>
50+
51+
<Grid item xs={12} sm={7}>
52+
<SubContentText
53+
{...textData[0]}
54+
title='Climate Risks'
55+
/>
56+
</Grid>
57+
58+
<Grid item xs={12} sm={5}>
59+
<BarChart
60+
{...barData}
61+
/>
62+
</Grid>
63+
64+
{/** Climate Change Scenarios Section */}
65+
<Grid item xs={12} sm={7}>
66+
<SubContentText
67+
{...textData[0]}
68+
title='Climate Change and Vulnerability'
69+
/>
70+
</Grid>
71+
72+
<Grid item xs={12} sm={5}>
73+
<LineGraph
74+
{...barData}
75+
/>
76+
</Grid>
77+
78+
{/** Other Lengthy Text Section */}
79+
{textData.map((item, index) => {
80+
if (index >= 1) {
81+
return <Grid item xs={12} key={index}>
82+
<ArticleText {...item} />
83+
</Grid>
84+
}
85+
})}
86+
</Grid>
87+
</Container>
88+
)
89+
}
90+
91+
export default ProfileCenteredComponent
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const styles = {
2+
container: {
3+
'& h3, h4': {
4+
textAlign: 'center',
5+
marginBottom: '32px'
6+
},
7+
marginTop: '40px'
8+
}
9+
}
10+
11+
export default styles
12+

domain/profile/countrylist/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function CountryList ({
66
handleSelectCountry
77
}) {
88
return (
9-
<Section maxWidth='lg'>
9+
<Section>
1010
{countries.map((country, index) => (
1111
<CountryButton
1212
variant='text'

pages/profile-centered/index.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { useEffect, useState } from 'react'
2+
import { useRouter } from 'next/router'
3+
import ProfileCenteredComponent from '@/components/profile-centered'
4+
import textData from '@/data/text_data'
5+
import donutChartData from '@/data/donut_data'
6+
import countries from '@/data/countries'
7+
import { options, labels, data } from '@/data/bar_data'
8+
import { capitalizeFirstLetter } from '@/utils/text'
9+
10+
function ProfileCentered () {
11+
const router = useRouter()
12+
const [country, setCountry] = useState('')
13+
14+
useEffect(() => {
15+
if (router.isReady) {
16+
const cntry = router.query.country
17+
18+
if (cntry) {
19+
setCountry(capitalizeFirstLetter(cntry))
20+
} else {
21+
console.error('country is not defined')
22+
}
23+
24+
}
25+
}, [router.isReady, router.query])
26+
27+
const handleSelectCountry = (e) => {
28+
const { value } = e.target
29+
setCountry(value)
30+
}
31+
32+
return (
33+
<ProfileCenteredComponent
34+
country={country}
35+
countries={countries}
36+
textData={textData}
37+
donutData={donutChartData}
38+
barData={{ options, labels, data }}
39+
handleSelectCountry={handleSelectCountry}
40+
/>
41+
)
42+
}
43+
44+
export default ProfileCentered

0 commit comments

Comments
 (0)