diff --git a/src/pages/catalogue/components/CatalogueItem.tsx b/src/pages/catalogue/components/CatalogueItem.tsx index d51a14a..62f369b 100644 --- a/src/pages/catalogue/components/CatalogueItem.tsx +++ b/src/pages/catalogue/components/CatalogueItem.tsx @@ -19,6 +19,30 @@ const CatalogueItem: FC = ({ item, refetch }) => { const deleteCatalog = useDleteCatalog() + const shareUrl = `${window.location.origin}${Paths.viewer}/${item.id}` + + const handleShare = async () => { + try { + if (typeof navigator.share === 'function') { + await navigator.share({ + title: item.name, + text: item.name, + url: shareUrl, + }) + return + } + await navigator.clipboard.writeText(shareUrl) + toast('لینک در کلیپ‌بورد کپی شد', 'success') + } catch (err) { + const isAbort = + err instanceof DOMException + ? err.name === 'AbortError' + : err instanceof Error && err.name === 'AbortError' + if (isAbort) return + toast(extractErrorMessage(err, 'امکان اشتراک‌گذاری وجود ندارد'), 'error') + } + } + const handleDelete = () => { deleteCatalog.mutate(item.id, { onSuccess: () => { @@ -55,9 +79,14 @@ const CatalogueItem: FC = ({ item, refetch }) => { -
+
+