improve page create and page listing

This commit is contained in:
2026-01-31 17:11:05 +01:00
parent b9462b040d
commit c1144139b5
6 changed files with 130 additions and 40 deletions

View File

@@ -158,7 +158,11 @@ class DirectusService {
for (const [key, value] of Object.entries(params)) {
if (value === undefined || value === null) continue
if (typeof value === 'object') {
if (key === 'sort' && Array.isArray(value)) {
searchParams.set(key, value.join(','))
} else if (key === 'fields' && Array.isArray(value)) {
searchParams.set(key, value.join(','))
} else if (typeof value === 'object') {
searchParams.set(key, JSON.stringify(value))
} else {
searchParams.set(key, value)
@@ -258,8 +262,7 @@ class DirectusService {
'category.icon',
'location.id',
'location.name',
'location.region',
'user_created.id'
'location.region'
],
filter: options.filter || { status: { _eq: 'published' } },
sort: options.sort || ['-date_created'],
@@ -285,9 +288,7 @@ class DirectusService {
'images.directus_files_id.*',
'category.*',
'category.translations.*',
'location.*',
'user_created.id',
'user_created.date_created'
'location.*'
]
})
return response.data
@@ -309,11 +310,11 @@ class DirectusService {
async getMyListings() {
const response = await this.get('/items/listings', {
fields: ['*', 'images.directus_files_id.id', 'category.name', 'location.name'],
fields: ['*', 'images.directus_files_id.id', 'category.id', 'category.name', 'location.name'],
filter: { user_created: { _eq: '$CURRENT_USER' } },
sort: ['-date_created']
})
return response.data
return response.data || []
}
async searchListings(query, options = {}) {
@@ -356,12 +357,12 @@ class DirectusService {
async getCategories() {
const response = await this.get('/items/categories', {
fields: ['*', 'translations.*', 'parent.id', 'parent.name'],
fields: ['*', 'translations.*'],
filter: { status: { _eq: 'published' } },
sort: ['sort', 'name'],
limit: -1
})
return response.data
return response.data || []
}
async getCategory(idOrSlug) {