import express from 'express';
import {
  // Authentication
  login,
  register,
  updateSqId,
  getSqId,
  getSyncId,
  
  // Master Data
  getTreeDetails,
  refreshSocietyRoad,
  getEnumerators,
  
  // Tree Survey
  storeTreeDetails,
  updateTreeDetails,
  getTreeDetailsByUserID,
  
  // QC
  getTreeDetailsForQC,
  qc,
  
  // Location Tracking
  submitLocation,
  saveTrackPath,
  getNearbyTrees,
  
  // Reports
  getExcelReport,
  getQcReport
} from '../controllers/mobileController.js';

/**
 * Mobile API Routes for Android Apps
 * Most routes are prefixed with /api/mobile/project/:treelogy_id
 * Login route is /api/mobile/project/login (no treelogy_id needed)
 */

const router = express.Router();

// Authentication Routes
router.post('/login', login); // No treelogy_id needed - determined from user mapping
router.post('/:treelogy_id/register', register);
router.post('/:treelogy_id/updateSqId', updateSqId);
router.post('/:treelogy_id/getSqId', getSqId);
router.post('/:treelogy_id/getSyncId', getSyncId);

// Master Data Routes
router.post('/:treelogy_id/treedetails', getTreeDetails);
router.post('/:treelogy_id/refreshsocietyroad', refreshSocietyRoad);
router.post('/:treelogy_id/getEnumerators', getEnumerators);

// Tree Survey Routes
router.post('/:treelogy_id/storetreedetails', storeTreeDetails);
router.post('/:treelogy_id/updatetreedetails', updateTreeDetails);
router.post('/:treelogy_id/getTreeDetailsByUserID', getTreeDetailsByUserID);

// QC Routes
router.post('/:treelogy_id/getTreeDetailsForQC', getTreeDetailsForQC);
router.post('/:treelogy_id/qc', qc);

// Location Tracking Routes
router.post('/:treelogy_id/submit_location', submitLocation);
router.post('/:treelogy_id/savetrackpath', saveTrackPath);
router.post('/:treelogy_id/getNearbyTrees', getNearbyTrees);

// Report Routes
router.post('/:treelogy_id/getExcelReport', getExcelReport); 
router.post('/:treelogy_id/getQcReport', getQcReport);

export default router;
