mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-12 23:36:00 +00:00
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:
parent
729f97f38a
commit
c92695eea7
2
.github/workflows/test.build.lib.yml
vendored
2
.github/workflows/test.build.lib.yml
vendored
@ -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:
|
||||
|
||||
@ -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') =>
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user