Update: 2026-06-26 02:00:23

This commit is contained in:
Hamza-Ayed
2026-06-26 02:00:23 +03:00
parent bd3ba7ecd7
commit 21f5105fa1
20 changed files with 175 additions and 114 deletions

View File

@@ -25,6 +25,33 @@ class CRUD {
static DateTime _lastErrorTimestamp = DateTime(2000);
static const Duration _errorLogDebounceDuration = Duration(minutes: 1);
// ── Country-aware phone normalizer ─────────────────────────────
static String normalizePhone(String input) {
final country = box.read(BoxName.countryCode)?.toString() ?? 'Jordan';
final clean = input.replaceAll(RegExp(r'\D+'), '');
switch (country) {
case 'Syria':
if (clean.length == 10 && clean.startsWith('09'))
return '963${clean.substring(1)}';
if (clean.length == 12 && clean.startsWith('963')) return clean;
if (clean.length == 9 && clean.startsWith('9')) return '963$clean';
return clean;
case 'Egypt':
if (clean.length == 11 && clean.startsWith('01'))
return '20${clean.substring(1)}';
if (clean.length == 13 && clean.startsWith('20')) return clean;
return clean;
case 'Jordan':
default:
if (clean.length == 10 && clean.startsWith('07'))
return '962${clean.substring(1)}';
if (clean.length == 12 && clean.startsWith('962')) return clean;
if (clean.length == 9 && clean.startsWith('7')) return '962$clean';
return clean;
}
}
// ── JWT Validity Check (No external libs) ──────────────────────
static bool isJwtValid(String? token) {
if (token == null || token.isEmpty) return false;