refactor: add typescript definition

This commit is contained in:
HD
2022-06-28 10:08:36 +08:00
parent e0bbbf4f30
commit 2a3535ea13
30 changed files with 325 additions and 204 deletions
+13 -3
View File
@@ -1,3 +1,4 @@
import { FC } from "react";
import styled from "styled-components";
import Avatar from "./Avatar";
import { useAppSelector } from "../../app/store";
@@ -46,14 +47,21 @@ const StyledWrapper = styled.div`
}
`;
export default function Channel({ interactive = true, id = "", compact = false, avatarSize = 32 }) {
interface Props {
interactive?: boolean;
id: number;
compact?: boolean;
avatarSize?: number;
}
const Channel: FC<Props> = ({ interactive = true, id, compact = false, avatarSize = 32 }) => {
const { channel, totalMemberCount } = useAppSelector((store) => {
return {
channel: store.channels.byId[id],
totalMemberCount: store.contacts.ids.length
};
});
console.log("channel item", id, channel);
if (!channel) return null;
const { name, members = [], is_public, avatar } = channel;
return (
@@ -71,4 +79,6 @@ export default function Channel({ interactive = true, id = "", compact = false,
)}
</StyledWrapper>
);
}
};
export default Channel;