From eab42d22892740fa451e2f51d11f65592453454c Mon Sep 17 00:00:00 2001
From: hamid zarghami
Date: Sat, 27 Dec 2025 12:12:38 +0330
Subject: [PATCH] share
---
src/components/menu/SideMenu.tsx | 68 ++++++++++++++++++++++++++++----
1 file changed, 61 insertions(+), 7 deletions(-)
diff --git a/src/components/menu/SideMenu.tsx b/src/components/menu/SideMenu.tsx
index fa41eab..b6b256c 100644
--- a/src/components/menu/SideMenu.tsx
+++ b/src/components/menu/SideMenu.tsx
@@ -18,6 +18,7 @@ import useToggle from '@/hooks/helpers/useToggle';
import { useGetAbout } from '@/app/[name]/(Main)/about/hooks/useAboutData';
import Image from 'next/image';
import { useGetProfile } from '@/app/[name]/(Profile)/profile/hooks/userProfileData';
+import { toast } from '../Toast';
type MenuItemType = {
href: string | undefined;
@@ -138,6 +139,50 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS
}
};
+ const getShareUrl = () => {
+ if (typeof window === 'undefined') return '';
+ return window.location.href;
+ };
+
+ const copyToClipboard = async (showToast: boolean = true) => {
+ try {
+ const url = getShareUrl();
+ await navigator.clipboard.writeText(url);
+ if (showToast) {
+ toast('لینک با موفقیت کپی شد', 'success');
+ }
+ return true;
+ } catch {
+ if (showToast) {
+ toast('خطا در کپی کردن لینک', 'error');
+ }
+ return false;
+ }
+ };
+
+ const handleCopyLink = async () => {
+ await copyToClipboard();
+ toggleShareModal();
+ };
+
+ const handleShareTelegram = () => {
+ const url = encodeURIComponent(getShareUrl());
+ window.open(`https://t.me/share/url?url=${url}`, '_blank');
+ };
+
+ const handleShareWhatsApp = () => {
+ const url = encodeURIComponent(getShareUrl());
+ const text = encodeURIComponent('اپلیکیشن ما را ببینید!');
+ window.open(`https://wa.me/?text=${text}%20${url}`, '_blank');
+ };
+
+ const handleShareInstagram = async () => {
+ const success = await copyToClipboard(false);
+ if (success) {
+ toast('لینک کپی شد. لطفاً آن را در اینستاگرام به اشتراک بگذارید', 'info');
+ }
+ };
+
const hrefOnClicks = [
{ href: '?logout', handler: toggleLogoutModal },
{ href: '?share', handler: toggleShareModal },
@@ -299,24 +344,33 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS
{tShareModal('Description')}
-