* feat: add `user_setting` model * chore: add global store * chore: update settings in web * chore: update `i18n` example
26 lines
546 B
TypeScript
26 lines
546 B
TypeScript
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|
|
|
interface State {
|
|
locale: Locale;
|
|
}
|
|
|
|
const globalSlice = createSlice({
|
|
name: "global",
|
|
initialState: {} as State,
|
|
reducers: {
|
|
setGlobalState: (_, action: PayloadAction<State>) => {
|
|
return action.payload;
|
|
},
|
|
setLocale: (state, action: PayloadAction<Locale>) => {
|
|
return {
|
|
...state,
|
|
locale: action.payload,
|
|
};
|
|
},
|
|
},
|
|
});
|
|
|
|
export const { setGlobalState, setLocale } = globalSlice.actions;
|
|
|
|
export default globalSlice.reducer;
|