package com.davos.assessment.legal;

import com.davos.assessment.project.Project;
import com.davos.assessment.project.ProjectAccessService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/api/legal/public", "/api/projects/{slug}/legal/public"})
public class PublicLegalController {
  private final LegalService legalService;
  private final ProjectAccessService projectAccessService;

  public PublicLegalController(LegalService legalService, ProjectAccessService projectAccessService) {
    this.legalService = legalService;
    this.projectAccessService = projectAccessService;
  }

  @GetMapping("/combined")
  public LegalService.LegalBundle combined() {
    Project project = projectAccessService.findEnabledProject(projectAccessService.currentSlugOrDefault());
    return legalService.currentBundle(project);
  }
}
