@@ -142,6 +162,16 @@ export default function EventType(props) {
}
export async function getServerSideProps(context) {
+ const session = await getSession(context);
+
+ const user = await prisma.user.findFirst({
+ where: {
+ email: session.user.email,
+ },
+ select: {
+ username: true
+ }
+ });
const eventType = await prisma.eventType.findUnique({
where: {
@@ -150,6 +180,7 @@ export async function getServerSideProps(context) {
select: {
id: true,
title: true,
+ slug: true,
description: true,
length: true,
hidden: true
@@ -158,6 +189,7 @@ export async function getServerSideProps(context) {
return {
props: {
+ user,
eventType
},
}
diff --git a/pages/availability/index.tsx b/pages/availability/index.tsx
index 403e4690..fbb4419a 100644
--- a/pages/availability/index.tsx
+++ b/pages/availability/index.tsx
@@ -15,6 +15,7 @@ export default function Availability(props) {
const [successModalOpen, setSuccessModalOpen] = useState(false);
const [showChangeTimesModal, setShowChangeTimesModal] = useState(false);
const titleRef = useRef();
+ const slugRef = useRef();
const descriptionRef = useRef();
const lengthRef = useRef();
const isHiddenRef = useRef();
@@ -54,6 +55,7 @@ export default function Availability(props) {
event.preventDefault();
const enteredTitle = titleRef.current.value;
+ const enteredSlug = slugRef.current.value;
const enteredDescription = descriptionRef.current.value;
const enteredLength = lengthRef.current.value;
const enteredIsHidden = isHiddenRef.current.checked;
@@ -62,7 +64,7 @@ export default function Availability(props) {
const response = await fetch('/api/availability/eventtype', {
method: 'POST',
- body: JSON.stringify({title: enteredTitle, description: enteredDescription, length: enteredLength, hidden: enteredIsHidden}),
+ body: JSON.stringify({title: enteredTitle, slug: enteredSlug, description: enteredDescription, length: enteredLength, hidden: enteredIsHidden}),
headers: {
'Content-Type': 'application/json'
}
@@ -154,7 +156,7 @@ export default function Availability(props) {
{eventType.length} minutes
- {eventType.hidden && View}
+ {eventType.hidden && View}
Edit
|
@@ -213,6 +215,23 @@ export default function Availability(props) {