import { ActionIcon, Box, Button, Center, Group, MediaQuery, Space, Stack, Table, Text, Title, } from "@mantine/core"; import { useClipboard } from "@mantine/hooks"; import { useModals } from "@mantine/modals"; import moment from "moment"; import Link from "next/link"; import { useEffect, useState } from "react"; import { TbEdit, TbInfoCircle, TbLink, TbTrash } from "react-icons/tb"; import { FormattedMessage } from "react-intl"; import Meta from "../../components/Meta"; import showShareInformationsModal from "../../components/account/showShareInformationsModal"; import showShareLinkModal from "../../components/account/showShareLinkModal"; import CenterLoader from "../../components/core/CenterLoader"; import useConfig from "../../hooks/config.hook"; import useTranslate from "../../hooks/useTranslate.hook"; import shareService from "../../services/share.service"; import { MyShare } from "../../types/share.type"; import toast from "../../utils/toast.util"; const webroot = process.env.WEBROOT || ""; const MyShares = () => { const modals = useModals(); const clipboard = useClipboard(); const config = useConfig(); const t = useTranslate(); const [shares, setShares] = useState(); useEffect(() => { shareService.getMyShares().then((shares) => setShares(shares)); }, []); if (!shares) return ; return ( <> <FormattedMessage id="account.shares.title" /> {shares.length == 0 ? (
<FormattedMessage id="account.shares.title.empty" />
) : ( {shares.map((share) => ( ))}
{share.id} {share.description || ""} {share.views} {moment(share.expiration).unix() === 0 ? "Never" : moment(share.expiration).format("LLL")} { showShareInformationsModal( modals, share, config.get("general.appUrl"), parseInt(config.get("share.maxSize")), ); }} > { if (window.isSecureContext) { clipboard.copy( `${config.get("general.appUrl")}/s/${share.id}`, ); toast.success(t("common.notify.copied")); } else { showShareLinkModal( modals, share.id, config.get("general.appUrl"), ); } }} > { modals.openConfirmModal({ title: t("account.shares.modal.delete.title", { share: share.id, }), children: ( ), confirmProps: { color: "red", }, labels: { confirm: t("common.button.delete"), cancel: t("common.button.cancel"), }, onConfirm: () => { shareService.remove(share.id); setShares( shares.filter((item) => item.id !== share.id), ); }, }); }} >
)} ); }; export default MyShares;