diff --git a/src/app/investor/dashboard/page.tsx b/src/app/investor/dashboard/page.tsx index 843d528..9d56ed0 100644 --- a/src/app/investor/dashboard/page.tsx +++ b/src/app/investor/dashboard/page.tsx @@ -1,5 +1,8 @@ +'use client'; + +import { useState, useEffect } from 'react'; import { investors, bikes, transactions } from '@/data/mockData'; -import { Wallet, TrendingUp, Bike, Target, DollarSign, FileText, Phone, BarChart3, Clock, ArrowRight, ShieldCheck, Zap, AlertCircle } from 'lucide-react'; +import { Wallet, TrendingUp, Bike, Target, DollarSign, FileText, Phone, BarChart3, Clock, ArrowRight, ShieldCheck, Zap, AlertCircle, Download, X, ExternalLink } from 'lucide-react'; import Link from 'next/link'; import TransactionList from '@/components/TransactionList'; import InvestorNotification from '@/components/InvestorNotification'; @@ -11,6 +14,40 @@ export default function InvestorDashboardPage() { const availableBalance = investor.totalEarnings - investor.totalWithdrawn - investor.withdrawalPending; + const [deferredPrompt, setDeferredPrompt] = useState(null); + const [showInstallBanner, setShowInstallBanner] = useState(false); + + useEffect(() => { + const handler = (e: Event) => { + e.preventDefault(); + setDeferredPrompt(e); + setShowInstallBanner(true); + }; + window.addEventListener('beforeinstallprompt', handler); + return () => window.removeEventListener('beforeinstallprompt', handler); + }, []); + + const handleInstall = async () => { + if (!deferredPrompt) return; + deferredPrompt.prompt(); + const { outcome } = await deferredPrompt.userChoice; + if (outcome === 'accepted') { + setDeferredPrompt(null); + } + setShowInstallBanner(false); + }; + + const dismissBanner = () => { + setShowInstallBanner(false); + localStorage.setItem('pwa_install_dismissed', 'true'); + }; + + useEffect(() => { + if (localStorage.getItem('pwa_install_dismissed') === 'true') { + setShowInstallBanner(false); + } + }, []); + return (
@@ -82,6 +119,29 @@ export default function InvestorDashboardPage() {
+ {/* PWA Install Banner */} + {showInstallBanner && ( +
+
+
+ +
+
+

Install JML Investor App

+

Add to home screen for quick access & offline support

+
+
+ + +
+
+
+ )} +