import { Controller, Get, Put, Body, UseGuards } from '@nestjs/common';
import { SettingsService } from './settings.service';
import { UpdateSettingsDto } from './dto/settings.dto';
import { AuthGuard } from 'src/auth/auth.guard';
import { RolesGuard } from 'src/guard/role.guard';
import { Roles } from 'src/guard/decorators/role.decorator';
import { UserType } from 'src/user/schema/users.schema';
import { ApiBearerAuth, ApiTags, ApiOperation, ApiBody, ApiResponse } from '@nestjs/swagger';

@ApiTags('Settings')
@Controller('settings')
export class SettingsController {
    constructor(private readonly settingsService: SettingsService) { }

    @Get()
    @ApiOperation({ summary: 'Get all settings' })
    @ApiResponse({ status: 200, description: 'Settings retrieved successfully' })
    async getSettings() {
        return this.settingsService.getSettings();
    }

    @Put()
    @UseGuards(AuthGuard, RolesGuard)
    @Roles(UserType.SUPER_ADMIN)
    @ApiBearerAuth('access_token')
    @ApiOperation({ summary: 'Update settings (payment gateway & commission)' })
    @ApiBody({ type: UpdateSettingsDto })
    @ApiResponse({ status: 200, description: 'Settings updated successfully' })
    async updateSettings(@Body() updateSettingsDto: UpdateSettingsDto) {
        return this.settingsService.updateSettings(updateSettingsDto);
    }
}
