import _Admin from './_Admin.js';

function ApplicationManager(ivnode){
return { view: function(vnode){
  return m('.application-manager',[
            m('h2', 'Open Applications'),
            m('button.btn.refresh-application-button',{onclick: function(){
              _Admin.getOpenApplications();
              }},[m('i.icon.icon-refresh'), 'Refresh']),
            m('ul.open-application-list', _Admin.open_applications.map(function(a){
              return m('li', [
                m('.name', a.salutation+' '+a.firstname+' '+a.lastname+ '('+a.position+' @ '+a.store+')'),
                m('.info', a.practice_type+' (Office: '+a.phone_office+', Cell: '+a.phone_cell+', Email: '+a.email+')'),
                m('.address', a.address),
                m('input[type=text][placeholder=Password].application',{
                  onchange: function(e){ a.password = e.target.value },
                  value: a.password
                  }),
                m('button.btn.btn-success.accept-application-button', {onclick: function(){
                  _Admin.acceptApplication(a);
                  }}, 'Accept'),
                m('button.btn.btn-error.accept-application-button', {onclick: function(){
                  _Admin.declineApplication(a);
                  }}, 'Decline')
                ]);
              }))
    ]);
}}}

export default ApplicationManager;