import { observable, action, computed } from 'mobx';

export default class TransportationModule {
	@observable transportationList = [];
	@observable transportationId = "";
	@observable transportationDetail = {
	  	id : '',
		name : '',
  };


	@observable isLoading = false;
	
	constructor(context) {
	    this.http = context.http;
	    this.context = context;
	}

	@action
	getAll(){
		this.isLoading = true;
		return this.http.get(`transportations`).then(res => {
			this.transportationList = res;
			// console.log(this.transportationList);
			this.isLoading = false;
		});
	}

	@action
	getById(id){
		this.transportationId = id;
		this.isLoading = true;
		return this.http.get(`transportations?id=${id}`).then(detail => {
			this.transportationDetail = detail[0];
			this.isLoading = false;
		})
	}


}
