| | |
| | | onSetUserAccount: (currentUserAccount: UserAccountListOutput) => any; |
| | | getDefaultUserAccount?: ( |
| | | userAccountList: UserAccountListOutput[] |
| | | ) => UserAccountListOutput | undefined; |
| | | ) => Promise<UserAccountListOutput | undefined>; |
| | | }; |
| | | |
| | | export function useSetUserAccountBySelect({ |
| | | lifePayOrderType, |
| | | onSetUserAccount, |
| | | getDefaultUserAccount = (data) => data[0], |
| | | getDefaultUserAccount = (data) => Promise.resolve(data[0]), |
| | | }: UseSetUserAccountBySelectOptions) { |
| | | const { userAccountAllList } = useUserAccountAllList({ |
| | | lifePayOrderType: lifePayOrderType, |
| | | onSuccess(data) { |
| | | if (data.length > 0) { |
| | | const currentUserAccount = getDefaultUserAccount(data); |
| | | if (currentUserAccount) { |
| | | onSetUserAccount?.(currentUserAccount); |
| | | async onSuccess(data) { |
| | | try { |
| | | if (data.length > 0) { |
| | | const currentUserAccount = await getDefaultUserAccount(data); |
| | | if (currentUserAccount) { |
| | | onSetUserAccount?.(currentUserAccount); |
| | | } |
| | | } |
| | | } |
| | | } catch (error) {} |
| | | }, |
| | | }); |
| | | |