🐛 (sheets) Fix update filter invalid indexes
This commit is contained in:
@@ -9,7 +9,6 @@ import { deepParseVariables } from '@/features/variables/deepParseVariable'
|
|||||||
import { ExecuteIntegrationResponse } from '@/features/chat/types'
|
import { ExecuteIntegrationResponse } from '@/features/chat/types'
|
||||||
import { saveErrorLog } from '@/features/logs/saveErrorLog'
|
import { saveErrorLog } from '@/features/logs/saveErrorLog'
|
||||||
import { saveSuccessLog } from '@/features/logs/saveSuccessLog'
|
import { saveSuccessLog } from '@/features/logs/saveSuccessLog'
|
||||||
import { TRPCError } from '@trpc/server'
|
|
||||||
import { matchFilter } from './helpers/matchFilter'
|
import { matchFilter } from './helpers/matchFilter'
|
||||||
|
|
||||||
export const updateRow = async (
|
export const updateRow = async (
|
||||||
@@ -53,15 +52,12 @@ export const updateRow = async (
|
|||||||
message: log.description,
|
message: log.description,
|
||||||
details: log.details,
|
details: log.details,
|
||||||
}))
|
}))
|
||||||
throw new TRPCError({
|
return { outgoingEdgeId, logs: log ? [log] : undefined }
|
||||||
code: 'NOT_FOUND',
|
|
||||||
message: `Could not find any row that matches the filter`,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const filteredRow of filteredRows) {
|
for (const filteredRow of filteredRows) {
|
||||||
const rowIndex = rows.findIndex((row) => row.id === filteredRow.id)
|
const rowIndex = filteredRow.rowIndex - 2 // -1 for 0-indexing, -1 for header row
|
||||||
for (const key in parsedValues) {
|
for (const key in parsedValues) {
|
||||||
rows[rowIndex][key] = parsedValues[key]
|
rows[rowIndex][key] = parsedValues[key]
|
||||||
}
|
}
|
||||||
@@ -78,6 +74,7 @@ export const updateRow = async (
|
|||||||
message: log.description,
|
message: log.description,
|
||||||
}))
|
}))
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.log(err)
|
||||||
log = {
|
log = {
|
||||||
status: 'error',
|
status: 'error',
|
||||||
description: `An error occured while updating the row`,
|
description: `An error occured while updating the row`,
|
||||||
|
|||||||
Reference in New Issue
Block a user