const { transformApiResponseToSearchCollection } = require('../../../modules/search/transformers')
const { transformCompanyToSubsidiaryListItem } = require('../transformers')
const { getCompanySubsidiaries } = require('../repos')
const { companyDetailsLabels } = require('../labels')
const { ENTITIES } = require('../../search/constants')

async function renderSubsidiaries (req, res, next) {
  try {
    const token = req.session.token
    const query = req.query
    const page = query.page || '1'

    const {
      id: companyId,
      name: companyName,
    } = res.locals.company

    const actionButtons = [{
      label: companyDetailsLabels.link_a_subsidiary,
      url: `/companies/${companyId}/subsidiaries/link`,
    }]

    const subsidiaryCollection = await getCompanySubsidiaries(token, companyId, page)
      .then(transformApiResponseToSearchCollection(
        { query },
        ENTITIES,
        transformCompanyToSubsidiaryListItem,
      ))

    const subsidiaries = {
      ...subsidiaryCollection,
      actionButtons,
      countLabel: 'subsidiary',
    }

    return res
      .breadcrumb(companyName, `/companies/${companyId}`)
      .breadcrumb(companyDetailsLabels.subsidiaries)
      .render('companies/views/subsidiaries.njk', { subsidiaries })
  } catch (error) {
    next(error)
  }
}

module.exports = {
  renderSubsidiaries,
}

@@ -494,16 +494,17 @@
 %7C%7C '1'%0A%0A
+%0A
     cons
@@ -505,23 +505,46 @@
   const 
-%7B%0A     
+actionButtons = %5B%7B%0A    const %7B
  id: com
@@ -550,22 +550,16 @@
 mpanyId,
-%0A     
  name: c
@@ -573,65 +573,57 @@
 ame,
-%0A    %7D = res.locals.company%0A%0A    const actionButtons = %5B%7B
+ archived: companyArchived %7D = res.locals.company
 %0A   

Make variable declaration consistent