Connected users with Kratos
This commit is contained in:
parent
b0af0de05b
commit
8da937d0c5
22 changed files with 479 additions and 228 deletions
|
|
@ -1,16 +1,41 @@
|
|||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { getUsers, fetchUsers } from '../redux';
|
||||
import { getUsers, fetchUsers, fetchUserById, updateUserById, createUser, deleteUser } from '../redux';
|
||||
import { getUserById, getUserModalLoading } from '../redux/selectors';
|
||||
|
||||
export function useUsers() {
|
||||
const dispatch = useDispatch();
|
||||
const users = useSelector(getUsers);
|
||||
const user = useSelector(getUserById);
|
||||
const userModalLoading = useSelector(getUserModalLoading);
|
||||
|
||||
function loadUsers() {
|
||||
return dispatch(fetchUsers());
|
||||
}
|
||||
|
||||
function loadUser(id: string) {
|
||||
return dispatch(fetchUserById(id));
|
||||
}
|
||||
|
||||
function editUserById(data: any) {
|
||||
return dispatch(updateUserById(data));
|
||||
}
|
||||
|
||||
function createNewUser(data: any) {
|
||||
return dispatch(createUser(data));
|
||||
}
|
||||
|
||||
function deleteUserById(id: string) {
|
||||
return dispatch(deleteUser(id));
|
||||
}
|
||||
|
||||
return {
|
||||
users,
|
||||
user,
|
||||
loadUser,
|
||||
loadUsers,
|
||||
editUserById,
|
||||
userModalLoading,
|
||||
createNewUser,
|
||||
deleteUserById,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue