1
+ import React , { useState , useEffect , useRef } from 'react' ;
2
+ import { useParams , useLocation } from 'react-router-dom' ;
3
+ import axios from 'axios' ;
4
+ import toast , { Toaster } from 'react-hot-toast' ;
5
+ import Searchbar from './searchbar' ;
6
+
7
+ const Finalbill = ( ) => {
8
+ const location = useLocation ( ) ;
9
+ const queryParams = new URLSearchParams ( location . search ) ;
10
+ const objectId = queryParams . get ( 'objectId' ) ;
11
+ const [ finalBill , setFinalBill ] = useState ( { } ) ;
12
+ const toastRef = useRef ( false ) ;
13
+
14
+ useEffect ( ( ) => {
15
+ axios . post ( `http://127.0.0.1:5001/get_finalbill` , {
16
+ objectId : objectId // Pass the objectId to the request body
17
+ } )
18
+ . then ( response => {
19
+ if ( ! toastRef . current ) {
20
+ toast . success ( 'Tickets confirmed' , {
21
+ position : "top-center" ,
22
+ style : {
23
+ border : '1px solid #713200' ,
24
+ padding : '24px' ,
25
+ color : '#713200' ,
26
+ tabSize :'20rem' ,
27
+ borderRadius :'50px' ,
28
+ } ,
29
+ iconTheme : {
30
+ primary : '#713200' ,
31
+ secondary : '#FFFAEE' ,
32
+ } ,
33
+ duration :4000 ,
34
+ } ) ;
35
+ toastRef . current = true ;
36
+ }
37
+ setFinalBill ( response . data ) ;
38
+ } )
39
+ . catch ( error => {
40
+ console . error ( error ) ;
41
+ } ) ;
42
+
43
+ } , [ objectId ] ) ;
44
+
45
+
46
+ return (
47
+ < div className = 'text-white px-24 py-3 h-screen' >
48
+ < Searchbar />
49
+ < Toaster />
50
+ < div className = 'flex justify-start pt-12' >
51
+ < p className = 'inline text-center text-5xl font-semibold font-poppins mb-14' > Final Bill</ p >
52
+ </ div >
53
+ < div className = 'flex justify-between px-4' >
54
+ < div className = 'border w-fit' >
55
+ { Object . keys ( finalBill ) . length > 0 && (
56
+ < div className = 'p-12' >
57
+ { Object . keys ( finalBill ) . map ( key => (
58
+ < p key = { key } className = 'w-fit text-4xl font-medium py-3' >
59
+ < span className = 'text-yellow-300' >
60
+ { key === 'Bill_id' ? 'Bill ID' : key }
61
+ </ span > : { finalBill [ key ] }
62
+ </ p >
63
+ ) ) }
64
+ </ div >
65
+ ) }
66
+ </ div >
67
+ < div >
68
+ < p className = 'text-4xl font-poppins font-semibold mb-3' > Thank you for choosing us</ p >
69
+ < p className = 'text-xl font-poppins font-medium text-center' > Make a note of your bill id</ p >
70
+ </ div >
71
+ </ div >
72
+ </ div >
73
+ ) ;
74
+ } ;
75
+
76
+ export default Finalbill ;
0 commit comments