/**
 * ==========================================================
 * Smart Attendance System
 * Attendance Routes
 * ==========================================================
 */

const express = require("express");

const router = express.Router();

const AttendanceController = require("./controller");

const asyncHandler = require("../../middleware/asyncHandler");

const deviceAuth = require("../../middleware/device.auth");

/**
 * ======================================================
 * Attendance Device APIs
 * ======================================================
 */

/**
 * Mark Attendance
 * POST /api/attendance/mark
 */

router.post(

    "/mark",

    deviceAuth,

    asyncHandler(

        AttendanceController.markAttendance

    )

);

/**
 * ======================================================
 * Web APIs
 * ======================================================
 */

/**
 * Checkout
 * POST /api/attendance/checkout
 */

router.post(

    "/checkout",

    asyncHandler(

        AttendanceController.checkout

    )

);

/**
 * Dashboard Statistics
 * GET /api/attendance/statistics
 */

router.get(

    "/statistics",

    asyncHandler(

        AttendanceController.statistics

    )

);

/**
 * Today's Attendance
 * GET /api/attendance/today
 */

router.get(

    "/today",

    asyncHandler(

        AttendanceController.todayAttendance

    )

);

/**
 * Student Attendance History
 * GET /api/attendance/student/:id
 */

router.get(

    "/student/:id",

    asyncHandler(

        AttendanceController.studentHistory

    )

);

/**
 * Monthly Attendance Report
 * GET /api/attendance/monthly
 */

router.get(

    "/monthly",

    asyncHandler(

        AttendanceController.monthlyReport

    )

);

module.exports = router;