Implement share button with Web Share API + clipboard fallback
All checks were successful
Build frontend / build (push) Successful in 41s
All checks were successful
Build frontend / build (push) Successful in 41s
- Uses navigator.share() on mobile (native share sheet) - Falls back to clipboard copy on desktop with toast confirmation
This commit is contained in:
@ -342,7 +342,21 @@ export default function PropertyDetailsPage() {
|
||||
<button className="p-2 hover:bg-gray-100 rounded-full transition-colors">
|
||||
<Heart className="w-5 h-5 text-gray-600" />
|
||||
</button>
|
||||
<button className="p-2 hover:bg-gray-100 rounded-full transition-colors">
|
||||
<button
|
||||
onClick={async () => {
|
||||
const url = window.location.href;
|
||||
const title = property?.title || 'عقار';
|
||||
if (navigator.share) {
|
||||
try {
|
||||
await navigator.share({ title, text: `تحقق من هذا العقار: ${title}`, url });
|
||||
} catch {}
|
||||
} else {
|
||||
await navigator.clipboard.writeText(url);
|
||||
toast.success('تم نسخ الرابط');
|
||||
}
|
||||
}}
|
||||
className="p-2 hover:bg-gray-100 rounded-full transition-colors"
|
||||
>
|
||||
<Share2 className="w-5 h-5 text-gray-600" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user