Type fixes
This commit is contained in:
parent
3d4de9476d
commit
cee41eabc7
12 changed files with 49 additions and 45 deletions
|
@ -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 });
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -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" });
|
||||
|
|
|
@ -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" });
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"extends": "@calcom/tsconfig/nextjs.json",
|
||||
"extends": "../../packages/tsconfig/nextjs.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
|
|
Loading…
Reference in a new issue