forked from ONEARMY/community-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ONEARMY#3033 from benfurber/3018-add-impact-data
feat: add user setting to update impact
- Loading branch information
Showing
23 changed files
with
611 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -303,41 +303,39 @@ export const users = { | |
collectedPlasticTypes: null, | ||
email: '[email protected]', | ||
password: 'test1234', | ||
impact: [ | ||
{ | ||
year: 2022, | ||
fields: [ | ||
{ | ||
label: 'plastic recycled', | ||
value: 43000, | ||
suffix: 'Kg of', | ||
isVisible: true, | ||
}, | ||
{ | ||
label: 'revenue', | ||
value: 36000, | ||
prefix: '$', | ||
suffix: 'in', | ||
isVisible: true, | ||
}, | ||
{ | ||
label: 'full time employees', | ||
value: 3, | ||
isVisible: true, | ||
}, | ||
{ | ||
label: 'volunteers', | ||
value: 45, | ||
isVisible: false, | ||
}, | ||
{ | ||
label: 'machines built', | ||
value: 2, | ||
isVisible: true, | ||
}, | ||
], | ||
}, | ||
], | ||
userRoles: ['beta-tester'], | ||
impact: { | ||
2022: [ | ||
{ | ||
label: 'plastic recycled', | ||
value: 43000, | ||
suffix: 'Kg of', | ||
isVisible: true, | ||
}, | ||
{ | ||
label: 'revenue', | ||
value: 36000, | ||
prefix: '$', | ||
suffix: 'in', | ||
isVisible: true, | ||
}, | ||
{ | ||
label: 'full time employees', | ||
value: 3, | ||
isVisible: true, | ||
}, | ||
{ | ||
label: 'volunteers', | ||
value: 45, | ||
isVisible: false, | ||
}, | ||
{ | ||
label: 'machines built', | ||
value: 2, | ||
isVisible: true, | ||
}, | ||
], | ||
}, | ||
}, | ||
mapview_testing_rejected: { | ||
openingHours: [], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/pages/UserSettings/content/formSections/Impact/Impact.section.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { useState } from 'react' | ||
import { Heading, Box, Button, Text } from 'theme-ui' | ||
|
||
import { buttons, fields } from 'src/pages/UserSettings/labels' | ||
import { IMPACT_YEARS } from 'src/pages/User/impact/constants' | ||
import { FlexSectionContainer } from '../elements' | ||
import { ImpactYearSection } from './ImpactYear.section' | ||
|
||
export const ImpactSection = () => { | ||
const [isExpanded, setIsExpanded] = useState<boolean>(false) | ||
const { description, title } = fields.impact | ||
const { expandClose, expandOpen } = buttons.impact | ||
|
||
const buttonLabel = isExpanded ? expandClose : expandOpen | ||
|
||
return ( | ||
<FlexSectionContainer> | ||
<Heading dangerouslySetInnerHTML={{ __html: title }} variant="small" /> | ||
<Text mt={4} mb={4}> | ||
{description} | ||
</Text> | ||
{isExpanded && ( | ||
<Box> | ||
{IMPACT_YEARS.map((year) => { | ||
return <ImpactYearSection year={year} key={year} /> | ||
})} | ||
</Box> | ||
)} | ||
<Box mt={2}> | ||
<Button | ||
dangerouslySetInnerHTML={{ __html: buttonLabel }} | ||
data-cy="impact-button-expand" | ||
onClick={() => setIsExpanded(!isExpanded)} | ||
variant="secondary" | ||
/> | ||
</Box> | ||
</FlexSectionContainer> | ||
) | ||
} |
Oops, something went wrong.