Ignore:
Timestamp:
04/01/25 22:58:15 (2 months ago)
Author:
ste08 <sjovanoska@…>
Branches:
master
Children:
8ae59d6
Parents:
3a74959
Message:

Adding review works\!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/resources/static/ReviewPage.html

    r3a74959 rff72ad2  
    1111    <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/css/all.min.css'>
    1212    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
    13 </head>
    1413<style>
    1514    .popup-overlay {
     
    7170
    7271</style>
     72</head>
    7373<body>
    7474
     
    7676    <header class="app-header">
    7777        <button class="logout-btn" @click="logout">Log Out</button>
    78         <button class="logout-btn" @click="leaveReview">Leave a review</button>
     78        <button class="show-popup" @click="leaveReview">Leave a review</button>
    7979    </header>
    8080
     
    9292        </div>
    9393    </div>
    94 </div>
     94    <div v-if="showPopup" class="popup-overlay">
     95        <div class="popup">
     96            <h3>Leave a review</h3>
    9597
    96 <div v-if="showPopup" class="popup-overlay">
    97     <div class="popup">
    98         <h3>Leave a review</h3>
     98            <select v-model="selectedFlightId" id="flightNumbers">
     99                <option value="" disabled selected>Select a flight</option>
     100                <option v-for="flight in flights" :key="flight.flightId" :value="flight.flightId">
     101                    {{ flight.flightNumber }}
     102                </option>
     103            </select>
    99104
    100         <select v-model="selectedFlightNumber" id="flights">
    101             <option value="" disabled selected>Select a flight</option>
    102             <option v-for="flight in flights" :key="flight.flightNumber" :value="flight.flightNumber">
    103                 {{ flight.flightNumber }}
    104             </option>
    105         </select>
    106105
    107         <textarea v-model="reviewComment" placeholder="Leave a comment here..." rows="5"></textarea>
    108106
    109         <textarea v-model="rating" placeholder="Rate 1-5" rows="1"></textarea>
     107            <textarea v-model="reviewComment" placeholder="Leave a comment here..." rows="5"></textarea>
    110108
    111         <div class="popup-actions">
    112             <button @click="submitReview" class="submit-btn">Submit</button>
    113             <button @click="closePopup" class="cancel-btn">Cancel</button>
     109            <textarea v-model="rating" placeholder="Rate 1-5" rows="1"></textarea>
     110
     111            <div class="popup-actions">
     112                <button @click="submitReview" class="submit-btn">Submit</button>
     113                <button @click="closePopup" class="cancel-btn">Cancel</button>
     114            </div>
    114115        </div>
    115116    </div>
    116117</div>
     118
    117119
    118120<script>
     
    126128            rating: '',
    127129            flights: [],
    128             selectedFlightNumber: ''
     130            selectedFlightId: '',
     131            flightNumbers:''
    129132        },
    130133        methods: {
     
    142145            leaveReview() {
    143146                this.showPopup = true;
     147                this.selectedFlightNumber = '';
    144148            },
    145149            closePopup() {
     
    147151            },
    148152            submitReview() {
    149                 if (this.reviewComment.trim() && this.selectedFlightNumber) {
     153                if (this.reviewComment.trim() && this.selectedFlightId) {
    150154                    const reviewData = {
    151                         userId: this.userId,
    152                         flightNumber: this.selectedFlightNumber,
     155                        userID: this.userId,
     156                        targetID: this.selectedFlightId,
    153157                        reviewComment: this.reviewComment,
    154158                        rating: this.rating
    155159                    };
     160                    console.log(reviewData);
    156161
    157162                    axios.post('/api/reviews', reviewData)
     
    169174                try {
    170175                    const response = await axios.get('/api/flights');
    171                     this.flights = response.data;
     176                    this.flights = response.data.map(flight => ({
     177                        flightId: flight.flightID,
     178                        flightNumber: flight.flightNumber
     179                    }));
    172180                    console.log(this.flights);
    173181                } catch (error) {
     
    181189            this.fetchReviews();
    182190            this.fetchFlights();
     191            this.showPopup = false;
    183192        }
    184193    });
Note: See TracChangeset for help on using the changeset viewer.