Skip to content

Commit

Permalink
change store structure
Browse files Browse the repository at this point in the history
  • Loading branch information
SKarolFolio committed Dec 10, 2024
1 parent 2771cf7 commit bb71499
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 33 deletions.
16 changes: 8 additions & 8 deletions src/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Stores
export * from './status';
export * from './loadingState';
export * from './marcPreview';
export * from './profile';
export * from './inputs';
export * from './config';
export * from './ui';
export * from './search';
export * from './stores/status';
export * from './stores/loadingState';
export * from './stores/marcPreview';
export * from './stores/profile';
export * from './stores/inputs';
export * from './stores/config';
export * from './stores/ui';
export * from './stores/search';

// Selector hooks
export * from './selectors';
16 changes: 8 additions & 8 deletions src/store/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { createSelectors } from './utils/selectors';
import { useStatusStore } from './status';
import { useLoadingStateStore } from './loadingState';
import { useMarcPreviewStore } from './marcPreview';
import { useProfileStore } from './profile';
import { useInputsStore } from './inputs';
import { useConfigStore } from './config';
import { useUIStore } from './ui';
import { useSearchStore } from './search';
import { useStatusStore } from './stores/status';
import { useLoadingStateStore } from './stores/loadingState';
import { useMarcPreviewStore } from './stores/marcPreview';
import { useProfileStore } from './stores/profile';
import { useInputsStore } from './stores/inputs';
import { useConfigStore } from './stores/config';
import { useUIStore } from './stores/ui';
import { useSearchStore } from './stores/search';

export const useStatusState = () => createSelectors(useStatusStore).use;
export const useLoadingState = () => createSelectors(useLoadingStateStore).use;
Expand Down
4 changes: 2 additions & 2 deletions src/store/config.ts → src/store/stores/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { LOCALES } from '@common/i18n/locales';
import { createBaseSlice, SliceState } from './utils/slice';
import { generateStore, type StateCreatorTyped } from './utils/storeCreator';
import { OKAPI_CONFIG } from '@common/constants/api.constants';
import { localStorageService } from '@common/services/storage';
import { createBaseSlice, SliceState } from '../utils/slice';
import { generateStore, type StateCreatorTyped } from '../utils/storeCreator';

type Locale = (typeof LOCALES)[keyof typeof LOCALES];
type CustomEvents = Record<string, string> | null;
Expand Down
4 changes: 2 additions & 2 deletions src/store/inputs.ts → src/store/stores/inputs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createBaseSlice, SliceState } from './utils/slice';
import { generateStore, type StateCreatorTyped } from './utils/storeCreator';
import { createBaseSlice, SliceState } from '../utils/slice';
import { generateStore, type StateCreatorTyped } from '../utils/storeCreator';

export type RecordState = RecordEntry | null;
export type SelectedRecordBlocksState = SelectedRecordBlocks | undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createBaseSlice, SliceState } from './utils/slice';
import { generateStore, type StateCreatorTyped } from './utils/storeCreator';
import { createBaseSlice, SliceState } from '../utils/slice';
import { generateStore, type StateCreatorTyped } from '../utils/storeCreator';

export type LoadingState = SliceState<'isLoading', boolean>;

Expand Down
4 changes: 2 additions & 2 deletions src/store/marcPreview.ts → src/store/stores/marcPreview.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createBaseSlice, SliceState } from './utils/slice';
import { generateStore, type StateCreatorTyped } from './utils/storeCreator';
import { createBaseSlice, SliceState } from '../utils/slice';
import { generateStore, type StateCreatorTyped } from '../utils/storeCreator';

type MarcPreviewData = MarcDTO | null;
type MarcPreviewMetaData = MarcPreviewMetadata | null;
Expand Down
4 changes: 2 additions & 2 deletions src/store/profile.ts → src/store/stores/profile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createBaseSlice, SliceState } from './utils/slice';
import { generateStore, type StateCreatorTyped } from './utils/storeCreator';
import { createBaseSlice, SliceState } from '../utils/slice';
import { generateStore, type StateCreatorTyped } from '../utils/storeCreator';

type SelectedProfileType = ProfileEntry | null;
type PreparedFieldsType = ResourceTemplates | null;
Expand Down
4 changes: 2 additions & 2 deletions src/store/search.ts → src/store/stores/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
DEFAULT_SEARCH_BY,
DEFAULT_SEARCH_LIMITERS,
} from '@common/constants/search.constants';
import { createBaseSlice, SliceState } from './utils/slice';
import { generateStore, type StateCreatorTyped } from './utils/storeCreator';
import { createBaseSlice, SliceState } from '../utils/slice';
import { generateStore, type StateCreatorTyped } from '../utils/storeCreator';

type Data = null | WorkAsSearchResultDTO[];
type SourceData = SourceDataDTO | null;
Expand Down
4 changes: 2 additions & 2 deletions src/store/status.ts → src/store/stores/status.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createBaseSlice, SliceState } from './utils/slice';
import { generateStore, type StateCreatorTyped } from './utils/storeCreator';
import { createBaseSlice, SliceState } from '../utils/slice';
import { generateStore, type StateCreatorTyped } from '../utils/storeCreator';

type LastSavedRecordId = string | null;

Expand Down
4 changes: 2 additions & 2 deletions src/store/ui.ts → src/store/stores/ui.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createBaseSlice, SliceState } from './utils/slice';
import { generateStore, type StateCreatorTyped } from './utils/storeCreator';
import { createBaseSlice, SliceState } from '../utils/slice';
import { generateStore, type StateCreatorTyped } from '../utils/storeCreator';

export type UIEntries = Set<string>;

Expand Down
2 changes: 1 addition & 1 deletion src/test/__tests__/views/Edit.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as Router from 'react-router-dom';
import * as recordHelper from '@common/helpers/record.helper';
import * as BibframeConstants from '@src/common/constants/bibframe.constants';
import { Edit } from '@views';
import { useProfileStore } from '@src/store/profile';
import { useProfileStore } from '@src/store/stores/profile';
import { setInitialGlobalState } from '@src/test/__mocks__/store';

const monograph = {
Expand Down

0 comments on commit bb71499

Please sign in to comment.