Change event types to use slug instead of ID (#612)

* Temporarily disable checking video busy times

* Add fix for create event type modal
pull/605/head^2
Bailey Pumfleet 2021-09-08 20:43:51 +01:00 committed by GitHub
parent 1269c43c99
commit 70f595ec08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 18 deletions

View File

@ -1062,15 +1062,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
const eventType = await prisma.eventType.findFirst({ const eventType = await prisma.eventType.findFirst({
where: { where: {
userId: user.id, AND: [{ userId: user.id }, { slug: typeParam }],
OR: [
{
slug: typeParam,
},
{
id: parseInt(typeParam),
},
],
}, },
select: { select: {
id: true, id: true,
@ -1090,7 +1082,6 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
periodEndDate: true, periodEndDate: true,
periodCountCalendarDays: true, periodCountCalendarDays: true,
requiresConfirmation: true, requiresConfirmation: true,
userId: true,
}, },
}); });
@ -1100,12 +1091,6 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
}; };
} }
if (eventType.userId != session.user.id) {
return {
notFound: true,
} as const;
}
const credentials = await prisma.credential.findMany({ const credentials = await prisma.credential.findMany({
where: { where: {
userId: user.id, userId: user.id,

View File

@ -36,7 +36,7 @@ const EventTypesPage = (props: inferSSRProps<typeof getServerSideProps>) => {
const router = useRouter(); const router = useRouter();
const createMutation = useMutation(createEventType, { const createMutation = useMutation(createEventType, {
onSuccess: async ({ eventType }) => { onSuccess: async ({ eventType }) => {
await router.push("/event-types/" + eventType.id); await router.push("/event-types/" + eventType.slug);
showToast(`${eventType.title} event type created successfully`, "success"); showToast(`${eventType.title} event type created successfully`, "success");
}, },
onError: (err: Error) => { onError: (err: Error) => {
@ -223,7 +223,7 @@ const EventTypesPage = (props: inferSSRProps<typeof getServerSideProps>) => {
className={classNames("hover:bg-neutral-50", item.$disabled && "pointer-events-none")} className={classNames("hover:bg-neutral-50", item.$disabled && "pointer-events-none")}
tabIndex={item.$disabled ? -1 : undefined}> tabIndex={item.$disabled ? -1 : undefined}>
<div className={"flex items-center px-4 py-4 sm:px-6"}> <div className={"flex items-center px-4 py-4 sm:px-6"}>
<Link href={"/event-types/" + item.id}> <Link href={"/event-types/" + item.slug}>
<a className="flex-1 min-w-0 sm:flex sm:items-center sm:justify-between hover:bg-neutral-50"> <a className="flex-1 min-w-0 sm:flex sm:items-center sm:justify-between hover:bg-neutral-50">
<span className="truncate"> <span className="truncate">
<div className="flex text-sm"> <div className="flex text-sm">