Changeset de83113 for src/main/resources/static
- Timestamp:
- 02/17/25 21:52:11 (4 months ago)
- Branches:
- master
- Children:
- 62bba0c
- Parents:
- 9868304
- Location:
- src/main/resources/static
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/resources/static/FlightSearch.html
r9868304 rde83113 252 252 <h2>Available Flights</h2> 253 253 <div class="flights-list"> 254 <div class="flight-item" v-for="flight in flights" :key="flight.flightI d">254 <div class="flight-item" v-for="flight in flights" :key="flight.flightID"> 255 255 <input type="checkbox" v-model="flight.selected" /> 256 256 <span>{{ flight.departureTime }} | {{ flight.arrivalTime }} | ${{ flight.price }} | {{ flight.availableSeats }}</span> … … 295 295 showReturnDate: false, 296 296 showPopup: false, 297 issueDescription: "" 297 issueDescription: '', 298 userId:'' 298 299 }, 299 300 computed: { … … 302 303 } 303 304 }, 305 304 306 methods: { 305 307 async searchFlights() { … … 337 339 338 340 const flight = this.selectedFlights[0]; 341 console.log(flight); 339 342 const totalCost = flight.price; 343 340 344 const bookingData = { 341 flightId: flight.flightI d,345 flightId: flight.flightID, 342 346 bookingDate: new Date().toISOString().split('T')[0], 343 347 status: 'PENDING', 344 totalCost: totalCost 348 totalCost: totalCost, 349 userId:this.userId 345 350 }; 346 347 351 axios.post('/api/bookings', bookingData) 348 352 .then(response => { 349 const bookingID = response.data.bookingI D;353 const bookingID = response.data.bookingId; 350 354 alert("Booked successfully!"); 351 window.location.href = `/transaction?amount=${encodeURIComponent(totalCost)}&bookingId=${encodeURIComponent(bookingID)}&flightId=${encodeURIComponent(flight.flightI d)}`;355 window.location.href = `/transaction?amount=${encodeURIComponent(totalCost)}&bookingId=${encodeURIComponent(bookingID)}&flightId=${encodeURIComponent(flight.flightID)}&userId=${encodeURIComponent(this.userId)}`; 352 356 }) 353 357 .catch(error => { … … 383 387 if (this.issueDescription.trim()) { 384 388 const reviewData = { 385 userID: 1,389 userID: this.userId, 386 390 subject: "Issue Report", 387 391 description: this.issueDescription … … 413 417 mounted() { 414 418 this.fetchFlights(); 419 const params = new URLSearchParams(window.location.search); 420 this.userId = params.get("userId"); 415 421 axios.get('api/flights') 416 422 .then(response => { … … 420 426 console.error("Error fetching flights", error); 421 427 }); 428 422 429 } 423 430 }); -
src/main/resources/static/TransactionPage.html
r9868304 rde83113 263 263 expiration: '', 264 264 amount: '', 265 paymentSuccess: false 266 }, 267 created(){ 268 const urlParams = new URLSearchParams(window.location.search); 269 this.flightId = urlParams.get('flightId'); 270 this.amount = urlParams.get('amount'); 271 this.bookingId = urlParams.get('bookingId') 272 273 const user = JSON.parse(localStorage.getItem("user")); 274 if(user){ 275 this.userId = user.id; 276 } 265 paymentSuccess: false, 266 flightId:'', 267 userId:'' 277 268 }, 278 269 methods: { … … 282 273 transaction_date:paymentDate, 283 274 payment_status:'SUCCESS', 284 amount: this.amount,285 userId: this.userId,286 bookingId: this.bookingId275 amount:Number(this.amount) || null, 276 userId:Number(this.userId) || null, 277 bookingId:Number(this.bookingId) || null 287 278 }; 288 279 console.log(transaction); … … 291 282 console.log(response.data); 292 283 this.paymentSuccess = true; 284 this.updateBooking(); 293 285 setTimeout(() => window.location.href = '/flights',2000); 294 286 }) 295 287 .catch(error => console.error("Payment failed", error)); 296 288 }, 289 updateBooking() { 290 const booking = { 291 bookingDate: new Date().toISOString().split('T')[0], 292 flightId:this.flightId, 293 payment_status:'SUCCESS', 294 total_cost:Number(this.amount) || null, 295 userId:Number(this.userId) || null, 296 bookingId:Number(this.bookingId) || null 297 }; 298 console.log(booking); 299 axios.put(`api/flights/${this.bookingId}`, booking) 300 .then(response => { 301 console.log(response.data); 302 }) 303 .catch(error => console.error("Booking update failed", error)); 304 }, 297 305 cancelPayment() { 298 window.location.href = '/flights'; // Redirecting to flight search on cancel306 window.location.href = '/flights'; 299 307 }, 300 308 validateForm() { … … 305 313 ); 306 314 } 315 }, 316 mounted(){ 317 const params = new URLSearchParams(window.location.search); 318 this.userId = params.get("userId"); 319 this.bookingId = params.get("bookingId"); 320 this.flightId = params.get("flightId"); 321 this.amount=params.get("amount"); 307 322 } 308 323 });
Note:
See TracChangeset
for help on using the changeset viewer.