| | |
| | | type UseSetUserAccountBySelectOptions = { |
| | | lifePayOrderType: MaybeRef<LifeRechargeConstants.LifePayOrderTypeEnum>; |
| | | onSetUserAccount: (currentUserAccount: UserAccountListOutput) => any; |
| | | getDefaultUserAccount?: ( |
| | | userAccountList: UserAccountListOutput[] |
| | | ) => UserAccountListOutput | undefined; |
| | | }; |
| | | |
| | | export function useSetUserAccountBySelect({ |
| | | lifePayOrderType, |
| | | onSetUserAccount, |
| | | getDefaultUserAccount = (data) => data[0], |
| | | }: UseSetUserAccountBySelectOptions) { |
| | | const { userAccountAllList } = useUserAccountAllList({ |
| | | lifePayOrderType: lifePayOrderType, |
| | | onSuccess(data) { |
| | | if (data.length > 0) { |
| | | const currentUserAccount = data[0]; |
| | | const currentUserAccount = getDefaultUserAccount(data); |
| | | if (currentUserAccount) { |
| | | onSetUserAccount?.(currentUserAccount); |
| | | } |
| | | } |
| | | }, |
| | | }); |
| | | |