Files
Ivan VasilovandJoshen Lim 845167ca14 chore: Delete MetaStore and RootStore (#20034)
* Replace all methods of MetaStore with react queries.

* Remove unneeded usages of MetaStore.

* Remove RootStore completely. The only thing left from these stores is uiStore.

* Remove unnecessary comments.

* Delete MetaStore.

* Fix the usage of the wrong toaster.

* Remove unused variables

* Remove onSqlQuery

* Convert some ui setNotification calls to direct toast calls

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2024-03-08 14:56:28 +08:00

53 lines
1.4 KiB
TypeScript

import type { SupaRow } from '../../types'
export interface CallbackInitialState {
onAddColumn: (() => void) | null
onAddRow: (() => void) | null
onError: ((error: any) => void) | null
onEditRow: ((row: SupaRow) => void) | null
onEditColumn: ((columnName: string) => void) | null
onDeleteColumn: ((columnName: string) => void) | null
}
export const callbackInitialState: CallbackInitialState = {
onAddColumn: null,
onAddRow: null,
onError: null,
onEditRow: null,
onEditColumn: null,
onDeleteColumn: null,
}
type CALLBACK_ACTIONTYPE = {
type: 'INIT_CALLBACK'
payload: {
onAddColumn: (() => void) | null
onAddRow: (() => void) | null
onError: ((error: any) => void) | null
onEditRow: ((row: SupaRow) => void) | null
onEditColumn: ((columnName: string) => void) | null
onDeleteColumn: ((columnName: string) => void) | null
}
}
const CallbackReducer = (state: CallbackInitialState, action: CALLBACK_ACTIONTYPE) => {
switch (action.type) {
case 'INIT_CALLBACK': {
return {
...state,
onAddColumn: action.payload.onAddColumn,
onAddRow: action.payload.onAddRow,
onError: action.payload.onError,
onEditRow: action.payload.onEditRow,
onEditColumn: action.payload.onEditColumn,
onDeleteColumn: action.payload.onDeleteColumn,
}
}
default:
return state
}
}
export default CallbackReducer