- Introduced parsing logic for Salesforce addresses in VerificationWorkflowService to improve address handling. - Updated CompleteAccountStep and VerificationStep components to utilize new address structure and improve user experience. - Enhanced OTP input handling in OtpStep and added expiry timer functionality for better user feedback. - Refactored PrefilledUserInfo and AddressFields components to accommodate new address data structure. - Added error handling improvements and ensured consistent state management across verification steps.
71 lines
2.3 KiB
TypeScript
71 lines
2.3 KiB
TypeScript
/**
|
|
* Address Domain - Constants
|
|
*
|
|
* Field length limits for address validation.
|
|
* These limits ensure composed values fit within WHMCS API constraints.
|
|
*/
|
|
|
|
// ============================================================================
|
|
// WHMCS Address Field Limits
|
|
// ============================================================================
|
|
|
|
/**
|
|
* Maximum lengths for WHMCS address API fields.
|
|
* These are the hard limits imposed by the WHMCS system.
|
|
*/
|
|
export const WHMCS_ADDRESS_LIMITS = {
|
|
/** Maximum length for address1 field (building + room) */
|
|
ADDRESS1_MAX: 200,
|
|
/** Maximum length for address2 field (town + street address) */
|
|
ADDRESS2_MAX: 200,
|
|
/** Maximum length for city field */
|
|
CITY_MAX: 100,
|
|
/** Maximum length for state field */
|
|
STATE_MAX: 100,
|
|
} as const;
|
|
|
|
// ============================================================================
|
|
// Street Address Pattern
|
|
// ============================================================================
|
|
|
|
/**
|
|
* Regex pattern for Japanese street address (chome-banchi-go).
|
|
* Matches: "1-5-3", "1-5", "15-3", "99-999-999"
|
|
* Used in both input validation (streetAddressDetailSchema) and
|
|
* parsing (extracting street number from concatenated SF MailingStreet).
|
|
*/
|
|
export const STREET_ADDRESS_PATTERN = /\d{1,2}-\d{1,3}(-\d{1,3})?/;
|
|
|
|
// ============================================================================
|
|
// Input Field Limits
|
|
// ============================================================================
|
|
|
|
/**
|
|
* Maximum lengths for user input fields.
|
|
* Calculated to ensure composed values fit within WHMCS limits.
|
|
*
|
|
* Building + Room composition for WHMCS address1:
|
|
* - "Building Name Room123" = buildingName + " " + roomNumber
|
|
* - Max: 169 + 1 (space) + 30 = 200 chars
|
|
*/
|
|
export const ADDRESS_INPUT_LIMITS = {
|
|
/**
|
|
* Building name max length (169 chars).
|
|
* Calculation: WHMCS_ADDRESS1_MAX(200) - space(1) - ROOM_NUMBER_MAX(30) = 169
|
|
*/
|
|
BUILDING_NAME_MAX: 169,
|
|
|
|
/**
|
|
* Room number max length (30 chars).
|
|
* Allows for long format like "Room 2051-A-Special"
|
|
*/
|
|
ROOM_NUMBER_MAX: 30,
|
|
|
|
/**
|
|
* Street address max length (20 chars).
|
|
* Format: chome-banchi-go (e.g., "99-999-999")
|
|
* Already enforced by streetAddressDetailSchema regex.
|
|
*/
|
|
STREET_ADDRESS_MAX: 20,
|
|
} as const;
|