@@ -3,8 +3,16 @@ import Image from "next/image";
3
3
import WebGLApp from "../bg/WebGLApp" ;
4
4
import Navigationbar from "../components/EventHeader" ;
5
5
import Footer from "../components/Footer" ;
6
- import { useState } from "react" ;
6
+ import { useEffect , useState } from "react" ;
7
7
import { FaAngleDoubleDown } from "react-icons/fa" ;
8
+ import {
9
+ EVENT_DATA_URL ,
10
+ EVENT_REGISTER_STEP_ONE ,
11
+ payU_Action ,
12
+ payU_Key ,
13
+ } from "../_util/constants" ;
14
+ import secureLocalStorage from "react-secure-storage" ;
15
+ import ToastAlert from "../_util/ToastAlerts" ;
8
16
9
17
const Lumere = ( ) => {
10
18
const [ webGLColors , setWebGLColors ] = useState ( {
@@ -38,11 +46,129 @@ const Lumere = () => {
38
46
39
47
const handleScrollMore = ( ) => {
40
48
window . scrollTo ( {
41
- top : window . scrollY + 700 ,
49
+ top : window . scrollY + 710 ,
42
50
behavior : "smooth" ,
43
51
} ) ;
44
52
} ;
45
53
54
+ const [ eventData , setEventData ] = useState ( { } ) ;
55
+ const [ isRegistered , setIsRegistered ] = useState ( false ) ;
56
+ const [ isOpen , setIsOpen ] = useState ( false ) ;
57
+ const [ loading , setLoading ] = useState ( true ) ;
58
+
59
+ const getPayUForm = async ( ) => {
60
+ try {
61
+ const response = await fetch ( EVENT_REGISTER_STEP_ONE , {
62
+ method : "POST" ,
63
+ headers : {
64
+ "Content-Type" : "application/json" ,
65
+ Authorization : `Bearer ${ secureLocalStorage . getItem (
66
+ "registerToken"
67
+ ) } `,
68
+ } ,
69
+ body : JSON . stringify ( {
70
+ eventId : 141 ,
71
+ totalMembers : 1 ,
72
+ isMarketPlacePaymentMode : "0" ,
73
+ } ) ,
74
+ } ) ;
75
+ const data = await response . json ( ) ;
76
+ if ( response . status === 200 ) {
77
+ console . log ( 200 ) ;
78
+ const payUData = {
79
+ key : payU_Key ,
80
+ txnid : data [ "txnid" ] ,
81
+ amount : data [ "amount" ] ,
82
+ productinfo : data [ "productinfo" ] ,
83
+ firstname : data [ "firstname" ] ,
84
+ email : data [ "email" ] ,
85
+ phone : data [ "phone" ] ,
86
+ surl : data [ "surl" ] ,
87
+ furl : data [ "furl" ] ,
88
+ hash : data [ "hash" ] ,
89
+ } ;
90
+
91
+ const payUForm = document . createElement ( "form" ) ;
92
+ payUForm . method = "post" ;
93
+ payUForm . action = payU_Action ;
94
+
95
+ for ( const key in payUData ) {
96
+ if ( payUData . hasOwnProperty ( key ) ) {
97
+ const hiddenField = document . createElement ( "input" ) ;
98
+ hiddenField . type = "hidden" ;
99
+ hiddenField . name = key ;
100
+ hiddenField . value = payUData [ key ] ;
101
+
102
+ payUForm . appendChild ( hiddenField ) ;
103
+ }
104
+ }
105
+
106
+ document . body . appendChild ( payUForm ) ;
107
+
108
+ payUForm . submit ( ) ;
109
+
110
+ // setMessage("Called PayU API to make payment.");
111
+ } else if ( response . status === 400 ) {
112
+ console . log ( data ) ;
113
+ ToastAlert ( "error" , "Registration Failed" , `${ data . MESSAGE } ` , toastRef ) ;
114
+ } else if ( response . status === 401 ) {
115
+ window . location . href = "/login" ;
116
+ } else {
117
+ ToastAlert ( "error" , "Registration Failed" , `${ data . MESSAGE } ` , toastRef ) ;
118
+ }
119
+ } catch ( err ) {
120
+ console . log ( err ) ;
121
+ // ToastAlert("error", "Registration Failed", `Error Occured`, toastRef);
122
+ }
123
+ } ;
124
+
125
+ useEffect ( ( ) => {
126
+ fetch ( `${ EVENT_DATA_URL } /141` , {
127
+ method : "GET" ,
128
+ headers : {
129
+ "Content-Type" : "application/json" ,
130
+ Authorization : `Bearer ${ secureLocalStorage . getItem ( "registerToken" ) } ` ,
131
+ } ,
132
+ } )
133
+ . then ( ( res ) => {
134
+ if ( res . ok ) {
135
+ return res . json ( ) ;
136
+ } else {
137
+ throw new Error ( `Error: ${ res . statusText } ` ) ;
138
+ }
139
+ } )
140
+ . then ( async ( data ) => {
141
+ if ( data . MODE === "0" ) {
142
+ secureLocalStorage . clear ( ) ;
143
+ }
144
+
145
+ setEventData ( data ) ;
146
+ setIsRegistered ( data . isRegistered === "1" ? true : false ) ;
147
+ setIsOpen ( data . seatsFilled >= data . maxSeats ? false : true ) ;
148
+ } )
149
+ . catch ( ( err ) => {
150
+ console . error ( "Error fetching data:" , err ) ;
151
+ } )
152
+ . finally ( ( ) => {
153
+ setLoading ( false ) ;
154
+ } ) ;
155
+ } , [ ] ) ;
156
+
157
+ const handleRegister = async ( e ) => {
158
+ e . preventDefault ( ) ;
159
+ if (
160
+ secureLocalStorage . getItem ( "isLoggedIn" ) == "0" ||
161
+ secureLocalStorage . getItem ( "isLoggedIn" ) == undefined ||
162
+ secureLocalStorage . getItem ( "isLoggedIn" ) == null
163
+ ) {
164
+ window . location . href = "/login" ;
165
+ return ;
166
+ }
167
+ confirm (
168
+ "Are you ready to make the payment? (You'll be redirected to the payment gateway to complete the registration.)"
169
+ ) && ( await getPayUForm ( ) ) ;
170
+ } ;
171
+
46
172
return (
47
173
< main className = "flex min-h-screen bg-[#192032] font-roobert text-md overflow-x-hidden" >
48
174
< WebGLApp colors = { webGLColors } className = "-z-10" />
@@ -75,49 +201,139 @@ const Lumere = () => {
75
201
2024
76
202
</ span >
77
203
</ p >
78
- < p className = "text-xl text-gray-200 z-10 max-w-3xl" >
79
- Lumière is a dynamic segment of Anokha 2024, where influential
80
- voices share insights on society, technology, and leadership.
204
+ < p className = "text-lg md:text- xl text-gray-200 z-10 max-w-3xl px-4 md:px-0 " >
205
+ A dynamic segment of Anokha 2024, where influential voices share
206
+ insights on society, technology, and leadership.
81
207
</ p >
82
- < button className = "mt-8 px-4 py-2 text-lg text-black bg-white font-semibold border rounded-full bg-red-10 z-10 hover:scale-105 transition" >
83
- Register
208
+ { ! loading ? (
209
+ < p className = "text-3xl md:text-xl font-bold bg-[rgba(0,0,0,0.3)] backdrop-blur-lg text-gray-200 z-10 max-w-3xl px-4 py-2 rounded-lg mt-4 border-2 border-gray-300" >
210
+ ₹{ Math . ceil ( eventData . eventPrice * 1.18 ) }
211
+ < span className = "text-sm" > { " (Incl. of GST)" } </ span >
212
+ </ p >
213
+ ) : null }
214
+ < button
215
+ className = { `mt-8 px-4 py-2 text-lg font-semibold border rounded-full z-10 transition
216
+ ${
217
+ loading || ! isOpen
218
+ ? "bg-gray-400 text-gray-700 cursor-not-allowed"
219
+ : "bg-white text-black hover:scale-105"
220
+ } `}
221
+ onClick = { handleRegister }
222
+ disabled = { loading || ! isOpen || isRegistered }
223
+ >
224
+ { loading ? (
225
+ < div className = "flex items-center" >
226
+ < svg
227
+ className = "animate-spin h-5 w-5 mr-3 text-black"
228
+ xmlns = "http://www.w3.org/2000/svg"
229
+ fill = "none"
230
+ viewBox = "0 0 24 24"
231
+ >
232
+ < circle
233
+ className = "opacity-25"
234
+ cx = "12"
235
+ cy = "12"
236
+ r = "10"
237
+ stroke = "currentColor"
238
+ strokeWidth = "4"
239
+ > </ circle >
240
+ < path
241
+ className = "opacity-75"
242
+ fill = "currentColor"
243
+ d = "M4 12a8 8 0 018-8v8H4z"
244
+ > </ path >
245
+ </ svg >
246
+ Checking Your Registration Status ...
247
+ </ div >
248
+ ) : isOpen ? (
249
+ secureLocalStorage . getItem ( "isLoggedIn" ) == "0" ||
250
+ secureLocalStorage . getItem ( "isLoggedIn" ) == undefined ||
251
+ secureLocalStorage . getItem ( "isLoggedIn" ) == null ? (
252
+ "Login to Register"
253
+ ) : isRegistered ? (
254
+ "Registered"
255
+ ) : (
256
+ "Register"
257
+ )
258
+ ) : (
259
+ "Registrations Closed"
260
+ ) }
84
261
</ button >
262
+
85
263
< div className = " inset-0 flex justify-center items-center" >
86
264
< div
87
265
onClick = { handleScrollMore }
88
- className = "bg-gray-400 tex animate-bounce absolute md:top-[92%] sm:top-[90%] w-32 rounded-full px-3 py-2 flex items-center justify-center cursor-pointer"
266
+ className = "bg-gray-400 tex animate-bounce absolute md:top-[92%] sm:top-[90%] w-36 rounded-full px-3 py-2 flex items-center justify-center cursor-pointer"
89
267
>
90
- Scroll More < FaAngleDoubleDown className = "ml-2" />
268
+ Know More < FaAngleDoubleDown className = "ml-2" />
91
269
</ div >
92
270
</ div >
93
271
</ div >
94
272
95
- < div className = "mt-16 px-4" >
273
+ < div className = "mt-16 px-4 min-h-fit sm:min-h-screen md:min-h-screen lg:min-h-fit " >
96
274
< h2 className = "text-4xl font-bold text-center mb-8 text-white" >
97
275
The Speakers
98
276
</ h2 >
99
- < p className = "text-center text-gray-300 mb-12" >
100
- Lumière features inspiring talks and an interactive Q& A , and a
101
- panel on & ldquo ; Language & Literature in the Age of Programming &
102
- AI & rdquo ;
103
- </ p >
277
+ < div className = "flex justify-center" >
278
+ < p className = "text-center text-gray-300 mb-12 lg:w-1/2" >
279
+ Lumière features inspiring talks from renowned figures, offering
280
+ interactive Q& A sessions for attendees to engage directly and
281
+ gain fresh insights .
282
+ </ p >
283
+ </ div >
284
+
104
285
< div className = "flex flex-wrap justify-center gap-8" >
105
- { speakers . map ( ( speaker , index ) => (
106
- < div
107
- key = { index }
108
- className = "py-4 px-12 rounded-lg w-full sm:w-auto"
109
- >
110
- < div className = "w-32 h-32 mx-auto mb-4 bg-gray-700 rounded-full flex items-center justify-center text-gray-400 text-4xl font-bold" >
111
- { speaker . name . charAt ( 0 ) }
286
+ { speakers . map ( ( speaker , index ) =>
287
+ index < 3 ? (
288
+ < div
289
+ key = { index }
290
+ className = "py-4 px-12 rounded-lg w-full sm:w-auto"
291
+ >
292
+ < div className = "w-32 h-32 mx-auto mb-4 bg-gray-700 rounded-full flex items-center justify-center text-gray-400 text-4xl font-bold" >
293
+ < Image
294
+ src = { `/images/speaker${ index + 1 } .jpg` }
295
+ width = { 128 }
296
+ height = { 128 }
297
+ alt = { speaker . name [ 0 ] }
298
+ className = "rounded-full"
299
+ />
300
+ </ div >
301
+ < h3 className = "font-bold text-xl text-white text-center mb-2" >
302
+ { speaker . name }
303
+ </ h3 >
304
+ < p className = "text-gray-300 text-center text-sm max-w-xs mx-auto" >
305
+ { speaker . role }
306
+ </ p >
112
307
</ div >
113
- < h3 className = "font-bold text-xl text-white text-center mb-2" >
114
- { speaker . name }
115
- </ h3 >
116
- < p className = "text-gray-300 text-center text-sm max-w-xs mx-auto" >
117
- { speaker . role }
118
- </ p >
119
- </ div >
120
- ) ) }
308
+ ) : null
309
+ ) }
310
+ </ div >
311
+
312
+ < div className = "flex flex-wrap justify-center gap-8" >
313
+ { speakers . map ( ( speaker , index ) =>
314
+ index > 2 ? (
315
+ < div
316
+ key = { index }
317
+ className = "py-4 px-12 rounded-lg w-full sm:w-auto"
318
+ >
319
+ < div className = "w-32 h-32 mx-auto mb-4 bg-gray-700 rounded-full flex items-center justify-center text-gray-400 text-4xl font-bold" >
320
+ < Image
321
+ src = { `/images/speaker${ index + 1 } .jpg` }
322
+ width = { 128 }
323
+ height = { 128 }
324
+ alt = { speaker . name [ 0 ] }
325
+ className = "rounded-full"
326
+ />
327
+ </ div >
328
+ < h3 className = "font-bold text-xl text-white text-center mb-2" >
329
+ { speaker . name }
330
+ </ h3 >
331
+ < p className = "text-gray-300 text-center text-sm max-w-xs mx-auto" >
332
+ { speaker . role }
333
+ </ p >
334
+ </ div >
335
+ ) : null
336
+ ) }
121
337
</ div >
122
338
</ div >
123
339
</ div >
0 commit comments