From bb714995b8381bcfc6909504855d3a882e5fc61f Mon Sep 17 00:00:00 2001 From: Siarhei Karol Date: Tue, 10 Dec 2024 16:55:54 +0500 Subject: [PATCH] change store structure --- src/store/index.ts | 16 ++++++++-------- src/store/selectors.ts | 16 ++++++++-------- src/store/{ => stores}/config.ts | 4 ++-- src/store/{ => stores}/inputs.ts | 4 ++-- src/store/{ => stores}/loadingState.ts | 4 ++-- src/store/{ => stores}/marcPreview.ts | 4 ++-- src/store/{ => stores}/profile.ts | 4 ++-- src/store/{ => stores}/search.ts | 4 ++-- src/store/{ => stores}/status.ts | 4 ++-- src/store/{ => stores}/ui.ts | 4 ++-- src/test/__tests__/views/Edit.test.tsx | 2 +- 11 files changed, 33 insertions(+), 33 deletions(-) rename src/store/{ => stores}/config.ts (86%) rename src/store/{ => stores}/inputs.ts (88%) rename src/store/{ => stores}/loadingState.ts (69%) rename src/store/{ => stores}/marcPreview.ts (82%) rename src/store/{ => stores}/profile.ts (87%) rename src/store/{ => stores}/search.ts (92%) rename src/store/{ => stores}/status.ts (86%) rename src/store/{ => stores}/ui.ts (89%) diff --git a/src/store/index.ts b/src/store/index.ts index 30f1140..39d218b 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -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'; diff --git a/src/store/selectors.ts b/src/store/selectors.ts index 5cbcc87..2936af2 100644 --- a/src/store/selectors.ts +++ b/src/store/selectors.ts @@ -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; diff --git a/src/store/config.ts b/src/store/stores/config.ts similarity index 86% rename from src/store/config.ts rename to src/store/stores/config.ts index 6487770..d20bc61 100644 --- a/src/store/config.ts +++ b/src/store/stores/config.ts @@ -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 | null; diff --git a/src/store/inputs.ts b/src/store/stores/inputs.ts similarity index 88% rename from src/store/inputs.ts rename to src/store/stores/inputs.ts index e3b394e..9e92d67 100644 --- a/src/store/inputs.ts +++ b/src/store/stores/inputs.ts @@ -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; diff --git a/src/store/loadingState.ts b/src/store/stores/loadingState.ts similarity index 69% rename from src/store/loadingState.ts rename to src/store/stores/loadingState.ts index 47d8f62..c3ac0ec 100644 --- a/src/store/loadingState.ts +++ b/src/store/stores/loadingState.ts @@ -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>; diff --git a/src/store/marcPreview.ts b/src/store/stores/marcPreview.ts similarity index 82% rename from src/store/marcPreview.ts rename to src/store/stores/marcPreview.ts index 8220501..1e85bc0 100644 --- a/src/store/marcPreview.ts +++ b/src/store/stores/marcPreview.ts @@ -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; diff --git a/src/store/profile.ts b/src/store/stores/profile.ts similarity index 87% rename from src/store/profile.ts rename to src/store/stores/profile.ts index d508393..59629ef 100644 --- a/src/store/profile.ts +++ b/src/store/stores/profile.ts @@ -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; diff --git a/src/store/search.ts b/src/store/stores/search.ts similarity index 92% rename from src/store/search.ts rename to src/store/stores/search.ts index 996f66e..848b5e3 100644 --- a/src/store/search.ts +++ b/src/store/stores/search.ts @@ -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; diff --git a/src/store/status.ts b/src/store/stores/status.ts similarity index 86% rename from src/store/status.ts rename to src/store/stores/status.ts index baf1417..7b7ded5 100644 --- a/src/store/status.ts +++ b/src/store/stores/status.ts @@ -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; diff --git a/src/store/ui.ts b/src/store/stores/ui.ts similarity index 89% rename from src/store/ui.ts rename to src/store/stores/ui.ts index ef74edc..5268f28 100644 --- a/src/store/ui.ts +++ b/src/store/stores/ui.ts @@ -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; diff --git a/src/test/__tests__/views/Edit.test.tsx b/src/test/__tests__/views/Edit.test.tsx index 54aecb1..da69984 100644 --- a/src/test/__tests__/views/Edit.test.tsx +++ b/src/test/__tests__/views/Edit.test.tsx @@ -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 = {