import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  UseGuards,
  Put,
  Req,
} from '@nestjs/common';
import { UsersService } from './users.service';
import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { ApiBearerAuth } from '@nestjs/swagger';
import { DEFAULT_USER_ID } from 'src/constants/auth';
import { AuthGuard } from '@nestjs/passport';
// import { AuthGuard } from "../auth/auth.guard";

@Controller('')
// @ApiBearerAuth("defaultBearerAuth")
// @UseGuards(AuthGuard)
export class UsersController {
  constructor(private readonly usersService: UsersService) {}

  @UseGuards(AuthGuard('jwt'))
  @Get('me')
  getMe(@Req() req) {
    console.log({ req });
    return req.user;
  }

  @Post()
  create(@Body() createUserDto: CreateUserDto) {
    return this.usersService.create(createUserDto);
  }

  @Get('count')
  getUserCounts() {
    return this.usersService.getUserCounts();
  }

  @Post('all')
  findAll(@Body() createUserDto: any) {
    return this.usersService.findAll(createUserDto);
  }

  @Get('profile/:id')
  findOne(@Param('id') id: string) {
    return this.usersService.findOne(id);
  }

  @Put()
  edit(@Body() editUserDto: any) {
    return this.usersService.edit(editUserDto.id, editUserDto);
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateUserDto: UpdateUserDto) {
    // return this.usersService.update(id, updateUserDto);
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    // return this.usersService.remove(id);
  }

  @Post('update-status')
  async updateStatus(
    @Body() body: any,
    // @SessionData() sessionData: SessionDataProps,
  ) {
    return await this.usersService.updateStatus(String(DEFAULT_USER_ID), body);
  }
}
// @Controller('users')
// export class UsersController {
//   constructor(private service: UsersService) {}

//   @Post()
//   create(@Body() dto: CreateUserDto) {
//     return this.service.create(dto);
//   }

//   @Get()
//   findAll() {
//     return this.service.findAll();
//   }

//   @Get(':id')
//   findOne(@Param('id') id: number) {
//     return this.service.findOne(+id);
//   }

//   @Patch(':id')
//   update(@Param('id') id: number, @Body() dto: UpdateUserDto) {
//     return this.service.update(+id, dto);
//   }

//   @Delete(':id')
//   remove(@Param('id') id: number) {
//     return this.service.remove(+id);
//   }
// }
