import { Controller, Get, Post, Body, Param, Headers, Patch } from '@nestjs/common';
import { TodoService } from '../services/todo.service';

@Controller('todo')
export class TodoController {
  constructor(private readonly todoService: TodoService) {}

  @Post()
  async createTodo(
    @Headers('x-tenant-id') tenantId: string,
    @Body() dto: any,
  ) {
    return this.todoService.createTodo(tenantId, dto);
  }

  @Get()
  async listTodos(@Headers('x-tenant-id') tenantId: string) {
    return this.todoService.listTodos(tenantId);
  }

  @Patch(':id/complete')
  async completeTodo(
    @Headers('x-tenant-id') tenantId: string,
    @Param('id') id: string,
  ) {
    return this.todoService.markComplete(tenantId, id);
  }
}
