Type fixes
This commit is contained in:
1 parent
3d4de9476d
commit
cee41eabc7
12 files changed
+49
-45
No files matched your search
@@ -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: {
|
||||
|
||||
Reference in new issue
Block a user