mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
adjust itemsApi
This commit is contained in:
parent
efaa9aac69
commit
3c0481cbfc
1615
package-lock.json
generated
1615
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -16,8 +16,7 @@
|
||||
"axios": "^1.6.5",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-router-dom": "^6.11.2",
|
||||
"utopia-ui": "^3.0.0-alpha.62"
|
||||
"react-router-dom": "^6.11.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.0.28",
|
||||
|
||||
@ -9,6 +9,8 @@ export class itemsApi<T> implements ItemsApi<T>{
|
||||
collectionName: string;
|
||||
filter: any;
|
||||
layerId: string | undefined;
|
||||
mapId: string | undefined;
|
||||
|
||||
|
||||
constructor(collectionName: string, layerId?: string | undefined, mapId?: string | undefined, filter?: any, ) {
|
||||
this.collectionName = collectionName;
|
||||
@ -18,9 +20,10 @@ export class itemsApi<T> implements ItemsApi<T>{
|
||||
if(layerId) {
|
||||
this.filter = {... filter, ... { "layer" : { "id": { "_eq": layerId }}}}
|
||||
}
|
||||
if(mapId) this.filter = {... filter, ... { "map" : { "id": { "_eq": mapId }}}}
|
||||
console.log(this.filter);
|
||||
|
||||
this.mapId = mapId;
|
||||
if(mapId) {
|
||||
this.filter = {... filter, ... { "map" : { "id": { "_eq": mapId }}}}
|
||||
}
|
||||
}
|
||||
|
||||
async getItems() {
|
||||
@ -47,7 +50,7 @@ export class itemsApi<T> implements ItemsApi<T>{
|
||||
|
||||
async createItem(item: T & { id?: string }) {
|
||||
try {
|
||||
return await directusClient.request(createItem(this.collectionName as keyof MyCollections, {...item, ...(this.layerId && {layer: this.layerId})}))
|
||||
return await directusClient.request(createItem(this.collectionName as keyof MyCollections, {...item, ...(this.layerId && {layer: this.layerId}), ...(this.layerId && {layer: this.layerId}), ...(this.mapId && {map: this.mapId})}))
|
||||
} catch (error: any) {
|
||||
console.log(error);
|
||||
if (error.errors[0]?.message)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user