Skip to content

Scheduling infrastructure for absolutely everyone.

Type fixes

zomarscee41eabc762
diff --git a/apps/web/components/integrations/IntegrationList.tsx b/apps/web/components/integrations/IntegrationList.tsx
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/apps/web/components/team/TeamSettings.tsx b/apps/web/components/team/TeamSettings.tsx
index c77f760e0db..d4b0ddfb276 100644
--- a/apps/web/components/team/TeamSettings.tsx
+++ b/apps/web/components/team/TeamSettings.tsx
@@ -54,7 +54,6 @@ export default function TeamSettings(props: Props) {
};
// remove unchanged variables
for (const key in variables) {
- //@ts-expect-error will fix types
if (variables[key] === team?.[key]) delete variables[key];
}
mutation.mutate({ id: team.id, ...variables });
diff --git a/apps/web/components/ui/form/PhoneInput.tsx b/apps/web/components/ui/form/PhoneInput.tsx
index 595dbbb9069..8d6f78389da 100644
--- a/apps/web/components/ui/form/PhoneInput.tsx
+++ b/apps/web/components/ui/form/PhoneInput.tsx
@@ -5,7 +5,9 @@ import "react-phone-number-input/style.css";
import classNames from "@lib/classNames";
import { Optional } from "@lib/types/utils";
-export const PhoneInput = (props: Optional<PhoneInputProps, "onChange">) => (
+export const PhoneInput = (
+ props: Optional<PhoneInputProps<React.InputHTMLAttributes<HTMLInputElement>>, "onChange">
+) => (
<BasePhoneInput
{...props}
className={classNames(
diff --git a/apps/web/components/ui/form/Schedule.tsx b/apps/web/components/ui/form/Schedule.tsx
index bce618da9a5..033704d4e94 100644
--- a/apps/web/components/ui/form/Schedule.tsx
+++ b/apps/web/components/ui/form/Schedule.tsx
@@ -27,7 +27,7 @@ const TIMES = (() => {
const end = dayjs().utc().endOf("day");
let t: Dayjs = dayjs().utc().startOf("day");
- const times = [];
+ const times: Dayjs[] = [];
while (t.isBefore(end)) {
times.push(t);
t = t.add(increment, "minutes");
diff --git a/apps/web/lib/emails/email-manager.ts b/apps/web/lib/emails/email-manager.ts
index f2fef7b6a0a..ad145c30f53 100644
--- a/apps/web/lib/emails/email-manager.ts
+++ b/apps/web/lib/emails/email-manager.ts
@@ -14,10 +14,10 @@ import TeamInviteEmail, { TeamInvite } from "@lib/emails/templates/team-invite-e
import { CalendarEvent } from "@lib/integrations/calendar/interfaces/Calendar";
export const sendScheduledEmails = async (calEvent: CalendarEvent) => {
- const emailsToSend = [];
+ const emailsToSend: Promise<unknown>[] = [];
emailsToSend.push(
- calEvent.attendees.map((attendee) => {
+ ...calEvent.attendees.map((attendee) => {
return new Promise((resolve, reject) => {
try {
const scheduledEmail = new AttendeeScheduledEmail(calEvent, attendee);
@@ -44,10 +44,10 @@ export const sendScheduledEmails = async (calEvent: CalendarEvent) => {
};
export const sendRescheduledEmails = async (calEvent: CalendarEvent) => {
- const emailsToSend = [];
+ const emailsToSend: Promise<unknown>[] = [];
emailsToSend.push(
- calEvent.attendees.map((attendee) => {
+ ...calEvent.attendees.map((attendee) => {
return new Promise((resolve, reject) => {
try {
const scheduledEmail = new AttendeeRescheduledEmail(calEvent, attendee);
@@ -85,10 +85,10 @@ export const sendOrganizerRequestEmail = async (calEvent: CalendarEvent) => {
};
export const sendDeclinedEmails = async (calEvent: CalendarEvent) => {
- const emailsToSend = [];
+ const emailsToSend: Promise<unknown>[] = [];
emailsToSend.push(
- calEvent.attendees.map((attendee) => {
+ ...calEvent.attendees.map((attendee) => {
return new Promise((resolve, reject) => {
try {
const declinedEmail = new AttendeeDeclinedEmail(calEvent, attendee);
@@ -104,10 +104,10 @@ export const sendDeclinedEmails = async (calEvent: CalendarEvent) => {
};
export const sendCancelledEmails = async (calEvent: CalendarEvent) => {
- const emailsToSend = [];
+ const emailsToSend: Promise<unknown>[] = [];
emailsToSend.push(
- calEvent.attendees.map((attendee) => {
+ ...calEvent.attendees.map((attendee) => {
return new Promise((resolve, reject) => {
try {
const scheduledEmail = new AttendeeCancelledEmail(calEvent, attendee);
@@ -145,10 +145,10 @@ export const sendOrganizerRequestReminderEmail = async (calEvent: CalendarEvent)
};
export const sendAwaitingPaymentEmail = async (calEvent: CalendarEvent) => {
- const emailsToSend = [];
+ const emailsToSend: Promise<unknown>[] = [];
emailsToSend.push(
- calEvent.attendees.map((attendee) => {
+ ...calEvent.attendees.map((attendee) => {
return new Promise((resolve, reject) => {
try {
const paymentEmail = new AttendeeAwaitingPaymentEmail(calEvent, attendee);
diff --git a/apps/web/lib/integrations/calendar/services/BaseCalendarService.ts b/apps/web/lib/integrations/calendar/services/BaseCalendarService.ts
index 8a3d18f478f..18d77b750c0 100644
--- a/apps/web/lib/integrations/calendar/services/BaseCalendarService.ts
+++ b/apps/web/lib/integrations/calendar/services/BaseCalendarService.ts
@@ -1,4 +1,4 @@
-import { Credential } from "@prisma/client";
+import { Credential, Prisma } from "@prisma/client";
import dayjs from "dayjs";
import timezone from "dayjs/plugin/timezone";
import utc from "dayjs/plugin/utc";
@@ -342,8 +342,7 @@ export default abstract class BaseCalendarService implements Calendar {
}
private async getEventsByUID(uid: string): Promise<CalendarEventType[]> {
- const events = [];
-
+ const events: Prisma.PromiseReturnType<typeof this.getEvents> = [];
const calendars = await this.listCalendars();
for (const cal of calendars) {
diff --git a/apps/web/pages/[user]/book.tsx b/apps/web/pages/[user]/book.tsx
index 9d1d61dcbd8..6d557d887ff 100644
--- a/apps/web/pages/[user]/book.tsx
+++ b/apps/web/pages/[user]/book.tsx
@@ -1,17 +1,15 @@
+import BookingPage from "@components/booking/pages/BookingPage";
+import { asStringOrThrow } from "@lib/asStringOrNull";
+import prisma from "@lib/prisma";
+import { inferSSRProps } from "@lib/types/inferSSRProps";
+import { Prisma } from "@prisma/client";
+import { ssrInit } from "@server/lib/ssr";
import dayjs from "dayjs";
import timezone from "dayjs/plugin/timezone";
import utc from "dayjs/plugin/utc";
import { GetServerSidePropsContext } from "next";
import { JSONObject } from "superjson/dist/types";
-import { asStringOrThrow } from "@lib/asStringOrNull";
-import prisma from "@lib/prisma";
-import { inferSSRProps } from "@lib/types/inferSSRProps";
-
-import BookingPage from "@components/booking/pages/BookingPage";
-
-import { ssrInit } from "@server/lib/ssr";
-
dayjs.extend(utc);
dayjs.extend(timezone);
@@ -107,10 +105,8 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
};
})[0];
- let booking = null;
-
- if (context.query.rescheduleUid) {
- booking = await prisma.booking.findFirst({
+ async function getBooking() {
+ return prisma.booking.findFirst({
where: {
uid: asStringOrThrow(context.query.rescheduleUid),
},
@@ -126,6 +122,13 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
});
}
+ type Booking = Prisma.PromiseReturnType<typeof getBooking>;
+ let booking: Booking | null = null;
+
+ if (context.query.rescheduleUid) {
+ booking = await getBooking();
+ }
+
return {
props: {
profile: {
diff --git a/apps/web/pages/api/book/confirm.ts b/apps/web/pages/api/book/confirm.ts
index eb62a2f8444..77c05317e3e 100644
--- a/apps/web/pages/api/book/confirm.ts
+++ b/apps/web/pages/api/book/confirm.ts
@@ -43,7 +43,7 @@ const authorized = async (
const log = logger.getChildLogger({ prefix: ["[api] book:user"] });
-export default async function handler(req: NextApiRequest, res: NextApiResponse): Promise<void> {
+export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const session = await getSession({ req: req });
if (!session?.user?.id) {
return res.status(401).json({ message: "Not authenticated" });
diff --git a/apps/web/pages/api/cron/bookingReminder.ts b/apps/web/pages/api/cron/bookingReminder.ts
index d4341d6227d..e68c2f2ade8 100644
--- a/apps/web/pages/api/cron/bookingReminder.ts
+++ b/apps/web/pages/api/cron/bookingReminder.ts
@@ -8,7 +8,7 @@ import prisma from "@lib/prisma";
import { getTranslation } from "@server/lib/i18n";
-export default async function handler(req: NextApiRequest, res: NextApiResponse): Promise<void> {
+export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const apiKey = req.headers.authorization || req.query.apiKey;
if (process.env.CRON_API_KEY !== apiKey) {
res.status(401).json({ message: "Not authenticated" });
diff --git a/apps/web/pages/getting-started.tsx b/apps/web/pages/getting-started.tsx
index 63531588229..c0b04b4e9f4 100644
--- a/apps/web/pages/getting-started.tsx
+++ b/apps/web/pages/getting-started.tsx
@@ -645,11 +645,6 @@ export async function getServerSideProps(context: NextPageContext) {
const session = await getSession(context);
- let integrations = [];
- let connectedCalendars = [];
- let credentials = [];
- let eventTypes = [];
- let schedules = [];
if (!session?.user?.id) {
return {
redirect: {
@@ -694,7 +689,7 @@ export async function getServerSideProps(context: NextPageContext) {
};
}
- credentials = await prisma.credential.findMany({
+ const credentials = await prisma.credential.findMany({
where: {
userId: user.id,
},
@@ -705,16 +700,16 @@ export async function getServerSideProps(context: NextPageContext) {
},
});
- integrations = getIntegrations(credentials)
+ const integrations = getIntegrations(credentials)
.filter((item) => item.type.endsWith("_calendar"))
.map((item) => omit(item, "key"));
// get user's credentials + their connected integrations
const calendarCredentials = getCalendarCredentials(credentials, user.id);
// get all the connected integrations' calendars (from third party)
- connectedCalendars = await getConnectedCalendars(calendarCredentials, user.selectedCalendars);
+ const connectedCalendars = await getConnectedCalendars(calendarCredentials, user.selectedCalendars);
- eventTypes = await prisma.eventType.findMany({
+ const eventTypes = await prisma.eventType.findMany({
where: {
userId: user.id,
},
@@ -728,7 +723,7 @@ export async function getServerSideProps(context: NextPageContext) {
},
});
- schedules = await prisma.schedule.findMany({
+ const schedules = await prisma.schedule.findMany({
where: {
userId: user.id,
},
diff --git a/apps/web/pages/team/[slug]/book.tsx b/apps/web/pages/team/[slug]/book.tsx
index e035eb4a4fb..ec7c1aa1a9c 100644
--- a/apps/web/pages/team/[slug]/book.tsx
+++ b/apps/web/pages/team/[slug]/book.tsx
@@ -6,6 +6,7 @@ import prisma from "@lib/prisma";
import { inferSSRProps } from "@lib/types/inferSSRProps";
import BookingPage from "@components/booking/pages/BookingPage";
+import { Prisma } from "@prisma/client";
export type TeamBookingPageProps = inferSSRProps<typeof getServerSideProps>;
@@ -69,10 +70,8 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
};
})[0];
- let booking = null;
-
- if (context.query.rescheduleUid) {
- booking = await prisma.booking.findFirst({
+ async function getBooking() {
+ return prisma.booking.findFirst({
where: {
uid: asStringOrThrow(context.query.rescheduleUid),
},
@@ -88,6 +87,13 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
});
}
+ type Booking = Prisma.PromiseReturnType<typeof getBooking>;
+ let booking: Booking | null = null;
+
+ if (context.query.rescheduleUid) {
+ booking = await getBooking();
+ }
+
return {
props: {
profile: {
diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json
index a8423c2525d..644c64f61a5 100644
--- a/apps/web/tsconfig.json
+++ b/apps/web/tsconfig.json
@@ -1,5 +1,5 @@
{
- "extends": "@calcom/tsconfig/nextjs.json",
+ "extends": "../../packages/tsconfig/nextjs.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {