Browse Source

:construction: create

visuddhinanda 3 years ago
parent
commit
1141d30df6
1 changed files with 33 additions and 0 deletions
  1. 33 0
      dashboard/src/reducers/open-article.ts

+ 33 - 0
dashboard/src/reducers/open-article.ts

@@ -0,0 +1,33 @@
+import { createSlice, PayloadAction } from "@reduxjs/toolkit";
+
+import type { RootState } from "../store";
+
+export interface IOpenArticle {
+  type: string;
+  articleId: string;
+}
+
+interface IState {
+  article?: IOpenArticle;
+}
+
+const initialState: IState = {};
+
+export const slice = createSlice({
+  name: "open-article",
+  initialState,
+  reducers: {
+    openArticle: (state, action: PayloadAction<IOpenArticle>) => {
+      state.article = action.payload;
+    },
+  },
+});
+
+export const open = slice.actions;
+
+export const openArticle = (state: RootState): IState => state.openArticle;
+
+export const articleInfo = (state: RootState): IOpenArticle | undefined =>
+  state.openArticle.article;
+
+export default slice.reducer;