✨ MAJOR FEATURES: • Auto-zoom intelligence với smart bounds fitting • Enhanced 3D GPS markers với pulsing effects • Professional route display với 6-layer rendering • Status-based parking icons với availability indicators • Production-ready build optimizations 🗺️ AUTO-ZOOM FEATURES: • Smart bounds fitting cho GPS + selected parking • Adaptive padding (50px) cho visual balance • Max zoom control (level 16) để tránh quá gần • Dynamic centering khi không có selection 🎨 ENHANCED VISUALS: • 3D GPS marker với multi-layer pulse effects • Advanced parking icons với status colors • Selection highlighting với animation • Dimming system cho non-selected items 🛣️ ROUTE SYSTEM: • OpenRouteService API integration • Multi-layer route rendering (glow, shadow, main, animated) • Real-time distance & duration calculation • Visual route info trong popup 📱 PRODUCTION READY: • SSR safe với dynamic imports • Build errors resolved • Global deployment via Vercel • Optimized performance 🌍 DEPLOYMENT: • Vercel: https://whatever-ctk2auuxr-phong12hexdockworks-projects.vercel.app • Bundle size: 22.8 kB optimized • Global CDN distribution • HTTPS enabled 💾 VERSION CONTROL: • MapView-v2.0.tsx backup created • MAPVIEW_VERSIONS.md documentation • Full version history tracking
64 lines
2.1 KiB
JavaScript
64 lines
2.1 KiB
JavaScript
import parsePhoneNumber from '../parsePhoneNumber.js'
|
|
|
|
/**
|
|
* Matches a phone number object against a phone number string.
|
|
* @param {string} phoneNumberString
|
|
* @param {PhoneNumber} phoneNumber
|
|
* @param {object} metadata — Metadata JSON
|
|
* @return {'INVALID_NUMBER'|'NO_MATCH'|'SHORT_NSN_MATCH'|'NSN_MATCH'|'EXACT_MATCH'}
|
|
*/
|
|
export default function matchPhoneNumberStringAgainstPhoneNumber(phoneNumberString, phoneNumber, metadata) {
|
|
// Parse `phoneNumberString`.
|
|
let phoneNumberStringContainsCallingCode = true
|
|
let parsedPhoneNumber = parsePhoneNumber(phoneNumberString, metadata)
|
|
if (!parsedPhoneNumber) {
|
|
// If `phoneNumberString` didn't contain a country calling code
|
|
// then substitute it with the `phoneNumber`'s country calling code.
|
|
phoneNumberStringContainsCallingCode = false
|
|
parsedPhoneNumber = parsePhoneNumber(phoneNumberString, { defaultCallingCode: phoneNumber.countryCallingCode }, metadata)
|
|
}
|
|
if (!parsedPhoneNumber) {
|
|
return 'INVALID_NUMBER'
|
|
}
|
|
|
|
// Check that the extensions match.
|
|
if (phoneNumber.ext) {
|
|
if (parsedPhoneNumber.ext !== phoneNumber.ext) {
|
|
return 'NO_MATCH'
|
|
}
|
|
} else {
|
|
if (parsedPhoneNumber.ext) {
|
|
return 'NO_MATCH'
|
|
}
|
|
}
|
|
|
|
// Check that country calling codes match.
|
|
if (phoneNumberStringContainsCallingCode) {
|
|
if (phoneNumber.countryCallingCode !== parsedPhoneNumber.countryCallingCode) {
|
|
return 'NO_MATCH'
|
|
}
|
|
}
|
|
|
|
// Check if the whole numbers match.
|
|
if (phoneNumber.number === parsedPhoneNumber.number) {
|
|
if (phoneNumberStringContainsCallingCode) {
|
|
return 'EXACT_MATCH'
|
|
} else {
|
|
return 'NSN_MATCH'
|
|
}
|
|
}
|
|
|
|
// Check if one national number is a "suffix" of the other.
|
|
if (
|
|
phoneNumber.nationalNumber.indexOf(parsedPhoneNumber.nationalNumber) === 0 ||
|
|
parsedPhoneNumber.nationalNumber.indexOf(phoneNumber.nationalNumber) === 0
|
|
) {
|
|
// "A SHORT_NSN_MATCH occurs if there is a difference because of the
|
|
// presence or absence of an 'Italian leading zero', the presence or
|
|
// absence of an extension, or one NSN being a shorter variant of the
|
|
// other."
|
|
return 'SHORT_NSN_MATCH'
|
|
}
|
|
|
|
return 'NO_MATCH'
|
|
} |