Browse Source

:construction: working

visuddhinanda 3 years ago
parent
commit
4c6adcd318
1 changed files with 17 additions and 9 deletions
  1. 17 9
      dashboard/src/reducers/open-article.ts

+ 17 - 9
dashboard/src/reducers/open-article.ts

@@ -2,13 +2,15 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
 
 import type { RootState } from "../store";
 
-export interface IOpenArticle {
-  type: string;
-  articleId: string;
+export interface ISite {
+  title: string;
+  url: string;
+  id: string;
 }
 
 interface IState {
-  article?: IOpenArticle;
+  site?: ISite;
+  title?: string;
 }
 
 const initialState: IState = {};
@@ -17,17 +19,23 @@ export const slice = createSlice({
   name: "open-article",
   initialState,
   reducers: {
-    openArticle: (state, action: PayloadAction<IOpenArticle>) => {
-      state.article = action.payload;
+    refresh: (state, action: PayloadAction<ISite>) => {
+      state.site = action.payload;
+    },
+    setTitle: (state, action: PayloadAction<string>) => {
+      state.title = action.payload;
     },
   },
 });
 
-export const open = slice.actions;
+export const { refresh, setTitle } = slice.actions;
 
 export const openArticle = (state: RootState): IState => state.openArticle;
 
-export const articleInfo = (state: RootState): IOpenArticle | undefined =>
-  state.openArticle.article;
+export const siteInfo = (state: RootState): ISite | undefined =>
+  state.openArticle.site;
+
+export const pageTitle = (state: RootState): string | undefined =>
+  state.openArticle.title;
 
 export default slice.reducer;