create-nova-vite-template
Version:
This is a dashboard template built with React and Vite. It provides a modern and responsive user interface for building web applications.
36 lines (30 loc) • 751 B
text/typescript
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
interface IAppState {
isLoading: boolean;
deviceId: string | null;
}
const initialState: IAppState = {
isLoading: false,
deviceId: null,
};
export const appSlice = createSlice({
name: "app",
initialState,
reducers: {
showLoader: (state) => ({
...state,
isLoading: true,
}),
hideLoader: (state) => ({
...state,
isLoading: false,
}),
setDeviceId: (state, action: PayloadAction<string>) => ({
...state,
deviceId: action.payload,
}),
},
});
// Action creators are generated for each case reducer function
export const { showLoader, hideLoader, setDeviceId } = appSlice.actions;
export default appSlice.reducer;