Several type fixes (#855)

* Several type fixes

* Update ee/lib/stripe/client.ts

Co-authored-by: Alex Johansson <[email protected]>

* Typo

* Refactors createPaymentLink

* Simplify calendarClietn type

Co-authored-by: Alex Johansson <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
authored and GitHub committed 2021-10-05 16:46:48 -06:00
1 parent 4474e9dd74
commit 95b49a5995
6 files changed
+37 -24

No files matched your search

+8 -8
View File
@@ -239,8 +239,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const teamMembers =
eventType.schedulingType === SchedulingType.COLLECTIVE
? users.slice(1).map((user) => ({
email: user.email,
name: user.name,
email: user.email || "",
name: user.name || "",
timeZone: user.timeZone,
}))
: [];
@@ -257,8 +257,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
startTime: reqBody.start,
endTime: reqBody.end,
organizer: {
name: users[0].name,
email: users[0].email,
name: users[0].name || "Nameless",
email: users[0].email || "Email-less",
timeZone: users[0].timeZone,
},
attendees: attendeesList,
@@ -328,6 +328,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
let referencesToCreate: PartialReference[] = [];
type User = Prisma.UserGetPayload<typeof userData>;
let user: User | null = null;
for (const currentUser of users) {
if (!currentUser) {
console.error(`currentUser not found`);
@@ -404,6 +405,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}
}
}
if (!user) throw Error("Can't continue, user not found.");
// After polling videoBusyTimes, credentials might have been changed due to refreshment, so query them again.
const eventManager = new EventManager(await refreshCredentials(user.credentials));
@@ -446,11 +450,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
if (typeof eventType.price === "number" && eventType.price > 0) {
try {
const [firstStripeCredential] = user.credentials.filter((cred) => cred.type == "stripe_payment");
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
/* @ts-ignore https://github.com/prisma/prisma/issues/9389 */
if (!booking.user) booking.user = user;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
/* @ts-ignore https://github.com/prisma/prisma/issues/9389 */
const payment = await handlePayment(evt, eventType, firstStripeCredential, booking);
res.status(201).json({ ...booking, message: "Payment required", paymentUid: payment.uid });