fix(users): Added merchant name is list merchants (#3289)

This commit is contained in:
Rachit Naithani
2024-01-09 15:50:09 +05:30
committed by GitHub
parent ee044a0be8
commit 8a354f4229
3 changed files with 24 additions and 4 deletions

View File

@ -640,9 +640,23 @@ pub async fn create_merchant_account(
pub async fn list_merchant_ids_for_user(
state: AppState,
user: auth::UserFromToken,
) -> UserResponse<Vec<String>> {
) -> UserResponse<Vec<user_api::UserMerchantAccount>> {
let merchant_ids = utils::user_role::get_merchant_ids_for_user(&state, &user.user_id).await?;
let merchant_accounts = state
.store
.list_multiple_merchant_accounts(merchant_ids)
.await
.change_context(UserErrors::InternalServerError)?;
Ok(ApplicationResponse::Json(
utils::user_role::get_merchant_ids_for_user(state, &user.user_id).await?,
merchant_accounts
.into_iter()
.map(|acc| user_api::UserMerchantAccount {
merchant_id: acc.merchant_id,
merchant_name: acc.merchant_name,
})
.collect(),
))
}