import {
  Controller,
  Get,
  Put,
  Body,
  UseGuards,
  Request,
} from '@nestjs/common';
import { SettingsService } from './settings.service';
import { JwtAuthGuard } from '../common/guards/jwt-auth.guard';
import { RolesGuard } from '../common/guards/roles.guard';
import { Roles } from '../common/decorators/roles.decorator';

@Controller('school/settings')
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles('school')
export class SettingsController {
  constructor(private readonly settingsService: SettingsService) {}

  @Get()
  getSettings(@Request() req: any) {
    return this.settingsService.getSettings(req.user.tenantId);
  }

  @Put()
  updateSettings(
    @Request() req: any,
    @Body() data: {
      schoolName?: string;
      schoolLogo?: string;
      address?: string;
      notifyOnLesson?: boolean;
      notifyOnTask?: boolean;
      notifyOnGrowth?: boolean;
    },
  ) {
    return this.settingsService.updateSettings(req.user.tenantId, data);
  }
}
