feat: add route links to user and server

This commit is contained in:
zerosoul
2022-04-24 10:36:09 +08:00
parent be3b91dc52
commit d00b0f5b57
2 changed files with 22 additions and 14 deletions
+8 -4
View File
@@ -2,6 +2,7 @@
import styled from "styled-components";
import Avatar from "../../common/component/Avatar";
import { useSelector } from "react-redux";
import { NavLink, useLocation } from "react-router-dom";
const StyledWrapper = styled.div`
padding: 10px 12px;
.avatar {
@@ -14,14 +15,17 @@ const StyledWrapper = styled.div`
}
}
`;
export default function ServerDropList({ uid = null }) {
export default function User({ uid = null }) {
const { pathname } = useLocation();
const user = useSelector((store) => store.contacts.byId[uid]);
if (!user) return null;
return (
<StyledWrapper>
<div className="avatar">
<Avatar url={user.avatar} name={user.name} />
</div>
<NavLink to={`/setting?nav=my_account&f=${pathname}`}>
<div className="avatar">
<Avatar url={user.avatar} name={user.name} />
</div>
</NavLink>
</StyledWrapper>
);
}