From 095d38cbc078c5493d2df9c5d44d446831df815e Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 31 Mar 2026 16:46:38 +0000 Subject: [PATCH] feat: add DOM-TOM country codes and auto-detect mobile prefixes during registration Co-authored-by: clemPerrousset <64415865+clemPerrousset@users.noreply.github.com> --- entourage/Tools/CountryCode.swift | 8 ++++++++ entourage/Tools/Utils.swift | 18 ++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/entourage/Tools/CountryCode.swift b/entourage/Tools/CountryCode.swift index 60d82e183..d8d809957 100644 --- a/entourage/Tools/CountryCode.swift +++ b/entourage/Tools/CountryCode.swift @@ -23,4 +23,12 @@ public let defaultCountryCode = CountryCode(country: "France", code: "+33", flag public let allCountryCodes: [CountryCode] = [ CountryCode(country: "France", code: "+33", flag: "🇫🇷"), CountryCode(country: "Belgique", code: "+32", flag: "🇧🇪"), + CountryCode(country: "Guadeloupe", code: "+590", flag: "🇫🇷"), + CountryCode(country: "Martinique", code: "+596", flag: "🇫🇷"), + CountryCode(country: "Guyane", code: "+594", flag: "🇫🇷"), + CountryCode(country: "La Réunion", code: "+262", flag: "🇫🇷"), + CountryCode(country: "Mayotte", code: "+262", flag: "🇫🇷"), + CountryCode(country: "Polynésie", code: "+689", flag: "🇫🇷"), + CountryCode(country: "Nouvelle-Calédonie", code: "+687", flag: "🇫🇷"), + CountryCode(country: "Saint-Martin / St-Barth", code: "+590", flag: "🇫🇷"), ] diff --git a/entourage/Tools/Utils.swift b/entourage/Tools/Utils.swift index cd2863a50..570dbf90d 100644 --- a/entourage/Tools/Utils.swift +++ b/entourage/Tools/Utils.swift @@ -100,11 +100,25 @@ import UIKit static func validatePhoneFormat(countryCode:String?, phone:String) -> String { var correctPhone = phone.trimmingCharacters(in: .whitespaces) + var appliedCountryCode = countryCode + + // Auto-detect DOM-TOM prefixes if France is selected or no country code is provided + if appliedCountryCode == "+33" || appliedCountryCode == nil { + if correctPhone.hasPrefix("0690") || correctPhone.hasPrefix("0691") { + appliedCountryCode = "+590" + } else if correctPhone.hasPrefix("0696") || correctPhone.hasPrefix("0697") { + appliedCountryCode = "+596" + } else if correctPhone.hasPrefix("0694") { + appliedCountryCode = "+594" + } else if correctPhone.hasPrefix("0692") || correctPhone.hasPrefix("0693") || correctPhone.hasPrefix("0639") { + appliedCountryCode = "+262" + } + } if correctPhone.starts(with: "0") { //correctPhone.remove(at: .init(encodedOffset: 0)) correctPhone.remove(at: .init(utf16Offset: 0, in: correctPhone)) - if let _code = countryCode { + if let _code = appliedCountryCode { correctPhone = _code + correctPhone } else { @@ -112,7 +126,7 @@ import UIKit } } else if !correctPhone.starts(with: "+") { - if let _code = countryCode { + if let _code = appliedCountryCode { correctPhone = _code + correctPhone } }