// internal/controllers/manager_controller.go
package controllers

import (
    "lost-and-found/internal/models"
    "lost-and-found/internal/repositories"
    "lost-and-found/internal/utils"
    "net/http"

    "github.com/gin-gonic/gin"
    "gorm.io/gorm"
)

type ManagerController struct {
    itemRepo  *repositories.ItemRepository
    claimRepo *repositories.ClaimRepository
}

func NewManagerController(db *gorm.DB) *ManagerController {
    return &ManagerController{
        itemRepo:  repositories.NewItemRepository(db),
        claimRepo: repositories.NewClaimRepository(db),
    }
}

func (c *ManagerController) GetDashboardStats(ctx *gin.Context) {
    totalItems, _ := c.itemRepo.CountAll()
    pendingClaims, _ := c.claimRepo.CountByStatus(models.ClaimStatusPending)
    verifiedItems, _ := c.itemRepo.CountByStatus(models.ItemStatusVerified)
    expiredItems, _ := c.itemRepo.CountByStatus(models.ItemStatusExpired)

    stats := map[string]interface{}{
        "total_items":    totalItems,
        "pending_claims": pendingClaims,
        "verified":       verifiedItems,
        "expired":        expiredItems,
    }

    utils.SuccessResponse(ctx, http.StatusOK, "Manager dashboard stats", stats)
}