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
|
// remove unchanged variables
|
||||||
for (const key in variables) {
|
for (const key in variables) {
|
||||||
//@ts-expect-error will fix types
|
|
||||||
if (variables[key] === team?.[key]) delete variables[key];
|
if (variables[key] === team?.[key]) delete variables[key];
|
||||||
}
|
}
|
||||||
mutation.mutate({ id: team.id, ...variables });
|
mutation.mutate({ id: team.id, ...variables });
|
||||||
|
|
|
@ -5,7 +5,9 @@ import "react-phone-number-input/style.css";
|
||||||
import classNames from "@lib/classNames";
|
import classNames from "@lib/classNames";
|
||||||
import { Optional } from "@lib/types/utils";
|
import { Optional } from "@lib/types/utils";
|
||||||
|
|
||||||
export const PhoneInput = (props: Optional<PhoneInputProps, "onChange">) => (
|
export const PhoneInput = (
|
||||||
|
props: Optional<PhoneInputProps<React.InputHTMLAttributes<HTMLInputElement>>, "onChange">
|
||||||
|
) => (
|
||||||
<BasePhoneInput
|
<BasePhoneInput
|
||||||
{...props}
|
{...props}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
|
|
|
@ -27,7 +27,7 @@ const TIMES = (() => {
|
||||||
const end = dayjs().utc().endOf("day");
|
const end = dayjs().utc().endOf("day");
|
||||||
let t: Dayjs = dayjs().utc().startOf("day");
|
let t: Dayjs = dayjs().utc().startOf("day");
|
||||||
|
|
||||||
const times = [];
|
const times: Dayjs[] = [];
|
||||||
while (t.isBefore(end)) {
|
while (t.isBefore(end)) {
|
||||||
times.push(t);
|
times.push(t);
|
||||||
t = t.add(increment, "minutes");
|
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";
|
import { CalendarEvent } from "@lib/integrations/calendar/interfaces/Calendar";
|
||||||
|
|
||||||
export const sendScheduledEmails = async (calEvent: CalendarEvent) => {
|
export const sendScheduledEmails = async (calEvent: CalendarEvent) => {
|
||||||
const emailsToSend = [];
|
const emailsToSend: Promise<unknown>[] = [];
|
||||||
|
|
||||||
emailsToSend.push(
|
emailsToSend.push(
|
||||||
calEvent.attendees.map((attendee) => {
|
...calEvent.attendees.map((attendee) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const scheduledEmail = new AttendeeScheduledEmail(calEvent, attendee);
|
const scheduledEmail = new AttendeeScheduledEmail(calEvent, attendee);
|
||||||
|
@ -44,10 +44,10 @@ export const sendScheduledEmails = async (calEvent: CalendarEvent) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const sendRescheduledEmails = async (calEvent: CalendarEvent) => {
|
export const sendRescheduledEmails = async (calEvent: CalendarEvent) => {
|
||||||
const emailsToSend = [];
|
const emailsToSend: Promise<unknown>[] = [];
|
||||||
|
|
||||||
emailsToSend.push(
|
emailsToSend.push(
|
||||||
calEvent.attendees.map((attendee) => {
|
...calEvent.attendees.map((attendee) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const scheduledEmail = new AttendeeRescheduledEmail(calEvent, attendee);
|
const scheduledEmail = new AttendeeRescheduledEmail(calEvent, attendee);
|
||||||
|
@ -85,10 +85,10 @@ export const sendOrganizerRequestEmail = async (calEvent: CalendarEvent) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const sendDeclinedEmails = async (calEvent: CalendarEvent) => {
|
export const sendDeclinedEmails = async (calEvent: CalendarEvent) => {
|
||||||
const emailsToSend = [];
|
const emailsToSend: Promise<unknown>[] = [];
|
||||||
|
|
||||||
emailsToSend.push(
|
emailsToSend.push(
|
||||||
calEvent.attendees.map((attendee) => {
|
...calEvent.attendees.map((attendee) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const declinedEmail = new AttendeeDeclinedEmail(calEvent, attendee);
|
const declinedEmail = new AttendeeDeclinedEmail(calEvent, attendee);
|
||||||
|
@ -104,10 +104,10 @@ export const sendDeclinedEmails = async (calEvent: CalendarEvent) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const sendCancelledEmails = async (calEvent: CalendarEvent) => {
|
export const sendCancelledEmails = async (calEvent: CalendarEvent) => {
|
||||||
const emailsToSend = [];
|
const emailsToSend: Promise<unknown>[] = [];
|
||||||
|
|
||||||
emailsToSend.push(
|
emailsToSend.push(
|
||||||
calEvent.attendees.map((attendee) => {
|
...calEvent.attendees.map((attendee) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const scheduledEmail = new AttendeeCancelledEmail(calEvent, attendee);
|
const scheduledEmail = new AttendeeCancelledEmail(calEvent, attendee);
|
||||||
|
@ -145,10 +145,10 @@ export const sendOrganizerRequestReminderEmail = async (calEvent: CalendarEvent)
|
||||||
};
|
};
|
||||||
|
|
||||||
export const sendAwaitingPaymentEmail = async (calEvent: CalendarEvent) => {
|
export const sendAwaitingPaymentEmail = async (calEvent: CalendarEvent) => {
|
||||||
const emailsToSend = [];
|
const emailsToSend: Promise<unknown>[] = [];
|
||||||
|
|
||||||
emailsToSend.push(
|
emailsToSend.push(
|
||||||
calEvent.attendees.map((attendee) => {
|
...calEvent.attendees.map((attendee) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const paymentEmail = new AttendeeAwaitingPaymentEmail(calEvent, attendee);
|
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 dayjs from "dayjs";
|
||||||
import timezone from "dayjs/plugin/timezone";
|
import timezone from "dayjs/plugin/timezone";
|
||||||
import utc from "dayjs/plugin/utc";
|
import utc from "dayjs/plugin/utc";
|
||||||
|
@ -342,8 +342,7 @@ export default abstract class BaseCalendarService implements Calendar {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getEventsByUID(uid: string): Promise<CalendarEventType[]> {
|
private async getEventsByUID(uid: string): Promise<CalendarEventType[]> {
|
||||||
const events = [];
|
const events: Prisma.PromiseReturnType<typeof this.getEvents> = [];
|
||||||
|
|
||||||
const calendars = await this.listCalendars();
|
const calendars = await this.listCalendars();
|
||||||
|
|
||||||
for (const cal of calendars) {
|
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 dayjs from "dayjs";
|
||||||
import timezone from "dayjs/plugin/timezone";
|
import timezone from "dayjs/plugin/timezone";
|
||||||
import utc from "dayjs/plugin/utc";
|
import utc from "dayjs/plugin/utc";
|
||||||
import { GetServerSidePropsContext } from "next";
|
import { GetServerSidePropsContext } from "next";
|
||||||
import { JSONObject } from "superjson/dist/types";
|
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(utc);
|
||||||
dayjs.extend(timezone);
|
dayjs.extend(timezone);
|
||||||
|
|
||||||
|
@ -107,10 +105,8 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||||
};
|
};
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
let booking = null;
|
async function getBooking() {
|
||||||
|
return prisma.booking.findFirst({
|
||||||
if (context.query.rescheduleUid) {
|
|
||||||
booking = await prisma.booking.findFirst({
|
|
||||||
where: {
|
where: {
|
||||||
uid: asStringOrThrow(context.query.rescheduleUid),
|
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 {
|
return {
|
||||||
props: {
|
props: {
|
||||||
profile: {
|
profile: {
|
||||||
|
|
|
@ -43,7 +43,7 @@ const authorized = async (
|
||||||
|
|
||||||
const log = logger.getChildLogger({ prefix: ["[api] book:user"] });
|
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 });
|
const session = await getSession({ req: req });
|
||||||
if (!session?.user?.id) {
|
if (!session?.user?.id) {
|
||||||
return res.status(401).json({ message: "Not authenticated" });
|
return res.status(401).json({ message: "Not authenticated" });
|
||||||
|
|
|
@ -8,7 +8,7 @@ import prisma from "@lib/prisma";
|
||||||
|
|
||||||
import { getTranslation } from "@server/lib/i18n";
|
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;
|
const apiKey = req.headers.authorization || req.query.apiKey;
|
||||||
if (process.env.CRON_API_KEY !== apiKey) {
|
if (process.env.CRON_API_KEY !== apiKey) {
|
||||||
res.status(401).json({ message: "Not authenticated" });
|
res.status(401).json({ message: "Not authenticated" });
|
||||||
|
|
|
@ -645,11 +645,6 @@ export async function getServerSideProps(context: NextPageContext) {
|
||||||
|
|
||||||
const session = await getSession(context);
|
const session = await getSession(context);
|
||||||
|
|
||||||
let integrations = [];
|
|
||||||
let connectedCalendars = [];
|
|
||||||
let credentials = [];
|
|
||||||
let eventTypes = [];
|
|
||||||
let schedules = [];
|
|
||||||
if (!session?.user?.id) {
|
if (!session?.user?.id) {
|
||||||
return {
|
return {
|
||||||
redirect: {
|
redirect: {
|
||||||
|
@ -694,7 +689,7 @@ export async function getServerSideProps(context: NextPageContext) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
credentials = await prisma.credential.findMany({
|
const credentials = await prisma.credential.findMany({
|
||||||
where: {
|
where: {
|
||||||
userId: user.id,
|
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"))
|
.filter((item) => item.type.endsWith("_calendar"))
|
||||||
.map((item) => omit(item, "key"));
|
.map((item) => omit(item, "key"));
|
||||||
|
|
||||||
// get user's credentials + their connected integrations
|
// get user's credentials + their connected integrations
|
||||||
const calendarCredentials = getCalendarCredentials(credentials, user.id);
|
const calendarCredentials = getCalendarCredentials(credentials, user.id);
|
||||||
// get all the connected integrations' calendars (from third party)
|
// 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: {
|
where: {
|
||||||
userId: user.id,
|
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: {
|
where: {
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,6 +6,7 @@ import prisma from "@lib/prisma";
|
||||||
import { inferSSRProps } from "@lib/types/inferSSRProps";
|
import { inferSSRProps } from "@lib/types/inferSSRProps";
|
||||||
|
|
||||||
import BookingPage from "@components/booking/pages/BookingPage";
|
import BookingPage from "@components/booking/pages/BookingPage";
|
||||||
|
import { Prisma } from "@prisma/client";
|
||||||
|
|
||||||
export type TeamBookingPageProps = inferSSRProps<typeof getServerSideProps>;
|
export type TeamBookingPageProps = inferSSRProps<typeof getServerSideProps>;
|
||||||
|
|
||||||
|
@ -69,10 +70,8 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||||
};
|
};
|
||||||
})[0];
|
})[0];
|
||||||
|
|
||||||
let booking = null;
|
async function getBooking() {
|
||||||
|
return prisma.booking.findFirst({
|
||||||
if (context.query.rescheduleUid) {
|
|
||||||
booking = await prisma.booking.findFirst({
|
|
||||||
where: {
|
where: {
|
||||||
uid: asStringOrThrow(context.query.rescheduleUid),
|
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 {
|
return {
|
||||||
props: {
|
props: {
|
||||||
profile: {
|
profile: {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"extends": "@calcom/tsconfig/nextjs.json",
|
"extends": "../../packages/tsconfig/nextjs.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
|
|
Loading…
Reference in a new issue