File tree Expand file tree Collapse file tree 4 files changed +9
-7
lines changed
src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/DatabaseBlock Expand file tree Collapse file tree 4 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
11
11
12
12
import { AddButtonComponent } from './AddColumnButton' ;
13
13
import { useColumns , useRows } from './hooks' ;
14
+ import { DatabaseRow } from './types' ;
14
15
import { addRowCellRenderer , autoSizeStrategy , createNewRow } from './utils' ;
15
16
16
17
export const DatabaseGrid = ( {
@@ -61,12 +62,12 @@ export const DatabaseGrid = ({
61
62
( [ key ] ) => key !== 'id' && key !== 'manualSort' ,
62
63
) ;
63
64
64
- const rowData1 : Record < string , string | number | boolean > [ ] = [ ] ;
65
+ const rowData1 : DatabaseRow [ ] = [ ] ;
65
66
66
67
const numRows = filteredEntries [ 0 ] ?. [ 1 ] . length ;
67
68
68
69
for ( let i = 0 ; i < numRows ; i ++ ) {
69
- const row : Record < string , string | boolean | number > = { } ;
70
+ const row : DatabaseRow = { } ;
70
71
for ( const [ key , values ] of filteredEntries ) {
71
72
row [ key ] = values [ i ] ?? '' ;
72
73
}
Original file line number Diff line number Diff line change 1
1
import { ColDef } from 'ag-grid-community' ;
2
2
import { useState } from 'react' ;
3
3
4
+ import { DatabaseRow } from './types' ;
5
+
4
6
export const useColumns = ( ) => {
5
7
const [ colDefs , setColDefs ] = useState < ColDef [ ] > ( ) ;
6
8
7
9
return { colDefs, setColDefs } ;
8
10
} ;
9
11
10
12
export const useRows = ( ) => {
11
- const [ rowData , setRowData ] =
12
- useState < Record < string , string | number | boolean > [ ] > ( ) ;
13
+ const [ rowData , setRowData ] = useState < DatabaseRow [ ] > ( ) ;
13
14
14
15
return { rowData, setRowData } ;
15
16
} ;
Original file line number Diff line number Diff line change
1
+ export type DatabaseRow = Record < string , string | number | boolean > ;
Original file line number Diff line number Diff line change 5
5
import { Dispatch , SetStateAction } from 'react' ;
6
6
7
7
import { AddRowButton } from './AddRowButton' ;
8
+ import { DatabaseRow } from './types' ;
8
9
9
10
export const autoSizeStrategy : SizeColumnsToContentStrategy = {
10
11
type : 'fitCellContents' ,
@@ -28,9 +29,7 @@ export const createNewRow = (
28
29
export const addRowCellRenderer = (
29
30
params : ICellRendererParams < Record < string , string > > ,
30
31
columns : string [ ] | undefined ,
31
- setRowData : Dispatch <
32
- SetStateAction < Record < string , string | number | boolean > [ ] | undefined >
33
- > ,
32
+ setRowData : Dispatch < SetStateAction < DatabaseRow [ ] | undefined > > ,
34
33
) => {
35
34
if ( params . data ) {
36
35
const addRowButton = {
You can’t perform that action at this time.
0 commit comments