import _Message from './_Message.js';

var _AccountApplication = {}

//_AccountApplication._show = false;
_AccountApplication.username = '';
_AccountApplication.salutation = '';
_AccountApplication.firstname = '';
_AccountApplication.lastname = '';
_AccountApplication.position = '';
_AccountApplication.store = '';
_AccountApplication.address = '';
_AccountApplication.practice_type = '';
_AccountApplication.phone_office = '';
_AccountApplication.phone_cell = '';
_AccountApplication.email = '';

_AccountApplication.salutations = [
  {value: 'mr', text: 'Mr.'},
  {value: 'ms', text: 'Ms.'},
  {value: 'mrs', text: 'Mrs.'},
  {value: 'dr', text: 'Dr.'}
  ];
_AccountApplication.positions = [
  {value: 'owner', text: 'Owner'},
  {value: 'manager', text: 'Manager'},
  {value: 'buyer', text: 'Buyer'},
  {value: 'other', text: 'Other'}
  ];
_AccountApplication.practice_types = [
  {value: 'optometrist', text: 'Optometrist'},
  {value: 'ophthalmologist', text: 'Ophthalmologist'},
  {value: 'optician', text: 'Optician'},
  {value: 'optical_retail_store', text: 'Optical Retail Store'},
  {value: 'optical_lab', text: 'Optical Lab'},
  {value: 'importer_distributor', text: 'Importer/Distributor'}
  ];

//_AccountApplication.show = function(){
//  _AccountApplication._show = true;
//  };
//_AccountApplication.hide = function(){
//  _AccountApplication._show = false;
//  };
//_AccountApplication.isShowing = function(){
//  return _AccountApplication._show === true;
//  };
_AccountApplication.submit = function(){
  m.request({
    method: 'POST',
    url: '/cgi/submitnewuserapplication',
    body: {
      username: _AccountApplication.username,
      salutation: _AccountApplication.salutation,
      firstname: _AccountApplication.firstname,
      lastname: _AccountApplication.lastname,
      position: _AccountApplication.position,
      store: _AccountApplication.store,
      address: _AccountApplication.address,
      practice_type: _AccountApplication.practice_type,
      phone_office: _AccountApplication.phone_office,
      phone_cell: _AccountApplication.phone_cell,
      email: _AccountApplication.email
      }
    }).then(function(){
      _Message.addNotification('Application Submitted!');
      _AccountApplication._show = false;
      _AccountApplication.username = '';
      _AccountApplication.salutation = '';
      _AccountApplication.firstname = '';
      _AccountApplication.lastname = '';
      _AccountApplication.position = '';
      _AccountApplication.store = '';
      _AccountApplication.address = '';
      _AccountApplication.practice_type = '';
      _AccountApplication.phone_office = '';
      _AccountApplication.phone_cell = '';
      _AccountApplication.email = '';
      });
  };

export default _AccountApplication;