Skip to content

Commit

Permalink
Merge pull request #21 from poojakarma/search_event_api
Browse files Browse the repository at this point in the history
PS-1012 : Delete Event by ID [status update]
  • Loading branch information
vaivk369 authored Aug 6, 2024
2 parents f487240 + 0cb885b commit c01c827
Show file tree
Hide file tree
Showing 4 changed files with 329 additions and 167 deletions.
2 changes: 1 addition & 1 deletion src/modules/event/dto/search-event.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class FilterDto {
@IsString()
title?: string;

@ApiProperty({ example: 'CohortId', description: 'CohortId' })
@ApiProperty({ example: 'CohortId', description: 'Cohort' })
@IsOptional()
@IsUUID('4')
cohortId?: string;
Expand Down
354 changes: 195 additions & 159 deletions src/modules/event/dto/update-event.dto.ts
Original file line number Diff line number Diff line change
@@ -1,181 +1,217 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsNotEmpty, IsOptional, IsString, IsUUID, IsEnum, IsLongitude, IsLatitude, IsBoolean, IsInt, Min, IsDateString, IsObject } from 'class-validator';
import { IsNotEmpty, IsOptional, IsString, IsUUID, IsEnum, IsLongitude, IsLatitude, IsBoolean, IsInt, Min, IsDateString, IsObject, ValidateIf, ValidateNested } from 'class-validator';
import { MeetingDetails } from "src/common/utils/types";
import { MeetingDetailsDto } from "./create-event.dto";
import { Type } from "class-transformer";

export class UpdateEventDto {

@ApiProperty({
type: String,
description: 'title',
example: 'Sample Event'
})
@IsString()
@IsNotEmpty()
@IsOptional()
title?: string;
// @ApiProperty({
// type: String,
// description: 'title',
// example: 'Sample Event'
// })
// @IsString()
// @IsNotEmpty()
// @IsOptional()
// title?: string;

@ApiProperty({
type: String,
description: 'Short Description',
example: 'This is a sample event',
required: false,
})
@IsString()
@IsNotEmpty()
@IsOptional()
shortDescription?: string;

@ApiProperty({
type: String,
description: 'Description',
example: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
description: 'Status',
example: 'live'
})
@IsString()
@IsNotEmpty()
@IsOptional()
description: string;


@ApiProperty({
type: String,
description: 'image',
example: 'https://example.com/sample-image.jpg'
@IsEnum(['live', 'draft', 'archived'], {
message: 'Status must be one of: live, draft, archived',
})
@IsString()
@IsNotEmpty()
@IsOptional()
image: string;

@ApiProperty({
type: String,
description: 'Event Type',
example: 'online'
})
@IsEnum(['online', 'offline', 'onlineandoffline'], {
message: 'Event Type must be one of: online, offline, onlineandoffline'
}
)
@IsString()
@IsNotEmpty()
@IsOptional()
eventType: string;
status: string;

@ApiProperty({
type: String,
description: 'isRestricted',
description: 'isRecurring',
example: true
})
@IsBoolean()
@IsOptional()
isRestricted: boolean;

@ApiProperty({
type: String,
description: 'Start Datetime',
example: '2024-03-18T10:00:00Z'
})
@IsDateString()
@IsOptional()
startDatetime: Date;

@ApiProperty({
type: String,
description: 'End Datetime',
example: '2024-03-18T10:00:00Z'
})
@IsDateString()
@IsOptional()
endDatetime: Date;

@ApiProperty({
type: String,
description: 'Location',
example: 'Event Location'
})
@IsString()
@IsNotEmpty()
@IsOptional()
location: string;


@ApiProperty({
type: Number,
description: 'Latitude',
example: 18.508345134886994
})
@IsLongitude()
@IsOptional()
longitude: number;

@ApiProperty({
type: Number,
description: 'Latitude',
example: 18.508345134886994
})
@IsLatitude()
@IsOptional()
latitude: number;

@ApiProperty({
type: String,
description: 'Online Provider',
example: 'Zoom'
})
@IsString()
@IsNotEmpty()
@IsOptional()
onlineProvider: string;

@ApiProperty({
type: String,
description: 'Registration Deadline',
example: '2024-03-18T10:00:00Z'
})
@IsDateString()
@IsOptional()
registrationDeadline: Date;

@ApiProperty({
type: Number,
description: 'Max Attendees',
example: 100
})
@IsInt()
@IsOptional()
@Min(0)
maxAttendees: number;

@ApiProperty({
type: Object,
description: 'Params',
// example: { cohortIds: ['eff008a8-2573-466d-b877-fddf6a4fc13e', 'e9fec05a-d6ab-44be-bfa4-eaeef2ef8fe9'] },
// example: { userIds: ['eff008a8-2573-466d-b877-fddf6a4fc13e', 'e9fec05a-d6ab-44be-bfa4-eaeef2ef8fe9'] },
example: { cohortIds: ['eff008a8-2573-466d-b877-fddf6a4fc13e'] },
})
@IsObject()
@IsOptional()
params: any;

@ApiProperty({
type: Object,
description: 'Recordings',
example: { url: 'https://example.com/recording' }
})
@IsObject()
@IsOptional()
recordings: any;

@ApiProperty({
type: String,
description: 'Status',
example: 'live'
})
@IsEnum(['live', 'draft', 'inActive'], {
message: 'Status must be one of: live, draft, inActive',
})
@IsString()
@IsOptional()
@IsNotEmpty()
status: string;
isMainEvent: boolean;

// @ApiProperty({
// type: MeetingDetailsDto,
// description: 'Online Meeting Details',
// example: {
// url: 'https://example.com/meeting',
// id: '123-456-789',
// password: 'xxxxxxx',
// },
// })
// @IsObject()
// @ValidateNested({ each: true })
// @IsOptional()
// @Type(() => MeetingDetailsDto)
// meetingDetails: MeetingDetails;

// Validation to ensure if isMainEvent is true, title or status must be provided
@ValidateIf(o => !o.title && !o.status && !o.onlineDetails && !o.location && !o.latitude) // Ensure that if neither title nor status is provided, validation fails
@IsNotEmpty({ message: 'If isMainEvent is provided, at least one of title or status must be provided.' })
dummyField?: any;


// @ApiProperty({
// type: String,
// description: 'Event Type',
// example: 'online'
// })
// @IsEnum(['online', 'offline', 'onlineandoffline'], {
// message: 'Event Type must be one of: online, offline, onlineandoffline'
// }
// )
// @IsString()
// @IsNotEmpty()
// @IsOptional()
// eventType: string;



// @ApiProperty({
// type: String,
// description: 'Start Datetime',
// example: '2024-03-18T10:00:00Z'
// })
// @IsDateString()
// @IsOptional()
// startDatetime: Date;

// @ApiProperty({
// type: String,
// description: 'End Datetime',
// example: '2024-03-18T10:00:00Z'
// })
// @IsDateString()
// @IsOptional()
// endDatetime: Date;

// @ApiProperty({
// type: String,
// description: 'Location',
// example: 'Event Location'
// })
// @IsString()
// @IsNotEmpty()
// @IsOptional()
// location: string;


// @ApiProperty({
// type: Number,
// description: 'Latitude',
// example: 18.508345134886994
// })
// @IsLongitude()
// @IsOptional()
// longitude: number;

// @ApiProperty({
// type: Number,
// description: 'Latitude',
// example: 18.508345134886994
// })
// @IsLatitude()
// @IsOptional()
// latitude: number;


// @ApiProperty({
// type: String,
// description: 'Short Description',
// example: 'This is a sample event',
// required: false,
// })
// @IsString()
// @IsNotEmpty()
// @IsOptional()
// shortDescription?: string;

// @ApiProperty({
// type: String,
// description: 'Description',
// example: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
// })
// @IsString()
// @IsNotEmpty()
// @IsOptional()
// description: string;


// @ApiProperty({
// type: String,
// description: 'image',
// example: 'https://example.com/sample-image.jpg'
// })
// @IsString()
// @IsNotEmpty()
// @IsOptional()
// image: string;

// @ApiProperty({
// type: String,
// description: 'Online Provider',
// example: 'Zoom'
// })
// @IsString()
// @IsNotEmpty()
// @IsOptional()
// onlineProvider: string;

// @ApiProperty({
// type: String,
// description: 'Registration Deadline',
// example: '2024-03-18T10:00:00Z'
// })
// @IsDateString()
// @IsOptional()
// registrationDeadline: Date;

// @ApiProperty({
// type: Number,
// description: 'Max Attendees',
// example: 100
// })
// @IsInt()
// @IsOptional()
// @Min(0)
// maxAttendees: number;

// @ApiProperty({
// type: Object,
// description: 'Params',
// // example: { cohortIds: ['eff008a8-2573-466d-b877-fddf6a4fc13e', 'e9fec05a-d6ab-44be-bfa4-eaeef2ef8fe9'] },
// // example: { userIds: ['eff008a8-2573-466d-b877-fddf6a4fc13e', 'e9fec05a-d6ab-44be-bfa4-eaeef2ef8fe9'] },
// example: { cohortIds: ['eff008a8-2573-466d-b877-fddf6a4fc13e'] },
// })
// @IsObject()
// @IsOptional()
// params: any;

// @ApiProperty({
// type: Object,
// description: 'Recordings',
// example: { url: 'https://example.com/recording' }
// })
// @IsObject()
// @IsOptional()
// recordings: any;

// @ApiProperty({
// type: String,
// description: 'isRestricted',
// example: true
// })
// @IsBoolean()
// @IsOptional()
// isRestricted: boolean;


@IsString()
Expand Down
Loading

0 comments on commit c01c827

Please sign in to comment.