File tree 1 file changed +32
-3
lines changed
1 file changed +32
-3
lines changed Original file line number Diff line number Diff line change 18
18
< h1 > Search a best price</ h1 >
19
19
20
20
< div class ="row ">
21
- < div class ="col ">
22
- < div class ="list-group " id ="airportList "> </ div >
23
- </ div >
24
21
< div class ="col ">
25
22
< form class ="row g-3 needs-validation " id ="formBestPrice " novalidate >
26
23
< div class ="col-md-6 mb-3 ">
@@ -75,6 +72,15 @@ <h1>Search a best price</h1>
75
72
</ div >
76
73
</ div >
77
74
</ div >
75
+
76
+ < div class ="row ">
77
+ < div class ="col ">
78
+ < div class ="list-group " id ="airportList "> </ div >
79
+ </ div >
80
+ < div class ="col ">
81
+ < ul class ="list-group " id ="flightList "> </ ul >
82
+ </ div >
83
+ </ div >
78
84
</ div >
79
85
80
86
< script
@@ -111,6 +117,29 @@ <h5 class="mb-1">${airport.name}</h5>
111
117
} ) ;
112
118
} ) ;
113
119
120
+ /* Get All Flights */
121
+ fetch ( "/flight" )
122
+ . then ( ( response ) => response . json ( ) )
123
+ . then ( ( data ) => {
124
+ data . forEach ( ( flight ) => {
125
+ let item = document . createElement ( "li" ) ;
126
+ item . classList . add (
127
+ "list-group-item" ,
128
+ "d-flex" ,
129
+ "justify-content-between"
130
+ ) ;
131
+ item . innerHTML = `
132
+ ${ flight . code_departure } -> ${ flight . code_arrival }
133
+ <span class='h4' >€ ${ flight . price } </span>
134
+ ` ;
135
+
136
+ document . querySelector ( "#flightList" ) . appendChild ( item ) ;
137
+ } ) ;
138
+ } )
139
+ . catch ( ( e ) => {
140
+ console . error ( e ) ;
141
+ } ) ;
142
+
114
143
let form = document . querySelector ( "#formBestPrice" ) ;
115
144
form . addEventListener (
116
145
"submit" ,
You can’t perform that action at this time.
0 commit comments