import { Body, Controller, Get, Post, Query } from "@nestjs/common";
import { AccountService } from "./account.service";
import { 
  CheckDuplicationRequest, CheckDuplicationResponse,
  SendVerificationCodeRequest, SendVerificationCodeResponse,
  VerifyCodeRequest, VerifyCodeResponse,
  LoginRequest, LoginResponse,
  SignupRequest, SignupResponse
} from "./dto";

@Controller('account')
export class AccountController {
  constructor(private readonly accountService: AccountService) {}

  @Get('/')
  async test() {
    return "Test"
  }

  @Get('check-duplication')
  async checkDuplication(@Query() query: CheckDuplicationRequest): Promise<CheckDuplicationResponse> {
    return await this.accountService.checkDuplication(query);
  }

  @Post('send-verification-code')
  async sendVerificationCode(@Body() body: SendVerificationCodeRequest): Promise<SendVerificationCodeResponse> {
    const result = await this.accountService.sendVerificationCode(body);
    return result;
  }

  @Post('verify-code')
  async verifyCode(@Body() body: VerifyCodeRequest): Promise<VerifyCodeResponse> {
    console.log(body.email);
    const result = await this.accountService.verifyCode(body);
    return result;
  }

  @Post('signup')
  async signup(@Body() body: SignupRequest): Promise<LoginResponse> {
    const result = await this.accountService.signup(body);
    return result;
  }
}