From e8f5de585d375cc63b0db70800a5ff094b2e10c6 Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Sun, 20 Sep 2026 00:46:06 +0300 Subject: [PATCH] fix: remove landing page nav tab and prevent crowdsource contribution modal from auto-opening on tourism map --- apps/web/src/App.tsx | 90 +++++------ .../components/SubmitContributionModal.tsx | 104 +++++++++---- apps/web/src/main.tsx | 144 +++++++++++++++++- apps/web/src/pages/TourismMapView.tsx | 20 ++- 4 files changed, 271 insertions(+), 87 deletions(-) diff --git a/apps/web/src/App.tsx b/apps/web/src/App.tsx index dfd84da..267b713 100644 --- a/apps/web/src/App.tsx +++ b/apps/web/src/App.tsx @@ -8,7 +8,7 @@ import { LandmarkCard, HeritageLandmarkData } from './components/LandmarkCard'; import { SubmitContributionModal } from './components/SubmitContributionModal'; import { GuidesModerationPanel } from './components/GuidesModerationPanel'; -const DEFAULT_API_KEY = (import.meta as any).env.VITE_API_KEY || localStorage.getItem('intaleq_api_key') || ''; +const DEFAULT_API_KEY = (import.meta as any).env.VITE_API_KEY || localStorage.getItem('intaleq_api_key') || localStorage.getItem('map_admin_key'); function App() { const [map, setMap] = useState(null); @@ -19,7 +19,7 @@ function App() { const [loading, setLoading] = useState(false); const [routeLoading, setRouteLoading] = useState(false); const [routeError, setRouteError] = useState(''); - + // Layer Toggles const [show3D, setShow3D] = useState(false); const [showPOIs, setShowPOIs] = useState(true); @@ -87,38 +87,38 @@ function App() { }; const regions = [ - { - name: 'Syria', - name_ar: 'سوريا', - center: [36.29, 33.51], - zoom: 11, + { + name: 'Syria', + name_ar: 'سوريا', + center: [36.29, 33.51], + zoom: 11, flag: '🇸🇾', defaultOrigin: '33.5138, 36.2765', // Damascus defaultDest: '36.2021, 37.1343' // Aleppo }, - { - name: 'Jordan', - name_ar: 'الأردن', - center: [35.91, 31.95], - zoom: 11, + { + name: 'Jordan', + name_ar: 'الأردن', + center: [35.91, 31.95], + zoom: 11, flag: '🇯🇴', defaultOrigin: '31.9539, 35.9106', // Amman defaultDest: '32.0608, 36.1032' // Zarqa }, - { - name: 'Iraq', - name_ar: 'العراق', - center: [44.3661, 33.3152], - zoom: 11, + { + name: 'Iraq', + name_ar: 'العراق', + center: [44.3661, 33.3152], + zoom: 11, flag: '🇮🇶', defaultOrigin: '33.3152, 44.3661', // Baghdad defaultDest: '32.0000, 44.4000' // Karbala / Babil }, - { - name: 'Egypt', - name_ar: 'مصر', - center: [31.23, 30.04], - zoom: 10, + { + name: 'Egypt', + name_ar: 'مصر', + center: [31.23, 30.04], + zoom: 10, flag: '🇪🇬', defaultOrigin: '30.0444, 31.2357', // Cairo defaultDest: '31.2001, 29.9187' // Alexandria @@ -447,12 +447,12 @@ function App() {
- setSearchQuery(e.target.value)} - onKeyDown={e => e.key === 'Enter' && handleSearch()} + setSearchQuery(e.target.value)} + onKeyDown={e => e.key === 'Enter' && handleSearch()} /> + {/* Submit & Cancel Buttons */} +
+ + +
)}
diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsx index b555d9f..171e275 100644 --- a/apps/web/src/main.tsx +++ b/apps/web/src/main.tsx @@ -25,7 +25,6 @@ try { // Lightweight hash router with Sovereign Executive Styling const NAV = [ - { hash: '#landing', label: 'Landing Page (صفحة الهبوط)', icon: '🚀' }, { hash: '#map', label: 'الخريطة والملاحة الشاملة', icon: '🗺️' }, { hash: '#terrain3d', label: 'الخريطة ثلاثية الأبعاد والتضاريس', icon: '🏔️' }, { hash: '#tourism', label: 'الخريطة السياحية والتراثية', icon: '🏛️' }, @@ -37,13 +36,33 @@ const NAV = [ function MasterHeader({ hash }: { hash: string }) { const currentHash = hash || '#map' const [isFullscreen, setIsFullscreen] = useState(false); + const [showAdminModal, setShowAdminModal] = useState(false); + const [adminKey, setAdminKey] = useState(() => { + return (import.meta as any).env.VITE_ADMIN_API_KEY || (import.meta as any).env.VITE_API_KEY || localStorage.getItem('map_admin_key') || localStorage.getItem('intaleq_api_key') || ''; + }); + const [keyInput, setKeyInput] = useState(adminKey); + const [savedSuccess, setSavedSuccess] = useState(false); + + const saveAdminKey = (newKey: string) => { + const trimmed = newKey.trim(); + localStorage.setItem('map_admin_key', trimmed); + localStorage.setItem('intaleq_api_key', trimmed); + sessionStorage.setItem('tactical_api_key', trimmed); + setAdminKey(trimmed); + setSavedSuccess(true); + setTimeout(() => { + setSavedSuccess(false); + setShowAdminModal(false); + window.location.reload(); + }, 800); + }; const toggleFullscreen = () => { if (!document.fullscreenElement) { - document.documentElement.requestFullscreen().catch(() => {}); + document.documentElement.requestFullscreen().catch(() => { }); setIsFullscreen(true); } else { - document.exitFullscreen().catch(() => {}); + document.exitFullscreen().catch(() => { }); setIsFullscreen(false); } }; @@ -149,8 +168,29 @@ function MasterHeader({ hash }: { hash: string }) { })} - {/* Left Section: Live Sovereign Telemetry & Fullscreen */} + {/* Left Section: Admin Key Clearance & Telemetry & Fullscreen */}
+ +
{isFullscreen ? '🗗' : '🗖'}
+ + {/* Admin Key Clearance Modal */} + {showAdminModal && ( +
+
+
+ 🛡️ +

تصريح المشرف الرسمي (Admin Clearance)

+
+

+ يُستخدم هذا المفتاح للوصول إلى المنظومة التكتيكية وتدقيق الطرق الذكي وكافة ميزات المنصة السيادية بصلاحيات المشرف الكاملة. +

+
+ + setKeyInput(e.target.value)} + placeholder="أدخل مفتاح الـ Admin هنا..." + style={{ + width: '100%', + padding: '10px 14px', + borderRadius: 8, + border: '1px solid rgba(255, 255, 255, 0.15)', + background: 'rgba(255, 255, 255, 0.05)', + color: '#facc15', + fontFamily: 'monospace', + fontSize: '0.9rem', + outline: 'none', + boxSizing: 'border-box' + }} + /> +
+ {savedSuccess && ( +
+ ✅ تم حفظ وتفعيل مفتاح المشرف بنجاح! جاري التحديث... +
+ )} +
+ + +
+
+
+ )} ) } @@ -261,9 +394,6 @@ function Root() { return window.location.hash; } const p = window.location.pathname.toLowerCase(); - if (p.includes('landing')) { - return '#landing'; - } if (p.includes('tourism') || p.includes('heritage') || p.includes('tourist') || window.location.href.includes('سياح')) { return '#tourism'; } diff --git a/apps/web/src/pages/TourismMapView.tsx b/apps/web/src/pages/TourismMapView.tsx index e92d7b0..251c59e 100644 --- a/apps/web/src/pages/TourismMapView.tsx +++ b/apps/web/src/pages/TourismMapView.tsx @@ -538,7 +538,7 @@ export const TourismMapView: React.FC = () => { startLat = fallbackHub[1]; } - const SOVEREIGN_MAP_API_KEY = 'zP9vL5mK2nQ8xR7jT4wS1yB6hG3fV0cX'; + const SOVEREIGN_MAP_API_KEY = (import.meta as any).env.VITE_API_KEY || (import.meta as any).env.VITE_ADMIN_API_KEY || localStorage.getItem('map_admin_key') || localStorage.getItem('intaleq_api_key') || ''; const queryParams = `fromLat=${startLat}&fromLng=${startLng}&toLat=${lat}&toLng=${lng}&profile=car&steps=true&locale=ar&key=${SOVEREIGN_MAP_API_KEY}`; const isServerEnv = window.location.hostname.includes('intaleqapp.com') || window.location.port === '3201' || window.location.port === '3204'; @@ -1000,12 +1000,18 @@ export const TourismMapView: React.FC = () => { /> )} - {/* 7. Crowdsourcing Contribution Modal */} - setIsContributeOpen(false)} - initialLandmark={contributeTarget} - /> + {/* 7. Crowdsourcing Contribution Modal (Only open on user action) */} + {isContributeOpen && ( + { + setIsContributeOpen(false); + setContributeTarget(undefined); + }} + initialLandmark={contributeTarget} + mapCenter={mapInstance ? { lat: mapInstance.getCenter().lat, lng: mapInstance.getCenter().lng } : undefined} + /> + )} {/* 8. Sovereign In-App Navigation HUD */} {activeNav && (