//
//  PushNotifSetupPresenter.swift
//  fuelhunter
//
//  Created by Guntis on 10/07/2019.
//  Copyright (c) 2019 . All rights reserved.
//
//  This file was generated by the Clean Swift Xcode Templates so
//  you can apply clean architecture to your iOS and Mac projects,
//  see http://clean-swift.com
//

import UIKit

protocol PushNotifSetupPresentationLogic {
  	func presentData(response: PushNotifSetup.SetUp.Response)
  	func returnBackToPreviousViewController()
}

class PushNotifSetupPresenter: PushNotifSetupPresentationLogic {
  	weak var viewController: PushNotifSetupDisplayLogic?
	weak var router: PushNotifSetupRouter?

  	// MARK: PushNotifSetupPresentationLogic

  	func presentData(response: PushNotifSetup.SetUp.Response) {

  		var descriptionString = "settings_receive_notif_if_price_drops_by_title".localized()

  		if response.value == 1 {
  			descriptionString.append(" \(response.convertedValue) \("settings_1_cent".localized())")
  		} else {
  			descriptionString.append(" \(response.convertedValue) \("settings_more_cents".localized())")
  		}

  		let displayItem = PushNotifSetup.SetUp.ViewModel.DisplayedItem(description: descriptionString, value: response.value, minValue: response.minValue, maxValue: response.maxValue, sortedCities: response.sortedCities, selectedCityName: response.selectedCityName)
    	let viewModel = PushNotifSetup.SetUp.ViewModel(displayedItem: displayItem)
    	viewController?.updateData(viewModel: viewModel)
  	}

  	func returnBackToPreviousViewController() {
  		router?.dismissCurrentViewController()
  	}
}
