2022-09-26 19:43:24 +00:00
|
|
|
import create from 'zustand';
|
|
|
|
import { persist } from 'zustand/middleware';
|
|
|
|
|
2022-11-13 08:10:18 +00:00
|
|
|
import { keyBuilder } from '@/react/hooks/useLocalStorage';
|
2022-09-26 19:43:24 +00:00
|
|
|
import {
|
|
|
|
paginationSettings,
|
|
|
|
sortableSettings,
|
|
|
|
} from '@/react/components/datatables/types';
|
|
|
|
|
|
|
|
import { TableSettings } from './types';
|
|
|
|
|
|
|
|
export const TRUNCATE_LENGTH = 32;
|
|
|
|
|
|
|
|
export function createStore(storageKey: string) {
|
|
|
|
return create<TableSettings>()(
|
|
|
|
persist(
|
|
|
|
(set) => ({
|
|
|
|
...sortableSettings(set),
|
|
|
|
...paginationSettings(set),
|
|
|
|
}),
|
|
|
|
{
|
|
|
|
name: keyBuilder(storageKey),
|
|
|
|
}
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|