feat: create new markNoShow endpoint (#15738)

* feat: create new markNoShow endpoint

* chore: add schema

* chore: update name

* chore: save progress

* refactor: improve code and types

* fix: unit test

* chore: improvements

* chore: move query to booking repository

* fix: type error
This commit is contained in:
Udit Takkar authored and GitHub committed 2024-08-07 15:16:31 +05:30
1 parent 3ab735ba9c
commit e075dcdeaa
13 files changed
+263 -115

No files matched your search

@@ -211,6 +211,7 @@ export class BookingsController {
@Permissions([BOOKING_WRITE])
@UseGuards(ApiAuthGuard)
async markNoShow(
@GetUser("id") userId: number,
@Body() body: MarkNoShowInput,
@Param("bookingUid") bookingUid: string
): Promise<MarkNoShowOutput> {
@@ -219,6 +220,7 @@ export class BookingsController {
bookingUid: bookingUid,
attendees: body.attendees,
noShowHost: body.noShowHost,
userId,
});
return { status: SUCCESS_STATUS, data: markNoShowResponse };
@@ -20,10 +20,6 @@ class HandleMarkNoShowData {
@IsOptional()
noShowHost?: boolean;
@IsString()
@IsOptional()
messageKey?: string;
@ValidateNested()
@Type(() => Attendee)
@IsArray()
@@ -668,12 +668,9 @@ const Attendee = (attendeeProps: AttendeeProps & NoShowProps) => {
const [openDropdown, setOpenDropdown] = useState(false);
const { copyToClipboard, isCopied } = useCopy();
const noShowMutation = trpc.viewer.public.noShow.useMutation({
const noShowMutation = trpc.viewer.markNoShow.useMutation({
onSuccess: async (data) => {
showToast(
t("messageKey" in data && data.messageKey ? data.messageKey : data.message, { x: name || email }),
"success"
);
showToast(data.message, "success");
},
onError: (err) => {
showToast(err.message, "error");
@@ -779,9 +776,9 @@ const GroupedAttendees = (groupedAttendeeProps: GroupedAttendeeProps) => {
};
});
const { t } = useLocale();
const noShowMutation = trpc.viewer.public.noShow.useMutation({
const noShowMutation = trpc.viewer.markNoShow.useMutation({
onSuccess: async (data) => {
showToast(t("messageKey" in data && data.messageKey ? data.messageKey : data.message), "success");
showToast(t(data.message), "success");
},
onError: (err) => {
showToast(err.message, "error");
@@ -178,7 +178,7 @@ export default function Success(props: PageProps) {
},
});
const noShowMutation = trpc.viewer.public.noShow.useMutation({
const hostNoShowMutation = trpc.viewer.public.markHostAsNoShow.useMutation({
onSuccess: async () => {
showToast("Thank you, feedback submitted", "success");
},
@@ -189,7 +189,7 @@ export default function Success(props: PageProps) {
useEffect(() => {
if (noShow) {
noShowMutation.mutate({ bookingUid: bookingInfo.uid, noShowHost: true });
hostNoShowMutation.mutate({ bookingUid: bookingInfo.uid, noShowHost: true });
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
+1 -1
View File
@@ -140,7 +140,7 @@ vi.mock("@calcom/trpc/react", () => ({
submitRating: {
useMutation: vi.fn(),
},
noShow: {
markHostAsNoShow: {
useMutation: vi.fn(),
},
},