@takentrade/takentrade-libs 4.0.3 → 4.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -61,4 +61,9 @@ export declare const toTitleCase: (text: string) => string;
61
61
  /**
62
62
  * Formats transaction status for display
63
63
  */
64
+ /**
65
+ * Normalizes a phone number to the international format for Nigeria (234...)
66
+ * Handles formats like '0803...', '803...', '+234803...'
67
+ */
68
+ export declare function toSmsSafeNigerianPhone(phone: string | number): string;
64
69
  export declare const formatTransactionStatus: (status: string) => string;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatTransactionStatus = exports.toTitleCase = exports.truncateText = exports.formatFileSize = exports.formatPercentage = exports.formatRelativeTime = exports.formatDateTime = exports.formatDate = exports.maskEmail = exports.maskAccountNumber = exports.formatAccountNumber = exports.formatAmount = exports.formatCurrency = void 0;
4
+ exports.toSmsSafeNigerianPhone = toSmsSafeNigerianPhone;
4
5
  /**
5
6
  * Formats currency (Naira)
6
7
  * 1234.56 → ₦1,234.56
@@ -149,6 +150,25 @@ exports.toTitleCase = toTitleCase;
149
150
  /**
150
151
  * Formats transaction status for display
151
152
  */
153
+ /**
154
+ * Normalizes a phone number to the international format for Nigeria (234...)
155
+ * Handles formats like '0803...', '803...', '+234803...'
156
+ */
157
+ function toSmsSafeNigerianPhone(phone) {
158
+ let digits = `${phone}`.replace(/\D/g, '').trim();
159
+ if (digits === '')
160
+ return '';
161
+ // If already 234... and correct length, return as is
162
+ if (digits.startsWith('234') && digits.length === 13) {
163
+ return digits;
164
+ }
165
+ // If starts with 0 and length is 11 (e.g. 0803...), strip the 0
166
+ if (digits.startsWith('0') && digits.length === 11) {
167
+ digits = digits.slice(1);
168
+ }
169
+ // Prepend 234 if not already present
170
+ return '234' + digits;
171
+ }
152
172
  const formatTransactionStatus = (status) => {
153
173
  const statusMap = {
154
174
  PENDING: 'Pending',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takentrade/takentrade-libs",
3
- "version": "4.0.3",
3
+ "version": "4.0.5",
4
4
  "author": "Solomon Olatunji",
5
5
  "description": "TakeNTrade shared libraries",
6
6
  "main": "./dist/index.js",