import { TextboxControl } from './control-textbox';
import { ControlBase } from './control-base';
import { DropdownControl } from './control-dropdown';
import { Injectable } from '@angular/core';

@Injectable()
export class ControlService {

  // Todo: get from a remote source of question metadata
  // Todo: make asynchronous
  getControls() {

    const controls: ControlBase<any>[] = [

      new DropdownControl({
        key: 'grantType',
        label: 'Grant Type',
        options: [
          { key: 'token', value: 'TOKEN' },
          { key: 'code', value: 'CODE' },
          { key: 'id_token', value: 'ID_TOKEN' }
        ],
        order: 3
      }),

      new TextboxControl({
        key: 'clientName',
        label: 'Client Name',
        value: '',
        required: true,
        order: 1
      }),

      new TextboxControl({
        key: 'clientId',
        label: 'Client ID',
        required: true,
        order: 2
      })
    ];

    return controls.sort((a, b) => a.order - b.order);
  }
}
