convertToStoreState.ts 412 B

123456789101112
  1. import { getPreloadedState } from '../../app/features/variables/state/helpers';
  2. import { StoreState } from '../../app/types';
  3. export const convertToStoreState = (key: string, models: any[]): StoreState => {
  4. const variables = models.reduce((byName, variable) => {
  5. byName[variable.name] = variable;
  6. return byName;
  7. }, {});
  8. return {
  9. ...getPreloadedState(key, { variables }),
  10. } as StoreState;
  11. };