add free plan (#549)

- add new fields to support this
- when free:
  - fade out all event types after first
  - hide events after first on booking page
  - make booking page after the first one 404 if accessed directly
- add e2e tests
This commit is contained in:
Alex Johansson authored and GitHub committed 2021-09-06 13:51:15 +00:00
1 parent fa35af7bd8
commit 7e6e935ed3
29 files changed
+880 -261

No files matched your search

+8
View File
@@ -1,3 +1,11 @@
export function asStringOrNull(str: unknown) {
return typeof str === "string" ? str : null;
}
export function asStringOrThrow(str: unknown): string {
const type = typeof str;
if (type !== "string") {
throw new Error(`Expected "string" - got ${type}`);
}
return str;
}
+31
View File
@@ -0,0 +1,31 @@
import { useRouter } from "next/router";
import { useMemo } from "react";
export function useToggleQuery(name: string) {
const router = useRouter();
const hrefOff = useMemo(() => {
const query = {
...router.query,
};
delete query[name];
return {
query,
};
}, [router.query, name]);
const hrefOn = useMemo(() => {
const query = {
...router.query,
[name]: "1",
};
return {
query,
};
}, [router.query, name]);
return {
hrefOn,
hrefOff,
isOn: router.query[name] === "1",
};
}
+3 -1
View File
@@ -7,7 +7,9 @@ if (process.env.NODE_ENV === "production") {
prisma = new PrismaClient();
} else {
if (!globalAny.prisma) {
globalAny.prisma = new PrismaClient();
globalAny.prisma = new PrismaClient({
log: ["query", "error", "warn"],
});
}
prisma = globalAny.prisma;
}
+1 -1
View File
@@ -2,7 +2,7 @@
type GetSSRResult<TProps> =
//
{ props: TProps } | { redirect: any } | { notFound: true };
{ props: TProps } | { redirect: any } | { notFound: boolean };
type GetSSRFn<TProps> = (...args: any[]) => Promise<GetSSRResult<TProps>>;