Skip to content

Commit

Permalink
Merge branch 'main' into 5336-cal-307-google-calendar-connection-send…
Browse files Browse the repository at this point in the history
…s-cancellation-emails-as-new-seats-are-booked
  • Loading branch information
emrysal authored Nov 5, 2022
2 parents 1398a1e + 7517feb commit 4af5a77
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 23 deletions.
8 changes: 4 additions & 4 deletions apps/web/lib/app-providers.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TooltipProvider } from "@radix-ui/react-tooltip";
import { SessionProvider } from "next-auth/react";
import { EventCollectionProvider } from "next-collect/client";
import { appWithTranslation } from "next-i18next";
import { appWithTranslation, SSRConfig } from "next-i18next";
import { ThemeProvider } from "next-themes";
import type { AppProps as NextAppProps, AppProps as NextJsAppProps } from "next/app";
import { NextRouter } from "next/router";
Expand All @@ -14,9 +14,9 @@ import { MetaProvider } from "@calcom/ui/v2/core/Meta";

import usePublicPage from "@lib/hooks/usePublicPage";

const I18nextAdapter = appWithTranslation<NextJsAppProps & { children: React.ReactNode }>(({ children }) => (
<>{children}</>
));
const I18nextAdapter = appWithTranslation<NextJsAppProps<SSRConfig> & { children: React.ReactNode }>(
({ children }) => <>{children}</>
);

// Workaround for https://github.com/vercel/next.js/issues/8592
export type AppProps = Omit<NextAppProps, "Component"> & {
Expand Down
49 changes: 32 additions & 17 deletions apps/web/pages/success.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,23 +369,12 @@ export default function Success(props: SuccessProps) {
<p className="text-bookinglight">{bookingInfo.user.email}</p>
</div>
)}
{!eventType.seatsShowAttendees
? bookingInfo?.attendees
.filter((attendee) => attendee.email === email)
.map((attendee) => (
<div key={attendee.name} className="mb-3">
<p>{attendee.name}</p>
<p className="text-bookinglight">{attendee.email}</p>
</div>
))
: bookingInfo?.attendees.map((attendee, index) => (
<div
key={attendee.name}
className={index === bookingInfo.attendees.length - 1 ? "" : "mb-3"}>
<p>{attendee.name}</p>
<p className="text-bookinglight">{attendee.email}</p>
</div>
))}
{bookingInfo?.attendees.map((attendee, index) => (
<div key={attendee.name} className="mb-3 last:mb-0">
<p>{attendee.name}</p>
<p className="text-bookinglight">{attendee.email}</p>
</div>
))}
</>
</div>
</>
Expand Down Expand Up @@ -786,6 +775,28 @@ const schema = z.object({
bookingId: strToNumber,
});

const handleSeatsEventTypeOnBooking = (
eventType: {
seatsPerTimeSlot?: boolean | null;
seatsShowAttendees: boolean | null;
[x: string | number | symbol]: unknown;
},
booking: Partial<
Prisma.BookingGetPayload<{ include: { attendees: { select: { name: true; email: true } } } }>
>,
email: string
) => {
if (eventType?.seatsPerTimeSlot !== null) {
// @TODO: right now bookings with seats doesn't save every description that its entered by every user
delete booking.description;
}
if (!eventType.seatsShowAttendees) {
const attendee = booking?.attendees?.find((a) => a.email === email);
booking["attendees"] = attendee ? [attendee] : [];
}
return;
};

export async function getServerSideProps(context: GetServerSidePropsContext) {
const ssr = await ssrInit(context);
const parsedQuery = schema.safeParse(context.query);
Expand Down Expand Up @@ -884,6 +895,10 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
},
},
});
if (bookingInfo !== null && email) {
handleSeatsEventTypeOnBooking(eventType, bookingInfo, email);
}

let recurringBookings = null;
if (recurringEventIdQuery) {
// We need to get the dates for the bookings to be able to show them in the UI
Expand Down
3 changes: 2 additions & 1 deletion packages/app-store/zoomvideo/lib/VideoApiAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ const ZoomVideoApiAdapter = (credential: CredentialPayload): VideoApiAdapter =>

const handleZoomResponse = async (response: Response, credentialId: Credential["id"]) => {
let _response = response.clone();
const responseClone = response.clone();
if (_response.headers.get("content-encoding") === "gzip") {
const responseString = await response.text();
_response = JSON.parse(responseString);
Expand All @@ -339,7 +340,7 @@ const handleZoomResponse = async (response: Response, credentialId: Credential["
throw Error(response.statusText);
}

return response.json();
return responseClone.json();
};

const invalidateCredential = async (credentialId: Credential["id"]) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/trpc/server/routers/viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const loggedInViewerRouter = createProtectedRouter()
locale: user.locale,
timeFormat: user.timeFormat,
timeZone: user.timeZone,
avatar: user.avatar,
avatar: `${CAL_URL}/${user.username}/avatar.png`,
createdDate: user.createdDate,
trialEndsAt: user.trialEndsAt,
completedOnboarding: user.completedOnboarding,
Expand Down

0 comments on commit 4af5a77

Please sign in to comment.