Skip to content
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 business details page to React Router #6416

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/apps/companies/__test__/router.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ 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',
Expand Down

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions src/apps/companies/apps/business-details/client/reducer.js

This file was deleted.

29 changes: 0 additions & 29 deletions src/apps/companies/apps/business-details/controllers.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/apps/companies/apps/business-details/router.js

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions src/apps/companies/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ const QUERY_FIELDS = Object.values(QUERY_FIELDS_MAP)
const NONE_TEXT = 'None'
const NOT_SET_TEXT = 'Not set'
const NOT_AVAILABLE_TEXT = 'Not available'
const COMPANY_DISSOLVED_OPTION = 'Company is dissolved'

module.exports = {
GLOBAL_NAV_ITEM,
Expand All @@ -92,5 +91,4 @@ module.exports = {
NONE_TEXT,
NOT_SET_TEXT,
NOT_AVAILABLE_TEXT,
COMPANY_DISSOLVED_OPTION,
}
21 changes: 0 additions & 21 deletions src/apps/companies/labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,6 @@ const exportPotentialLabels = {
},
}

const exportSegmentsLabels = {
hep: 'High export potential',
'non-hep': 'Not high export potential',
}
const exportSubSegmentsLabels = {
sustain_nurture_and_grow: 'Sustain: nurture & grow',
sustain_develop_export_capability: 'Sustain: develop export capability',
sustain_communicate_benefits: 'Sustain: communicate benefits',
sustain_increase_competitiveness: 'Sustain: increase competitiveness',
reassure_nurture_and_grow: 'Reassure: nurture & grow',
reassure_develop_export_capability: 'Reassure: develop export capability',
reassure_leave_be: 'Reassure: leave be',
reassure_change_the_game: 'Reassure: change the game',
promote_develop_export_capability: 'Promote: develop export capability',
promote_communicate_benefits: 'Promote: communicate benefits',
promote_change_the_game: 'Promote: change the game',
challenge: 'Challenge',
}

module.exports = {
companyDetailsLabels,
companyTypeOptions,
Expand All @@ -132,6 +113,4 @@ module.exports = {
aboutLabels,
businessHierarchyLabels,
exportPotentialLabels,
exportSegmentsLabels,
exportSubSegmentsLabels,
}
41 changes: 0 additions & 41 deletions src/apps/companies/middleware/hierarchies.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,6 @@ function transformErrorMessage(error) {
return get(error, 'global_headquarters', ['There has been an error'])[0]
}

async function setGlobalHQ(req, res, next) {
const companyId = req.params.companyId
const globalHqId = req.params.globalHqId
const body = { global_headquarters: globalHqId }
const detailsUrl = `/companies/${companyId}/business-details`

try {
await updateCompany(req, companyId, body)

req.flash('success', 'You’ve linked the Global Headquarters')
return res.redirect(detailsUrl)
} catch (error) {
if (error.statusCode === 400) {
req.flash('error', transformErrorMessage(error.error))
return res.redirect(detailsUrl)
}
next(error)
}
}

async function removeGlobalHQ(req, res, next) {
const companyId = req.params.companyId
const body = { global_headquarters: null }
const detailsUrl = `/companies/${companyId}/business-details`

try {
await updateCompany(req, companyId, body)

req.flash('success', 'You’ve removed the link to Global Headquarters')
return res.redirect(detailsUrl)
} catch (error) {
if (error.statusCode === 400) {
req.flash('error', transformErrorMessage(error.error))
return res.redirect(detailsUrl)
}
next(error)
}
}

async function addSubsidiary(req, res, next) {
const { companyId, subsidiaryCompanyId } = req.params
const body = { global_headquarters: companyId }
Expand All @@ -64,7 +25,5 @@ async function addSubsidiary(req, res, next) {
}

module.exports = {
setGlobalHQ,
removeGlobalHQ,
addSubsidiary,
}
Loading