|
|
|
@ -3,6 +3,7 @@ import * as React from "react";
|
|
|
|
|
import InboxIcon from "@material-ui/icons/Inbox";
|
|
|
|
|
import LabelIcon from "@material-ui/icons/LabelOutlined";
|
|
|
|
|
import AddIcon from "@material-ui/icons/Add";
|
|
|
|
|
import EditIcon from "@material-ui/icons/EditOutlined";
|
|
|
|
|
|
|
|
|
|
import IconButton from "@material-ui/core/IconButton";
|
|
|
|
|
|
|
|
|
@ -15,19 +16,27 @@ interface ListItemPropsType {
|
|
|
|
|
primaryText: string;
|
|
|
|
|
filterByGroup: string | undefined;
|
|
|
|
|
setFilterByGroup: (group: string | undefined) => void;
|
|
|
|
|
editGroup: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function SidebarListItem(props: ListItemPropsType) {
|
|
|
|
|
const { name, icon, primaryText, filterByGroup } = props;
|
|
|
|
|
const { name, icon, primaryText, filterByGroup, editGroup } = props;
|
|
|
|
|
|
|
|
|
|
const handleClick = () => props.setFilterByGroup(name);
|
|
|
|
|
|
|
|
|
|
const selected = name === filterByGroup;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<ListItem
|
|
|
|
|
onClick={handleClick}
|
|
|
|
|
selected={name === filterByGroup}
|
|
|
|
|
selected={selected}
|
|
|
|
|
leftIcon={icon}
|
|
|
|
|
primaryText={primaryText}
|
|
|
|
|
secondaryAction={name && selected &&
|
|
|
|
|
<IconButton onClick={editGroup}>
|
|
|
|
|
<EditIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
@ -37,10 +46,11 @@ interface PropsType {
|
|
|
|
|
filterByGroup: string | undefined;
|
|
|
|
|
setFilterByGroup: (group: string | undefined) => void;
|
|
|
|
|
newGroup: () => void;
|
|
|
|
|
editGroup: (group: ContactType) => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default React.memo(function Sidebar(props: PropsType) {
|
|
|
|
|
const { groups, filterByGroup, setFilterByGroup, newGroup } = props;
|
|
|
|
|
const { groups, filterByGroup, setFilterByGroup, newGroup, editGroup } = props;
|
|
|
|
|
|
|
|
|
|
const groupList = [...groups].sort((a, b) => a.fn.localeCompare(b.fn)).map((group) => (
|
|
|
|
|
<SidebarListItem
|
|
|
|
@ -50,6 +60,7 @@ export default React.memo(function Sidebar(props: PropsType) {
|
|
|
|
|
icon={<LabelIcon />}
|
|
|
|
|
filterByGroup={filterByGroup}
|
|
|
|
|
setFilterByGroup={setFilterByGroup}
|
|
|
|
|
editGroup={() => editGroup(group)}
|
|
|
|
|
/>
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
@ -61,6 +72,7 @@ export default React.memo(function Sidebar(props: PropsType) {
|
|
|
|
|
icon={<InboxIcon />}
|
|
|
|
|
filterByGroup={filterByGroup}
|
|
|
|
|
setFilterByGroup={setFilterByGroup}
|
|
|
|
|
editGroup={newGroup}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<div style={{ display: "flex", justifyContent: "space-between" }}>
|
|
|
|
|