Fixed issue causing reviews from other issues not to be displayed
parent
822ef4510a
commit
04fb307b7a
|
|
@ -16,7 +16,13 @@ const props = defineProps({
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{ data: "name", title: "Name" },
|
{ data: "name", title: "Name" },
|
||||||
{ data: "tags", title: "Tags" },
|
{
|
||||||
|
data: "tags",
|
||||||
|
title: "Tags",
|
||||||
|
render: {
|
||||||
|
_: "[, ]",
|
||||||
|
},
|
||||||
|
},
|
||||||
{ data: "average_rating", title: "" },
|
{ data: "average_rating", title: "" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref, watch } from "vue";
|
import { ref, watch } from "vue";
|
||||||
import { pb } from "../pocketbase";
|
import { pb } from "../pocketbase";
|
||||||
import RatingField from "./RatingField.vue";
|
import RatingField from "./RatingField.vue";
|
||||||
|
|
||||||
|
|
@ -10,11 +10,26 @@ const props = defineProps({
|
||||||
const reviews = ref<Object[]>([]);
|
const reviews = ref<Object[]>([]);
|
||||||
|
|
||||||
async function load(restaurantId: string) {
|
async function load(restaurantId: string) {
|
||||||
reviews.value = await pb.collection("reviews").getFullList({
|
const _reviews = await pb.collection("reviews").getFullList({
|
||||||
filter: pb.filter("restaurant ~ {:id}", { id: restaurantId }),
|
filter: pb.filter("restaurant ~ {:id}", { id: restaurantId }),
|
||||||
expand: "user",
|
|
||||||
sort: "-created",
|
sort: "-created",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const users = await pb.collection("public_users").getFullList();
|
||||||
|
|
||||||
|
const usersmap: Record<string, string> = users.reduce(
|
||||||
|
(previous, current) => ({
|
||||||
|
...previous,
|
||||||
|
[current.id]: current.username,
|
||||||
|
}),
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
|
||||||
|
_reviews.forEach((review) => {
|
||||||
|
review.username = usersmap[review.user];
|
||||||
|
});
|
||||||
|
|
||||||
|
reviews.value = _reviews;
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
@ -48,7 +63,7 @@ defineExpose({ refresh });
|
||||||
<template v-for="review in reviews" :key="review.id">
|
<template v-for="review in reviews" :key="review.id">
|
||||||
<div class="card card-compact bg-base-100 shadow-xl">
|
<div class="card card-compact bg-base-100 shadow-xl">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h2 class="card-title">{{ review.expand.user.username }}</h2>
|
<h2 class="card-title">{{ review.username }}</h2>
|
||||||
<div class="flex flex-row">
|
<div class="flex flex-row">
|
||||||
<p class="text-left">{{ review.text }}</p>
|
<p class="text-left">{{ review.text }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue