Commit 30be624d authored by Diego Iván's avatar Diego Iván
Browse files

agregando mensaje de confirmacion al crear un Place

parent b5ee99bd
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ import {
} from '@nestjs/common';
import { PlaceService } from './place.service';
import { CreatePlaceDateTradDto } from './dto/create-place-date.dto';
import { ApiBearerAuth, ApiBody, ApiConsumes, ApiParam, ApiQuery, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiBody, ApiConsumes, ApiParam, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger';
import { Roles } from 'src/auth/role.decorator';
import { ALL_ROLES } from 'src/shared/enum/admin-role.enum';
import { fileInterceptor } from 'src/shared/interceptors/file-save.interceptor';
@@ -23,6 +23,7 @@ import { LANGUAGES } from 'src/shared/enum/languages.enum';
import { CustomAdminRequest } from 'src/auth/admin/interface/customAdminReq';
import { UpdatePlaceReqDto } from './dto/update-place.req.dto';
import { AuthAdminGuard } from 'src/auth/admin/authAdmin.guard';
import { GetPlaceDto } from './dto/get-place.dto';

@Controller('place')
@ApiTags('Place')
@@ -31,6 +32,7 @@ export class PlaceController {

  @ApiBody({ type: CreatePlaceDateTradDto })
  @ApiConsumes('multipart/form-data')
  @ApiResponse({ type: GetPlaceDto, status: 201, description: 'Created' })
  @UseGuards(AuthAdminGuard)
  @Roles([ALL_ROLES.ADMIN])
  @ApiBearerAuth('jwt')
@@ -46,7 +48,8 @@ export class PlaceController {
        throw new UnauthorizedException('This is not your assigned town');
      }
      createPlaceDto.image = file;
      return await this.placeService.create(createPlaceDto);
      await this.placeService.create(createPlaceDto);
      return { message: 'Place created successfully' };
    } catch (e) {
      throw e;
    }
@@ -83,13 +86,12 @@ export class PlaceController {
    @Req() req: CustomAdminRequest,
  ) {
    try {
      const place = await this.placeService.findOne(idPlace);
      console.log({ place });
      if (req.admin.idTown.townId != updatePlaceReqDto.idTown) {
        throw new UnauthorizedException('This is not your assigned town');
      }
      updatePlaceReqDto.image = file;
      return await this.placeService.update(idPlace, updatePlaceReqDto);
      await this.placeService.update(idPlace, updatePlaceReqDto);
      return { message: 'Place updated successfully' };
    } catch (e) {
      throw e;
    }