package com.example.demo.dashboard;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/dashboard")
public class DashboardController {

    private final DashboardService dashboardService;

    public DashboardController(DashboardService dashboardService) {
        this.dashboardService = dashboardService;
    }

    @GetMapping("/overview")
    public ResponseEntity<DashboardOverviewResponse> overview(
            @RequestHeader(name = "X-Shop-Id", required = false) Long shopId,
            @RequestHeader(name = "X-User-Id", required = false) Long userId
    ) {
        return ResponseEntity.ok(dashboardService.getOverviewByUserOrShop(userId, shopId));
    }
}



