-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Adding breacdrumbs to go back to list * CRUD for users
- Loading branch information
1 parent
1cd0418
commit 2a9173f
Showing
17 changed files
with
475 additions
and
166 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
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,43 +1,8 @@ | ||
import { fetchAll } from '@/services/users'; | ||
import { Effect } from 'dva'; | ||
import { Reducer } from 'react'; | ||
import { UsersService } from '@/services/users'; | ||
import { User } from '@/services/definitions'; | ||
import { ReadWriteReduxResource } from '@/utils/reduxModel'; | ||
|
||
export type UsersModelState = User[]; | ||
|
||
export interface SaveAllUsersPayload { | ||
payload: { results: User[] }; | ||
} | ||
|
||
export interface UsersModelType { | ||
namespace: string; | ||
state: UsersModelState; | ||
effects: { | ||
fetchAll: Effect; | ||
}; | ||
reducers: { | ||
saveAll: Reducer<UsersModelState, SaveAllUsersPayload>; | ||
}; | ||
} | ||
|
||
const defaultUsersState: User[] = []; | ||
|
||
const UsersModel: UsersModelType = { | ||
export default ReadWriteReduxResource<User>({ | ||
namespace: 'users', | ||
state: defaultUsersState, | ||
effects: { | ||
*fetchAll(_, { call, put }) { | ||
const response = yield call(fetchAll); | ||
yield put({ | ||
type: 'saveAll', | ||
payload: response, | ||
}); | ||
}, | ||
}, | ||
reducers: { | ||
saveAll(_, { payload }) { | ||
return payload.results; | ||
}, | ||
}, | ||
}; | ||
export default UsersModel; | ||
service: UsersService, | ||
}); |
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
Oops, something went wrong.