This commit is contained in:
@@ -22,3 +22,26 @@ export const getExchangeBusinessErrorMessage = (value: unknown): string | undefi
|
||||
const failure = getBusinessFailure(value)
|
||||
return failure?.msg || failure?.message
|
||||
}
|
||||
|
||||
export interface ExchangeNewAssetContext {
|
||||
asset_identifier?: string
|
||||
associated_phones?: string[] | null
|
||||
}
|
||||
|
||||
// 新资产上下文由提交时选中的资产提供,绝不回退到旧资产。
|
||||
export const getExchangePhoneAssociationQuery = (
|
||||
failure: unknown,
|
||||
newAsset: ExchangeNewAssetContext
|
||||
): { asset_identifier: string; phone: string } | undefined => {
|
||||
const response = getBusinessFailure(failure)
|
||||
if (Number(response?.code) !== 1202) return undefined
|
||||
const asset_identifier = newAsset.asset_identifier?.trim() || ''
|
||||
const responsePhone = typeof response?.data?.phone === 'string' ? response.data.phone.trim() : ''
|
||||
const phone =
|
||||
responsePhone ||
|
||||
newAsset.associated_phones
|
||||
?.find((value) => typeof value === 'string' && value.trim())
|
||||
?.trim() ||
|
||||
''
|
||||
return asset_identifier && phone ? { asset_identifier, phone } : undefined
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user