-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev-4347 account spending tables #1706
Merged
Merged
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
24e71c8
Initial Table Container
ebdabbs affca38
added pagination and additional column mappings
ebdabbs 136ecca
Merge remote-tracking branch 'origin/dev' into ftr/dev-4347-agency-bu…
ebdabbs 698d41f
Added missing Fontawesome icons
ebdabbs 40fb096
Store the agency's total obligation in Redux
ebdabbs 6735b51
added unit tests
ebdabbs b350470
added data model for account spending row, parsing function, and sort…
e050da8
added loading and error states
0bf6de3
added BaseAccountSpendingRow test
722b2a0
added disabled prop
64f11e2
added pagination buttons when loading or errored
aaa4541
updated percentage function in base model
6de64d3
added styling for table and count tabs
0a4c413
added word-break
b0642b3
Merge branch 'dev' into ftr/dev-4347-account-spending-tables
5516767
updated tabs to use color variables
jameslee40 935dae9
Refactored CountTab onClick for performance reasons
jameslee40 a3d7648
added error state to AgencyContainerV2
jameslee40 bf90684
Refactored state naming
jameslee40 0b72344
Removed useless parenthesis
jameslee40 a34c352
Refactored function to useCallback
jameslee40 3d1e8a8
Removed value from button
jameslee40 9448b7c
moved params and setLoading inside callback instead of passing params
jameslee40 c56e2cb
Merge branch 'dev' into ftr/dev-4347-account-spending-tables
jameslee40 b8ecb06
updated data-transparency-ui version
jameslee40 04d499a
Merge branch 'dev' into ftr/dev-4347-account-spending-tables
jameslee40 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,19 +3,19 @@ | |
* Created by Maxwell Kendall 01/31/2020 | ||
*/ | ||
|
||
/* eslint-disable no-unused-vars */ | ||
/* eslint-disable react/prop-types */ | ||
|
||
import React, { useState, useEffect } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
import { useDispatch } from 'react-redux'; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { startCase, snakeCase } from "lodash"; | ||
import { | ||
TooltipWrapper, | ||
Picker | ||
} from 'data-transparency-ui'; | ||
|
||
import { setAgencyOverview, resetAgency } from 'redux/actions/agency/agencyActions'; | ||
import { setBudgetaryResources } from 'redux/actions/agencyV2/agencyV2Actions'; | ||
import { fetchBudgetaryResources } from 'helpers/agencyV2Helper'; | ||
import BaseAgencyBudgetaryResources from 'models/v2/agency/BaseAgencyBudgetaryResources'; | ||
|
||
import { agencyPageMetaTags } from 'helpers/metaTagHelper'; | ||
import { scrollToY } from 'helpers/scrollToHelper'; | ||
|
@@ -32,10 +32,10 @@ import { defaultSortFy } from 'components/sharedComponents/pickers/FYPicker'; | |
import ShareIcon from 'components/sharedComponents/stickyHeader/ShareIcon'; | ||
|
||
import AccountSpending from 'components/agency/v2/accountSpending/AccountSpending'; | ||
import Error from '../../../components/sharedComponents/Error'; | ||
|
||
require('pages/agency/v2/index.scss'); | ||
|
||
// document.querySelector('.site-navigation').offsetHeight + document.querySelector('.site-navigation').offsetTop | ||
const scrollPositionOfSiteHeader = 96; | ||
|
||
const TooltipComponent = () => ( | ||
|
@@ -70,15 +70,39 @@ const ComingSoon = () => ( | |
</div> | ||
); | ||
|
||
const propTypes = { | ||
params: PropTypes.shape({ | ||
agencyId: PropTypes.string | ||
}) | ||
}; | ||
|
||
export const AgencyProfileV2 = ({ | ||
agencyOverview, | ||
agencyId, | ||
params, | ||
clearAgency, | ||
setOverview | ||
params | ||
}) => { | ||
const dispatch = useDispatch(); | ||
const [activeSection, setActiveSection] = useState('overview'); | ||
const [selectedFy, setSelectedFy] = useState(FiscalYearHelper.defaultFiscalYear()); | ||
const [loading, setLoading] = useState(true); | ||
const [error, setError] = useState(false); | ||
|
||
useEffect(() => { | ||
setLoading(true); | ||
// request budgetary resources data for this agency | ||
const budgetaryResourcesRequest = fetchBudgetaryResources(params.agencyId); | ||
budgetaryResourcesRequest.promise | ||
.then((res) => { | ||
// parse the response using our data model | ||
setLoading(false); | ||
const budgetaryResources = Object.create(BaseAgencyBudgetaryResources); | ||
budgetaryResources.populate(res.data); | ||
// store the data model object in Redux | ||
dispatch(setBudgetaryResources(budgetaryResources)); | ||
}).catch((err) => { | ||
setError(true); | ||
setLoading(false); | ||
console.error(err); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added error handling for this, as well as, rendering the error. |
||
}, [params.agencyId]); | ||
|
||
const componentByAgencySection = { | ||
overview: <ComingSoon />, | ||
|
@@ -154,7 +178,8 @@ export const AgencyProfileV2 = ({ | |
<ShareIcon | ||
slug={slug} | ||
email={{ | ||
subject: `USAspending.gov Agency Profile: ${agencyOverview.name}`, | ||
// TODO - add agency name when the data is available | ||
subject: 'USAspending.gov Agency Profile: ', | ||
body: `View the spending activity of this agency on USAspending.gov: ${getBaseUrl(slug)}` | ||
}} /> | ||
<div className="sticky-header__toolbar-item"> | ||
|
@@ -166,7 +191,7 @@ export const AgencyProfileV2 = ({ | |
</div> | ||
</> | ||
</StickyHeader> | ||
<LoadingWrapper isLoading={false} > | ||
<LoadingWrapper isLoading={loading} > | ||
<main id="main-content" className="main-content usda__flex-row"> | ||
<div className="sidebar usda__flex-col"> | ||
<Sidebar | ||
|
@@ -180,28 +205,26 @@ export const AgencyProfileV2 = ({ | |
label: startCase(section) | ||
}))} /> | ||
</div> | ||
<div className="body usda__flex-col"> | ||
{Object.keys(componentByAgencySection).map((section) => ( | ||
<AgencySection key={section} section={section} > | ||
{componentByAgencySection[section]} | ||
</AgencySection> | ||
))} | ||
</div> | ||
{error && | ||
<div className="body usda__flex-col"> | ||
<Error /> | ||
</div>} | ||
{!error && | ||
<div className="body usda__flex-col"> | ||
{Object.keys(componentByAgencySection).map((section) => ( | ||
<AgencySection key={section} section={section} > | ||
{componentByAgencySection[section]} | ||
</AgencySection> | ||
))} | ||
</div> | ||
} | ||
</main> | ||
</LoadingWrapper> | ||
<Footer /> | ||
</div> | ||
); | ||
}; | ||
|
||
const mapStateToProps = (state) => ({ | ||
agencyOverview: state.agency.overview, | ||
agencyId: state.agency.id | ||
}); | ||
|
||
const mapDispatchToProps = (dispatch) => ({ | ||
clearAgency: () => dispatch(resetAgency()), | ||
setOverview: (agency) => dispatch(setAgencyOverview(agency)) | ||
}); | ||
AgencyProfileV2.propTypes = propTypes; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(AgencyProfileV2); | ||
export default AgencyProfileV2; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very Nice!