const { getContact } = require('../../contacts/repos')

function setInteractionsDetails (req, res, next) {
  res.locals.interactions = {
    returnLink: `/contacts/${req.params.contactId}/interactions/`,
    entityName: `${res.locals.contact.first_name} ${res.locals.contact.last_name}`,
    query: { contacts_id: req.params.contactId },
    view: 'contacts/views/interactions',
    canAdd: true,
  }

  next()
}

async function setCompanyDetails (req, res, next) {
  try {
    const contact = await getContact(req.session.token, req.params.contactId)
    res.locals.company = contact.company
    next()
  } catch (error) {
    next(error)
  }
}

module.exports = {
  setInteractionsDetails,
  setCompanyDetails,
}

@@ -303,16 +303,17 @@
 ontacts_
+_
 id: req.

Add missing underscore on query param to contacts