utopia-ui/app/src/api/layersApi.ts
Anton Tranelis 75516b8c3a
fix(app): layer sort (#347)
* layer sort

* change dev port back to 5174
2025-09-02 14:11:07 +02:00

37 lines
942 B
TypeScript

/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable no-console */
import { readItems } from '@directus/sdk'
import { directusClient } from './directus'
export class layersApi {
mapId: string
constructor(mapId: string) {
this.mapId = mapId
}
async getItems() {
try {
const layers = await directusClient.request(
readItems('layers' as any, {
fields: [
'*',
{ itemType: ['*.*', { profileTemplate: ['*', 'item.*.*.*.*'] }] },
{ markerIcon: ['*'] } as any,
],
filter: { maps: { maps_id: { id: { _eq: this.mapId } } } },
limit: 500,
sort: ['sort'],
}),
)
return layers
} catch (error: any) {
console.log(error)
if (error.errors[0]?.message) throw error.errors[0].message
else throw error
}
}
}