hotfix: bookings and availability pages
commit 36e1c9272fa9b86cbe9e53e03e83799820674f17 Author: zomars <zomars@me.com> Date: Tue Jul 26 18:27:57 2022 -0600 Update [schedule].tsx commit f39535feea22a11a857d179f3506803602a95728 Author: zomars <zomars@me.com> Date: Tue Jul 26 18:07:30 2022 -0600 Update [status].tsx commit c3ac1bcc8c7ff8dc7ebf178d23a6e5c7ea223749 Author: zomars <zomars@me.com> Date: Tue Jul 26 17:53:43 2022 -0600 Update [schedule].tsx commit 39364d8476b3c582d4a7fe3f8d139c5d254e3ecf Author: zomars <zomars@me.com> Date: Tue Jul 26 17:43:13 2022 -0600 Debugging prod commit 4b428d22dec734dab19096b4fe07741f18e5bc5d Author: zomars <zomars@me.com> Date: Tue Jul 26 17:20:44 2022 -0600 Update checkLicense.ts commit 4212e6d61908face52d647bb661d71db959cf864 Author: zomars <zomars@me.com> Date: Tue Jul 26 17:11:37 2022 -0600 Booking fixes attempt commit e3160027ea0ce40d129b445daeb3bb17711ac640 Author: zomars <zomars@me.com> Date: Tue Jul 26 13:52:35 2022 -0600 migration conflict fixes
This commit is contained in:
1 parent
5ad25a692f
commit
cf5912335e
9 files changed
+65
-37
No files matched your search
@@ -125,12 +125,9 @@ const Layout = ({
|
||||
}: LayoutProps & { status: SessionContextValue["status"]; plan?: UserPlan; isLoading: boolean }) => {
|
||||
const isEmbed = useIsEmbed();
|
||||
const router = useRouter();
|
||||
const { data: routingForms } = trpc.useQuery([
|
||||
"viewer.appById",
|
||||
{
|
||||
appId: "routing_forms",
|
||||
},
|
||||
]);
|
||||
const { data: routingForms } = trpc.useQuery(["viewer.appById", { appId: "routing_forms" }], {
|
||||
enabled: status === "authenticated",
|
||||
});
|
||||
|
||||
const { t } = useLocale();
|
||||
const navigation = [
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { BadgeCheckIcon } from "@heroicons/react/solid";
|
||||
import { GetStaticPaths, GetStaticProps } from "next";
|
||||
import { useRouter } from "next/router";
|
||||
import { useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
|
||||
import { DEFAULT_SCHEDULE, availabilityAsString } from "@calcom/lib/availability";
|
||||
import { availabilityAsString, DEFAULT_SCHEDULE } from "@calcom/lib/availability";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import showToast from "@calcom/lib/notification";
|
||||
import { stringOrNumber } from "@calcom/prisma/zod-utils";
|
||||
import { inferQueryOutput, trpc } from "@calcom/trpc/react";
|
||||
import Button from "@calcom/ui/Button";
|
||||
import Switch from "@calcom/ui/Switch";
|
||||
@@ -124,15 +127,15 @@ export function AvailabilityForm(props: inferQueryOutput<"viewer.availability.sc
|
||||
);
|
||||
}
|
||||
|
||||
const querySchema = z.object({
|
||||
schedule: stringOrNumber,
|
||||
});
|
||||
|
||||
export default function Availability() {
|
||||
const router = useRouter();
|
||||
const { i18n } = useLocale();
|
||||
const query = trpc.useQuery([
|
||||
"viewer.availability.schedule",
|
||||
{
|
||||
scheduleId: parseInt(router.query.schedule as string),
|
||||
},
|
||||
]);
|
||||
const { schedule: scheduleId } = router.isReady ? querySchema.parse(router.query) : { schedule: -1 };
|
||||
const query = trpc.useQuery(["viewer.availability.schedule", { scheduleId }], { enabled: router.isReady });
|
||||
const [name, setName] = useState<string>();
|
||||
return (
|
||||
<div>
|
||||
@@ -158,3 +161,23 @@ export default function Availability() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export const getStaticProps: GetStaticProps = (ctx) => {
|
||||
const params = querySchema.safeParse(ctx.params);
|
||||
|
||||
if (!params.success) return { notFound: true };
|
||||
|
||||
return {
|
||||
props: {
|
||||
schedule: params.data.schedule,
|
||||
},
|
||||
revalidate: 10, // seconds
|
||||
};
|
||||
};
|
||||
|
||||
export const getStaticPaths: GetStaticPaths = () => {
|
||||
return {
|
||||
paths: [],
|
||||
fallback: "blocking",
|
||||
};
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
import { CalendarIcon } from "@heroicons/react/outline";
|
||||
import { GetStaticPaths, GetStaticProps } from "next";
|
||||
import { useRouter } from "next/router";
|
||||
import { Fragment } from "react";
|
||||
import { z } from "zod";
|
||||
@@ -20,6 +21,8 @@ import SkeletonLoader from "@components/booking/SkeletonLoader";
|
||||
type BookingListingStatus = inferQueryInput<"viewer.bookings">["status"];
|
||||
type BookingOutput = inferQueryOutput<"viewer.bookings">["bookings"][0];
|
||||
|
||||
const validStatuses = ["upcoming", "recurring", "past", "cancelled"] as const;
|
||||
|
||||
const descriptionByStatus: Record<BookingListingStatus, string> = {
|
||||
upcoming: "upcoming_bookings",
|
||||
recurring: "recurring_bookings",
|
||||
@@ -28,11 +31,12 @@ const descriptionByStatus: Record<BookingListingStatus, string> = {
|
||||
};
|
||||
|
||||
const querySchema = z.object({
|
||||
status: z.enum(["upcoming", "recurring", "past", "cancelled"]),
|
||||
status: z.enum(validStatuses),
|
||||
});
|
||||
|
||||
export default function Bookings() {
|
||||
const router = useRouter();
|
||||
console.log("router", JSON.stringify(router));
|
||||
const { status } = router.isReady ? querySchema.parse(router.query) : { status: "upcoming" as const };
|
||||
const { t } = useLocale();
|
||||
|
||||
@@ -137,3 +141,25 @@ export default function Bookings() {
|
||||
</Shell>
|
||||
);
|
||||
}
|
||||
|
||||
export const getStaticProps: GetStaticProps = (ctx) => {
|
||||
const params = querySchema.safeParse(ctx.params);
|
||||
|
||||
if (!params.success) return { notFound: true };
|
||||
|
||||
return {
|
||||
props: {
|
||||
status: params.data.status,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const getStaticPaths: GetStaticPaths = () => {
|
||||
return {
|
||||
paths: validStatuses.map((status) => ({
|
||||
params: { status },
|
||||
locale: "en",
|
||||
})),
|
||||
fallback: "blocking",
|
||||
};
|
||||
};
|
||||
@@ -1,18 +0,0 @@
|
||||
import { NextPageContext } from "next";
|
||||
|
||||
import { getSession } from "@lib/auth";
|
||||
|
||||
function RedirectPage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function getServerSideProps(context: NextPageContext) {
|
||||
const session = await getSession(context);
|
||||
if (!session?.user?.id) {
|
||||
return { redirect: { permanent: false, destination: "/auth/login" } };
|
||||
}
|
||||
|
||||
return { redirect: { permanent: false, destination: "/bookings/upcoming" } };
|
||||
}
|
||||
|
||||
export default RedirectPage;
|
||||
@@ -5,7 +5,6 @@ import { CONSOLE_URL } from "@calcom/lib/constants";
|
||||
const CACHING_TIME = 86400000; // 24 hours in milliseconds
|
||||
|
||||
async function checkLicense(license: string): Promise<boolean> {
|
||||
return true;
|
||||
if (!!process.env.NEXT_PUBLIC_IS_E2E) return true;
|
||||
const url = `${CONSOLE_URL}/api/license?key=${license}`;
|
||||
const cachedResponse = cache.get(url);
|
||||
|
||||
@@ -9,7 +9,8 @@ export const perfObserver =
|
||||
new PerformanceObserver((items) => {
|
||||
items.getEntries().forEach((entry) => {
|
||||
// Log entry duration in seconds with four decimal places.
|
||||
console.log(entry.name.replace("$1", `${(entry.duration / 1000.0).toFixed(4)}s`));
|
||||
if (!!process.env.NEXT_PUBLIC_DEBUG)
|
||||
console.log(entry.name.replace("$1", `${(entry.duration / 1000.0).toFixed(4)}s`));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "DestinationCalendar" DROP CONSTRAINT "DestinationCalendar_bookingId_fkey";
|
||||
ALTER TABLE "DestinationCalendar" DROP CONSTRAINT IF EXISTS "DestinationCalendar_bookingId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "DestinationCalendar" DROP CONSTRAINT "DestinationCalendar_eventTypeId_fkey";
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
*/
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "DestinationCalendar" DROP CONSTRAINT "DestinationCalendar_bookingId_fkey";
|
||||
ALTER TABLE "DestinationCalendar" DROP CONSTRAINT IF EXISTS "DestinationCalendar_bookingId_fkey";
|
||||
|
||||
-- DropIndex
|
||||
DROP INDEX "DestinationCalendar_bookingId_key";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { LocationType } from "@calcom/core/location";
|
||||
import { LocationType } from "@calcom/app-store/locations";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { slugify } from "@calcom/lib/slugify";
|
||||
|
||||
|
||||
Reference in new issue
Block a user