diff --git a/packages/frontend-core/src/components/grid/stores/datasources/table.ts b/packages/frontend-core/src/components/grid/stores/datasources/table.ts index 894a65ba4c..65d68a7d5d 100644 --- a/packages/frontend-core/src/components/grid/stores/datasources/table.ts +++ b/packages/frontend-core/src/components/grid/stores/datasources/table.ts @@ -31,7 +31,8 @@ export const createActions = (context: StoreContext): TableActions => { ...row, tableId: get(datasource)?.tableId, } - return await API.saveRow(row, SuppressErrors) + const newRow = await API.saveRow(row, SuppressErrors) + return { ...newRow, _id: newRow._id! } } const deleteRows = async (rows: Row[]) => { @@ -52,7 +53,12 @@ export const createActions = (context: StoreContext): TableActions => { }, paginate: false, }) - return res?.rows?.[0] + const row = res?.rows?.[0] + if (!row) { + return + } + + return { ...row, _id: row._id! } } const canUseColumn = (name: string) => { diff --git a/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts b/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts index d9cac5397d..e18b9f71c0 100644 --- a/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts +++ b/packages/frontend-core/src/components/grid/stores/datasources/viewV2.ts @@ -34,8 +34,10 @@ export const createActions = (context: StoreContext): ViewActions => { tableId: $datasource?.tableId, _viewId: $datasource?.id, } + const newRow = await API.saveRow(row, SuppressErrors) return { - ...(await API.saveRow(row, SuppressErrors)), + ...newRow, + _id: newRow._id!, _viewId: row._viewId, } } @@ -54,7 +56,12 @@ export const createActions = (context: StoreContext): ViewActions => { }, paginate: false, }) - return res?.rows?.[0] + const row = res?.rows?.[0] + if (!row) { + return + } + + return { ...row, _id: row._id! } } const isDatasourceValid = (datasource: UIDatasource) => {