import { Router } from 'express';
import { AuthController } from '../controllers/auth.controller';

import { authenticate, requireRole } from '../middleware/auth.middleware';

const router = Router();
const authController = new AuthController();

router.post('/register', authController.register); // Keep for initial admin setup in dev
router.post('/login', authController.login);
router.post('/refresh', authController.refresh);

// Invite Flow
router.get('/me', authenticate, authController.getCurrentUser);
router.put('/profile', authenticate, authController.updateProfile);
router.post('/invite', authenticate, requireRole('ADMIN'), authController.invitePartner);
router.get('/invite/:token', authController.validateInvite);
router.post('/invite/accept', authController.acceptInvite);
router.get('/partners', authenticate, requireRole('ADMIN'), authController.listPartners);
router.put('/partners/:partnerId', authenticate, requireRole('ADMIN'), authController.updatePartner);
router.post('/partners/:partnerId/resend-invite', authenticate, requireRole('ADMIN'), authController.resendInvite);

export default router;
