Browse Source

Improve UserList, add title and refresh button.

main
Titouan Rigoudy 4 years ago
parent
commit
bbbe6cb8d9
1 changed files with 24 additions and 2 deletions
  1. +24
    -2
      src/modules/user/UserList.tsx

+ 24
- 2
src/modules/user/UserList.tsx View File

@ -1,7 +1,8 @@
import { FC } from "react"; import { FC } from "react";
import { useDispatch } from "react-redux";
import SearchableList from "components/SearchableList"; import SearchableList from "components/SearchableList";
import { UserMap } from "modules/user/slice";
import { UserMap, userGetAll } from "modules/user/slice";
import UserListEntry from "modules/user/UserListEntry"; import UserListEntry from "modules/user/UserListEntry";
const SearchableUserList = SearchableList(UserListEntry); const SearchableUserList = SearchableList(UserListEntry);
@ -10,6 +11,27 @@ interface Props {
users: UserMap; users: UserMap;
} }
const UserList: FC<Props> = ({ users }) => <SearchableUserList map={users} />;
const UserList: FC<Props> = ({ users }) => {
const dispatch = useDispatch();
const onClick: ReactEventHandler = (event) => {
event.preventDefault();
dispatch(userGetAll());
};
return (
<div>
<div className="flex justify-between p-3">
<h1 className="pl-3 text-2xl font-bold text-yellow-800 text-center">
Users
</h1>
<button onClick={onClick} className="button">
Refresh
</button>
</div>
<SearchableUserList map={users} />
</div>
);
};
export default UserList; export default UserList;

Loading…
Cancel
Save