import { Router } from 'express'
import { parseBody } from '../../http/validate'
import { created, ok } from '../../http/respond'
import { accountStartSchema } from './auth.account.schemas'
import * as service from './auth.account.service'

const router = Router()

/**
 * POST /api/v1/auth/account/start
 *
 * Minimal signup — Step 0 of progressive profiling.
 * Creates a DRAFT company + OWNER employee and sends a verification email.
 * The user must verify their email before signing in.
 */
router.post('/start', async (req, res, next) => {
  try {
    const body = parseBody(accountStartSchema, req)
    const result = await service.startAccount(body)
    created(res, result)
  } catch (err) { next(err) }
})

export default router
