refactor: more TS code

This commit is contained in:
Tristan Yang
2022-07-08 10:18:23 +08:00
parent be6822e568
commit 678b8515ca
36 changed files with 210 additions and 220 deletions
+11 -9
View File
@@ -1,17 +1,15 @@
// import React from "react";
// import { useSelector } from "react-redux";
import { FC, FormEvent } from "react";
import styled from "styled-components";
import usePinMessage from "../../../common/hook/usePinMessage";
import PreviewMessage from "../../../common/component/Message/PreviewMessage";
import IconSurprise from "../../../assets/icons/emoji.suprise.svg";
// import IconForward from "../../../assets/icons/forward.svg";
import IconSurprise from "../../../assets/icons/emoji.surprise.svg";
import IconClose from "../../../assets/icons/close.svg";
const Styled = styled.div`
padding: 16px;
background: #f9fafb;
filter: drop-shadow(0px 25px 50px rgba(31, 41, 55, 0.25));
border-radius: 12px;
width: 406px;
min-width: 406px;
> .head {
font-weight: 600;
font-size: 16px;
@@ -81,11 +79,14 @@ const Styled = styled.div`
}
}
`;
export default function PinList({ id }) {
type Props = {
id: number;
};
const PinList: FC<Props> = ({ id }: Props) => {
const { pins, unpinMessage, canPin } = usePinMessage(id);
const handleUnpin = (evt) => {
const handleUnpin = (evt: FormEvent<HTMLButtonElement>) => {
const { mid } = evt.currentTarget.dataset;
console.log("unpin msg", mid);
if (!mid) return;
unpinMessage(+mid);
};
const noPins = pins.length == 0;
@@ -125,4 +126,5 @@ export default function PinList({ id }) {
)}
</Styled>
);
}
};
export default PinList;