Add customer Excel import/export and Gama bulk SMS sending.
Business SMS uses optional settings.sms.senderNumber (else advertising shortcode) with SendQuick for one recipient and SendBulk for quantity. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
cf459807d8
commit
b1dcecc468
@@ -121,6 +121,16 @@ function readString(value: unknown, fallback = '') {
|
||||
return typeof value === 'string' ? value.trim() : fallback;
|
||||
}
|
||||
|
||||
/** Gama / Iranian service shortcodes are numeric (e.g. 5000123456). */
|
||||
export function normalizeSmsSenderNumber(value: unknown): string | null {
|
||||
if (value == null) return null;
|
||||
if (typeof value !== 'string' && typeof value !== 'number') return null;
|
||||
const digits = String(value).replace(/\D/g, '');
|
||||
if (!digits) return null;
|
||||
if (digits.length < 8 || digits.length > 16) return null;
|
||||
return digits;
|
||||
}
|
||||
|
||||
function isPaymentGatewayId(value: unknown): value is PaymentGatewayId {
|
||||
return (
|
||||
typeof value === 'string' &&
|
||||
@@ -380,6 +390,7 @@ export function normalizeBusinessSettings(raw: unknown): BusinessSettings {
|
||||
const store = isRecord(source.store) ? source.store : {};
|
||||
const modules = isRecord(source.modules) ? source.modules : {};
|
||||
const website = isRecord(source.website) ? source.website : {};
|
||||
const sms = isRecord(source.sms) ? source.sms : {};
|
||||
const hasModulesKey = Object.prototype.hasOwnProperty.call(source, 'modules');
|
||||
const enabledModules = hasModulesKey
|
||||
? Array.isArray(modules.enabled)
|
||||
@@ -431,6 +442,9 @@ export function normalizeBusinessSettings(raw: unknown): BusinessSettings {
|
||||
),
|
||||
sitemapConfig: normalizeWebsiteSitemapConfig(website.sitemapConfig),
|
||||
},
|
||||
sms: {
|
||||
senderNumber: normalizeSmsSenderNumber(sms.senderNumber),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -482,6 +496,12 @@ export function mergeBusinessSettings(
|
||||
? patch.website.sitemapConfig
|
||||
: current.website.sitemapConfig,
|
||||
},
|
||||
sms: {
|
||||
senderNumber:
|
||||
patch.sms?.senderNumber !== undefined
|
||||
? patch.sms.senderNumber
|
||||
: current.sms.senderNumber,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user