import { Router } from 'express'
import { parseBody } from '../../http/validate'
import { created } from '../../http/respond'
import { companySignupSchema } from './auth.company.schemas'
import * as service from './auth.company.service'

const router = Router()

router.post('/signup', async (req, res, next) => {
  try {
    const body = parseBody(companySignupSchema, req)
    created(res, await service.signup(body))
  } catch (err) { next(err) }
})

router.post('/complete-signup', (_req, res) => {
  service.completeSignupDisabled()
  res.end()
})

router.post('/verify-email', (_req, res) => {
  service.verifyEmailDisabled()
  res.end()
})

export default router
