Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
101 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { | ||
StoriesPageAction, | ||
StoriesPageState, | ||
StoriesPageActionTypes, | ||
} from "./types"; | ||
import { Dispatch } from "react"; | ||
|
||
export const setUserStories = (data: any) => { | ||
return (dispatch: Dispatch<StoriesPageAction>) => { | ||
dispatch({ | ||
type: StoriesPageActionTypes.SET_USER_STORIES, | ||
payload: data, | ||
}); | ||
}; | ||
}; | ||
|
||
export const setStoryIndex = (data: StoriesPageState["storyIndex"]) => { | ||
return (dispatch: Dispatch<StoriesPageAction>) => { | ||
dispatch({ | ||
type: StoriesPageActionTypes.SET_STORY_INDEX, | ||
payload: data, | ||
}); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { | ||
StoriesPageAction, | ||
StoriesPageState, | ||
StoriesPageActionTypes, | ||
} from "./types"; | ||
|
||
const initialState: StoriesPageState = { | ||
storyIndex: 0, | ||
data: [], | ||
}; | ||
|
||
const userStoriesReducer = ( | ||
state: StoriesPageState = initialState, | ||
action: StoriesPageAction | ||
) => { | ||
switch (action.type) { | ||
case StoriesPageActionTypes.SET_USER_STORIES: | ||
return { | ||
...state, | ||
data: action.payload.sort((a, b) => { | ||
if (a.type !== "bot" || b.type !== "bot") { | ||
return; | ||
} else { | ||
return Math.random() - 0.5; | ||
} | ||
}), | ||
}; | ||
case StoriesPageActionTypes.SET_STORY_INDEX: | ||
return { | ||
...state, | ||
storyIndex: action.payload, | ||
}; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default userStoriesReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { YoutubeVideos } from "../../../../interface/youtubeVideos"; | ||
|
||
export interface StoriesPageState { | ||
storyIndex: number; | ||
data: []; | ||
} | ||
|
||
export enum StoriesPageActionTypes { | ||
SET_USER_STORIES = "setUserStories", | ||
SET_STORY_INDEX = "setStoryIndex", | ||
} | ||
export interface SetUserStoriesAction { | ||
type: StoriesPageActionTypes.SET_USER_STORIES; | ||
payload: any; | ||
} | ||
|
||
export interface SetStoriesIndexAction { | ||
type: StoriesPageActionTypes.SET_STORY_INDEX; | ||
payload: number; | ||
} | ||
|
||
export type StoriesPageAction = SetUserStoriesAction | SetStoriesIndexAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters