Skip to content

Commit

Permalink
Merge pull request #6466 from uktrade/feature-merge/company-layout-re…
Browse files Browse the repository at this point in the history
…factoring

Company layout refactoring
  • Loading branch information
cgsunkel authored Jan 26, 2024
2 parents 761dbe5 + 1d5b9d9 commit 2fdde6c
Show file tree
Hide file tree
Showing 131 changed files with 1,478 additions and 1,843 deletions.
5 changes: 0 additions & 5 deletions src/apps/companies/__test__/router.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ describe('Company router', () => {
'/:companyId/unarchive',
'/:companyId',
'/:companyId/details',
'/:companyId/business-details',
'/:companyId/hierarchies/ghq/:globalHqId/add',
'/:companyId/hierarchies/ghq/remove',
'/:companyId/hierarchies/subsidiaries/:subsidiaryCompanyId/add',
'/:companyId/contacts',
'/:companyId/orders',
'/:companyId/manage-company-list',
'/:companyId/subsidiaries',
])
Expand Down
18 changes: 0 additions & 18 deletions src/apps/companies/apps/account-management/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,6 @@ const companyToLeadITA = ({ one_list_group_global_account_manager: leadITA }) =>
team: get(leadITA, 'dit_team.name'),
}

async function renderAccountManagement(req, res) {
const { company, dnbRelatedCompaniesCount, localNavItems, returnUrl } =
res.locals
const permissions = res.locals.user.permissions

res.render('companies/apps/account-management/views/client-container', {
props: {
dnbRelatedCompaniesCount,
permissions,
localNavItems: localNavItems,
flashMessages: res.locals.getMessages(),
companyId: company.id,
returnUrl: returnUrl,
},
})
}

// istanbul ignore next: Covered by functional tests
const form = (req, res) => {
const {
Expand Down Expand Up @@ -66,7 +49,6 @@ async function submit(req, res, next) {
}

module.exports = {
renderAccountManagement,
submit,
form,
}
7 changes: 1 addition & 6 deletions src/apps/companies/apps/account-management/router.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
const router = require('express').Router()

const urls = require('../../../../lib/urls')
const { submit, renderAccountManagement, form } = require('./controllers')
const { submit, form } = require('./controllers')
const { allPermissionsOr403 } = require('../../../../middleware/conditionals')

router.get(
urls.companies.accountManagement.index.route,
renderAccountManagement
)

router
.route([
urls.companies.accountManagement.advisers.assign.route,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ const router = require('../router')
describe('Activity feed routes', () => {
it('should define all routes', () => {
const paths = router.stack.filter((r) => r.route).map((r) => r.route.path)
expect(paths).to.deep.equal([
'/:companyId/activity',
'/:companyId/activity/data',
])
expect(paths).to.deep.equal(['/:companyId/activity/data'])
})
})

This file was deleted.

35 changes: 0 additions & 35 deletions src/apps/companies/apps/activity-feed/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,6 @@ const {
} = require('./transformers')
const dataHubCompanyActivityQuery = require('./es-queries/data-hub-company-activity-query')

async function renderActivityFeed(req, res, next) {
const { company, dnbHierarchyCount, dnbRelatedCompaniesCount } = res.locals

res.locals.title = `Activities - ${company.name} - Companies`

try {
const contentProps = company.archived
? {
companyId: company.id,
flashMessages: res.locals.getMessages(),
localNavItems: res.locals.localNavItems,
company,
}
: {
companyId: company.id,
flashMessages: res.locals.getMessages(),
isOverview: false,
localNavItems: res.locals.localNavItems,
dnbHierarchyCount,
dnbRelatedCompaniesCount,
company,
}

const props = {
...contentProps,
apiEndpoint: urls.companies.activity.data(company.id),
}

res.render('companies/apps/activity-feed/views/client-container', { props })
} catch (error) {
next(error)
}
}

function getContactFromEmailAddress(emailAddress, contacts) {
const contact = contacts.find((contact) => contact.email === emailAddress)
return contact
Expand Down Expand Up @@ -674,7 +640,6 @@ async function fetchAllActivityFeedEvents(req, res, next) {
}

module.exports = {
renderActivityFeed,
fetchActivityFeedHandler,
fetchActivitiesForContact,
fetchAventriEvent,
Expand Down
6 changes: 1 addition & 5 deletions src/apps/companies/apps/activity-feed/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ const router = require('express').Router()

const urls = require('../../../../lib/urls')
const { convertQueryTypes } = require('./translators')
const {
renderActivityFeed,
fetchActivityFeedHandler,
} = require('./controllers')
const { fetchActivityFeedHandler } = require('./controllers')

router.get(urls.companies.activity.index.route, renderActivityFeed)
router.get(
urls.companies.activity.data.route,
convertQueryTypes,
Expand Down
10 changes: 0 additions & 10 deletions src/apps/companies/apps/activity-feed/views/client-container.njk

This file was deleted.

This file was deleted.

Loading

0 comments on commit 2fdde6c

Please sign in to comment.