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