import { useState } from 'react'; import { refreshableSettings, createPersistedStore, ZustandSetFunc, } from '@@/datatables/types'; import { useTableState } from '@@/datatables/useTableState'; import { TableSettings } from './DefaultDatatableSettings'; import { systemResourcesSettings } from './SystemResourcesSettings'; export function createStore( storageKey: string, initialSortBy?: string | { id: string; desc: boolean }, create: (set: ZustandSetFunc) => Omit = () => ({}) as T ) { return createPersistedStore( storageKey, initialSortBy, (set) => ({ ...refreshableSettings(set), ...systemResourcesSettings(set), ...create(set), }) as T ); } export function useKubeStore( ...args: Parameters> ) { const [store] = useState(() => createStore(...args)); return useTableState(store, args[0]); }