fix(frontend): update directus collections (#269)

* Update directus collections

* item_secrets is not a collection we call via directus client

---------

Co-authored-by: Anton Tranelis <31516529+antontranelis@users.noreply.github.com>
This commit is contained in:
Max 2025-07-03 09:21:31 +02:00 committed by GitHub
parent 729f97f38a
commit c92695eea7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 10 deletions

View File

@ -37,7 +37,7 @@ jobs:
build-examples:
if: needs.files-changed.outputs.build == 'true'
name: Test Example Apps
needs: build
needs: [build, files-changed]
runs-on: ubuntu-latest
strategy:
matrix:

View File

@ -6,6 +6,7 @@ import { createDirectus, rest, authentication } from '@directus/sdk'
import type { AuthenticationData, AuthenticationStorage } from '@directus/sdk'
import type { Point } from 'geojson'
import type { Item } from 'utopia-ui'
export interface Place {
id: string
@ -57,6 +58,10 @@ export interface MyCollections {
tags: Tag[]
projects: Project[]
directus_users: CustomUserFields[]
items: Item[]
team: any[]
features: any[]
attestations: any[]
}
export const authLocalStorage = (mainKey = 'directus_storage') =>

View File

@ -12,14 +12,14 @@ import type { MyCollections } from './directus'
import type { ItemsApi } from 'utopia-ui'
export class itemsApi<T> implements ItemsApi<T> {
collectionName: string
collectionName: keyof MyCollections
filter: any
layerId: string | undefined
mapId: string | undefined
customParameter: any
constructor(
collectionName: string,
collectionName: keyof MyCollections,
layerId?: string | undefined,
mapId?: string | undefined,
filter?: any,
@ -81,7 +81,7 @@ export class itemsApi<T> implements ItemsApi<T> {
async createItem(item: T & { id?: string }): Promise<T> {
try {
const result = await directusClient.request(
createItem(this.collectionName as keyof MyCollections, {
createItem(this.collectionName, {
...item,
...(this.customParameter && this.customParameter),
...(this.layerId && { layer: this.layerId }),
@ -99,9 +99,7 @@ export class itemsApi<T> implements ItemsApi<T> {
async updateItem(item: T & { id?: string }): Promise<T> {
try {
const result = await directusClient.request(
updateItem(this.collectionName as keyof MyCollections, item.id!, item),
)
const result = await directusClient.request(updateItem(this.collectionName, item.id!, item))
return result as T
} catch (error: any) {
console.log(error)
@ -112,9 +110,7 @@ export class itemsApi<T> implements ItemsApi<T> {
async deleteItem(id: string): Promise<boolean> {
try {
const result = await directusClient.request(
deleteItem(this.collectionName as keyof MyCollections, id),
)
const result = await directusClient.request(deleteItem(this.collectionName, id))
return result as unknown as boolean
} catch (error: any) {
console.log(error)