import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
  static targets = ["providerNetworkField", "networkLogoField", "providerSectionField"]

  connect() {
    console.log("---provider update---")
  }

  syncDefaults() {
    const pnValue = this.providerNetworkFieldTarget.value
    if (pnValue == "Cigna") {
      this.networkLogoFieldTarget.value = 9
      this.providerSectionFieldTarget.value = 5
    } else if (pnValue == "MedCost") {
      this.networkLogoFieldTarget.value = 7
      this.providerSectionFieldTarget.value = 4
    } else {
      this.networkLogoFieldTarget.value = ""
      this.providerSectionFieldTarget.value = ""
    }
    const event = new Event('change', { bubbles: true });
    this.networkLogoFieldTarget.dispatchEvent(event);
  }
}