Change event types to use slug instead of ID (#612)
* Temporarily disable checking video busy times * Add fix for create event type modalpull/605/head^2
parent
1269c43c99
commit
70f595ec08
|
@ -1062,15 +1062,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
|||
|
||||
const eventType = await prisma.eventType.findFirst({
|
||||
where: {
|
||||
userId: user.id,
|
||||
OR: [
|
||||
{
|
||||
slug: typeParam,
|
||||
},
|
||||
{
|
||||
id: parseInt(typeParam),
|
||||
},
|
||||
],
|
||||
AND: [{ userId: user.id }, { slug: typeParam }],
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
|
@ -1090,7 +1082,6 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
|||
periodEndDate: true,
|
||||
periodCountCalendarDays: 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({
|
||||
where: {
|
||||
userId: user.id,
|
||||
|
|
|
@ -36,7 +36,7 @@ const EventTypesPage = (props: inferSSRProps<typeof getServerSideProps>) => {
|
|||
const router = useRouter();
|
||||
const createMutation = useMutation(createEventType, {
|
||||
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");
|
||||
},
|
||||
onError: (err: Error) => {
|
||||
|
@ -223,7 +223,7 @@ const EventTypesPage = (props: inferSSRProps<typeof getServerSideProps>) => {
|
|||
className={classNames("hover:bg-neutral-50", item.$disabled && "pointer-events-none")}
|
||||
tabIndex={item.$disabled ? -1 : undefined}>
|
||||
<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">
|
||||
<span className="truncate">
|
||||
<div className="flex text-sm">
|
||||
|
|
Loading…
Reference in New Issue