import { Body, Controller, Post, Request, Headers } from "@nestjs/common";
import type { RequestWithUser } from "@bff/modules/auth/auth.types.js";
import { SimOrderActivationService } from "./sim-order-activation.service.js";
import { createZodDto } from "nestjs-zod";
import { simOrderActivationRequestSchema } from "@customer-portal/domain/sim";

class SimOrderActivationRequestDto extends createZodDto(simOrderActivationRequestSchema) {}

@Controller("subscriptions/sim/orders")
export class SimOrdersController {
  constructor(private readonly activation: SimOrderActivationService) {}

  @Post("activate")
  async activate(
    @Request() req: RequestWithUser,
    @Body() body: SimOrderActivationRequestDto,
    @Headers("x-idempotency-key") idempotencyKey?: string
  ) {
    const result = await this.activation.activate(req.user.id, body, idempotencyKey);
    return result;
  }
}
