'use client' import { useState } from 'react' import { Card, CardContent, CardDescription, CardHeader, CardTitle, Button, Badge, MobileHeader, useOnlineStatus, useInstallPrompt, getCurrentPosition, calculateDistance, formatDistance, formatDate, formatDateTime, getRelativeTime, toOdooDatetime, } from '@kodeme-io/next-core-ui' import { Wifi, WifiOff, Download, MapPin, Calendar, Smartphone } from 'lucide-react' export default function ExamplesPage() { const isOnline = useOnlineStatus() const { isInstallable, isInstalled, install } = useInstallPrompt() const [position, setPosition] = useState<{ latitude: number; longitude: number } | null>(null) const [distance, setDistance] = useState(null) const handleGetLocation = async () => { try { const pos = await getCurrentPosition() setPosition({ latitude: pos.latitude, longitude: pos.longitude }) // Calculate distance to Jakarta (example) const jakartaLat = -6.2088 const jakartaLon = 106.8456 const dist = calculateDistance(pos.latitude, pos.longitude, jakartaLat, jakartaLon) setDistance(dist) } catch (error) { console.error('Failed to get location:', error) alert('Failed to get location. Make sure you granted permission.') } } const handleInstallPWA = async () => { const success = await install() if (success) { alert('App installed successfully!') } } return (
{/* Online Status */} {isOnline ? ( ) : ( )} Network Status Real-time online/offline detection {isOnline ? 'Online' : 'Offline'}

{isOnline ? 'You are connected to the internet' : 'You are offline. Changes will sync when reconnected.'}

{/* PWA Installation */} PWA Installation Install this app on your device {isInstalled ? ( App is installed ) : isInstallable ? (
Installation available
) : ( Not installable on this device )}

Install this app to use it offline and get a native app experience.

{/* GPS / Geolocation */} GPS & Geolocation Get your current location {position && (
Latitude: {position.latitude.toFixed(6)}
Longitude: {position.longitude.toFixed(6)}
{distance !== null && (
Distance to Jakarta: {formatDistance(distance)}
)}
)}

Uses browser Geolocation API for GPS positioning and distance calculations.

{/* Date Formatting */} Date Utilities Format dates for display and Odoo
Current Date: {formatDate(new Date())}
Current DateTime: {formatDateTime(new Date())}
Relative Time: {getRelativeTime(new Date())}
Odoo Format: {toOdooDatetime(new Date())}

Utilities for date formatting, Odoo integration, and localization.

{/* Component Examples */} Available Components PWA and mobile components included
  • ✅ PWAProvider - Service worker & installation
  • ✅ OfflineBanner - Network status indicator
  • ✅ AuthWrapper - Route protection
  • ✅ MobileHeader - Mobile-optimized headers
  • ✅ AppShell - Responsive layout with navigation
  • ✅ ThemeProvider - Dark/light mode support
{/* Utility Functions */} Available Utilities 24 utility functions ready to use
PWA Utils:
  • • registerServiceWorker()
  • • useOnlineStatus()
  • • useInstallPrompt()
  • • isPWAInstalled()
Geofence Utils:
  • • calculateDistance()
  • • validateGeofence()
  • • getCurrentPosition()
  • • watchPosition()
Date Utils:
  • • toOdooDatetime()
  • • formatDate()
  • • getRelativeTime()
  • • addDays(), isToday()
) }