| 1 |
import { createSlice, PayloadAction } from "@reduxjs/toolkit"; |
| 2 |
import { BreadCrumbItem } from "src/components/layouts/BreadCrumb"; |
| 3 |
|
| 4 |
interface RoutesState { |
| 5 |
breadCrumbPath: BreadCrumbItem[] | null; |
| 6 |
activePageName: string; |
| 7 |
activeFirstLevel: string; |
| 8 |
activeSecondLevel: string; |
| 9 |
browserTitle: string; |
| 10 |
} |
| 11 |
|
| 12 |
const initialState: RoutesState = { |
| 13 |
breadCrumbPath: null, |
| 14 |
activePageName: "", |
| 15 |
activeFirstLevel: "", |
| 16 |
activeSecondLevel: "", |
| 17 |
browserTitle: "", |
| 18 |
}; |
| 19 |
|
| 20 |
const routesSlice = createSlice({ |
| 21 |
name: "routes", |
| 22 |
initialState, |
| 23 |
reducers: { |
| 24 |
updateBreadCrumbPath: (state, action: PayloadAction<BreadCrumbItem[]>) => { |
| 25 |
state.breadCrumbPath = action.payload; |
| 26 |
}, |
| 27 |
updateActivePageName: (state, action: PayloadAction<string>) => { |
| 28 |
state.activePageName = action.payload; |
| 29 |
}, |
| 30 |
updateActiveFirstLevel: (state, action: PayloadAction<string>) => { |
| 31 |
state.activeFirstLevel = action.payload; |
| 32 |
}, |
| 33 |
updateActiveSecondLevel: (state, action: PayloadAction<string>) => { |
| 34 |
state.activeSecondLevel = action.payload; |
| 35 |
}, |
| 36 |
updateBrowserTitle: (state, action: PayloadAction<string>) => { |
| 37 |
state.browserTitle = action.payload; |
| 38 |
}, |
| 39 |
}, |
| 40 |
}); |
| 41 |
|
| 42 |
export const { |
| 43 |
updateBreadCrumbPath, |
| 44 |
updateActivePageName, |
| 45 |
updateActiveFirstLevel, |
| 46 |
updateActiveSecondLevel, |
| 47 |
updateBrowserTitle, |
| 48 |
} = routesSlice.actions; |
| 49 |
export default routesSlice.reducer; |