visuddhinanda 2 years ago
parent
commit
ad72ac67ad
1 changed files with 30 additions and 0 deletions
  1. 30 0
      dashboard/src/reducers/focus.ts

+ 30 - 0
dashboard/src/reducers/focus.ts

@@ -0,0 +1,30 @@
+import { createSlice, PayloadAction } from "@reduxjs/toolkit";
+
+import type { RootState } from "../store";
+
+export interface IFocus {
+  type: string;
+  id?: string | null;
+}
+
+interface IState {
+  focus?: IFocus;
+}
+
+const initialState: IState = {};
+
+export const slice = createSlice({
+  name: "focus",
+  initialState,
+  reducers: {
+    refresh: (state, action: PayloadAction<IFocus>) => {
+      state.focus = action.payload;
+    },
+  },
+});
+
+export const { refresh } = slice.actions;
+
+export const currFocus = (state: RootState): IState => state.focus;
+
+export default slice.reducer;