import { ActionIcon, Button, Center, Group, LoadingOverlay, Space, Table, Text, Title, } from "@mantine/core"; import { useClipboard } from "@mantine/hooks"; import { useModals } from "@mantine/modals"; import { NextLink } from "@mantine/next"; import moment from "moment"; import { useEffect, useState } from "react"; import { Link, Trash } from "tabler-icons-react"; import Meta from "../../components/Meta"; import shareService from "../../services/share.service"; import { MyShare } from "../../types/share.type"; import toast from "../../utils/toast.util"; const MyShares = () => { const modals = useModals(); const clipboard = useClipboard(); const [shares, setShares] = useState(); useEffect(() => { shareService.getMyShares().then((shares) => setShares(shares)); }, []); if (!shares) return ; return ( <> My shares {shares.length == 0 ? (
It's empty here 👀 You don't have any shares.
) : ( {shares.map((share) => ( ))}
Name Visitors Expires at
{share.id} {share.views} {moment(share.expiration).format("MMMM DD YYYY, HH:mm")} { clipboard.copy( `${window.location.origin}/share/${share.id}` ); toast.success("Your link was copied to the keyboard."); }} > { modals.openConfirmModal({ title: `Delete share ${share.id}`, children: ( Do you really want to delete this share? ), confirmProps: { color: "red", }, labels: { confirm: "Confirm", cancel: "Cancel" }, onConfirm: () => { shareService.remove(share.id); setShares( shares.filter((item) => item.id !== share.id) ); }, }); }} >
)} ); }; export default MyShares;