Ignore:
Timestamp:
02/23/25 20:37:56 (3 months ago)
Author:
ste08 <sjovanoska@…>
Branches:
master
Children:
fda671c
Parents:
de83113
git-author:
ste08 <sjovanoska@…> (02/23/25 20:37:23)
git-committer:
ste08 <sjovanoska@…> (02/23/25 20:37:56)
Message:

Report working, Wishlist partly working.

File:
1 edited

Legend:

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

    rde83113 r62bba0c  
    44    <meta charset="UTF-8">
    55    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6     <title>SkyChase-mk</title>
     6    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
     7    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
     8    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
     9    <link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/css/all.min.css'>
     10
     11    <title>SkyChase - Wishlist</title>
    712    <style>
    813        body {
     
    2429            display: flex;
    2530            align-items: center;
    26             background-color:rebeccapurple;
     31            background-color: rebeccapurple;
    2732            padding: 10px;
    2833            width: 100%;
     
    7378            background-color: #0056b3;
    7479        }
     80
    7581        .adminlogin {
    76             top:0;
     82            top: 0;
    7783            right: 0;
    7884            background-color: rebeccapurple;
    79             border:0;
    80             color:white;
     85            border: 0;
     86            color: white;
    8187            padding: 0 1200px;
     88        }
     89
     90        .wishlist-content {
     91            margin-top: 60px;
     92            color: white;
     93        }
     94
     95        ul {
     96            list-style-type: none;
     97        }
     98
     99        li {
     100            margin: 10px 0;
     101            font-size: 18px;
    82102        }
    83103    </style>
     
    90110</div>
    91111
    92 <div class="buttons">
    93     <h1>Test</h1>
     112<div class="wishlist-content">
     113    <h1>Your Wishlist</h1>
     114    <ul>
     115        <li v-if="wishlist.length === 0">Your wishlist is empty!</li>
     116        <li v-else v-for="item in wishlist" :key="item.wishlistID">{{ item.targetId }} || {{item.userId}}</li>
     117    </ul>
    94118</div>
     119
     120<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
     121
     122<script>
     123    new Vue({
     124        el: '#app',
     125        data: {
     126            userId: ''
     127        },
     128        mounted() {
     129            const params = new URLSearchParams(window.location.search);
     130            this.userId = params.get("userId");
     131            this.fetchWishlist();
     132        },
     133        async fetchWishlist() {
     134            try {
     135                const response = await fetch(`/api/wishlists/${this.userId}`);
     136                const wishlist = await response.json();
     137
     138                const wishlistElement = document.getElementById('wishlist');
     139                const emptyMessage = document.getElementById('empty-message');
     140
     141                if (wishlist.length === 0) {
     142                    emptyMessage.style.display = 'block';
     143                } else {
     144                    emptyMessage.style.display = 'none';
     145                    wishlistElement.innerHTML = wishlist.map(item => `<li>${item.name}</li>`).join('');
     146                }
     147            } catch (error) {
     148                console.error('Error fetching wishlist:', error);
     149            }
     150        }
     151    })
     152    //window.onload = fetchWishlist;
     153</script>
    95154</body>
    96155</html>
Note: See TracChangeset for help on using the changeset viewer.