mirror of
https://gitlab.com/little-lines/frontend.git
synced 2024-11-22 07:16:51 +00:00
front_get
This commit is contained in:
parent
82e1e4e86a
commit
b570367142
1 changed files with 62 additions and 78 deletions
|
@ -1,79 +1,63 @@
|
||||||
<template>
|
<template>
|
||||||
<!-- <h1>Favorite</h1> -->
|
<div>
|
||||||
|
<h1>My Favorites</h1>
|
||||||
<!-- <v-card
|
<ul>
|
||||||
class="mx-auto"
|
<li v-for="(favorite, index) in favorites" :key="index">
|
||||||
max-width="420"
|
<p>Favorite {{ index + 1 }}:</p>
|
||||||
height="600"
|
<p>Favorite ID: {{ favorite.place_name }}</p>
|
||||||
>
|
<p>Favorite Name: {{ favorite.place_name }}</p>
|
||||||
|
<!-- แสดงข้อมูลเพิ่มเติมหรือ field อื่นๆ ตามต้องการ -->
|
||||||
<v-list lines="two">
|
</li>
|
||||||
<v-list-item
|
</ul>
|
||||||
v-for="item in items"
|
</div>
|
||||||
:key="item.title"
|
|
||||||
:title="item.title"
|
|
||||||
:subtitle="item.desc"
|
|
||||||
:prepend-avatar="pin_svg"
|
|
||||||
></v-list-item>
|
|
||||||
</v-list>
|
|
||||||
|
|
||||||
</v-card> -->
|
|
||||||
|
|
||||||
<v-card fluid
|
|
||||||
class="mx-auto"
|
|
||||||
max-width="500px"
|
|
||||||
width="90vw"
|
|
||||||
|
|
||||||
max-height="600px"
|
|
||||||
height="90vh"
|
|
||||||
>
|
|
||||||
<v-list
|
|
||||||
item-props
|
|
||||||
lines="three"
|
|
||||||
>
|
|
||||||
<v-list-item
|
|
||||||
v-for="(item, i) in items"
|
|
||||||
:to="{name: 'destination-info'}"
|
|
||||||
:key="i"
|
|
||||||
:value="item"
|
|
||||||
|
|
||||||
>
|
|
||||||
<template v-slot:prepend>
|
|
||||||
<v-avatar>
|
|
||||||
<v-img
|
|
||||||
:height="30"
|
|
||||||
src= "./icons/Adwaita/pin.svg"
|
|
||||||
></v-img>
|
|
||||||
</v-avatar>
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<v-list-item-title v-text="item.title"></v-list-item-title>
|
<script>
|
||||||
<v-list-item-subtitle v-text="item.desc"></v-list-item-subtitle>
|
import { ref, onMounted } from 'vue';
|
||||||
<v-divider></v-divider>
|
|
||||||
</v-list-item>
|
|
||||||
</v-list>
|
|
||||||
</v-card>
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
const favorites = ref([]);
|
||||||
|
|
||||||
</template>
|
onMounted(async () => {
|
||||||
|
try {
|
||||||
|
const currentUser = JSON.parse(sessionStorage.getItem('current_user'));
|
||||||
|
|
||||||
<script setup>
|
if (currentUser && currentUser.id) {
|
||||||
import {RouterLink} from 'vue-router';
|
const response = await fetch(`https://little-lines-backend.techtransthai.org/api/favorites/${currentUser.id}`);
|
||||||
|
|
||||||
const pin_svg = "./icons/Adwaita/pin.svg"
|
if (!response.ok) {
|
||||||
const items = [
|
throw new Error('Failed to fetch favorites');
|
||||||
{
|
}
|
||||||
title: 'หอพักนักศึกษา',
|
|
||||||
desc: 'ลาดกระบัง, กรุงเทพมหานคร',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'อนุสาวรีย์ชัยสมรภูมิ',
|
|
||||||
desc: 'ราชเทวี, กรุงเทพมหานคร',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style >
|
const data = await response.json();
|
||||||
|
favorites.value = data.favorites;
|
||||||
|
console.log(data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
favorites
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
/* สามารถใส่ style ได้ตามต้องการ */
|
||||||
|
/* ตัวอย่าง */
|
||||||
|
ul {
|
||||||
|
list-style-type: none;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
li {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
</style>
|
|
Loading…
Reference in a new issue