Skip to content

Commit

Permalink
Merge pull request #17 from weaponsforge/dev
Browse files Browse the repository at this point in the history
v1.0.3
  • Loading branch information
weaponsforge authored Nov 22, 2022
2 parents 1ea3669 + 7534920 commit ade7f64
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 3 deletions.
7 changes: 5 additions & 2 deletions components/common/layout/section/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import PropTypes from 'prop-types'
import Container from '@mui/material/Container'
import AppCard from '@/components/common/ui/appcard'

function Section ({ children }) {
function Section ({ maxWidth, children }) {
const mWidth = maxWidth || 'md'

return (
<Container maxWidth='md'>
<Container maxWidth={mWidth}>
<AppCard>
{children}
</AppCard>
Expand All @@ -13,6 +15,7 @@ function Section ({ children }) {
}

Section.propTypes = {
props: PropTypes.object,
children: PropTypes.node
}

Expand Down
1 change: 1 addition & 0 deletions components/common/ui/appcard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { styled } from '@mui/material/styles'

const AppCard = styled(Card)(({ theme }) => ({
width: '100%',
textAlign: 'center',
padding: theme.spacing(2),
borderRadius: theme.spacing(1),
marginTop: theme.spacing(3),
Expand Down
91 changes: 91 additions & 0 deletions components/profile-centered/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import Container from '@mui/material/Container'
import Grid from '@mui/material/Grid'
import Typography from '@mui/material/Typography'
import SubContentText from '@/components/common/layout/subtcontenttext'
import DonutChart from '@/components/common/ui/charts/donut'
import BarChart from '@/components/common/ui/charts/bar'
import LineGraph from '@/components/common/ui/charts/line'
import ArticleText from '@/components/common/layout/articletext'
import CountryList from '@/domain/profile/countrylist'
import styles from './styles'

function ProfileCenteredComponent ({
country,
countries,
textData,
donutData,
barData,
handleSelectCountry
}) {
return (
<Container maxWidth='lg'>
<Grid container sx={styles.container}>
<Grid item xs={12} sx={{ marginBottom: '48px' }}>
<Typography variant="h3">
Climate Profile
{country !== '' && ` - ${country}`}
</Typography>

<CountryList
countries={countries}
handleSelectCountry={handleSelectCountry}
/>
</Grid>

{/** Greehouse Gas (GHG) Emmissions Section */}
<Grid item xs={12} sm={5}>
<DonutChart {...donutData} />
</Grid>

<Grid item xs={12} sm={7}>
<SubContentText {...textData[0]} />
</Grid>

{/** Climate Risks Section */}
<Grid item xs={12}>
<Typography variant="h4">
Climate Change Scenarios
</Typography>
</Grid>

<Grid item xs={12} sm={7}>
<SubContentText
{...textData[0]}
title='Climate Risks'
/>
</Grid>

<Grid item xs={12} sm={5}>
<BarChart
{...barData}
/>
</Grid>

{/** Climate Change Scenarios Section */}
<Grid item xs={12} sm={7}>
<SubContentText
{...textData[0]}
title='Climate Change and Vulnerability'
/>
</Grid>

<Grid item xs={12} sm={5}>
<LineGraph
{...barData}
/>
</Grid>

{/** Other Lengthy Text Section */}
{textData.map((item, index) => {
if (index >= 1) {
return <Grid item xs={12} key={index}>
<ArticleText {...item} />
</Grid>
}
})}
</Grid>
</Container>
)
}

export default ProfileCenteredComponent
12 changes: 12 additions & 0 deletions components/profile-centered/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const styles = {
container: {
'& h3, h4': {
textAlign: 'center',
marginBottom: '32px'
},
marginTop: '40px'
}
}

export default styles

2 changes: 1 addition & 1 deletion domain/profile/countrylist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function CountryList ({
handleSelectCountry
}) {
return (
<Section maxWidth='lg'>
<Section>
{countries.map((country, index) => (
<CountryButton
variant='text'
Expand Down
44 changes: 44 additions & 0 deletions pages/profile-centered/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { useEffect, useState } from 'react'
import { useRouter } from 'next/router'
import ProfileCenteredComponent from '@/components/profile-centered'
import textData from '@/data/text_data'
import donutChartData from '@/data/donut_data'
import countries from '@/data/countries'
import { options, labels, data } from '@/data/bar_data'
import { capitalizeFirstLetter } from '@/utils/text'

function ProfileCentered () {
const router = useRouter()
const [country, setCountry] = useState('')

useEffect(() => {
if (router.isReady) {
const cntry = router.query.country

if (cntry) {
setCountry(capitalizeFirstLetter(cntry))
} else {
console.error('country is not defined')
}

}
}, [router.isReady, router.query])

const handleSelectCountry = (e) => {
const { value } = e.target
setCountry(value)
}

return (
<ProfileCenteredComponent
country={country}
countries={countries}
textData={textData}
donutData={donutChartData}
barData={{ options, labels, data }}
handleSelectCountry={handleSelectCountry}
/>
)
}

export default ProfileCentered

0 comments on commit ade7f64

Please sign in to comment.