import { Controller, Get, Put, Body, UseGuards } from '@nestjs/common';
import { AdminSettingsService } from './admin-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('admin/settings')
@UseGuards(JwtAuthGuard, RolesGuard)
@Roles('admin')
export class AdminSettingsController {
  constructor(private readonly settingsService: AdminSettingsService) {}

  @Get()
  async getAllSettings() {
    return this.settingsService.getSettings();
  }

  @Put()
  async updateSettings(@Body() data: Record<string, any>) {
    return this.settingsService.updateSettings(data);
  }

  @Get('basic')
  async getBasicSettings() {
    return this.settingsService.getBasicSettings();
  }

  @Put('basic')
  async updateBasicSettings(@Body() data: Record<string, any>) {
    return this.settingsService.updateSettings(data);
  }

  @Get('security')
  async getSecuritySettings() {
    return this.settingsService.getSecuritySettings();
  }

  @Put('security')
  async updateSecuritySettings(@Body() data: Record<string, any>) {
    return this.settingsService.updateSettings(data);
  }

  @Get('notification')
  async getNotificationSettings() {
    return this.settingsService.getNotificationSettings();
  }

  @Put('notification')
  async updateNotificationSettings(@Body() data: Record<string, any>) {
    return this.settingsService.updateSettings(data);
  }

  @Get('storage')
  async getStorageSettings() {
    return this.settingsService.getStorageSettings();
  }

  @Put('storage')
  async updateStorageSettings(@Body() data: Record<string, any>) {
    return this.settingsService.updateSettings(data);
  }

  @Get('tenant-defaults')
  async getTenantDefaults() {
    return this.settingsService.getTenantDefaults();
  }
}
