import React, { FC, useState } from "react"; import Router from "next/router"; import styled from "styled-components"; import URL from "url"; import QRCode from "qrcode.react"; import { Flex } from "reflexbox/styled-components"; import TBodyButton from "./TBodyButton"; import Modal from "../../Modal"; interface Props { showModal: any; url: { count: number; domain: string; id: string; password: boolean; shortLink: string; visit_count: number; }; } const Actions = styled(Flex).attrs({ justifyContent: "center", alignItems: "center" })` button { margin: 0 2px 0 12px; } `; const Icon = styled.img` width: 12px; height: 12px; `; const TBodyCount: FC = ({ url }) => { const [showModal, setShowModal] = useState(false); const toggleQrCodeModal = () => setShowModal(current => !current); function goTo(e) { e.preventDefault(); const { id, domain } = url; Router.push(`/stats?id=${id}${domain ? `&domain=${domain}` : ""}`); } const showQrCode = window.innerWidth > 640; return ( {url.visit_count || 0} {url.password && } {url.visit_count > 0 && ( Stats )} {showQrCode && ( )} ); }; export default TBodyCount;