const fs = require('fs'); const path = require('path'); const filePath = 'c:\\ignosidev\\Igcrm\\apps\\mobile\\src\\screens\\AttendanceScreen.js'; let content = fs.readFileSync(filePath, 'utf8'); // 1. Add Linking to imports content = content.replace( /import { View, Text, StyleSheet, PermissionsAndroid, Platform, Alert, ActivityIndicator, TouchableOpacity, FlatList, RefreshControl } from 'react-native';/, "import { View, Text, StyleSheet, PermissionsAndroid, Platform, Alert, ActivityIndicator, TouchableOpacity, FlatList, RefreshControl, Linking } from 'react-native';" ); // 2. Add openMap function and update renderHistoryItem const openMapFunc = ` const openMap = (lat, lng) => { const url = Platform.select({ ios: \`maps:0,0?q=\${lat},\${lng}\`, android: \`geo:0,0?q=\${lat},\${lng}(Attendance Location)\` }); Linking.openURL(url); }; const renderHistoryItem = ({ item }) => ( {getDayMonth(item.checkInTime)} In: {formatDate(item.checkInTime)} Out: {item.checkOutTime ? formatDate(item.checkOutTime) : 'Active'} {(item.checkInLat && item.checkInLng) && ( openMap(item.checkInLat, item.checkInLng)} style={styles.locationContainer} > 📍 {item.checkInLat.toFixed(4)}, {item.checkInLng.toFixed(4)} View Map )} );`; content = content.replace(/const renderHistoryItem = \({ item }\) => \([\s\S]*?\n\s{4}\);/, openMapFunc); // 3. Add styles const newStyles = ` emptyText: { textAlign: 'center', marginTop: 30, color: Colors.textLight }, locationContainer: { flexDirection: 'row', alignItems: 'center', marginTop: 8, paddingTop: 8, borderTopWidth: 1, borderTopColor: Colors.borderLight, }, locationText: { fontSize: 11, color: Colors.textMuted, marginRight: 10 }, mapLink: { fontSize: 11, color: Colors.secondary, fontWeight: 'bold', textDecorationLine: 'underline' } });`; content = content.replace(/emptyText: {[\s\S]*?\n\s{4}}\n}\);/, newStyles); fs.writeFileSync(filePath, content, 'utf8'); console.log('File updated successfully!');