mirror of
https://github.com/simstudioai/sim.git
synced 2026-10-28 02:41:36 +08:00
fix(table): fixed resolution of query params & headers
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { TableRow } from './types'
|
||||
|
||||
/**
|
||||
* Transforms a table from the store format to a key-value object
|
||||
* @param table Array of table rows from the store
|
||||
* @returns Record of key-value pairs
|
||||
*/
|
||||
export const transformTable = (table: TableRow[] | null): Record<string, string> => {
|
||||
if (!table) return {}
|
||||
|
||||
return table.reduce(
|
||||
(acc, row) => {
|
||||
if (row.cells?.Key && row.cells?.Value !== undefined) {
|
||||
acc[row.cells.Key] = row.cells.Value
|
||||
}
|
||||
return acc
|
||||
},
|
||||
{} as Record<string, string>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user