Skip to content

Commit

Permalink
stores config refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
SKarolFolio committed Dec 11, 2024
1 parent 7c27031 commit 2804335
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/store/stores/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const STORE_NAME = 'Inputs';
const sliceConfigs: SliceConfigs = {
userValues: {
initialValue: {},
canAddSingleItem: true,
singleItem: { type: {} as UserValue },
},
previewContent: {
Expand Down
1 change: 0 additions & 1 deletion src/store/stores/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const sliceConfigs: SliceConfigs = {
statusMessages: {
initialValue: [],
singleItem: { type: {} },
canAddSingleItem: true,
},
};

Expand Down
5 changes: 2 additions & 3 deletions src/store/utils/createStoreFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ type SliceConfig<Value = any, SingleItemType = any> = {
singleItem?: {
type: SingleItemType;
};
canAddSingleItem?: boolean;
};

export type SliceConfigs = Record<string, SliceConfig>;
Expand All @@ -24,14 +23,14 @@ export function createStoreFactory<U, T extends SliceConfigs>(configs: T, storeN

const storeCreator: StateCreatorTyped<State> = (set, get, api) =>
Object.entries(configs).reduce(
(acc, [key, { initialValue, canAddSingleItem }]) => ({
(acc, [key, { initialValue, singleItem }]) => ({
...acc,
...createBaseSlice(
{
basic: key as keyof T & string,
},
initialValue,
canAddSingleItem,
!!singleItem,
)(set as any, get as any, api as any),
}),
{} as State,
Expand Down

0 comments on commit 2804335

Please sign in to comment.