From e7f1a829fdd1571d5e495e9e488d1725feebea2b Mon Sep 17 00:00:00 2001 From: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com> Date: Wed, 18 May 2022 23:05:49 +0200 Subject: [PATCH] save additional inputs as json + view details of booking (#2796) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * move custom inputs from description to own json object * show custom inputs on success page * fix type error * add custom inputs to email and webhook * add custom inputs to all emails * add values for custom inputs when rescheduling * add custom input everywhere description is shown * fix bug with boolean value * fix issues with null values * disable custom inputs and add notes for organizer * don't show custom input with empty string * don't show custom inputs with empty string in calender event and email * add link to booking details page * redirect to success page to see booking details * add functionality to cancel and reschedule booking * fix bookings that require confirmation * clean code * fix infinite lopp in useEffect of success page * show web conference details message when integration as location * improve design of cancelling event * clean code * disable darkmode for organizer on booking details page * fix dark mode for cancelling booking * fix build error * Fixes infinite loop * Fixes infinite loop * Fixes infinite loop * Update all Yarn dependencies (2022-05-16) (#2769) * Update all Yarn dependencies (2022-05-16) * Upgrade dependencies * Removes deprecated packages * Upgrades deps * Updates submodules * Update yarn.lock * Linting * Linting * Update website * Build fixes * TODO: fix this * Module resolving * Type fixes * Intercom fixes on SSG * Fixes infinite loop * Upgrades to React 18 * Type fixes * Locks node version to 14 * Upgrades daily-js * Readds missing types * Upgrades playwright * Noop when intercom is not installed * Update website * Removed yarn.lock in favor of monorepo Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> Co-authored-by: zomars * Create ci.yml * Update ci.yml * Reintroduces typescript-eslint Buckle up! * Type fixes * Update ci.yml * Update api * Update admin * Reusable inferSSRProps * Linting * Linting * Prisma fixes * Update ci.yml * Cache testing * Update e2e.yml * Update DatePicker.tsx * Update e2e.yml * Revert "Linting" This reverts commit adf817766e181ec42e7770fa9ea10c0bfc0e8b9b. * Revert "Linting" This reverts commit 1b59dacd644e20551e104a99685429e20e55215d. * Linting * Update e2e.yml * Ci updates * Add team Id to hash url (#2803) * Fix missing tabs - Embed (#2804) * Fix missing tabs * Fix Eslint error * Fix Eslint errors * Add import statement (#2812) * Add import statement * Update apps/docs/next.config.js Co-authored-by: Omar López * Show success page if booking was deleted on calendar (#2808) * Add exception to 410 * Fix type error * Add GoogelCalError type * only show invite link for app.cal.dev (#2807) Co-authored-by: CarinaWolli Co-authored-by: Omar López * fix: update eslint config to test .ts and .js separately (#2805) * fix: update eslint config * fix: update ts ignore * fix: update eslint config * Update TeamAvailabilityScreen.tsx * Type fixes * Update useIntercom.ts Co-authored-by: Omar López * fix: sync api to latest commit (#2810) Co-authored-by: Agusti Fernandez Pardo Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * Embed React improvements (#2782) * Add off support. Add getApi export. * Add publish command * Add embed-snippet in prod deps * Update README * Update package.json Co-authored-by: Bailey Pumfleet Co-authored-by: zomars Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> * Consolidates test-results * Type fixes * Abstracts minimal booking select * Type fixes * Update listBookings.ts * Update common.json * Update bookingReminder.ts * Consolidates isOutOfBounds * Update webhookResponse-chromium.txt * Update TableActions.tsx * Type fixes * Update BookingPage.tsx * Update webhookResponse-chromium.txt Co-authored-by: CarinaWolli Co-authored-by: Alex van Andel Co-authored-by: Bailey Pumfleet Co-authored-by: zomars Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com> Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Co-authored-by: Hariom Balhara Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Co-authored-by: iamkun Co-authored-by: Agusti Fernandez Pardo Co-authored-by: Agusti Fernandez Pardo Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../components/booking/BookingListItem.tsx | 64 ++++++++-- apps/web/components/booking/CancelBooking.tsx | 119 ++++++++++++++++++ apps/web/components/booking/DatePicker.tsx | 39 +----- .../components/booking/pages/BookingPage.tsx | 50 ++++---- apps/web/components/ui/TableActions.tsx | 26 ++-- .../api/integrations/stripepayment/webhook.ts | 13 +- .../attendee-awaiting-payment-email.ts | 2 + .../templates/attendee-cancelled-email.ts | 2 + .../templates/attendee-declined-email.ts | 2 + .../templates/attendee-request-email.ts | 2 + .../attendee-request-reschedule-email.ts | 2 + .../templates/attendee-rescheduled-email.ts | 3 + .../templates/attendee-scheduled-email.ts | 23 ++++ .../templates/organizer-cancelled-email.ts | 2 + .../organizer-payment-refund-failed-email.ts | 2 + .../templates/organizer-request-email.ts | 2 + .../organizer-request-reminder-email.ts | 2 + .../organizer-request-reschedule-email.ts | 2 + .../templates/organizer-rescheduled-email.ts | 2 + .../templates/organizer-scheduled-email.ts | 23 ++++ apps/web/lib/getBooking.tsx | 1 + apps/web/lib/isOutOfBounds.tsx | 40 ++++++ apps/web/lib/types/booking.ts | 2 +- apps/web/pages/api/book/confirm.ts | 11 +- apps/web/pages/api/book/event.ts | 47 +++---- apps/web/pages/api/cancel.ts | 12 +- apps/web/pages/api/cron/bookingReminder.ts | 11 +- apps/web/pages/cancel/[uid].tsx | 9 +- apps/web/pages/reschedule/[uid].tsx | 9 +- apps/web/pages/success.tsx | 85 ++++++++++--- apps/web/pages/video/[uid].tsx | 13 +- apps/web/pages/video/meeting-ended/[uid].tsx | 9 +- .../pages/video/meeting-not-started/[uid].tsx | 11 +- .../webhookResponse-chromium.txt | 2 +- apps/web/public/static/locales/en/common.json | 7 +- apps/web/server/routers/viewer.tsx | 12 +- .../zapier/api/subscriptions/listBookings.ts | 7 +- packages/lib/CalEventParser.ts | 25 +++- packages/lib/index.ts | 1 + packages/lib/isPrismaObj.ts | 11 ++ packages/prisma/index.ts | 3 + .../migration.sql | 2 + packages/prisma/schema.prisma | 1 + packages/prisma/selects/booking.ts | 11 ++ packages/prisma/selects/index.ts | 1 + packages/types/Calendar.d.ts | 3 +- 46 files changed, 521 insertions(+), 207 deletions(-) create mode 100644 apps/web/components/booking/CancelBooking.tsx create mode 100644 apps/web/lib/isOutOfBounds.tsx create mode 100644 packages/lib/index.ts create mode 100644 packages/lib/isPrismaObj.ts create mode 100644 packages/prisma/migrations/20220511095513_add_custom_inputs_to_booking/migration.sql create mode 100644 packages/prisma/selects/booking.ts create mode 100644 packages/prisma/selects/index.ts diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsx index 45492c72a6..28e97d498a 100644 --- a/apps/web/components/booking/BookingListItem.tsx +++ b/apps/web/components/booking/BookingListItem.tsx @@ -1,8 +1,15 @@ -import { BanIcon, CheckIcon, ClockIcon, XIcon, PencilAltIcon } from "@heroicons/react/outline"; -import { PaperAirplaneIcon } from "@heroicons/react/outline"; +import { + BanIcon, + CheckIcon, + ClockIcon, + PaperAirplaneIcon, + PencilAltIcon, + XIcon, +} from "@heroicons/react/outline"; import { RefreshIcon } from "@heroicons/react/solid"; import { BookingStatus } from "@prisma/client"; import dayjs from "dayjs"; +import { useRouter } from "next/router"; import { useState } from "react"; import { useMutation } from "react-query"; import { Frequency as RRuleFrequency } from "rrule"; @@ -17,7 +24,7 @@ import { TextArea } from "@calcom/ui/form/fields"; import { HttpError } from "@lib/core/http/error"; import useMeQuery from "@lib/hooks/useMeQuery"; import { parseRecurringDates } from "@lib/parseDate"; -import { inferQueryOutput, trpc, inferQueryInput } from "@lib/trpc"; +import { inferQueryInput, inferQueryOutput, trpc } from "@lib/trpc"; import { RescheduleDialog } from "@components/dialog/RescheduleDialog"; import TableActions, { ActionType } from "@components/ui/TableActions"; @@ -37,6 +44,7 @@ function BookingListItem(booking: BookingItemProps) { const user = query.data; const { t, i18n } = useLocale(); const utils = trpc.useContext(); + const router = useRouter(); const [rejectionReason, setRejectionReason] = useState(""); const [rejectionDialogIsOpen, setRejectionDialogIsOpen] = useState(false); const mutation = useMutation( @@ -81,7 +89,10 @@ function BookingListItem(booking: BookingItemProps) { booking.listingStatus === "upcoming" && booking.recurringEventId !== null ? t("reject_all") : t("reject"), - onClick: () => setRejectionDialogIsOpen(true), + onClick: (e) => { + e.stopPropagation(); + setRejectionDialogIsOpen(true); + }, icon: BanIcon, disabled: mutation.isLoading, }, @@ -91,7 +102,10 @@ function BookingListItem(booking: BookingItemProps) { booking.listingStatus === "upcoming" && booking.recurringEventId !== null ? t("confirm_all") : t("confirm"), - onClick: () => mutation.mutate(true), + onClick: (e) => { + e.stopPropagation(); + mutation.mutate(true); + }, icon: CheckIcon, disabled: mutation.isLoading, color: "primary", @@ -120,7 +134,10 @@ function BookingListItem(booking: BookingItemProps) { id: "reschedule_request", icon: ClockIcon, label: t("send_reschedule_request"), - onClick: () => setIsOpenRescheduleDialog(true), + onClick: (e) => { + e.stopPropagation(); + setIsOpenRescheduleDialog(true); + }, }, ], }, @@ -150,6 +167,7 @@ function BookingListItem(booking: BookingItemProps) { i18n ); } + return ( <> - + + router.push({ + pathname: "/success", + query: { + date: booking.startTime, + type: booking.eventType.id, + eventSlug: booking.eventType.slug, + user: user?.username || "", + name: booking.attendees[0].name, + email: booking.attendees[0].email, + location: booking.location + ? booking.location.includes("integration") + ? (t("web_conferencing_details_to_follow") as string) + : booking.location + : "", + eventName: booking.eventType.eventName || "", + bookingId: booking.id, + recur: booking.recurringEventId, + reschedule: booking.confirmed, + }, + }) + }>
{startTime}
@@ -264,9 +305,12 @@ function BookingListItem(booking: BookingItemProps) { )} {booking.attendees.length !== 0 && ( - + e.stopPropagation()}> + {booking.attendees[0].email} + )} {isCancelled && booking.rescheduled && (
diff --git a/apps/web/components/booking/CancelBooking.tsx b/apps/web/components/booking/CancelBooking.tsx new file mode 100644 index 0000000000..f71b18e16e --- /dev/null +++ b/apps/web/components/booking/CancelBooking.tsx @@ -0,0 +1,119 @@ +import { XIcon } from "@heroicons/react/solid"; +import { useRouter } from "next/router"; +import { useState } from "react"; + +import { useLocale } from "@calcom/lib/hooks/useLocale"; +import { Button } from "@calcom/ui/Button"; + +import useTheme from "@lib/hooks/useTheme"; +import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry"; + +type Props = { + booking: { + title?: string; + uid?: string; + }; + profile: { + name: string | null; + slug: string | null; + }; + team?: string | null; + setIsCancellationMode: (value: boolean) => void; + theme: string | null; +}; + +export default function CancelBooking(props: Props) { + const [cancellationReason, setCancellationReason] = useState(""); + const { t } = useLocale(); + const router = useRouter(); + const { booking, profile, team } = props; + const [loading, setLoading] = useState(false); + const telemetry = useTelemetry(); + const [error, setError] = useState(booking ? null : t("booking_already_cancelled")); + const { isReady, Theme } = useTheme(props.theme); + + if (isReady) { + return ( + <> + + {error && ( +
+
+ +
+
+ +
+
+ )} + {!error && ( +
+ +