const express = require('express');
const router = express.Router();
const subscriptionController = require('../controllers/subscriptionController');
const { authenticateJWT } = require('../middleware/authMiddleware');
// 구독 목록 조회
router.get('/', authenticateJWT, subscriptionController.getClubSubscriptions);

// 구독 플랜 관리 (관리자 전용)
router.get('/plans', authenticateJWT, subscriptionController.getSubscriptionPlans);
router.post('/plans', authenticateJWT, subscriptionController.createSubscriptionPlan);
router.put('/plans/:id', authenticateJWT, subscriptionController.updateSubscriptionPlan);
router.delete('/plans/:id', authenticateJWT, subscriptionController.deleteSubscriptionPlan);
router.get('/plans/:planId/subscriptions', authenticateJWT, subscriptionController.getPlanSubscriptions);

// 플랜 상세 정보 조회 (포함된 기능 포함)
router.get('/plans/:planId', authenticateJWT, subscriptionController.getPlanDetail);

// 클럽 구독 관리
router.post('/subscribe', authenticateJWT, subscriptionController.subscribeClub);
router.post('/clubs', authenticateJWT, subscriptionController.getClubSubscription);

// 클럽 구독 정보 및 결제 내역 (POST, 클럽 기준)
router.post('/current', authenticateJWT, subscriptionController.getCurrentSubscription);
router.post('/payments', authenticateJWT, subscriptionController.getSubscriptionPayments);
router.post('/change-with-features', authenticateJWT, subscriptionController.changeWithFeatures);

// 토스페이먼츠 결제 관련 라우트
router.post('/payment/request', authenticateJWT, subscriptionController.requestPayment);
router.post('/payment/success', subscriptionController.processPaymentSuccess);
router.post('/payment/fail', subscriptionController.processPaymentFail);

// 인앱 결제 영수증 검증 엔드포인트
router.post('/verify-receipt', authenticateJWT, subscriptionController.verifyReceipt);

module.exports = router;