import express from 'express';
import {
  // Members
  getAllMembers,
  getMemberById,
  getMemberDetail,
  approveMember,
  rejectMember,
  addRemark,
  verifyRegistrationPayment,
  searchMember,
  updateMember,
  getDashboardStats,
  getAllTransactions,
  getAllWithdrawals,


} from '../controllers/adminController.js';
import { authenticateAdmin } from '../middleware/auth.js';
import { distributePPPIncomeController, getPPPIncomeHistory, getPPPIncomePreview } from '../controllers/admin/income.js';

const router = express.Router();

// ── Dashboard ────────────────────────────────
router.get('/dashboard', authenticateAdmin, getDashboardStats);

// ── Members ──────────────────────────────────
router.get( '/members',                                authenticateAdmin, getAllMembers);
router.get( '/members/:id',                            authenticateAdmin, getMemberById);
router.get( '/members/:memberId/detail',               authenticateAdmin, getMemberDetail);
router.put( '/members/:id/approve',                    authenticateAdmin, approveMember);
router.put( '/members/:id/reject',                     authenticateAdmin, rejectMember);
router.put( '/members/:id/remark',                     authenticateAdmin, addRemark);
router.put( '/members/:id/verify-payment',             authenticateAdmin, verifyRegistrationPayment);
router.get( '/search-member/:searchType/:searchValue', authenticateAdmin, searchMember);
router.put( '/update-member/:id',                      authenticateAdmin, updateMember);

router.get('/transactions',  authenticateAdmin, getAllTransactions);
router.get('/withdrawals',   authenticateAdmin, getAllWithdrawals);

// ── Partner Package Income (PPP) ─────────────
router.get( '/ppp-income/preview',    authenticateAdmin, getPPPIncomePreview);
router.post('/ppp-income/distribute', authenticateAdmin, distributePPPIncomeController);
router.get( '/ppp-income/history',    authenticateAdmin, getPPPIncomeHistory);

export default router;