refactor: add typescript support to project

This commit is contained in:
HD
2022-06-21 15:08:35 +08:00
parent 88ec2b742a
commit bd799ebea8
259 changed files with 1042 additions and 458 deletions
+41
View File
@@ -0,0 +1,41 @@
import { FC } from "react";
import styled from "styled-components";
import { NavLink, useLocation } from "react-router-dom";
import Avatar from "../../common/component/Avatar";
import { useAppSelector } from "../../app/store";
const StyledWrapper = styled.div`
padding: 10px 12px;
.avatar {
width: 32px;
height: 32px;
img {
object-fit: cover;
border-radius: 50%;
width: 100%;
height: 100%;
}
}
`;
interface Props {
uid: number;
}
const User: FC<Props> = ({ uid }) => {
const { pathname } = useLocation();
const user = useAppSelector((store) => store.contacts.byId[uid]);
if (!user) return null;
return (
<StyledWrapper>
<NavLink to={`/setting?nav=my_account&f=${pathname}`}>
<div className="avatar">
<Avatar url={user.avatar} name={user.name} />
</div>
</NavLink>
</StyledWrapper>
);
};
export default User;