UNPKG

@cranberry-money/shared-utils

Version:

Shared utility functions for Blueberry platform

28 lines 1.31 kB
const STATUS_LABELS = { verified: 'Verified', pending: 'Pending', rejected: 'Rejected', not_started: 'Not Started', not_verified: 'Not Verified', unknown: 'Unknown', }; export function getUserVerificationStatus(profile) { // If the profile object has isIdVerified set, that's the definitive answer if (typeof profile === 'object' && profile?.isIdVerified) { return { type: 'verified', label: STATUS_LABELS.verified }; } const status = typeof profile === 'string' ? profile : profile?.sumsubVerificationStatus; if (!status) return { type: 'not_started', label: STATUS_LABELS.not_started }; const normalized = status.toLowerCase(); if (normalized === 'verified' || normalized === 'approved') return { type: 'verified', label: STATUS_LABELS.verified }; if (normalized === 'pending' || normalized === 'in_progress') return { type: 'pending', label: STATUS_LABELS.pending }; if (normalized === 'rejected' || normalized === 'failed') return { type: 'rejected', label: STATUS_LABELS.rejected }; if (normalized === 'not_verified') return { type: 'not_verified', label: STATUS_LABELS.not_verified }; return { type: 'unknown', label: STATUS_LABELS.unknown }; } //# sourceMappingURL=user-verification.js.map