1
1
import { Navbar } from "@/components/Navbar" ;
2
+ import { CheckCircle2Icon } from "lucide-react" ;
3
+ import { X } from "lucide-react" ;
2
4
import { Inter } from "next/font/google" ;
3
5
import { useRouter } from "next/router" ;
4
6
5
7
import { useGetBooking , useCancelBooking } from "@calcom/atoms" ;
8
+ import dayjs from "@calcom/dayjs" ;
6
9
7
10
const inter = Inter ( { subsets : [ "latin" ] } ) ;
8
11
9
12
export default function Bookings ( props : { calUsername : string ; calEmail : string } ) {
10
13
const router = useRouter ( ) ;
14
+
11
15
const { isLoading, data : booking , refetch } = useGetBooking ( ( router . query . bookingUid as string ) ?? "" ) ;
16
+ const startTime = dayjs ( booking ?. startTime ) . format ( 12 === 12 ? "h:mma" : "HH:mm" ) ;
17
+ const endTime = dayjs ( booking ?. endTime ) . format ( 12 === 12 ? "h:mma" : "HH:mm" ) ;
18
+ const date = dayjs ( booking ?. startTime ) . toDate ( ) ;
19
+ const dateToday = dayjs ( booking ?. startTime ) . date ( ) ;
20
+ const year = dayjs ( booking ?. startTime ) . year ( ) ;
21
+ const day = dayjs ( date ) . format ( "dddd" ) ;
22
+ const month = dayjs ( date ) . format ( "MMMM" ) ;
23
+
12
24
const { mutate : cancelBooking } = useCancelBooking ( {
13
25
onSuccess : ( ) => {
14
26
refetch ( ) ;
@@ -20,41 +32,118 @@ export default function Bookings(props: { calUsername: string; calEmail: string
20
32
< Navbar username = { props . calUsername } />
21
33
{ isLoading && < p > Loading...</ p > }
22
34
{ ! isLoading && booking && (
23
- < div key = { booking . id } className = "my-2 w-[440px] overflow-hidden rounded p-2 shadow-md" >
24
- < div className = "px-6 py-4" >
25
- < div className = "text-md mb-0.5 font-semibold" >
26
- < p > { booking . title } </ p >
35
+ < div
36
+ key = { booking . id }
37
+ className = "my-10 w-[440px] overflow-hidden rounded-md border-[0.7px] border-black px-10 py-5" >
38
+ { booking . status === "ACCEPTED" ? (
39
+ < div className = "mx-2 my-4 flex flex-col items-center justify-center text-center" >
40
+ < CheckCircle2Icon className = "my-5 flex h-[40px] w-[40px] rounded-full bg-green-500" />
41
+ < h1 className = "text-xl font-bold" > This meeting is scheduled</ h1 >
42
+ < p > We sent an email with a calendar invitation with the details to everyone.</ p >
27
43
</ div >
44
+ ) : (
45
+ < div className = "mx-2 my-4 flex flex-col items-center justify-center text-center" >
46
+ < X className = "my-5 flex h-[40px] w-[40px] rounded-full bg-red-400" />
47
+ < h4 className = "text-2xl font-bold" > This event is cancelled</ h4 >
48
+ </ div >
49
+ ) }
50
+ < hr className = "mx-2 bg-black text-black" />
51
+ < div className = "mx-2 my-7 flex flex-col gap-y-3" >
52
+ < div className = "flex gap-[70px]" >
53
+ < div >
54
+ < h4 > What</ h4 >
55
+ </ div >
56
+ < div >
57
+ < p > { booking . title } </ p >
58
+ </ div >
59
+ </ div >
60
+ < div className = "flex gap-[70px]" >
61
+ < div >
62
+ < h4 > When</ h4 >
63
+ </ div >
64
+ < div >
65
+ < div >
66
+ < p
67
+ style = { {
68
+ textDecoration : booking . status === "ACCEPTED" ? "normal" : "line-through" ,
69
+ } } >
70
+ { `${ day } , ${ month } ${ dateToday } , ${ year } ` }
71
+ </ p >
72
+ </ div >
73
+ < div >
74
+ < p
75
+ style = { {
76
+ textDecoration : booking . status === "ACCEPTED" ? "normal" : "line-through" ,
77
+ } } >
78
+ { `${ startTime } ` } - { `${ endTime } ` }
79
+ </ p >
80
+ </ div >
81
+ </ div >
82
+ </ div >
83
+ < div className = "flex gap-[70px]" >
84
+ < div > Who</ div >
85
+ < div >
86
+ < div >
87
+ < div >
88
+ < h4 >
89
+ { booking . user . name } { " " }
90
+ < span className = "rounded-md bg-blue-800 px-2 text-sm text-white" > Host</ span >
91
+ </ h4 >
92
+ < p > { booking . user . email } </ p >
93
+ </ div >
94
+ </ div >
95
+ < div >
96
+ < div >
97
+ < h4 > { `${ booking . responses . name } ` } </ h4 >
98
+ < p > { `${ booking . responses . email } ` } </ p >
99
+ </ div >
100
+ </ div >
101
+ </ div >
102
+ </ div >
103
+ { booking . responses . notes && (
104
+ < div className = "flex gap-[70px]" >
105
+ < div className = "w-[40px]" >
106
+ < h4 > Additional notes</ h4 >
107
+ </ div >
108
+ < div >
109
+ < p > { `${ booking . responses . notes } ` } </ p >
110
+ </ div >
111
+ </ div >
112
+ ) }
28
113
</ div >
29
- < div className = "px-6 pb-2" >
30
- < p > { booking . description } </ p >
31
- < p > { booking . startTime } </ p >
32
- < p > { booking . endTime } </ p >
33
- < p > { booking . status } </ p >
34
- </ div >
35
- < div className = "px-6" >
36
- < button
37
- className = "rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700"
38
- onClick = { ( ) => {
39
- cancelBooking ( {
40
- id : parseInt ( booking . id ) ,
41
- uid : booking . uid ,
42
- cancellationReason : "User request" ,
43
- allRemainingBookings : true ,
44
- } ) ;
45
- } } >
46
- Cancel
47
- </ button >
48
- < button
49
- className = "ml-4 rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700"
50
- onClick = { ( ) => {
51
- router . push (
52
- `/booking?rescheduleUid=${ booking ?. uid } &eventTypeSlug=${ booking ?. eventType ?. slug } `
53
- ) ;
54
- } } >
55
- Reschedule
56
- </ button >
57
- </ div >
114
+
115
+ { booking . status === "ACCEPTED" && (
116
+ < >
117
+ < hr className = "mx-3" />
118
+ < div className = "mx-2 my-3 text-center" >
119
+ < p >
120
+ Need to make a change?{ " " }
121
+ < button
122
+ className = "underline"
123
+ onClick = { ( ) => {
124
+ router . push (
125
+ `/booking?rescheduleUid=${ booking ?. uid } &eventTypeSlug=${ booking ?. eventType ?. slug } `
126
+ ) ;
127
+ } } >
128
+ Reschedule
129
+ </ button > { " " }
130
+ or{ " " }
131
+ < button
132
+ className = "underline"
133
+ onClick = { ( ) => {
134
+ cancelBooking ( {
135
+ id : parseInt ( booking . id ) ,
136
+ uid : booking . uid ,
137
+ cancellationReason : "User request" ,
138
+ allRemainingBookings : true ,
139
+ } ) ;
140
+ } } >
141
+ Cancel
142
+ </ button >
143
+ </ p >
144
+ </ div >
145
+ </ >
146
+ ) }
58
147
</ div >
59
148
) }
60
149
</ main >
0 commit comments