-
Notifications
You must be signed in to change notification settings - Fork 7
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
Migrate company overview to React Router #6400
Merged
cgsunkel
merged 4 commits into
feature-merge/company-layout-refactoring
from
feature/migrate-company-overview-to-react-router
Jan 5, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8014818
Create new version of CompanyLayout that uses the DefaultLayout
cgsunkel 053275f
Migrate CompanyOverview page to use React Router
cgsunkel 10048fa
Remove legacy code
cgsunkel 88c1760
Move CompanyOverview code into the modules directory
cgsunkel 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
76 changes: 0 additions & 76 deletions
76
src/apps/companies/apps/company-overview/client/CompanyOverview.jsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
src/apps/companies/apps/company-overview/views/client-container.njk
This file was deleted.
Oops, something went wrong.
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
251 changes: 251 additions & 0 deletions
251
src/client/components/CompanyLocalHeader/CompanyLocalHeaderNew.jsx
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,251 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import styled from 'styled-components' | ||
import Main from '@govuk-react/main' | ||
import GridCol from '@govuk-react/grid-col' | ||
import GridRow from '@govuk-react/grid-row' | ||
import Button from '@govuk-react/button' | ||
import Details from '@govuk-react/details' | ||
import { SPACING, FONT_SIZE, BREAKPOINTS } from '@govuk-react/constants' | ||
import { Link } from 'govuk-react' | ||
import { H4 } from '@govuk-react/heading' | ||
|
||
import { GREY_3, TEXT_COLOUR } from '../../utils/colours' | ||
import LocalHeaderCompanyLists from './LocalHeaderCompanyLists' | ||
import LocalHeaderCompanyRefer from './LocalHeaderCompanyRefer' | ||
import Badge from '../Badge' | ||
import StatusMessage from '../StatusMessage' | ||
import { addressToStringResource } from '../../utils/addresses' | ||
import urls from '../../../lib/urls' | ||
import ArchivePanel from '../ArchivePanel' | ||
import { isItaTierDAccount } from '../../modules/Companies/utils' | ||
import { RelatedCompaniesCountResource } from '../Resource' | ||
|
||
const LocalHeaderTradingNames = styled(H4)` | ||
font-weight: normal; | ||
` | ||
|
||
const StyledAddress = styled('p')` | ||
margin-top: ${SPACING.SCALE_2}; | ||
margin-bottom: ${SPACING.SCALE_2}; | ||
` | ||
|
||
const BadgeText = styled('span')` | ||
font-weight: 600; | ||
font-size: ${FONT_SIZE.SIZE_16}; | ||
` | ||
|
||
const TypeWrapper = styled('div')` | ||
@media (min-width: ${BREAKPOINTS.TABLET}) { | ||
display: table-row; | ||
} | ||
` | ||
const StyledButtonContainer = styled('div')` | ||
width: 100%; | ||
display: inline-block; | ||
` | ||
|
||
const StyledList = styled('div')` | ||
padding-bottom: 10px; | ||
display: inline-flex; | ||
` | ||
|
||
const StyledButtonLink = styled.a({ | ||
marginBottom: 10, | ||
float: 'right', | ||
}) | ||
|
||
const BadgeWrapper = styled('div')` | ||
@media (min-width: ${BREAKPOINTS.TABLET}) { | ||
display: table-cell; | ||
} | ||
` | ||
|
||
const StyledDetails = styled(Details)` | ||
@media (min-width: ${BREAKPOINTS.TABLET}) { | ||
margin: 0 0 0 ${SPACING.SCALE_3}; | ||
} | ||
span, | ||
div { | ||
font-size: ${FONT_SIZE.SIZE_16}; | ||
} | ||
` | ||
|
||
const StyledDescription = styled('div')` | ||
padding: ${SPACING.SCALE_2}; | ||
background-color: ${GREY_3}; | ||
|
||
* + & { | ||
margin-top: ${SPACING.SCALE_3}; | ||
} | ||
|
||
p { | ||
margin-top: 0; | ||
margin-bottom: 0; | ||
|
||
&:not(:last-child) { | ||
margin-bottom: ${SPACING.SCALE_2}; | ||
} | ||
} | ||
|
||
& + * { | ||
margin-top: ${SPACING.SCALE_3}; | ||
} | ||
` | ||
|
||
const StyledMain = styled(Main)` | ||
padding-top: ${SPACING.SCALE_1}; | ||
div { | ||
font-size: ${FONT_SIZE.SIZE_20}; | ||
} | ||
` | ||
const StyledRelatedCompaniesWrapper = styled('div')` | ||
padding-bottom: 20px; | ||
` | ||
|
||
const isUltimate = (company) => !!company.isGlobalUltimate | ||
const isGlobalHQ = (company) => | ||
company.headquarterType && company.headquarterType.name === 'ghq' | ||
|
||
const hasAllocatedLeadIta = (company) => | ||
company.oneListGroupGlobalAccountManager != null | ||
|
||
const hasManagedAccountDetails = (company) => | ||
company.oneListGroupTier && hasAllocatedLeadIta(company) | ||
|
||
const CompanyLocalHeaderNew = ({ company, returnUrl, csrfToken }) => | ||
company && ( | ||
<> | ||
<GridRow> | ||
<GridCol setWidth="two-thirds"> | ||
{company?.tradingNames?.length > 0 && ( | ||
<LocalHeaderTradingNames data-test="trading-names"> | ||
Trading as: {company.tradingNames.join(', ')} | ||
</LocalHeaderTradingNames> | ||
)} | ||
|
||
<StyledAddress data-test="address"> | ||
{addressToStringResource(company.address)} | ||
</StyledAddress> | ||
<RelatedCompaniesCountResource id={company.id}> | ||
{({ relatedCompaniesCount }) => | ||
relatedCompaniesCount > 0 && ( | ||
<StyledRelatedCompaniesWrapper> | ||
<Link | ||
href={urls.companies.dnbHierarchy.tree(company.id)} | ||
data-test="company-tree-link" | ||
> | ||
{`View company tree: ${ | ||
relatedCompaniesCount + 1 | ||
} companies`} | ||
</Link> | ||
</StyledRelatedCompaniesWrapper> | ||
) | ||
} | ||
</RelatedCompaniesCountResource> | ||
</GridCol> | ||
<GridCol setWith="one-third"> | ||
<StyledButtonContainer> | ||
<Button | ||
as={StyledButtonLink} | ||
data-test="header-add-interaction" | ||
href={urls.companies.interactions.create(company.id)} | ||
aria-label={`Add interaction with ${company.name}`} | ||
> | ||
Add interaction | ||
</Button> | ||
<Button | ||
as={StyledButtonLink} | ||
data-test="header-add-export-project" | ||
href={urls.exportPipeline.create(company.id)} | ||
aria-label={`Add export project`} | ||
buttonColour={GREY_3} | ||
buttonTextColour={TEXT_COLOUR} | ||
> | ||
Add export project | ||
</Button> | ||
</StyledButtonContainer> | ||
</GridCol> | ||
</GridRow> | ||
<StyledList> | ||
<LocalHeaderCompanyLists company={company} returnUrl={returnUrl} /> | ||
<LocalHeaderCompanyRefer companyId={company.id} /> | ||
</StyledList> | ||
{(isUltimate(company) || isGlobalHQ(company)) && ( | ||
<TypeWrapper> | ||
<BadgeWrapper> | ||
<Badge> | ||
<BadgeText data-test="badge"> | ||
{isUltimate(company) ? 'Ultimate HQ' : 'Global HQ'} | ||
</BadgeText> | ||
</Badge> | ||
</BadgeWrapper> | ||
{isUltimate(company) && ( | ||
<StyledDetails | ||
summary="What does Ultimate HQ mean?" | ||
data-test="ultimate-hq-details" | ||
> | ||
This HQ is in control of all related company records for{' '} | ||
{company.name}. | ||
</StyledDetails> | ||
)} | ||
</TypeWrapper> | ||
)} | ||
{hasManagedAccountDetails(company) && ( | ||
<StyledDescription data-test="description"> | ||
{hasManagedAccountDetails(company) && ( | ||
<> | ||
<p> | ||
This is an account managed company (One List{' '} | ||
{company.oneListGroupTier.name}) | ||
</p> | ||
<p> | ||
{isItaTierDAccount(company.oneListGroupTier) | ||
? 'Lead ITA' | ||
: 'Global Account Manager'} | ||
: {company.oneListGroupGlobalAccountManager.name}{' '} | ||
<a href={urls.companies.accountManagement.index(company.id)}> | ||
{isItaTierDAccount(company.oneListGroupTier) | ||
? 'View Lead adviser' | ||
: 'View core team'} | ||
</a> | ||
</p> | ||
</> | ||
)} | ||
</StyledDescription> | ||
)} | ||
|
||
{company.archived && ( | ||
<ArchivePanel | ||
archivedBy={company.archivedBy} | ||
archivedOn={company.archivedOn} | ||
archiveReason={company.archivedReason} | ||
unarchiveUrl={`${urls.companies.unarchive( | ||
company.id | ||
)}?_csrf=${csrfToken}`} | ||
type="company" | ||
/> | ||
)} | ||
|
||
{company.pendingDnbInvestigation && ( | ||
<StyledMain data-test="investigation-message"> | ||
<StatusMessage> | ||
This company record is based on information that has not yet been | ||
validated. This information is currently being checked by the Data | ||
Hub support team. | ||
</StatusMessage> | ||
</StyledMain> | ||
)} | ||
</> | ||
) | ||
|
||
CompanyLocalHeaderNew.propTypes = { | ||
company: PropTypes.object.isRequired, | ||
returnUrl: PropTypes.string, | ||
} | ||
|
||
CompanyLocalHeaderNew.defaultProps = { | ||
returnUrl: null, | ||
} | ||
|
||
export default CompanyLocalHeaderNew |
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.
The changes to this file are very minimal when compared with the original version