* fix: event-types input service transform length property * feat: create organizations event-types controller, service and repository * feat: enable organizations event types * fix: create team request user isOrgAdmin check * refactor: hosts array required in team input and output * chore: use platform-libraries at version 0.0.19 * tests: test organizations event-types * feat: enable managed event-types * chore: fix main merge into this branch * feat: assign all team members for managed event-types * refactor: gathering managed event-type users ids * chore: include assignAllTeamMembers in team event response * test: assign all team members db event * chore: delete unused files * docs: swagger create and update request body objects * revert: event-types platform-libraries update * refactor: organisations event-types endpoints accessible by TEAM_ADMIN and up * fix: managed event types output hosts array empty * fix: dont allow creating event-type for non-team member * chore: delete unused variables * tests: negative tests * chore: finish main merge
72 lines
2.1 KiB
TypeScript
72 lines
2.1 KiB
TypeScript
import { API_VERSIONS_VALUES } from "@/lib/api-versions";
|
|
import { SlotsService } from "@/modules/slots/services/slots.service";
|
|
import { Query, Body, Controller, Get, Delete, Post, Req, Res } from "@nestjs/common";
|
|
import { ApiTags as DocsTags } from "@nestjs/swagger";
|
|
import { Response as ExpressResponse, Request as ExpressRequest } from "express";
|
|
|
|
import { SUCCESS_STATUS } from "@calcom/platform-constants";
|
|
import { getAvailableSlots } from "@calcom/platform-libraries-0.0.19";
|
|
import type { AvailableSlotsType } from "@calcom/platform-libraries-0.0.19";
|
|
import { RemoveSelectedSlotInput, ReserveSlotInput } from "@calcom/platform-types";
|
|
import { ApiResponse, GetAvailableSlotsInput } from "@calcom/platform-types";
|
|
|
|
@Controller({
|
|
path: "/v2/slots",
|
|
version: API_VERSIONS_VALUES,
|
|
})
|
|
@DocsTags("Slots")
|
|
export class SlotsController {
|
|
constructor(private readonly slotsService: SlotsService) {}
|
|
|
|
@Post("/reserve")
|
|
async reserveSlot(
|
|
@Body() body: ReserveSlotInput,
|
|
@Res({ passthrough: true }) res: ExpressResponse,
|
|
@Req() req: ExpressRequest
|
|
): Promise<ApiResponse<string>> {
|
|
const uid = await this.slotsService.reserveSlot(body, req.cookies?.uid);
|
|
|
|
res.cookie("uid", uid);
|
|
return {
|
|
status: SUCCESS_STATUS,
|
|
data: uid,
|
|
};
|
|
}
|
|
|
|
@Delete("/selected-slot")
|
|
async deleteSelectedSlot(
|
|
@Query() params: RemoveSelectedSlotInput,
|
|
@Req() req: ExpressRequest
|
|
): Promise<ApiResponse> {
|
|
const uid = req.cookies?.uid || params.uid;
|
|
|
|
await this.slotsService.deleteSelectedslot(uid);
|
|
|
|
return {
|
|
status: SUCCESS_STATUS,
|
|
};
|
|
}
|
|
|
|
@Get("/available")
|
|
async getAvailableSlots(
|
|
@Query() query: GetAvailableSlotsInput,
|
|
@Req() req: ExpressRequest
|
|
): Promise<ApiResponse<AvailableSlotsType>> {
|
|
const isTeamEvent = await this.slotsService.checkIfIsTeamEvent(query.eventTypeId);
|
|
const availableSlots = await getAvailableSlots({
|
|
input: {
|
|
...query,
|
|
isTeamEvent,
|
|
},
|
|
ctx: {
|
|
req,
|
|
},
|
|
});
|
|
|
|
return {
|
|
data: availableSlots,
|
|
status: SUCCESS_STATUS,
|
|
};
|
|
}
|
|
}
|