Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(redux): added ts on notificationBox
fixing #109
- Loading branch information
1 parent
3fc39b9
commit b5641f7
Showing
6 changed files
with
82 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./global/rootUserFriends/action"; | ||
export * from "./global/rootUserProfileDetail/action"; | ||
export * from "./components/commentBox/action"; | ||
export * from "./components/notificationBox/action"; |
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
27 changes: 27 additions & 0 deletions
27
client/src/services/redux/components/notificationBox/action.ts
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,27 @@ | ||
import { | ||
// NotificationBoxState, | ||
NotificationBoxActionTypes, | ||
NotificationBoxAction, | ||
NotificationBoxState, | ||
} from "./types"; | ||
import { Dispatch } from "react"; | ||
|
||
export const openNotificationBox = (data: NotificationBoxState["open"]) => { | ||
return (dispatch: Dispatch<NotificationBoxAction>) => { | ||
dispatch({ | ||
type: NotificationBoxActionTypes.OPEN_NOTIFICATION_BOX, | ||
payload: data, | ||
}); | ||
}; | ||
}; | ||
|
||
export const setNotificationData = ( | ||
data: NotificationBoxState["notificationData"] | ||
) => { | ||
return (dispatch: Dispatch<NotificationBoxAction>) => { | ||
dispatch({ | ||
type: NotificationBoxActionTypes.SET_NOTIFICATION_DATA, | ||
payload: data, | ||
}); | ||
}; | ||
}; |
32 changes: 32 additions & 0 deletions
32
client/src/services/redux/components/notificationBox/reducer.ts
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,32 @@ | ||
import { | ||
NotificationBoxState, | ||
NotificationBoxAction, | ||
NotificationBoxActionTypes, | ||
} from "./types"; | ||
|
||
const initialState: NotificationBoxState = { | ||
notificationData: [], | ||
open: false, | ||
}; | ||
|
||
const notificationBoxReducer = ( | ||
state: NotificationBoxState = initialState, | ||
action: NotificationBoxAction | ||
): NotificationBoxState => { | ||
switch (action.type) { | ||
case NotificationBoxActionTypes.OPEN_NOTIFICATION_BOX: | ||
return { | ||
...state, | ||
open: action.payload, | ||
}; | ||
case NotificationBoxActionTypes.SET_NOTIFICATION_DATA: | ||
return { | ||
...state, | ||
notificationData: action.payload, | ||
}; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default notificationBoxReducer; |
20 changes: 20 additions & 0 deletions
20
client/src/services/redux/components/notificationBox/types.ts
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,20 @@ | ||
export interface NotificationBoxState { | ||
notificationData: []; | ||
open: boolean; | ||
} | ||
|
||
export enum NotificationBoxActionTypes { | ||
OPEN_NOTIFICATION_BOX = "openNotificationBox", | ||
SET_NOTIFICATION_DATA = "setNotificationData", | ||
} | ||
export interface OpenNotificationBox { | ||
type: NotificationBoxActionTypes.OPEN_NOTIFICATION_BOX; | ||
payload: any; | ||
} | ||
|
||
export interface SetNotificationData { | ||
type: NotificationBoxActionTypes.SET_NOTIFICATION_DATA; | ||
payload: any; | ||
} | ||
|
||
export type NotificationBoxAction = OpenNotificationBox | SetNotificationData; |
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