import { Controller, Get, UseGuards, Req } from '@nestjs/common';
import { Request } from 'express';
import { MaterialService } from './material.service';
import { AuthGuard } from '../auth/guards/auth.guard';
import { User } from '../user/user.entity';

@Controller('materials')
export class MaterialController {
  constructor(private readonly materialService: MaterialService) {}

  @Get()
  findAll() {
    return this.materialService.findAll();
  }

  @Get('inventory')
  @UseGuards(AuthGuard)
  getInventory(@Req() req: Request & { user: User }) {
    return this.materialService.getInventory(req.user);
  }
}
