hotfix: bookings and availability pages
commit36e1c9272f
Author: zomars <zomars@me.com> Date: Tue Jul 26 18:27:57 2022 -0600 Update [schedule].tsx commitf39535feea
Author: zomars <zomars@me.com> Date: Tue Jul 26 18:07:30 2022 -0600 Update [status].tsx commitc3ac1bcc8c
Author: zomars <zomars@me.com> Date: Tue Jul 26 17:53:43 2022 -0600 Update [schedule].tsx commit39364d8476
Author: zomars <zomars@me.com> Date: Tue Jul 26 17:43:13 2022 -0600 Debugging prod commit4b428d22de
Author: zomars <zomars@me.com> Date: Tue Jul 26 17:20:44 2022 -0600 Update checkLicense.ts commit4212e6d619
Author: zomars <zomars@me.com> Date: Tue Jul 26 17:11:37 2022 -0600 Booking fixes attempt commite3160027ea
Author: zomars <zomars@me.com> Date: Tue Jul 26 13:52:35 2022 -0600 migration conflict fixes
This commit is contained in:
parent
5ad25a692f
commit
cf5912335e
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user