import {
  ChangeDetectorRef,
  Component,
  Inject,
  OnInit,
  ViewEncapsulation,
} from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { SiteService } from 'app/modules/polyglot/domain/services/site.service';
import { IdentityService } from 'app/modules/polyglot/member/services/identity.service';
import { Site } from 'app/modules/protobuf/models/domain/site_pb';

export interface CompComposeData {
  price: string;
  memo: string;
}
export interface CompComposeResult {
  price: string;
  memo: string;
}

@Component({
  selector: 'app-comp-compose',
  templateUrl: './comp-compose.component.html',
  encapsulation: ViewEncapsulation.None,
})
export class CompComposeComponent implements OnInit {
  composeForm!: FormGroup;
  sites: any[] = [];
  // quillModules: any = {
  //   toolbar: [
  //     ['bold', 'italic', 'underline'],
  //     [{ align: [] }, { list: 'ordered' }, { list: 'bullet' }],
  //     ['clean'],
  //   ],
  // };

  /**
   * Constructor
   */
  constructor(
    public matDialogRef: MatDialogRef<CompComposeComponent>,
    @Inject(MAT_DIALOG_DATA) public data: CompComposeData,
    private _formBuilder: FormBuilder,
    private _identityService: IdentityService,
    private _changeDetectorRef: ChangeDetectorRef
  ) {}

  // -----------------------------------------------------------------------------------------------------
  // @ Lifecycle hooks
  // -----------------------------------------------------------------------------------------------------

  /**
   * On init
   */
  ngOnInit(): void {
    // Create the form
    this.composeForm = this._formBuilder.group({
      price: ['', [Validators.required]],
      memo: ['', [Validators.required]],
    });
  }

  // -----------------------------------------------------------------------------------------------------
  // @ Public methods
  // -----------------------------------------------------------------------------------------------------

  /**
   * Save and close
   */
  saveAndClose(): void {
    // Save the message as a draft
    this.saveAsDraft();

    // Close the dialog
    this.matDialogRef.close();
  }

  /**
   * Discard the message
   */
  discard(): void {}

  /**
   * Save the message as a draft
   */
  saveAsDraft(): void {}

  /**
   * Send the message
   */
  send(): void {}
}
