9
9
} from '@chakra-ui/react'
10
10
import { AlignLeftTextIcon } from '@/components/icons'
11
11
import { ResultHeaderCell , ResultsTablePreferences } from '@typebot.io/schemas'
12
- import React , { useEffect , useRef , useState } from 'react'
12
+ import React , { useCallback , useEffect , useRef , useState } from 'react'
13
13
import { LoadingRows } from './LoadingRows'
14
14
import {
15
15
useReactTable ,
@@ -48,7 +48,7 @@ export const ResultsTable = ({
48
48
onResultExpandIndex,
49
49
} : ResultsTableProps ) => {
50
50
const background = useColorModeValue ( 'white' , colors . gray [ 900 ] )
51
- const { updateTypebot } = useTypebot ( )
51
+ const { updateTypebot, isReadOnly } = useTypebot ( )
52
52
const [ rowSelection , setRowSelection ] = useState < Record < string , boolean > > ( { } )
53
53
const [ isTableScrolled , setIsTableScrolled ] = useState ( false )
54
54
const bottomElement = useRef < HTMLDivElement | null > ( null )
@@ -185,6 +185,14 @@ export const ResultsTable = ({
185
185
getCoreRowModel : getCoreRowModel ( ) ,
186
186
} )
187
187
188
+ const handleObserver = useCallback (
189
+ ( entities : IntersectionObserverEntry [ ] ) => {
190
+ const target = entities [ 0 ]
191
+ if ( target . isIntersecting ) onScrollToBottom ( )
192
+ } ,
193
+ [ onScrollToBottom ]
194
+ )
195
+
188
196
useEffect ( ( ) => {
189
197
if ( ! bottomElement . current ) return
190
198
const options : IntersectionObserverInit = {
@@ -197,21 +205,17 @@ export const ResultsTable = ({
197
205
return ( ) => {
198
206
observer . disconnect ( )
199
207
}
200
- // eslint-disable-next-line react-hooks/exhaustive-deps
201
- } , [ bottomElement . current ] )
202
-
203
- const handleObserver = ( entities : IntersectionObserverEntry [ ] ) => {
204
- const target = entities [ 0 ]
205
- if ( target . isIntersecting ) onScrollToBottom ( )
206
- }
208
+ } , [ handleObserver ] )
207
209
208
210
return (
209
211
< Stack maxW = "1600px" px = "4" overflowY = "hidden" spacing = { 6 } >
210
212
< HStack w = "full" justifyContent = "flex-end" >
211
- < SelectionToolbar
212
- selectedResultsId = { Object . keys ( rowSelection ) }
213
- onClearSelection = { ( ) => setRowSelection ( { } ) }
214
- />
213
+ { isReadOnly ? null : (
214
+ < SelectionToolbar
215
+ selectedResultsId = { Object . keys ( rowSelection ) }
216
+ onClearSelection = { ( ) => setRowSelection ( { } ) }
217
+ />
218
+ ) }
215
219
< TableSettingsButton
216
220
resultHeader = { resultHeader }
217
221
columnVisibility = { columnsVisibility }
0 commit comments