From 47309c30dc4b5a71555e6b118c1ea6e08967405c Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Sat, 2 May 2026 14:13:30 +0330 Subject: [PATCH] share catalogue --- .../catalogue/components/CatalogueItem.tsx | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) 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 }) => { -
+
+