import { Controller, Post, Param, Get, UseGuards } from "@nestjs/common";
import { ApiBearerAuth, ApiTags } from "@nestjs/swagger";

import { SocialPosterService } from "./social-poster.service";
import { Roles } from "../../common/decorators";
import { RolesGuard } from "../auth/guards/auth.guards";

@ApiTags("Social Poster")
@ApiBearerAuth()
@UseGuards(RolesGuard)
@Roles("superadmin")
@Controller("social-poster")
export class SocialPosterController {
  constructor(private readonly socialPosterService: SocialPosterService) {}

  @Get("preview/:matchId")
  async previewCard(@Param("matchId") matchId: string) {
    return this.socialPosterService.renderPreview(matchId);
  }

  @Post("post/:matchId")
  async postMatch(@Param("matchId") matchId: string) {
    return this.socialPosterService.manualPost(matchId);
  }
}
