refactor: v2 event types endpoint paths (#14545)

* refactor: rename event-types/:username/public to event-types/public/:username

* refactor: move /events/public to /event-types/public/:username/:eventSlug

* fix: remove EVENT_TYPE_READ permission from public GET event-types/public/:username

* docs: add response DTO to generate docs for /public/:username/:slug aka ex. events/public

* tests: public event types endpoints

* refactor: have /public at the end of event-types routes

* correct swagger doc
This commit is contained in:
Lauris Skraucis authored and GitHub committed 2024-04-13 12:47:35 +03:00
1 parent 296678046c
commit 8ad80f7ac3
10 files changed
+994 -236

No files matched your search

@@ -2,7 +2,7 @@ import { useQuery } from "@tanstack/react-query";
import { shallow } from "zustand/shallow";
import { useBookerStore } from "@calcom/features/bookings/Booker/store";
import { SUCCESS_STATUS } from "@calcom/platform-constants";
import { SUCCESS_STATUS, V2_ENDPOINTS } from "@calcom/platform-constants";
import type { PublicEventType } from "@calcom/platform-libraries";
import type { ApiResponse } from "@calcom/platform-types";
@@ -16,18 +16,22 @@ export const usePublicEvent = (props: { username: string; eventSlug: string }) =
const isTeamEvent = useBookerStore((state) => state.isTeamEvent);
const org = useBookerStore((state) => state.org);
const requestUsername = username ?? props.username;
const requestEventSlug = eventSlug ?? props.eventSlug;
const event = useQuery({
queryKey: [QUERY_KEY, username ?? props.username, eventSlug ?? props.eventSlug],
queryFn: () => {
return http
.get<ApiResponse<PublicEventType>>("/events/public", {
params: {
username: username ?? props.username,
eventSlug: eventSlug ?? props.eventSlug,
isTeamEvent,
org: org ?? null,
},
})
.get<ApiResponse<PublicEventType>>(
`/${V2_ENDPOINTS.eventTypes}/${requestUsername}/${requestEventSlug}/public`,
{
params: {
isTeamEvent,
org: org ?? null,
},
}
)
.then((res) => {
if (res.data.status === SUCCESS_STATUS) {
return res.data.data;
-25
View File
@@ -1,25 +0,0 @@
import { ApiProperty } from "@nestjs/swagger";
import { Transform } from "class-transformer";
import { IsBoolean, IsOptional, IsString } from "class-validator";
export class GetPublicEventInput {
@IsString()
@Transform(({ value }: { value: string }) => value.toLowerCase())
@ApiProperty({ required: true })
username!: string;
@IsString()
@ApiProperty({ required: true })
eventSlug!: string;
@Transform(({ value }: { value: string }) => value === "true")
@IsBoolean()
@IsOptional()
@ApiProperty({ required: false })
isTeamEvent?: boolean;
@ApiProperty({ required: false })
@IsString()
@IsOptional()
org?: string;
}
-1
View File
@@ -1,7 +1,6 @@
export * from "./permissions";
export * from "./api";
export * from "./oauth-clients";
export * from "./events";
export * from "./slots";
export * from "./calendars";
export * from "./schedules";