import { FormGroup, FormControl } from '@angular/forms';
import { Component, OnInit } from '@angular/core';
import { Store } from '@ngrx/store';

// Models
import { GlobalState } from '@app/core/state';

// Actions
import { ChangePlanName } from '@app/degree-planner/store/actions/plan.actions';

@Component({
  selector: 'cse-course-details-dialog',
  templateUrl: './modify-plan-dialog.component.html',
})
export class ModifyPlanDialogComponent implements OnInit {
  public form: FormGroup;

  constructor(private store: Store<GlobalState>) {
    this.form = new FormGroup({
      planName: new FormControl(),
    });
  }

  ngOnInit() {}

  renamePlanSave() {
    this.store.dispatch(new ChangePlanName(this.form.value.planName));
    console.log('PUT /degreePlan/<planId> { primary: <bool>, name: <string> }');
  }
  makePlanPrimarySave() {
    // Open confirm dialog
    console.log('PUT /degreePlan/<planId> { primary: true, name: <string> }');
  }
  createPlanSave() {
    console.log('POST /degreePlan { primary: <bool>, name: <string> }');
  }
}