1
+ 'use client'
2
+
3
+ import { motion } from 'framer-motion'
4
+ import { ChevronLeft } from 'lucide-react'
5
+ import { Button } from '@/components/ui/button'
6
+ import { Card } from '@/components/ui/card'
7
+ import Image from 'next/image'
8
+ import { Planet , Departure , User } from '@/types/Travel'
9
+
10
+ interface BookingConfirmationProps {
11
+ planet : Planet
12
+ departure : Departure
13
+ user : User
14
+ onBack : ( ) => void
15
+ } ;
16
+
17
+ function QRCodePattern ( ) {
18
+ const size = 10
19
+ const cells = Array ( size * size ) . fill ( 0 ) . map ( ( ) => Math . random ( ) > 0.5 )
20
+
21
+ return (
22
+ < div className = "w-48 h-48 bg-[#2C4F64] p-4 rounded-3xl" >
23
+ < div className = "w-full h-full grid grid-cols-10 gap-1" >
24
+ { cells . map ( ( filled , i ) => (
25
+ < div key = { i } className = { `rounded-sm ${ filled ? 'bg-[#5FCBC3]' : 'bg-transparent' } ` } > </ div >
26
+ ) ) }
27
+ </ div >
28
+ </ div >
29
+ ) ;
30
+ } ;
31
+
32
+ export default function BookingConfirmation ( { planet, departure, user, onBack } : BookingConfirmationProps ) {
33
+ return (
34
+ < div className = "h-[calc(100vh-4rem)]" >
35
+ < header className = "flex items-center gap-4 mb-8" >
36
+ < button onClick = { onBack } className = "w-10 h-10 rounded-full bg-[#2C4F64] flex items-center justify-center" >
37
+ < ChevronLeft className = "w-6 h-6" />
38
+ </ button >
39
+ < h1 className = "text-2xl font-bold" > Booking Confirmation</ h1 >
40
+ </ header >
41
+
42
+ < motion . div
43
+ initial = { { opacity : 0 , y : 20 } }
44
+ animate = { { opacity : 1 , y : 0 } }
45
+ className = "space-y-6"
46
+ >
47
+ < Card className = "bg-[#2C4F64] border-none p-6" >
48
+ < div className = "flex justify-between items-start mb-6" >
49
+ < div >
50
+ < h2 className = "text-2xl font-bold mb-1" > { planet . name } </ h2 >
51
+ < p className = "text-sm text-[#F7F5E9]/60" > { planet . station } </ p >
52
+ </ div >
53
+ < Image
54
+ src = { planet . image }
55
+ alt = { planet . name }
56
+ width = { 60 }
57
+ height = { 60 }
58
+ className = "rounded-lg"
59
+ />
60
+ </ div >
61
+
62
+ < div className = "space-y-4" >
63
+ < div className = "flex justify-between" >
64
+ < span className = "text-[#F7F5E9]/60" > Passenger</ span >
65
+ < span > { user . name
66
+ } </ span >
67
+ </ div >
68
+ < div className = "flex justify-between" >
69
+ < span className = "text-[#F7F5E9]/60" > Departure</ span >
70
+ < span > { new Date ( departure . departureTime ) . toLocaleString ( ) } , Gate { departure . gate } </ span >
71
+ </ div >
72
+ < div className = "flex justify-between" >
73
+ < span className = "text-[#F7F5E9]/60" > Duration</ span >
74
+ < span > { departure . duration } </ span >
75
+ </ div >
76
+ < div className = "flex justify-between" >
77
+ < span className = "text-[#F7F5E9]/60" > Rocket</ span >
78
+ < span > { departure . rocketType } </ span >
79
+ </ div >
80
+ </ div >
81
+
82
+ < div className = "mt-6 pt-6 border-t border-[#F7F5E9]/10" >
83
+ < div className = "flex justify-between items-end" >
84
+ < div >
85
+ < span className = "text-sm text-[#F7F5E9]/60" > Total Price</ span >
86
+ < p className = "text-2xl font-bold" > ${ departure . price } </ p >
87
+ </ div >
88
+ < div className = "text-right" >
89
+ < span className = "text-sm text-[#F7F5E9]/60" > Booking Reference</ span >
90
+ < p className = "font-mono" > { planet . name . substring ( 0 , 3 ) . toUpperCase ( ) } -{ Math . random ( ) . toString ( 36 ) . substring ( 2 , 7 ) . toUpperCase ( ) } </ p >
91
+ </ div >
92
+ </ div >
93
+ </ div >
94
+ </ Card >
95
+
96
+ < div className = "flex justify-center" >
97
+ < QRCodePattern />
98
+ </ div >
99
+
100
+ < Button
101
+ className = "w-full bg-[#5FCBC3] hover:bg-[#B9E678] text-[#1D2833]"
102
+ size = "lg"
103
+ >
104
+ Download Ticket
105
+ </ Button >
106
+ </ motion . div >
107
+ </ div >
108
+ ) ;
109
+ } ;
0 commit comments