diff --git a/pages/[user]/[type].tsx b/pages/[user]/[type].tsx
index 7c3acfff3a..36cc1c79f1 100644
--- a/pages/[user]/[type].tsx
+++ b/pages/[user]/[type].tsx
@@ -82,7 +82,7 @@ export default function Type(props) {
// Get router variables
const router = useRouter();
- const { user } = router.query;
+ const { user, rescheduleUid } = router.query;
// Handle month changes
const incrementMonth = () => {
@@ -180,7 +180,7 @@ export default function Type(props) {
// Display available times
const availableTimes = times.map((time) =>
- {props.eventType.title} | {props.user.name || props.user.username} |
+ {rescheduleUid && "Reschedule"} {props.eventType.title} | {props.user.name || props.user.username} |
Calendso
@@ -413,7 +413,7 @@ export async function getServerSideProps(context) {
return {
props: {
user,
- eventType
+ eventType,
},
}
}
diff --git a/pages/[user]/book.tsx b/pages/[user]/book.tsx
index 79f94e61ee..5beed1940e 100644
--- a/pages/[user]/book.tsx
+++ b/pages/[user]/book.tsx
@@ -19,7 +19,7 @@ dayjs.extend(timezone);
export default function Book(props) {
const router = useRouter();
- const { date, user } = router.query;
+ const { date, user, rescheduleUid } = router.query;
const [ is24h, setIs24h ] = useState(false);
const [ preferredTimeZone, setPreferredTimeZone ] = useState('');
@@ -57,6 +57,7 @@ export default function Book(props) {
notes: event.target.notes.value,
timeZone: preferredTimeZone,
eventName: props.eventType.title,
+ rescheduleUid: rescheduleUid
};
if (selectedLocation) {
@@ -75,7 +76,7 @@ export default function Book(props) {
}
);
- let successUrl = `/success?date=${date}&type=${props.eventType.id}&user=${props.user.username}`;
+ let successUrl = `/success?date=${date}&type=${props.eventType.id}&user=${props.user.username}&reschedule=1`;
if (payload['location']) {
successUrl += "&location=" + encodeURIComponent(payload['location']);
}
@@ -86,7 +87,7 @@ export default function Book(props) {
return (
-
Confirm your {props.eventType.title} with {props.user.name || props.user.username} | Calendso
+
{rescheduleUid ? 'Reschedule' : 'Confirm'} your {props.eventType.title} with {props.user.name || props.user.username} | Calendso
@@ -116,13 +117,13 @@ export default function Book(props) {
{locations.length > 1 && (
@@ -144,11 +145,11 @@ export default function Book(props) {
)}
-
+
-
-
+
+
Cancel
@@ -190,10 +191,30 @@ export async function getServerSideProps(context) {
}
});
+ let booking = undefined;
+
+ if(context.query.rescheduleUid) {
+ booking = await prisma.booking.findFirst({
+ where: {
+ uid: context.query.rescheduleUid
+ },
+ select: {
+ description: true,
+ attendees: {
+ select: {
+ email: true,
+ name: true
+ }
+ }
+ }
+ });
+ }
+
return {
props: {
user,
- eventType
+ eventType,
+ booking
},
}
}
\ No newline at end of file
diff --git a/pages/reschedule/[uid].tsx b/pages/reschedule/[uid].tsx
new file mode 100644
index 0000000000..99b5625d96
--- /dev/null
+++ b/pages/reschedule/[uid].tsx
@@ -0,0 +1,31 @@
+import prisma from '../../lib/prisma';
+
+export default function Type(props) {
+ // Just redirect to the schedule page to reschedule it.
+ return null;
+}
+
+export async function getServerSideProps(context) {
+ const booking = await prisma.booking.findFirst({
+ where: {
+ uid: context.query.uid,
+ },
+ select: {
+ id: true,
+ user: {select: {username: true}},
+ eventType: {select: {slug: true}},
+ title: true,
+ description: true,
+ startTime: true,
+ endTime: true,
+ attendees: true
+ }
+ });
+
+ return {
+ redirect: {
+ destination: '/' + booking.user.username + '/' + booking.eventType.slug + '?rescheduleUid=' + context.query.uid,
+ permanent: false,
+ },
+ }
+}