@@ -34,7 +34,7 @@ import { ArrowBackIcon, ArrowForwardIcon } from '@chakra-ui/icons'
3434import demoData from './data'
3535import { useDatabase } from './useDatabase'
3636import './style.css'
37- import { FilterMethod } from './json-edit-react/src/types'
37+ import { FilterFunction } from './json-edit-react/src/types'
3838
3939function App ( ) {
4040 const [ selectedData , setSelectedData ] = useState ( 'basic' )
@@ -53,7 +53,7 @@ function App() {
5353 const previousThemeName = useRef ( '' ) // Used when resetting after theme editing
5454 const toast = useToast ( )
5555
56- const { guestbook , updateGuestbook } = useDatabase ( )
56+ const { liveData , updateLiveData } = useDatabase ( )
5757
5858 const [ { present : data } , { set : setData , reset, undo, redo, canUndo, canRedo } ] = useUndo (
5959 demoData [ selectedData ] . data
@@ -63,10 +63,10 @@ function App() {
6363 switch ( selectedData ) {
6464 case 'editTheme' :
6565 return
66- case 'liveGuestbook ' :
67- setCollapseLevel ( demoData . liveGuestbook . collapse )
68- if ( ! guestbook ) reset ( { 'Oops!' : "We couldn't load this data, sorry " } )
69- else reset ( guestbook )
66+ case 'liveData ' :
67+ setCollapseLevel ( demoData . liveData . collapse )
68+ if ( ! liveData ) reset ( { 'Oops!' : "We couldn't load this data, sorry " } )
69+ else reset ( liveData )
7070 return
7171 default :
7272 const newData = demoData [ selectedData ]
@@ -75,19 +75,19 @@ function App() {
7575 }
7676 } , [ selectedData , reset ] )
7777
78- const restrictEdit : FilterMethod | boolean = ( ( ) => {
78+ const restrictEdit : FilterFunction | boolean = ( ( ) => {
7979 const customRestrictor = demoData [ selectedData ] ?. restrictEdit
8080 if ( customRestrictor ) return ( input ) => ! allowEdit || customRestrictor ( input )
8181 return ! allowEdit
8282 } ) ( )
8383
84- const restrictDelete : FilterMethod | boolean = ( ( ) => {
84+ const restrictDelete : FilterFunction | boolean = ( ( ) => {
8585 const customRestrictor = demoData [ selectedData ] ?. restrictDelete
8686 if ( customRestrictor ) return ( input ) => ! allowDelete || customRestrictor ( input )
8787 return ! allowDelete
8888 } ) ( )
8989
90- const restrictAdd : FilterMethod | boolean = ( ( ) => {
90+ const restrictAdd : FilterFunction | boolean = ( ( ) => {
9191 const customRestrictor = demoData [ selectedData ] ?. restrictAdd
9292 if ( customRestrictor ) return ( input ) => ! allowAdd || customRestrictor ( input )
9393 return ! allowAdd
@@ -115,9 +115,9 @@ function App() {
115115 case 'editTheme' :
116116 reset ( themes [ previousThemeName . current ] )
117117 return
118- case 'liveGuestbook ' :
118+ case 'liveData ' :
119119 setIsSaving ( true )
120- await updateGuestbook ( data )
120+ await updateLiveData ( data )
121121 setIsSaving ( false )
122122 toast ( {
123123 title : 'Whoosh!' ,
@@ -126,7 +126,7 @@ function App() {
126126 duration : 5000 ,
127127 isClosable : true ,
128128 } )
129- console . log ( guestbook )
129+ console . log ( liveData )
130130 reset ( data )
131131 return
132132 default :
@@ -207,6 +207,7 @@ function App() {
207207 showArrayIndices = { showIndices }
208208 maxWidth = { 650 }
209209 className = "block-shadow"
210+ stringTruncate = { 80 }
210211 />
211212 < VStack w = "100%" align = "flex-end" gap = { 4 } >
212213 < HStack w = "100%" justify = "space-between" mt = { 4 } >
@@ -238,13 +239,13 @@ function App() {
238239 </ Text >
239240 < Button
240241 colorScheme = "accentScheme"
241- leftIcon = { selectedData === 'liveGuestbook ' ? < AiOutlineCloudUpload /> : < BiReset /> }
242+ leftIcon = { selectedData === 'liveData ' ? < AiOutlineCloudUpload /> : < BiReset /> }
242243 variant = "outline"
243244 onClick = { handleReset }
244245 visibility = { canUndo ? 'visible' : 'hidden' }
245246 isLoading = { isSaving }
246247 >
247- { selectedData === 'liveGuestbook ' ? 'Push to the cloud' : 'Reset' }
248+ { selectedData === 'liveData ' ? 'Push to the cloud' : 'Reset' }
248249 </ Button >
249250 </ HStack >
250251 </ VStack >
0 commit comments