@@ -405,15 +405,35 @@ private extension ProductsViewController {
405405 }
406406
407407 func showPriceBulkEditingModal() {
408- let priceInputViewModel = PriceInputViewModel(productListViewModel: viewModel) { [weak self] in
408+ let priceInputViewModel = PriceInputViewModel(productListViewModel: viewModel)
409+ let priceInputViewController = PriceInputViewController(viewModel: priceInputViewModel)
410+ priceInputViewModel.cancelClosure = { [weak self] in
409411 self?.dismissModal()
410- } applyClosure: { newPrice in
411- //
412412 }
413- let priceInputViewController = PriceInputViewController(viewModel: priceInputViewModel)
413+ priceInputViewModel.applyClosure = { [weak self] newPrice in
414+ self?.applyBulkEditingPrice(newPrice: newPrice, modalVC: priceInputViewController)
415+ }
414416 present(WooNavigationController(rootViewController: priceInputViewController), animated: true)
415417 }
416418
419+ func applyBulkEditingPrice(newPrice: String?, modalVC: UIViewController) {
420+ guard let newPrice else { return }
421+
422+ displayProductsSavingInProgressView(on: modalVC)
423+ viewModel.updateSelectedProducts(with: newPrice) { [weak self] result in
424+ guard let self else { return }
425+
426+ self.dismiss(animated: true, completion: nil)
427+ switch result {
428+ case .success:
429+ self.finishBulkEditing()
430+ self.presentNotice(title: Localization.priceUpdatedNotice)
431+ case .failure:
432+ self.presentNotice(title: Localization.updateErrorNotice)
433+ }
434+ }
435+ }
436+
417437 func displayProductsSavingInProgressView(on vc: UIViewController) {
418438 let viewProperties = InProgressViewProperties(title: Localization.productsSavingTitle, message: Localization.productsSavingMessage)
419439 let inProgressViewController = InProgressViewController(viewProperties: viewProperties)
@@ -1311,6 +1331,8 @@ private extension ProductsViewController {
13111331
13121332 static let statusUpdatedNotice = NSLocalizedString("Status updated",
13131333 comment: "Title of the notice when a user updated status for selected products")
1334+ static let priceUpdatedNotice = NSLocalizedString("Price updated",
1335+ comment: "Title of the notice when a user updated price for selected products")
13141336 static let updateErrorNotice = NSLocalizedString("Cannot update products",
13151337 comment: "Title of the notice when there is an error updating selected products")
13161338 }
0 commit comments