test
This commit is contained in:
@@ -7,10 +7,19 @@ export interface BannerInfoState {
|
||||
setBannerInfo: (update: SetStateAction<Partial<BannerInfo>>) => void;
|
||||
};
|
||||
|
||||
const initialBannerInfoState = {
|
||||
export interface CommonState {
|
||||
serviceCodes: Array<any>;
|
||||
setServiceCodes: (update: SetStateAction<Array<any>>) => void;
|
||||
};
|
||||
|
||||
const initialBannerInfoState = {
|
||||
bannerInfo: {} as BannerInfo,
|
||||
} as BannerInfoState;
|
||||
|
||||
const initialCommonState = {
|
||||
serviceCodes: [] as Array<any>,
|
||||
} as CommonState;
|
||||
|
||||
export const createBannerInfoStore = lens<BannerInfoState>((set, get) => ({
|
||||
...initialBannerInfoState,
|
||||
setBannerInfo: (update) => {
|
||||
@@ -28,3 +37,19 @@ export const createBannerInfoStore = lens<BannerInfoState>((set, get) => ({
|
||||
},
|
||||
|
||||
}));
|
||||
|
||||
export const createCommonStore = lens<CommonState>((set, get) => ({
|
||||
...initialCommonState,
|
||||
setServiceCodes: (update) => {
|
||||
set((state: CommonState) => {
|
||||
const newServiceCodes = (typeof update === 'function')
|
||||
? update(state.serviceCodes): update;
|
||||
return {
|
||||
...state,
|
||||
serviceCodes: [
|
||||
...newServiceCodes
|
||||
]
|
||||
};
|
||||
});
|
||||
}
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user