import { Action , AnyAction } from 'redux' ; import { createSlice , PayloadAction } from '@reduxjs/toolkit' ; import { QueryInfo , RtkQueryMonitorState , QueryFormValues , RtkQueryMonitorProps , QueryPreviewTabs , } from './types' ; import { QueryComparators } from './utils/comparators' ; import { QueryFilters } from './utils/filters' ; const initialState = { queryForm : { values : { queryComparator : QueryComparators . fulfilledTimeStamp , isAscendingQueryComparatorOrder : false , searchValue : '' , isRegexSearch : false , queryFilter : QueryFilters . queryKey , } , } , selectedPreviewTab : QueryPreviewTabs . queryinfo , selectedQueryKey : null , } ; const monitorSlice = createSlice ( { see lifedAction name : '@@rtk-query-monitor' , initialState , reducers : { changeQueryFormValues ( state , action ) { state . queryForm . values = { ... state . queryForm . values , ... action . payload } ; } , selectQueryKey ( state , action ) { state . selectedQueryKey = { queryKey : action . payload . queryKey , reducerPath : action . payload . reducerPath , } ; } , selectedPreviewTab ( state , action ) { state . selectedPreviewTab = action . payload ; } , } , } ) ; export function reducer < S , A extends Action < unknown > > ( props , state , action ) { return monitorSlice . reducer ( state , action ) ; } export const { selectQueryKey , changeQueryFormValues , selectedPreviewTab } = monitorSlice . actions ;