import { Body, Controller, Get, HttpCode, Post } from '@nestjs/common';
import { DemoLoginRequestSchema, type DemoLoginRequest } from '@siop/shared';
import { ZodValidationPipe } from '../../common/zod-validation.pipe';
import { AuthService } from '../auth.service';
import { Public } from '../public.decorator';

/** ADR-002 — ces routes n'existent que si DemoAuthModule est enregistré
 *  (DEMO_MODE=true) ; sinon : 404, vérifié par test e2e. */
@Controller('auth')
export class DemoAuthController {
  constructor(private readonly authService: AuthService) {}

  @Public()
  @Get('demo-accounts')
  listDemoAccounts() {
    return this.authService.listDemoAccounts();
  }

  @Public()
  @Post('demo-login')
  @HttpCode(200)
  demoLogin(
    @Body(new ZodValidationPipe(DemoLoginRequestSchema)) body: DemoLoginRequest,
  ) {
    return this.authService.demoLogin(body.userId);
  }
}
