diff --git a/components/Layout/Footer.vue b/components/Layout/Footer.vue
index 019739997..0c7a340f1 100644
--- a/components/Layout/Footer.vue
+++ b/components/Layout/Footer.vue
@@ -36,7 +36,8 @@ export default defineNuxtComponent({
>
-
+
+
diff --git a/components/Layout/Header.vue b/components/Layout/Header.vue
index 40ec50333..97729d7e5 100644
--- a/components/Layout/Header.vue
+++ b/components/Layout/Header.vue
@@ -43,6 +43,8 @@ export default defineNuxtComponent({
:logo-url="theme && theme.logo_url"
/>
+
+
diff --git a/components/PoisList/Actions.vue b/components/PoisList/Actions.vue
index a1ba8b3a3..7986ac534 100644
--- a/components/PoisList/Actions.vue
+++ b/components/PoisList/Actions.vue
@@ -1,19 +1,16 @@
diff --git a/components/PoisList/PoisList.vue b/components/PoisList/PoisList.vue
deleted file mode 100644
index f11f350b5..000000000
--- a/components/PoisList/PoisList.vue
+++ /dev/null
@@ -1,144 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/components/PoisList/PoisTable.vue b/components/PoisList/PoisTable.vue
index a9a223f70..2c3dfd25f 100644
--- a/components/PoisList/PoisTable.vue
+++ b/components/PoisList/PoisTable.vue
@@ -8,6 +8,8 @@ import IconButton from '~/components/UI/IconButton.vue'
import ContribFieldGroup from '~/components/Fields/ContribFieldGroup.vue'
import Actions from '~/components/PoisList/Actions.vue'
import TeritorioIconBadge from '~/components/UI/TeritorioIconBadge.vue'
+import { getPoiByCategoryId } from '~/lib/apiPois'
+import { siteStore as useSiteStore } from '~/stores/site'
interface DataTableHeader {
filterable: boolean
@@ -18,23 +20,44 @@ interface DataTableHeader {
const props = defineProps<{
category: ApiMenuCategory
- fields: FieldsListItem[]
- pois: ApiPois
}>()
const { t } = useI18n()
+const siteStore = useSiteStore()
const { $propertyTranslations } = useNuxtApp()
const { contribMode, isContribEligible, getContributorFields } = useContrib()
-
const search = ref('')
-function customFilter(value: any, query: string): boolean {
- return query !== null && value !== null && typeof value === 'string' && value.toLowerCase().includes(query.toLowerCase())
-}
+// Fetch POIs by Cache or API
+const { data: pois, pending, error } = await useAsyncData(`pois-${props.category.id}`, async () => {
+ const { data: cache } = useNuxtData(`pois-${props.category.id}`)
+ if (cache.value)
+ return cache.value as ApiPois
+
+ return await getPoiByCategoryId(
+ siteStore.config!,
+ props.category.id,
+ { geometry_as: 'point', short_description: true },
+ )
+}, {
+ watch: [props.category],
+})
+
+if (error.value || !pois.value)
+ throw createError({ statusCode: 404, statusMessage: 'POIs not found.' })
+// Handle default config field if not provided by API
+const fields = computed((): FieldsListItem[] => {
+ return (
+ (pois.value?.features[0].properties.editorial?.list_fields)
+ || [{ field: 'name' }]
+ )
+})
+
+// Transform headers data to be compliant with Vuetify's standards
const headers = computed((): Array => {
// Basic Fields
- const headers: Array = props.fields.map(f => ({
+ const headers: Array = fields.value.map(f => ({
filterable: true,
key: f.field,
title: $propertyTranslations.p(
@@ -62,10 +85,14 @@ const headers = computed((): Array => {
return headers
})
+
+function customFilter(value: any, query: string): boolean {
+ return query !== null && value !== null && typeof value === 'string' && value.toLowerCase().includes(query.toLowerCase())
+}
-
+
=> {
/>
=> {
+
+
+
diff --git a/lib/apiPois.ts b/lib/apiPois.ts
index 385ee4dfd..fa6c63fd7 100644
--- a/lib/apiPois.ts
+++ b/lib/apiPois.ts
@@ -166,13 +166,13 @@ export function getPoiByCategoryIdUrl(
)
}
-export function getPoiByCategoryId(
+export async function getPoiByCategoryId(
vidoConfig: VidoConfig,
categoryId: number | string,
options: ApiPoisOptions = {},
): Promise
{
options = Object.assign(defaultOptions, { geometry_as: 'point' }, options)
- return fetch(getPoiByCategoryIdUrl(vidoConfig, categoryId, options)).then(
+ return await fetch(getPoiByCategoryIdUrl(vidoConfig, categoryId, options)).then(
(data) => {
if (data.ok) {
return data.json() as unknown as ApiPois
diff --git a/lib/apiSettings.ts b/lib/apiSettings.ts
index 23334be8c..8778a1328 100644
--- a/lib/apiSettings.ts
+++ b/lib/apiSettings.ts
@@ -50,8 +50,8 @@ export interface Settings {
themes: SiteInfosTheme[]
}
-export function getSettings(vidoConfig: VidoConfig): Promise {
- return fetch(
+export async function getSettings(vidoConfig: VidoConfig): Promise {
+ return await fetch(
`${vidoConfig.API_ENDPOINT}/${vidoConfig.API_PROJECT}/${vidoConfig.API_THEME}/settings.json`,
)
.then((data) => {
diff --git a/pages/category/[id].vue b/pages/category/[id].vue
index b4d9894d5..cad6ceba6 100644
--- a/pages/category/[id].vue
+++ b/pages/category/[id].vue
@@ -1,171 +1,111 @@
-
-
+
+
+
+
+