From 4dd60ec14aea4ccb7f5f95a1b7df21dbe26714c4 Mon Sep 17 00:00:00 2001 From: Claw AI Date: Mon, 30 Mar 2026 16:28:09 +0000 Subject: [PATCH] Fix copy link & Instagram sharing: add clipboard fallback for HTTP --- app/property/[id]/PropertyDetail.js | 44 +++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/app/property/[id]/PropertyDetail.js b/app/property/[id]/PropertyDetail.js index 5c65812..b927a1f 100644 --- a/app/property/[id]/PropertyDetail.js +++ b/app/property/[id]/PropertyDetail.js @@ -49,6 +49,30 @@ import { getRentProperty, getSaleProperty, bookReservation, checkAvailability, g import AuthService from '../../services/AuthService'; import { BuildingTypeKeys, PropertyStatusKeys, extractCity } from '../../enums'; +// Copy to clipboard that works on HTTP too +async function copyToClipboard(text) { + try { + await navigator.clipboard.writeText(text); + return true; + } catch { + // Fallback for HTTP / older browsers + const textarea = document.createElement('textarea'); + textarea.value = text; + textarea.style.position = 'fixed'; + textarea.style.opacity = '0'; + document.body.appendChild(textarea); + textarea.select(); + try { + document.execCommand('copy'); + return true; + } catch { + return false; + } finally { + document.body.removeChild(textarea); + } + } +} + // Map API response to the UI format function mapApiDetail(item) { if (!item) return null; @@ -478,9 +502,13 @@ export default function PropertyDetailsPage() { {/* Instagram (copy link) */}