parent
00dc873319
commit
5524b5e412
@ -0,0 +1,25 @@ |
||||
import { GitHubUser } from '@remix-ui/git'; |
||||
import { AppModal } from '../interface' |
||||
|
||||
type ActionMap<M extends { [index: string]: any }> = { |
||||
[Key in keyof M]: M[Key] extends undefined |
||||
? { |
||||
type: Key; |
||||
} |
||||
: { |
||||
type: Key; |
||||
payload: M[Key]; |
||||
} |
||||
} |
||||
|
||||
export const enum appActionTypes { |
||||
setGitHubUser = 'SET_GITHUB_USER', |
||||
} |
||||
|
||||
type AppPayload = { |
||||
[appActionTypes.setGitHubUser]: GitHubUser |
||||
} |
||||
|
||||
export type AppAction = ActionMap<AppPayload>[keyof ActionMap< |
||||
AppPayload |
||||
>] |
@ -0,0 +1,13 @@ |
||||
import { AppAction, appActionTypes } from "../actions/app"; |
||||
import { AppState } from "../interface"; |
||||
|
||||
export const appReducer = (state: AppState, action: AppAction): AppState => { |
||||
switch (action.type) { |
||||
case appActionTypes.setGitHubUser:{ |
||||
return { |
||||
...state, |
||||
gitHubUser: action.payload |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,6 @@ |
||||
import { GitHubUser } from "@remix-ui/git"; |
||||
import { AppState } from "../interface"; |
||||
|
||||
export const appInitialState: AppState = { |
||||
gitHubUser: {} as GitHubUser, |
||||
} |
Loading…
Reference in new issue