Initial commit
This commit is contained in:
131
src/common/stores/agent.js
Normal file
131
src/common/stores/agent.js
Normal file
@@ -0,0 +1,131 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class Agent {
|
||||
|
||||
@observable agentList = [];
|
||||
@observable selectedAgent = {};
|
||||
@observable isLoading = false;
|
||||
@observable agentId = '';
|
||||
@observable agentData = {
|
||||
name : '',
|
||||
phone_number : '',
|
||||
email : '',
|
||||
address : '',
|
||||
id: '',
|
||||
created_at: '',
|
||||
user_id:'',
|
||||
id_tax_number : '',
|
||||
id_type : '',
|
||||
id_number : '',
|
||||
id_photo : '',
|
||||
passport_number: '',
|
||||
passport_photo : '',
|
||||
error_email : '',
|
||||
};
|
||||
@observable orders = [];
|
||||
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
// @action
|
||||
// getAgentList(){
|
||||
// this.isLoading = true;
|
||||
// return this.http.get(`agents`).then(res => {
|
||||
// this.agentList = res;
|
||||
// this.isLoading = false;
|
||||
// });
|
||||
// }
|
||||
@action
|
||||
getAgentList() {
|
||||
this.isLoading = true;
|
||||
return this.http.get("agents")
|
||||
.then(res => {
|
||||
this.agentList = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@computed
|
||||
get isAgentEmpty() {
|
||||
if(this.agentList.length > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@action
|
||||
getDetail(id){
|
||||
this.isLoading = true;
|
||||
this.agentId = id;
|
||||
return this.http.get(`agents/${id}`).then(detail => {
|
||||
this.agentData = detail[0];
|
||||
this.isLoading = false;
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
@action
|
||||
post(){
|
||||
this.isLoading = true;
|
||||
this.http.post('agents', this.agentData).then(res => {
|
||||
this.isLoading = false;
|
||||
this.getAgentList();
|
||||
return res;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
put(id){
|
||||
this.isLoading = true;
|
||||
this.http.put(`agents/${id}`, this.agentData).then(res => {
|
||||
this.isLoading = false;
|
||||
this.getAgentList();
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
getOrder(id=this.selectedAgent.id) {
|
||||
this.isLoading = true;
|
||||
return this.http.get(`agents/${id}/orders`)
|
||||
.then(res => {
|
||||
this.orders = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
editData(id,data){
|
||||
this.isLoading = true;
|
||||
this.http.put(`agents/${id}`, data).then(res => {
|
||||
this.isLoading = false;
|
||||
this.getDetail(id);
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
delete(id){
|
||||
this.agentId = id;
|
||||
this.isLoading = true;
|
||||
this.http.delete(`agentData/${id}`).then(res => {
|
||||
this.isLoading = false;
|
||||
// console.log(detail[0]);
|
||||
this.getAgentList();
|
||||
return res;
|
||||
})
|
||||
}
|
||||
}
|
||||
35
src/common/stores/airlines.js
Normal file
35
src/common/stores/airlines.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import { action, computed, extendObservable, observable } from 'mobx';
|
||||
import moment from 'moment';
|
||||
|
||||
export default class Airlines {
|
||||
@observable airlines = [];
|
||||
@observable airlineData = {
|
||||
id: '',
|
||||
name: '',
|
||||
code: '',
|
||||
airline_type_id: '',
|
||||
image_path: '',
|
||||
created_at: '',
|
||||
updated_at: '',
|
||||
deleted_at: '',
|
||||
};
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
getAirlines(){
|
||||
return this.http.get(`airline`).then(res => {
|
||||
this.airlines = res;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getAirlineById(id){
|
||||
return this.http.get(`airline/${id}`).then(res => {
|
||||
this.airlineData = res;
|
||||
})
|
||||
}
|
||||
}
|
||||
724
src/common/stores/airlines_domestic.js
Normal file
724
src/common/stores/airlines_domestic.js
Normal file
@@ -0,0 +1,724 @@
|
||||
import { action, computed, extendObservable, observable } from 'mobx';
|
||||
import moment from 'moment';
|
||||
import sortBy from 'lodash.sortby';
|
||||
|
||||
export default class AirlinesDomestic {
|
||||
|
||||
@observable lists = [];
|
||||
@observable isLoading = false;
|
||||
@observable isLoadingSearch = false;
|
||||
@observable isReturn = 0;
|
||||
@observable serviceCharge = 0;
|
||||
@observable queries = {
|
||||
fromcity: 'CGK',
|
||||
tocity: 'SUB',
|
||||
departuredate: moment().add(1,'day').format("DD-MMM-YYYY"),
|
||||
arrivaldate: "",
|
||||
listairlines: "GA",
|
||||
cabin: '',
|
||||
adult: 1,
|
||||
child: 0,
|
||||
infant: 0,
|
||||
cheapestclass: false,
|
||||
results: {
|
||||
departure: [],
|
||||
returning: []
|
||||
}
|
||||
};
|
||||
@observable sortBy = 'price_low_to_high';
|
||||
@observable stopFilter = 'any';
|
||||
|
||||
@action
|
||||
setSortBy(sortBy) {
|
||||
this.sortBy = sortBy;
|
||||
}
|
||||
@action
|
||||
setStopFilter(filter) {
|
||||
this.stopFilter = filter;
|
||||
}
|
||||
|
||||
@computed
|
||||
get departureLists() {
|
||||
let result = [];
|
||||
if(this.sortBy === 'price_low_to_high') {
|
||||
result = sortBy(this.queries.results.departure.slice(), (it => it.price_range_start));
|
||||
} else if (this.sortBy === 'price_high_to_low') {
|
||||
result = sortBy(this.queries.results.departure.slice(), (it => it.price_range_start)).reverse();
|
||||
} else if (this.sortBy === 'duration') {
|
||||
|
||||
result = sortBy(this.queries.results.departure.slice(), (it => {
|
||||
return parseInt(it.durationhour) * 60 + parseInt(it.durationminute);
|
||||
}));
|
||||
|
||||
} else if (this.sortBy === 'departure_time') {
|
||||
result = sortBy(this.queries.results.departure.slice(), (it => {
|
||||
let [hour,minute] = it.departtime.split(':');
|
||||
return parseInt(hour) * 60 + parseInt(minute);
|
||||
}));
|
||||
}
|
||||
|
||||
if(this.stopFilter === 'no_stop') {
|
||||
result = result.filter(it => it.no_of_flight === 1);
|
||||
} else if (this.stopFilter === 'one_or_less') {
|
||||
result = result.filter(it => it.no_of_flight <= 2);
|
||||
} else if (this.stopFilter === 'two_or_less') {
|
||||
result = result.filter(it => it.no_of_flight <= 3);
|
||||
}
|
||||
result = result.filter(it => it.price_range_start !== 0);
|
||||
|
||||
if(this.priceMaxFilter !== 0) {
|
||||
result = result.filter(it => it.price_range_start <= this.priceMaxFilter);
|
||||
}
|
||||
|
||||
result = result.filter(it => {
|
||||
let returning = false;
|
||||
this.selectedAirlinesFilter.forEach(airlineName => {
|
||||
if(it.airline.includes(airlineName)) {
|
||||
returning = true;
|
||||
}
|
||||
});
|
||||
return returning;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@computed
|
||||
get priceMin() {
|
||||
if(this.queries.results.departure.slice().length === 0) {
|
||||
return 0;
|
||||
}
|
||||
return Math.min(...this.queries.results.departure.slice().map(it => it.price_range_start));
|
||||
}
|
||||
@computed
|
||||
get priceMax() {
|
||||
if(this.queries.results.departure.slice().length === 0) {
|
||||
return 0;
|
||||
}
|
||||
return Math.max(...this.queries.results.departure.slice().map(it => it.price_range_start));
|
||||
}
|
||||
|
||||
@observable priceMaxFilter = 0;
|
||||
|
||||
@action
|
||||
setPriceMaxFilter(value) {
|
||||
this.priceMaxFilter = value;
|
||||
}
|
||||
|
||||
@computed
|
||||
get airlineFilterList() {
|
||||
return this.queries.results.departure.slice().map(it => it.airline.split(',')[0]).filter((value, index, self) => {
|
||||
return self.indexOf(value) === index;
|
||||
});
|
||||
}
|
||||
|
||||
@observable selectedAirlinesFilter = [];
|
||||
|
||||
@action
|
||||
setSelectedAirlinesFilter(airlines) {
|
||||
this.selectedAirlinesFilter = airlines;
|
||||
}
|
||||
|
||||
@computed
|
||||
get isSelectedAirlinesFilterIndeterminate() {
|
||||
if(this.selectedAirlinesFilter.length === 0) {
|
||||
return false;
|
||||
}
|
||||
if(this.selectedAirlinesFilter.length === this.airlineFilterList.length) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@computed
|
||||
get isAllSelectedAirlinesChecked() {
|
||||
return this.selectedAirlinesFilter.length === this.airlineFilterList.length;
|
||||
}
|
||||
|
||||
|
||||
@observable flightCodeClasses = [];
|
||||
|
||||
@observable selectedAirline = 'GA';
|
||||
|
||||
// @observable selectedDepartureFlight = {
|
||||
// airline: "",
|
||||
// airlinecode: "",
|
||||
// arrivaldate: "",
|
||||
// arrivetime: "",
|
||||
// departdate: "",
|
||||
// departtime: "",
|
||||
// flightno: "",
|
||||
// flights: [],
|
||||
// fromcity: "",
|
||||
// tocity: ""
|
||||
// };
|
||||
|
||||
// @observable selectedDepartureFlight = {
|
||||
// 'flightno': 'QG 815',
|
||||
// 'airline': 'Citilink',
|
||||
// 'no_of_flight': 1,
|
||||
// 'airlinecode': 'QG',
|
||||
// 'departdate': '09-Dec-2017',
|
||||
// 'arrivaldate': '09-Dec-2017',
|
||||
// 'fromcity': 'CGK',
|
||||
// 'tocity': 'SUB',
|
||||
// 'fromcity_airport': 'Soekarno Hatta',
|
||||
// 'tocity_airport': 'Juanda',
|
||||
// 'fromcity_long': 'Surabaya',
|
||||
// 'tocity_long': 'Surabaya',
|
||||
// 'departtime': '04:10',
|
||||
// 'arrivetime': '05:40',
|
||||
// 'durationhour': 1,
|
||||
// 'durationminute': 30,
|
||||
// 'flights': [
|
||||
// {
|
||||
// 'flightno': 'QG 815',
|
||||
// 'airline': 'Citilink',
|
||||
// 'airlinecode': 'QG',
|
||||
// 'departdate': '09-Dec-2017',
|
||||
// 'arrivaldate': '09-Dec-2017',
|
||||
// 'fromcity': 'CGK',
|
||||
// 'tocity': 'SUB',
|
||||
// 'fromcity_airport': 'Soekarno Hatta',
|
||||
// 'tocity_airport': 'Juanda',
|
||||
// 'fromcity_long': 'Jakarta',
|
||||
// 'tocity_long': 'Surabaya',
|
||||
// 'departtime': '04:10',
|
||||
// 'arrivetime': '05:40',
|
||||
// 'durationhour': 1,
|
||||
// 'durationminute': 30,
|
||||
// selected_class: 'K',
|
||||
// 'classes': [
|
||||
// {
|
||||
// 'code': 'K',
|
||||
// 'availcode': 5,
|
||||
// 'fare': 781000,
|
||||
// 'currency': 'IDR',
|
||||
// 'pairid': '',
|
||||
// 'baggagekilos': 15,
|
||||
// 'cabin': 'ECONOMY',
|
||||
// },
|
||||
// {
|
||||
// 'code': 'H',
|
||||
// 'availcode': 5,
|
||||
// 'fare': 841500,
|
||||
// 'currency': 'IDR',
|
||||
// 'pairid': '',
|
||||
// 'baggagekilos': 15,
|
||||
// 'cabin': 'ECONOMY',
|
||||
// },
|
||||
// {
|
||||
// 'code': 'G',
|
||||
// 'availcode': 5,
|
||||
// 'fare': 902000,
|
||||
// 'currency': 'IDR',
|
||||
// 'pairid': '',
|
||||
// 'baggagekilos': 15,
|
||||
// 'cabin': 'ECONOMY',
|
||||
// },
|
||||
// {
|
||||
// 'code': 'F',
|
||||
// 'availcode': 5,
|
||||
// 'fare': 974600,
|
||||
// 'currency': 'IDR',
|
||||
// 'pairid': '',
|
||||
// 'baggagekilos': 15,
|
||||
// 'cabin': 'ECONOMY',
|
||||
// },
|
||||
// {
|
||||
// 'code': 'E',
|
||||
// 'availcode': 5,
|
||||
// 'fare': 1059300,
|
||||
// 'currency': 'IDR',
|
||||
// 'pairid': '',
|
||||
// 'baggagekilos': 15,
|
||||
// 'cabin': 'ECONOMY',
|
||||
// },
|
||||
// {
|
||||
// 'code': 'D',
|
||||
// 'availcode': 5,
|
||||
// 'fare': 1119800,
|
||||
// 'currency': 'IDR',
|
||||
// 'pairid': '',
|
||||
// 'baggagekilos': 15,
|
||||
// 'cabin': 'ECONOMY',
|
||||
// },
|
||||
// {
|
||||
// 'code': 'B',
|
||||
// 'availcode': 5,
|
||||
// 'fare': 1162150,
|
||||
// 'currency': 'IDR',
|
||||
// 'pairid': '',
|
||||
// 'baggagekilos': 15,
|
||||
// 'cabin': 'ECONOMY',
|
||||
// },
|
||||
// {
|
||||
// 'code': 'A',
|
||||
// 'availcode': 5,
|
||||
// 'fare': 1336500,
|
||||
// 'currency': 'IDR',
|
||||
// 'pairid': '',
|
||||
// 'baggagekilos': 15,
|
||||
// 'cabin': 'ECONOMY',
|
||||
// }],
|
||||
// }],
|
||||
// 'price_range_start': 781000,
|
||||
// 'price_range_end': 1336500,
|
||||
// };
|
||||
|
||||
@observable selectedDepartureFlight = {
|
||||
'flightno': '',
|
||||
'airline': '',
|
||||
'no_of_flight': '',
|
||||
'airlinecode': '',
|
||||
'departdate': '',
|
||||
'arrivaldate': '',
|
||||
'fromcity': '',
|
||||
'tocity': '',
|
||||
'fromcity_airport': '',
|
||||
'tocity_airport': '',
|
||||
'fromcity_long': '',
|
||||
'tocity_long': '',
|
||||
'departtime': '',
|
||||
'arrivetime': '',
|
||||
'durationhour': 0,
|
||||
'durationminute': 0,
|
||||
'flights': [],
|
||||
'price_range_start': 0,
|
||||
'price_range_end': 0,
|
||||
};
|
||||
@observable selectedReturningFlight = {
|
||||
'flightno': '',
|
||||
'airline': '',
|
||||
'no_of_flight': '',
|
||||
'airlinecode': '',
|
||||
'departdate': '',
|
||||
'arrivaldate': '',
|
||||
'fromcity': '',
|
||||
'tocity': '',
|
||||
'fromcity_airport': '',
|
||||
'tocity_airport': '',
|
||||
'fromcity_long': '',
|
||||
'tocity_long': '',
|
||||
'departtime': '',
|
||||
'arrivetime': '',
|
||||
'durationhour': 0,
|
||||
'durationminute': 0,
|
||||
'flights': [],
|
||||
'price_range_start': 0,
|
||||
'price_range_end': 0,
|
||||
};
|
||||
|
||||
@observable passengerData = [{
|
||||
key: 'adult_0',
|
||||
index: 0,
|
||||
type: 'adult',
|
||||
data: {
|
||||
'id': 'c5065ae1-c313-41c0-9c90-e44d749d56f9',
|
||||
'agent_id': '54e9a8c4-d0c9-4403-ad64-aef00a4cc889',
|
||||
'name': 'Hasta Ragil',
|
||||
'date_of_birth': '1997-12-02T17:00:00.000Z',
|
||||
'gender': 'Man',
|
||||
'address': '1969892',
|
||||
'occupation': '1969892',
|
||||
'passport_number': '123',
|
||||
'created_at': '2017-12-03T18:05:03.400Z',
|
||||
'updated_at': '2017-12-03T18:05:03.401Z',
|
||||
'deleted_at': null,
|
||||
'email': 'hasta.ragil@gmail.com',
|
||||
'birth_place': '1969892',
|
||||
'phone': '1969892',
|
||||
'handphone': '1969892',
|
||||
'martial_status': 'Married',
|
||||
'id_tax_number': '123',
|
||||
'id_type': 'Resident ID Card',
|
||||
'id_number': '322',
|
||||
'id_photo': '/api/v1/upload/e7190139-3a1e-4a76-8ba8-09935ac94614.png',
|
||||
'passport_photo': '/api/v1/upload/9d0ab0c9-53f5-4815-8913-b98a155e3ccb.png',
|
||||
'search_text': 'Hasta Ragil - 322',
|
||||
},
|
||||
}];
|
||||
|
||||
@observable picInfo = {
|
||||
'id': 'c5065ae1-c313-41c0-9c90-e44d749d56f9',
|
||||
'agent_id': '54e9a8c4-d0c9-4403-ad64-aef00a4cc889',
|
||||
'name': 'Hasta Ragil',
|
||||
'date_of_birth': '1997-12-02T17:00:00.000Z',
|
||||
'gender': 'Man',
|
||||
'address': '1969892',
|
||||
'occupation': '1969892',
|
||||
'passport_number': '123',
|
||||
'created_at': '2017-12-03T18:05:03.400Z',
|
||||
'updated_at': '2017-12-03T18:05:03.401Z',
|
||||
'deleted_at': null,
|
||||
'email': 'hasta.ragil@gmail.com',
|
||||
'birth_place': '1969892',
|
||||
'phone': '1969892',
|
||||
'handphone': '1969892',
|
||||
'martial_status': 'Married',
|
||||
'id_tax_number': '123',
|
||||
'id_type': 'Resident ID Card',
|
||||
'id_number': '322',
|
||||
'id_photo': '/api/v1/upload/e7190139-3a1e-4a76-8ba8-09935ac94614.png',
|
||||
'passport_photo': '/api/v1/upload/9d0ab0c9-53f5-4815-8913-b98a155e3ccb.png',
|
||||
'search_text': 'Hasta Ragil - 322',
|
||||
};
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
setServiceCharge(value) {
|
||||
this.serviceCharge = value;
|
||||
}
|
||||
|
||||
@action
|
||||
setPicInfo(info) {
|
||||
this.picInfo = info;
|
||||
}
|
||||
|
||||
@action
|
||||
setSelectedAirline(item) {
|
||||
this.selectedAirline = item;
|
||||
}
|
||||
|
||||
@action
|
||||
setDepartureAirport(item) {
|
||||
this.queries.fromcity = item;
|
||||
}
|
||||
|
||||
@action
|
||||
setArrivalAirport(item) {
|
||||
this.queries.tocity = item;
|
||||
}
|
||||
|
||||
@action
|
||||
setDepartureDate(item) {
|
||||
this.queries.departuredate = item;
|
||||
}
|
||||
|
||||
@action
|
||||
setArrivalDate(item) {
|
||||
this.queries.arrivaldate = item;
|
||||
}
|
||||
|
||||
@action
|
||||
setCabin(item) {
|
||||
this.queries.cabin = item;
|
||||
}
|
||||
|
||||
@action
|
||||
setAdult(item) {
|
||||
this.queries.adult = item;
|
||||
}
|
||||
|
||||
@action
|
||||
setChild(item) {
|
||||
this.queries.child = item;
|
||||
}
|
||||
|
||||
@action
|
||||
setInfant(item) {
|
||||
this.queries.infant = item;
|
||||
}
|
||||
|
||||
@action
|
||||
setSelectedClassForFlightCode(flightCode, selectedClass, departureOrReturning = 'departure') {
|
||||
if(departureOrReturning === 'departure') {
|
||||
let flightIndex = this.selectedDepartureFlight.flights.findIndex(it => it.flightno === flightCode);
|
||||
this.selectedDepartureFlight.flights[flightIndex].selected_class = selectedClass;
|
||||
this.selectedDepartureFlight.flights = this.selectedDepartureFlight.flights.map(it => it);
|
||||
} else {
|
||||
let flightIndex = this.selectedReturningFlight.flights.findIndex(it => it.flightno === flightCode);
|
||||
this.selectedReturningFlight.flights[flightIndex].selected_class = selectedClass;
|
||||
this.selectedReturningFlight.flights = this.selectedReturningFlight.flights.map(it => it);
|
||||
}
|
||||
}
|
||||
|
||||
@computed
|
||||
get totalPassenger() {
|
||||
return (+this.queries.adult) + (+this.queries.child) + (+this.queries.infant);
|
||||
}
|
||||
|
||||
@action
|
||||
getAllAirlines() {
|
||||
this.isLoading = true;
|
||||
return this.http.get(`master/airlines`).then(res => {
|
||||
this.lists = res;
|
||||
this.isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
setReturn() {
|
||||
this.isReturn = 1;
|
||||
}
|
||||
|
||||
@action
|
||||
setOneway() {
|
||||
this.isReturn = 0;
|
||||
}
|
||||
|
||||
@action
|
||||
searchAirlines() {
|
||||
let passenger = [];
|
||||
for (let x = 0; x < this.queries.adult; x++) {
|
||||
passenger.push({
|
||||
key: 'adult_' + x,
|
||||
index: x,
|
||||
type: 'adult',
|
||||
data: {}
|
||||
});
|
||||
}
|
||||
for (let x = 0; x < this.queries.child; x++) {
|
||||
passenger.push({
|
||||
key: 'child_' + x,
|
||||
index: x,
|
||||
type: 'child',
|
||||
data: {}
|
||||
});
|
||||
}
|
||||
for (let x = 0; x < this.queries.infant; x++) {
|
||||
passenger.push({
|
||||
key: 'infant_' + x,
|
||||
index: x,
|
||||
type: 'infant',
|
||||
data: {}
|
||||
});
|
||||
}
|
||||
|
||||
this.passengerData = passenger;
|
||||
// console.log(this.passengerData, 'this.passengerData');
|
||||
|
||||
|
||||
this.isLoadingSearch = true;
|
||||
let fromCity = (this.queries.fromcity) ? `fromcity=${this.queries.fromcity}` : "";
|
||||
let toCity = (this.queries.tocity) ? `&tocity=${this.queries.tocity}` : "";
|
||||
let departDate = (this.queries.departuredate) ? `&departdate=${this.queries.departuredate}` : "";
|
||||
let returnDate = (this.queries.arrivaldate) ? `&returndate=${this.queries.arrivaldate}` : "";
|
||||
let airlines = (this.selectedAirline) ? `&listairline=${this.selectedAirline}` : "";
|
||||
let adult = (this.queries.adult) ? `&adult=${this.queries.adult}` : "";
|
||||
let child = (this.queries.child) ? `&child=${this.queries.child}` : "";
|
||||
let infant = (this.queries.infant) ? `&infant=${this.queries.infant}` : "";
|
||||
let uri = `vendor/airlines/search_new?${fromCity}${toCity}${departDate}${returnDate}${airlines}${adult}${child}${infant}`;
|
||||
// console.log(uri, "uri");
|
||||
|
||||
this.queries.results = {
|
||||
departure: []
|
||||
};
|
||||
return this.http.get(uri).then(res => {
|
||||
// console.log(this.queries, res, "results");
|
||||
this.queries.results = res;
|
||||
this.priceMaxFilter = this.priceMax;
|
||||
this.selectedAirlinesFilter = this.airlineFilterList.slice();
|
||||
this.isLoadingSearch = false;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
setDepartureItem(item) {
|
||||
// console.log(JSON.stringify(item));
|
||||
item.flights = item.flights.map(flight => {
|
||||
let lowestClass = flight.classes.reduce((currentLowest, current) => {
|
||||
if(currentLowest.fare > current.fare) {
|
||||
return current;
|
||||
}
|
||||
return currentLowest;
|
||||
}, {fare: Infinity});
|
||||
|
||||
flight.selected_class = lowestClass.code;
|
||||
return flight;
|
||||
});
|
||||
|
||||
this.selectedDepartureFlight = item;
|
||||
}
|
||||
|
||||
@action
|
||||
setReturningItem(item) {
|
||||
// console.log(JSON.stringify(item));
|
||||
item.flights = item.flights.map(flight => {
|
||||
let lowestClass = flight.classes.reduce((currentLowest, current) => {
|
||||
if(currentLowest.fare > current.fare) {
|
||||
return current;
|
||||
}
|
||||
return currentLowest;
|
||||
}, {fare: Infinity});
|
||||
|
||||
flight.selected_class = lowestClass.code;
|
||||
return flight;
|
||||
});
|
||||
|
||||
this.selectedReturningFlight = item;
|
||||
}
|
||||
|
||||
@action
|
||||
setPassengerData(type, index, data) {
|
||||
let passengerIndex = this.passengerData.findIndex(it => it.key === `${type}_${index}`);
|
||||
if(passengerIndex === -1) {
|
||||
this.passengerData.push({
|
||||
type: type,
|
||||
key: type + '_' + index,
|
||||
index: index,
|
||||
data: data
|
||||
});
|
||||
} else {
|
||||
this.passengerData[passengerIndex].data = data;
|
||||
}
|
||||
}
|
||||
|
||||
@computed
|
||||
get totalForAdult() {
|
||||
let totalPerAdult = this.selectedDepartureFlight.flights.map(flight => {
|
||||
if(!flight.selected_class) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return flight.classes.find(classes => classes.code === flight.selected_class).fare;
|
||||
}).reduce((total, curr) => total + curr, 0);
|
||||
|
||||
let totalPerAdultReturning = this.selectedReturningFlight.flights.map(flight => {
|
||||
if(!flight.selected_class) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return flight.classes.find(classes => classes.code === flight.selected_class).fare;
|
||||
}).reduce((total, curr) => total + curr, 0);
|
||||
return this.queries.adult * (totalPerAdult + totalPerAdultReturning);
|
||||
}
|
||||
@computed
|
||||
get totalForChild() {
|
||||
let totalPerAdult = this.selectedDepartureFlight.flights.map(flight => {
|
||||
if(!flight.selected_class) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return flight.classes.find(classes => classes.code === flight.selected_class).fare;
|
||||
}).reduce((total, curr) => total + curr, 0);
|
||||
|
||||
let totalPerAdultReturning = this.selectedReturningFlight.flights.map(flight => {
|
||||
if(!flight.selected_class) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return flight.classes.find(classes => classes.code === flight.selected_class).fare;
|
||||
}).reduce((total, curr) => total + curr, 0);
|
||||
return this.queries.child * (totalPerAdult + totalPerAdultReturning);
|
||||
}
|
||||
@computed
|
||||
get totalForInfant() {
|
||||
let totalPerAdult = this.selectedDepartureFlight.flights.map(flight => {
|
||||
if(!flight.selected_class) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return flight.classes.find(classes => classes.code === flight.selected_class).fare;
|
||||
}).reduce((total, curr) => total + curr, 0);
|
||||
|
||||
let totalPerAdultReturning = this.selectedReturningFlight.flights.map(flight => {
|
||||
if(!flight.selected_class) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return flight.classes.find(classes => classes.code === flight.selected_class).fare;
|
||||
}).reduce((total, curr) => total + curr, 0);
|
||||
return this.queries.infant * (totalPerAdult + totalPerAdultReturning);
|
||||
}
|
||||
|
||||
@computed
|
||||
get totalForAll() {
|
||||
return this.totalForChild + this.totalForAdult + this.totalForInfant;
|
||||
}
|
||||
|
||||
@computed
|
||||
get totalForAllWithServiceCharge() {
|
||||
return this.totalForAll + this.serviceCharge;
|
||||
}
|
||||
|
||||
@action
|
||||
book() {
|
||||
let departureFlights = {
|
||||
airlinecode: this.selectedDepartureFlight.airlinecode,
|
||||
tripdate: this.selectedDepartureFlight.tripdate,
|
||||
departdate: this.selectedDepartureFlight.departdate,
|
||||
flights: this.selectedDepartureFlight.flights.map(flight => {
|
||||
return ({
|
||||
flightno: flight.flightno,
|
||||
classcode: flight.selected_class,
|
||||
fromcity: flight.fromcity,
|
||||
tocity: flight.tocity,
|
||||
departdate: flight.departdate,
|
||||
departtime: flight.departtime,
|
||||
arrivetime: flight.arrivetime
|
||||
})
|
||||
})
|
||||
};
|
||||
|
||||
let returningFlight = {
|
||||
};
|
||||
|
||||
if(this.isReturn) {
|
||||
returningFlight = {
|
||||
airlinecode: this.selectedReturningFlight.airlinecode,
|
||||
tripdate: this.selectedReturningFlight.tripdate,
|
||||
departdate: this.selectedReturningFlight.departdate,
|
||||
flights: this.selectedReturningFlight.flights.map(flight => {
|
||||
return ({
|
||||
flightno: flight.flightno,
|
||||
classcode: flight.selected_class,
|
||||
fromcity: flight.fromcity,
|
||||
tocity: flight.tocity,
|
||||
departdate: flight.departdate,
|
||||
departtime: flight.departtime,
|
||||
arrivetime: flight.arrivetime
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
let paxes = this.passengerData.map(passenger => {
|
||||
let splitted = passenger.data.name.split(' ');
|
||||
let firstname = '';
|
||||
let lastname = '';
|
||||
if(splitted.length <= 1) {
|
||||
firstname = splitted[0];
|
||||
lastname = splitted[1];
|
||||
} else {
|
||||
lastname = splitted.pop();
|
||||
firstname = splitted.join(' ');
|
||||
}
|
||||
return {
|
||||
title: 'MR',
|
||||
customer_id: passenger,
|
||||
firstname: firstname,
|
||||
lastname: lastname,
|
||||
type: passenger.type.toUpperCase(),
|
||||
id_number: passenger.data.id_number
|
||||
}
|
||||
});
|
||||
|
||||
let pic = this.picInfo;
|
||||
|
||||
this.context.globalUI.openLoading();
|
||||
|
||||
let postData = {
|
||||
departure: departureFlights,
|
||||
pax: paxes,
|
||||
pic,
|
||||
request_data: {
|
||||
selectedDepartureFlight: this.selectedDepartureFlight,
|
||||
selectedReturningFlight: this.selectedReturningFlight
|
||||
}
|
||||
};
|
||||
|
||||
if(this.isReturn){
|
||||
postData.returning = returningFlight;
|
||||
}
|
||||
|
||||
return this.http.post('vendor/airlines/book', postData).then((data) => {
|
||||
this.context.globalUI.closeLoading();
|
||||
return data;
|
||||
});
|
||||
}
|
||||
}
|
||||
53
src/common/stores/airports.js
Normal file
53
src/common/stores/airports.js
Normal file
@@ -0,0 +1,53 @@
|
||||
import {observable, action, computed} from 'mobx';
|
||||
|
||||
export default class Airports {
|
||||
|
||||
@observable lists = [];
|
||||
@observable searchResults = [];
|
||||
@observable isLoading = false;
|
||||
@observable selectedDepartureAirport = "";
|
||||
@observable selectedArrivalAirport = "";
|
||||
|
||||
@computed
|
||||
get listForSearch() {
|
||||
return this.lists;
|
||||
}
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
setSelectedAirport(item, type) {
|
||||
console.log(item, type)
|
||||
if (type == 'departure') {
|
||||
this.selectedDepartureAirport = item;
|
||||
} else {
|
||||
this.selectedArrivalAirport = item;
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
getAllAirports() {
|
||||
this.isLoading = true;
|
||||
return this.http.get(`master/airports`).then(res => {
|
||||
this.lists = res;
|
||||
this.isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
searchAirports(name) {
|
||||
this.isLoading = true;
|
||||
return this.http.get(`master/airports?search=${name}`)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.lists = res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
}
|
||||
29
src/common/stores/app.js
Normal file
29
src/common/stores/app.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class AppStore {
|
||||
|
||||
@observable type = 'agent';
|
||||
@observable isLoading = false;
|
||||
|
||||
constructor(context) {
|
||||
this.context = context;
|
||||
this.http = context.http;
|
||||
}
|
||||
|
||||
@action
|
||||
getAppType() {
|
||||
this.isLoading = true;
|
||||
|
||||
return this.http.get("app/type")
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.type = res.type;
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
167
src/common/stores/appstate.js
Normal file
167
src/common/stores/appstate.js
Normal file
@@ -0,0 +1,167 @@
|
||||
import {observable, action, autorun, computed} from 'mobx';
|
||||
import {Http} from "../util/http";
|
||||
import {Authentication} from "./authenticaton";
|
||||
|
||||
import GlobalUI from './global_ui';
|
||||
import Agent from './agent';
|
||||
import Employee from './employee';
|
||||
import Reward from './reward';
|
||||
import User from './user';
|
||||
import PackageSchedules from './package_schedules';
|
||||
import PackagePaymentMethod from './package_payment_method';
|
||||
import Notification from './notification';
|
||||
import Dashboard from './dashboard';
|
||||
import Bank from './bank';
|
||||
import PaymentMethod from './payment_method.js';
|
||||
import Currency from './currency.js';
|
||||
import PackagesService from './package_service.js';
|
||||
import Packages from './packages.js';
|
||||
import CustomerStore from "./customer";
|
||||
import OrderStore from "./order";
|
||||
import TransportationModule from './transportationStore';
|
||||
import DepositStore from "./deposit";
|
||||
import WithdrawStore from "./withdraw";
|
||||
import Task from './task';
|
||||
import Transaction from './transaction';
|
||||
import {Firebase} from './firebase';
|
||||
import AirlinesDomestic from "./airlines_domestic";
|
||||
import Airports from "./airports";
|
||||
import Categories from './categories';
|
||||
import Recipes from './recipes';
|
||||
import Help from './help';
|
||||
import ContentManager from './content_manager';
|
||||
import Setting from './setting';
|
||||
import Roles from './roles';
|
||||
import Commission from './commission';
|
||||
import AppStore from './app';
|
||||
import Airlines from './airlines';
|
||||
import UserBanks from './user_banks';
|
||||
import Profile from './profile';
|
||||
import Stores from './stores';
|
||||
import StoreList from './store_list';
|
||||
import UserAddress from './user_address';
|
||||
import { ItemStore } from './item';
|
||||
import { MyStoreStore } from './my_store';
|
||||
import { MyStoreItemStore } from './my_store_item';
|
||||
import { ShippingMethodStore } from './shipping_method';
|
||||
import {MyStoreShippingMethodStore} from "./my_store_shipping_method";
|
||||
import {Messages} from "./message";
|
||||
import {FeaturedItem} from './featured_item';
|
||||
import {FeaturedStore} from './featured_store';
|
||||
import EntitiesStore from "./entities";
|
||||
import {CustomMenus} from './custom_menus';
|
||||
import {FeaturedCategory} from "./featured_category";
|
||||
import {FeaturedBanner} from "./featured_banner";
|
||||
import {Tags} from './tags';
|
||||
import Surf from './surf';
|
||||
import Odoo from './odoo';
|
||||
|
||||
|
||||
export default class AppState {
|
||||
http = new Http(this.token);
|
||||
app = new AppStore(this);
|
||||
auth = new Authentication(this);
|
||||
bank = new Bank(this);
|
||||
reward = new Reward(this);
|
||||
agent = new Agent(this);
|
||||
airlinesDomestic = new AirlinesDomestic(this);
|
||||
airports = new Airports(this);
|
||||
packageSchedules = new PackageSchedules(this);
|
||||
packagePaymentMethod = new PackagePaymentMethod(this);
|
||||
transportationStore = new TransportationModule(this);
|
||||
currencyStore = new Currency(this);
|
||||
employee = new Employee(this);
|
||||
commission = new Commission(this);
|
||||
airlines = new Airlines(this);
|
||||
featured_item = new FeaturedItem(this);
|
||||
featured_banner = new FeaturedBanner(this);
|
||||
custom_menu = new CustomMenus(this);
|
||||
featured_store = new FeaturedStore(this);
|
||||
featured_category = new FeaturedCategory(this);
|
||||
dashboard = new Dashboard(this);
|
||||
paymentMethod = new PaymentMethod(this);
|
||||
packages = new Packages(this);
|
||||
packageServiceStore = new PackagesService(this);
|
||||
user = new User(this);
|
||||
roles = new Roles(this);
|
||||
globalUI = new GlobalUI();
|
||||
customer = new CustomerStore(this);
|
||||
profile = new Profile(this);
|
||||
category = new Categories(this);
|
||||
recipes = new Recipes(this);
|
||||
help = new Help(this);
|
||||
contentManager = new ContentManager(this);
|
||||
order = new OrderStore(this);
|
||||
deposit = new DepositStore(this);
|
||||
withdraw = new WithdrawStore(this);
|
||||
task = new Task(this);
|
||||
transaction = new Transaction(this);
|
||||
setting = new Setting(this);
|
||||
firebase = new Firebase(this);
|
||||
userBanks = new UserBanks(this);
|
||||
stores = new Stores(this);
|
||||
storeList = new StoreList(this);
|
||||
userAddress = new UserAddress(this);
|
||||
item = new ItemStore(this);
|
||||
myStore = new MyStoreStore(this);
|
||||
myStoreItem = new MyStoreItemStore(this);
|
||||
myStoreShippingMethod = new MyStoreShippingMethodStore(this);
|
||||
shippingMethod = new ShippingMethodStore(this);
|
||||
message = new Messages(this);
|
||||
odoo = new Odoo(this);
|
||||
entities = new EntitiesStore(this);
|
||||
notification = new Notification(this);
|
||||
tags = new Tags(this);
|
||||
surf_turf = new Surf(this);
|
||||
|
||||
|
||||
constructor(initialState) {
|
||||
this.token = initialState.token;
|
||||
this.http.token = this.token;
|
||||
if (typeof window !== 'undefined') {
|
||||
if (!this.token) {
|
||||
localStorage.removeItem('id_token');
|
||||
} else {
|
||||
localStorage.setItem('id_token', this.token);
|
||||
this.user.getUserGeolocation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
setLogin(status) {
|
||||
this.isLoggedIn = status;
|
||||
}
|
||||
|
||||
@action
|
||||
setToken(token) {
|
||||
this.token = token;
|
||||
this.http.token = token;
|
||||
localStorage.setItem('id_token', token);
|
||||
}
|
||||
|
||||
@action
|
||||
setUserData(data) {
|
||||
// this.userData = data;
|
||||
}
|
||||
|
||||
@action
|
||||
addItem(item) {
|
||||
this.items.push(item);
|
||||
}
|
||||
|
||||
@computed get userData() {
|
||||
const token = localStorage.getItem('id_token');
|
||||
if (!token) {
|
||||
return {
|
||||
user_id: '',
|
||||
role: ''
|
||||
}
|
||||
}
|
||||
|
||||
let tokenData = JSON.parse(atob(token.split('.')[1]));
|
||||
|
||||
return tokenData;
|
||||
}
|
||||
}
|
||||
|
||||
260
src/common/stores/authenticaton.js
Normal file
260
src/common/stores/authenticaton.js
Normal file
@@ -0,0 +1,260 @@
|
||||
import { observable, action, computed} from 'mobx';
|
||||
import * as fetch from 'isomorphic-fetch';
|
||||
|
||||
export class Authentication {
|
||||
|
||||
@observable isLoading = false;
|
||||
@observable isRegistering = false;
|
||||
@observable isLoggingIn = false;
|
||||
@observable isInviting = false;
|
||||
@observable removingUser = false;
|
||||
|
||||
@observable userWallet = {};
|
||||
@observable userProfile = {
|
||||
email : '',
|
||||
role : '',
|
||||
username : '',
|
||||
status :'',
|
||||
agent : {
|
||||
name : '',
|
||||
phone_number : '',
|
||||
email : '',
|
||||
address : '',
|
||||
id: '',
|
||||
created_at: '',
|
||||
user_id:'',
|
||||
id_tax_number : '',
|
||||
id_type : '',
|
||||
id_number : '',
|
||||
id_photo : '',
|
||||
passport_number: '',
|
||||
passport_photo : '',
|
||||
error_email : '',
|
||||
},
|
||||
// role_data: {
|
||||
// airline_blacklisteds: [],
|
||||
// airline_settings: []
|
||||
// }
|
||||
};
|
||||
|
||||
constructor(context) {
|
||||
this.context = context;
|
||||
this.http = context.http;
|
||||
}
|
||||
|
||||
@action
|
||||
login(data) {
|
||||
// this.context.setToken('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJkaWdpc3VpdGVzIiwiZXhwIjoxNDg1ODcyMTYzLCJzdWIiOiJjcmVkZW50aWFsIiwidXNlciI6Imhhc3RhLnJhZ2lsQGdtYWlsLmNvbSIsInJvbGVzIjpbIlRyYXZlbCBBZ2VudCJdfQ.u3MEelOz3FWyP78QLTvTh4n-ueH1G4R0GWcXrjXUPMY');
|
||||
this.isLoggingIn = true;
|
||||
|
||||
return this.http.post("authentication/login", data)
|
||||
.then(res => {
|
||||
this.isLoggingIn = false;
|
||||
this.context.setToken(res.token);
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoggingIn = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
forgetPassword(email) {
|
||||
return this.http.post("authentication/forgot_password", email)
|
||||
.then(res => {
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
logout() {
|
||||
return this.http.post("authentication/logout", {token : localStorage.getItem('tokens')})
|
||||
.then(res => {
|
||||
this.context.setToken("");
|
||||
this.context.setUserData({});
|
||||
|
||||
localStorage.removeItem('id_token');
|
||||
localStorage.removeItem('user.name');
|
||||
localStorage.removeItem('user.profile_image');
|
||||
localStorage.setItem('isLoggingIn', false);
|
||||
let cookies = document.cookie.split(";");
|
||||
for (let i = 0; i < cookies.length; i++) {
|
||||
this.eraseCookie(cookies[i].split("=")[0]);
|
||||
}
|
||||
|
||||
if (window && window.Tawk_API && window.Tawk_API.isChatHidden()) {
|
||||
window.Tawk_API.hideWidget()
|
||||
}
|
||||
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
throw err;
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@action
|
||||
register(data) {
|
||||
this.isRegistering = true;
|
||||
return this.http.post("register", data)
|
||||
.then(res => {
|
||||
this.isRegistering = false;
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isRegistering = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
createCookie(name,value,days) {
|
||||
let expires
|
||||
if (days) {
|
||||
let date = new Date();
|
||||
date.setTime(date.getTime()+(days*24*60*60*1000));
|
||||
let expires = "; expires="+date.toGMTString();
|
||||
}
|
||||
else {
|
||||
let expires = "";
|
||||
}
|
||||
document.cookie = name+"="+value+expires+"; path=/";
|
||||
}
|
||||
|
||||
@action
|
||||
changePassword(data){
|
||||
return this.http.post(`authentication/reset_password`,{password : data.password,old_password : data.old_password,id : this.userProfile.id})
|
||||
.then(res=>{
|
||||
return res;
|
||||
})
|
||||
}
|
||||
|
||||
eraseCookie(name) {
|
||||
this.createCookie(name,"",-1);
|
||||
}
|
||||
|
||||
invite(email) {
|
||||
this.isInviting = true;
|
||||
return this.http.post(`invite_user`, {email})
|
||||
.then(res => {
|
||||
this.isInviting = false;
|
||||
return res;
|
||||
})
|
||||
}
|
||||
|
||||
removeUserFromEntity(id) {
|
||||
this.removingUser = true;
|
||||
return this.http.post('remove_user_from_entity', {id})
|
||||
.then(res => {
|
||||
this.removingUser = false;
|
||||
|
||||
return res;
|
||||
})
|
||||
}
|
||||
|
||||
inviteUserToEntity(email, roleId, entityId) {
|
||||
this.isInviting = true;
|
||||
return this.http.post(`invite_user_to_entity_or_project`, {email, role_id: roleId, entity_id: entityId})
|
||||
.then(res => {
|
||||
this.isInviting = false;
|
||||
return res;
|
||||
})
|
||||
}
|
||||
|
||||
inviteUserToProject(email, roleId, entityId, projectId) {
|
||||
this.isInviting = true;
|
||||
return this.http.post(`invite_user_to_entity_or_project`, {email, role_id: roleId, entity_id: entityId, project_id: projectId})
|
||||
.then(res => {
|
||||
this.isInviting = false;
|
||||
return res;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
acceptInvite(token, password) {
|
||||
return this.http.post('invite_user_accept', {token, password});
|
||||
}
|
||||
|
||||
@action
|
||||
getProfile() {
|
||||
// console.log('get profile nih');
|
||||
this.isLoading = true;
|
||||
return this.http.get('profile')
|
||||
.then(res => {
|
||||
this.userProfile.username = res.user.username;
|
||||
this.userProfile.role = res.user.type.name;
|
||||
this.isLoading = false;
|
||||
// this.userProfile = res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
updateProfile() {
|
||||
this.isLoading = true;
|
||||
return this.http.put('profile', this.userProfile.agent)
|
||||
.then(res => this.getProfile())
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getWallet() {
|
||||
this.isLoading = true;
|
||||
return this.http.get("wallet")
|
||||
.then(res => {
|
||||
this.userWallet = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
checkEmailAvaliability(data){
|
||||
return this.http.get(`users?email=${data}`)
|
||||
.then(res=>{
|
||||
if(res.length == 0){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
checkUsernameAvaliability(data){
|
||||
return this.http.get(`users?username=${data}`)
|
||||
.then(res=>{
|
||||
if(res.length == 0){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@computed
|
||||
get isLoggedIn() {
|
||||
return !!(this.context.token);
|
||||
}
|
||||
|
||||
toJson() {
|
||||
return {
|
||||
items: this.items
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
66
src/common/stores/bank.js
Normal file
66
src/common/stores/bank.js
Normal file
@@ -0,0 +1,66 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class Bank {
|
||||
|
||||
@observable list = [];
|
||||
@observable listAdmin = [];
|
||||
@observable isLoading = false;
|
||||
@observable data = {
|
||||
name : '',
|
||||
currency_id: '',
|
||||
account_number : '',
|
||||
on_behalf : '',
|
||||
id: '',
|
||||
};
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
@action
|
||||
getAll(){
|
||||
this.isLoading = true;
|
||||
return this.http.get(`user_banks?user_id=hai`).then(res => {
|
||||
this.isLoading = false;
|
||||
this.list = res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
getAdminBank(){
|
||||
this.isLoading = true;
|
||||
return this.http.get(`dsm_bank`).then(res => {
|
||||
this.isLoading = false;
|
||||
this.listAdmin = res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
getByUserID(id){
|
||||
this.isLoading = true;
|
||||
return this.http.get(`user_banks?user_id=${id}`).then(res => {
|
||||
this.isLoading = false;
|
||||
this.list = res;
|
||||
});
|
||||
}
|
||||
|
||||
@computed
|
||||
get isEmpty() {
|
||||
if(this.list.length > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@action
|
||||
post(){
|
||||
this.isLoading = true;
|
||||
this.http.post('user_banks', this.data).then(res => {
|
||||
this.isLoading = false;
|
||||
this.getByUserID();
|
||||
return res;
|
||||
})
|
||||
}
|
||||
}
|
||||
191
src/common/stores/base_store.js
Normal file
191
src/common/stores/base_store.js
Normal file
@@ -0,0 +1,191 @@
|
||||
import {
|
||||
action,
|
||||
observable,
|
||||
computed
|
||||
} from 'mobx';
|
||||
import { queryStringBuilder } from '../util/index';
|
||||
|
||||
export class BaseStore {
|
||||
|
||||
url = '';
|
||||
mode = 'multi';
|
||||
|
||||
@observable data = this.mode === 'multi' ? [] : {};
|
||||
// @observable data = [] ;
|
||||
@observable selectedId = '';
|
||||
@observable selectedData = {};
|
||||
|
||||
@observable isSearching = false;
|
||||
@observable dataFiltered = [];
|
||||
@observable searchResult = [];
|
||||
@observable isLoading = false;
|
||||
|
||||
@observable currentPage = 1;
|
||||
@observable maxPage = 1;
|
||||
@observable dataPerPage = 30;
|
||||
|
||||
@observable reqQuery = {};
|
||||
constructor(context) {
|
||||
this.context = context;
|
||||
this.http = context.http;
|
||||
}
|
||||
|
||||
filterData = (query) => {
|
||||
return this.data.filter((data) => data.id.indexOf(query) > -1 || data.name.toLowerCase().indexOf(query.toLowerCase()) > -1 );
|
||||
}
|
||||
|
||||
|
||||
@action
|
||||
search(text){
|
||||
this.dataFiltered = this.filterData(text);
|
||||
console.log("dataFiltered" ,this.filterData(text));
|
||||
}
|
||||
|
||||
@action
|
||||
nextPage(reload=false) {
|
||||
if(this.currentPage == this.maxPage){
|
||||
return;
|
||||
}
|
||||
this.currentPage++;
|
||||
if (reload) {
|
||||
return this.getAll(true);
|
||||
}
|
||||
|
||||
return Promise.resolve(true);
|
||||
};
|
||||
|
||||
@action
|
||||
prevPage(reload=false) {
|
||||
if(this.currentPage == 1){
|
||||
return;
|
||||
}
|
||||
this.currentPage--;
|
||||
|
||||
if (reload) {
|
||||
return this.getAll();
|
||||
}
|
||||
|
||||
return Promise.resolve(true);
|
||||
};
|
||||
|
||||
@action
|
||||
async getAll(append=false) {
|
||||
this.isLoading = true;
|
||||
|
||||
const q = queryStringBuilder(Object.assign({
|
||||
page: this.currentPage,
|
||||
per_page: this.dataPerPage,
|
||||
},this.reqQuery));
|
||||
|
||||
const res = await this.http.get(`${this.url}?${q}`)
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
});
|
||||
|
||||
this.maxPage = Math.ceil(res.max/this.dataPerPage);
|
||||
|
||||
if (!append) {
|
||||
if(!res.data){
|
||||
this.data = res;
|
||||
}
|
||||
else{
|
||||
this.data = res.data;
|
||||
}
|
||||
} else {
|
||||
if(!res.data){
|
||||
this.data.replace(this.data.concat(res));
|
||||
}
|
||||
else{
|
||||
this.data.replace(this.data.concat(res.data));
|
||||
}
|
||||
}
|
||||
|
||||
this.selectedData = {};
|
||||
this.selectedId = '';
|
||||
|
||||
this.isLoading = false;
|
||||
return res;
|
||||
}
|
||||
|
||||
@action
|
||||
async getDetail(id) {
|
||||
this.isLoading = true;
|
||||
const res = await this.http.get(`${this.url}/${id}`)
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
});
|
||||
|
||||
this.isLoading = false;
|
||||
this.setSelectedData(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
@action
|
||||
setSelectedData(data) {
|
||||
this.selectedData = data;
|
||||
this.selectedId = data.id;
|
||||
}
|
||||
|
||||
@action
|
||||
create(data) {
|
||||
this.isLoading = true;
|
||||
return this.http.post(this.url, data)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getAll();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
update(id, data) {
|
||||
this.isLoading = true;
|
||||
return this.http.put(this.url + "/" + id, data)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getAll();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
delete(id) {
|
||||
this.isLoading = true;
|
||||
return this.http.delete(this.url + "/" + id)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
setRequestQuery(q){
|
||||
//q is an object
|
||||
this.reqQuery = q;
|
||||
}
|
||||
|
||||
@action
|
||||
reset(num=false){
|
||||
this.currentPage = 1;
|
||||
this.reqQuery = {};
|
||||
}
|
||||
|
||||
@computed
|
||||
get isEmpty(){
|
||||
return this.data.length === 0;
|
||||
}
|
||||
}
|
||||
98
src/common/stores/categories.js
Normal file
98
src/common/stores/categories.js
Normal file
@@ -0,0 +1,98 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class Categories {
|
||||
|
||||
@observable categoryList = [];
|
||||
@observable selectedCategory = '';
|
||||
@observable categoryListLoading = false;
|
||||
@observable detailCategoryLoading = false;
|
||||
@observable postCategoryLoading = false;
|
||||
@observable categoryId = '';
|
||||
@observable delCategoryLoading = false;
|
||||
@observable putCategoryLoading = false;
|
||||
@observable isSearching = false;
|
||||
@observable dataFiltered = [];
|
||||
@observable categoryData = {
|
||||
id: '',
|
||||
name: ''
|
||||
};
|
||||
|
||||
@observable currentPage = 1;
|
||||
@observable maxPage;
|
||||
@observable dataPerPage = 30;
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
getCategoryList(){
|
||||
this.categoryListLoading = true;
|
||||
return this.http.get(`categories`).then(res => {
|
||||
this.categoryList = res.data;
|
||||
this.categoryListLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
getCategoryDetail(id){
|
||||
this.categoryId = id;
|
||||
this.detailCategoryLoading = true;
|
||||
return this.http.get(`categories/${id}`).then(detail => {
|
||||
this.categoryData = detail[0];
|
||||
this.detailCategoryLoading = false;
|
||||
})
|
||||
}
|
||||
|
||||
@computed
|
||||
get isCategoryEmpty() {
|
||||
if(this.categoryList.length > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@action
|
||||
postCategory(data){
|
||||
this.postCategoryLoading = true;
|
||||
return this.http.post('categories', data).then(res => {
|
||||
this.postCategoryLoading = false;
|
||||
this.getCategoryList();
|
||||
return res;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
putCategory(id,data){
|
||||
delete data.total_items;
|
||||
this.putCategoryLoading = true;
|
||||
return this.http.put(`categories/${id}`, data).then(res => {
|
||||
this.getCategoryList();
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
deleteCategory(id){
|
||||
this.categoryId = id;
|
||||
this.delCategoryLoading = true;
|
||||
return this.http.delete(`categories/${id}`).then(res => {
|
||||
this.delCategoryLoading = false;
|
||||
// console.log(detail[0]);
|
||||
this.getCategoryList();
|
||||
return res;
|
||||
})
|
||||
}
|
||||
|
||||
filterData = (query) => {
|
||||
return this.categoryList.filter((data) => data.name.toLowerCase().indexOf(query) > -1);
|
||||
}
|
||||
|
||||
@action
|
||||
search(text) {
|
||||
console.log(this.categoryList);
|
||||
this.dataFiltered = this.filterData(text);
|
||||
}
|
||||
}
|
||||
80
src/common/stores/commission.js
Normal file
80
src/common/stores/commission.js
Normal file
@@ -0,0 +1,80 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class Commission {
|
||||
@observable commissions = [];
|
||||
@observable isLoading = false;
|
||||
@observable commissionId = '';
|
||||
@observable selectedData = {};
|
||||
@observable commissionData = {
|
||||
id : '',
|
||||
airlines_id : '',
|
||||
value : '',
|
||||
from : '',
|
||||
to: '',
|
||||
created_at: '',
|
||||
modified_at:'',
|
||||
deleted_at : '',
|
||||
};
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
getAll() {
|
||||
this.isLoading = true;
|
||||
return this.http.get("commision")
|
||||
.then(res => {
|
||||
res.map(item => {
|
||||
if(item.airlines_id != null && item.to === null){
|
||||
this.commissions.push(item)
|
||||
}
|
||||
})
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
delete(id){
|
||||
this.http.put(`commision/${id}`, {}).then(res => {
|
||||
return res;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
add(data){
|
||||
return this.http.post(`commision/role`, data).then(res => {})
|
||||
}
|
||||
|
||||
@action
|
||||
getById(id){
|
||||
this.taskId = id;
|
||||
this.isLoading = true;
|
||||
return this.http.get(`commision/${id}`).then(detail => {
|
||||
this.commissionData = detail;
|
||||
this.isLoading = false;
|
||||
})
|
||||
}
|
||||
|
||||
@computed
|
||||
get isEmpty(){
|
||||
if(this.commissions.length > 0){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@action
|
||||
saveCommission(){
|
||||
this.isLoading = true;
|
||||
return this.http.post(`commision`, this.commissions).then(res => {
|
||||
this.isLoading = false;
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
211
src/common/stores/content_manager.js
Normal file
211
src/common/stores/content_manager.js
Normal file
@@ -0,0 +1,211 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
import {TreeSelect} from "antd";
|
||||
import React from "react";
|
||||
|
||||
export default class ContentManager {
|
||||
|
||||
@observable list = [];
|
||||
@observable listItems = [];
|
||||
@observable listTags = [];
|
||||
@observable listTypes = [];
|
||||
@observable selected = {};
|
||||
@observable istLoading = false;
|
||||
@observable isSearching = false;
|
||||
@observable filtered = [];
|
||||
// @observable itemSearch = [{value : 'cou',title:'cooo',selectable: false,children :[{value :'yeyeye',title :'KOKOKO'}]},
|
||||
// {value : 'skemberlu',title:'anehya',selectable: false,children :[{value :'ngerti',title :'nice'}]}];
|
||||
@observable itemSearch = [];
|
||||
@observable selectedItems = [];
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
addSelectedItem(id){
|
||||
// this.itemSearch = this.itemSearch.filter(it=>it.id === id);
|
||||
// this.selectedItems = this.selectedItems.concat(this.itemSearch);
|
||||
this.selectedItems.push(this.itemSearch.find(it=>it.id === id));
|
||||
this.itemSearch = this.selectedItems;
|
||||
console.log(this.selectedItems,'==== selected');
|
||||
}
|
||||
|
||||
@action
|
||||
clearItems(){
|
||||
this.selectedItems = [];
|
||||
this.itemSearch = [];
|
||||
}
|
||||
|
||||
|
||||
@action
|
||||
itemChange(ids){
|
||||
console.log('item changed',ids,this.selectedItems.length);
|
||||
if(this.selectedItems.length === ids.length){
|
||||
return
|
||||
}
|
||||
else{
|
||||
this.selectedItems = this.selectedItems.filter(it=>ids.findIndex(id=>id == it.id) > -1);
|
||||
this.itemSearch = this.selectedItems;
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
loadItems(ids){
|
||||
let query = ids.reduce((acc,value)=>{
|
||||
acc = acc+'item_ids='+value+"&";
|
||||
return acc;
|
||||
},'');
|
||||
this.isLoading = true;
|
||||
|
||||
return this.http.get("items?"+query)
|
||||
.then(res => {
|
||||
this.itemSearch = res.data;
|
||||
this.selectedItems = res.data;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getItem(search){
|
||||
if(this.selectedItems.length == 0){
|
||||
this.itemSearch = [];
|
||||
}
|
||||
|
||||
if(search == ''){
|
||||
this.itemSearch = this.selectedItems.concat([]);
|
||||
return;
|
||||
}
|
||||
|
||||
this.isLoading = true;
|
||||
console.log('searching');
|
||||
return this.http.get("items?search="+search)
|
||||
.then(res => {
|
||||
this.itemSearch = this.selectedItems.concat(res.data);
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getList(){
|
||||
this.isLoading = true;
|
||||
return this.http.get("posts")
|
||||
.then(res => {
|
||||
this.list = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getTags(){
|
||||
this.isLoading = true;
|
||||
return this.http.get("tags")
|
||||
.then(res => {
|
||||
this.listTags = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getTypes(){
|
||||
this.isLoading = true;
|
||||
return this.http.get("posts")
|
||||
.then(res => {
|
||||
this.listTypes = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getDetail(id){
|
||||
this.isLoading = true;
|
||||
return this.http.get(`posts/${id}`)
|
||||
.then(res => {
|
||||
console.log(res,'ini res store')
|
||||
this.selected = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
post(data){
|
||||
this.isLoading = true;
|
||||
return this.http.post("posts", data)
|
||||
.then(res => {
|
||||
console.log('rest men',res);
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err,'err men')
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
put(id,data){
|
||||
this.isLoading = true;
|
||||
return this.http.put(`posts/${id}`, data)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
delete(id){
|
||||
this.isLoading = true;
|
||||
return this.http.delete(`posts/${id}`)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
filterItems = (query) => {
|
||||
return this.list.filter((el) =>
|
||||
el.title.toLowerCase().indexOf(query.toLowerCase()) > -1
|
||||
);
|
||||
}
|
||||
|
||||
@action
|
||||
search(text){
|
||||
this.filtered = this.filterItems(text);
|
||||
}
|
||||
}
|
||||
92
src/common/stores/currency.js
Normal file
92
src/common/stores/currency.js
Normal file
@@ -0,0 +1,92 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class Currency {
|
||||
@observable currencyList = [];
|
||||
@observable currencyId = "";
|
||||
@observable currencyData = {
|
||||
id : '',
|
||||
name : '',
|
||||
kurs: '',
|
||||
is_primary : ''
|
||||
};
|
||||
|
||||
@observable isLoading = false;
|
||||
@observable isPrimarySet = false;
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
getAll(){
|
||||
this.isLoading = true;
|
||||
return this.http.get(`currencies`).then(res => {
|
||||
this.currencyList = res;
|
||||
// console.log(this.currencyList);
|
||||
this.isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@action
|
||||
getById(id){
|
||||
this.currencyId = id;
|
||||
this.isLoading = true;
|
||||
return this.http.get(`currencies?id=${id}`).then(detail => {
|
||||
this.currencyData = detail[0];
|
||||
this.isLoading = false;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getPrimary(){
|
||||
this.http.get(`currencies?is_primary=true`).then(res => {
|
||||
if(res.length == 0){
|
||||
this.isPrimarySet = false;
|
||||
}
|
||||
else{
|
||||
this.isPrimarySet = true;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@computed
|
||||
get isEmpty(){
|
||||
if(this.currencyList.length > 0){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@action
|
||||
post(){
|
||||
this.isLoading = true;
|
||||
this.http.post(`currencies`, this.currencyData).then(res => {
|
||||
this.isLoading = false;
|
||||
this.getAll();
|
||||
return res;
|
||||
});
|
||||
console.log(this.currencyData);
|
||||
}
|
||||
|
||||
@action
|
||||
put(id){
|
||||
this.isLoading = true;
|
||||
this.http.put(`currencies/${id}`, this.currencyData).then(res => {
|
||||
this.isLoading = false;
|
||||
this.getAll();
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
del(id){
|
||||
this.isLoading = true;
|
||||
this.http.delete(`currencies/${id}`).then(res => {
|
||||
this.isLoading = false;
|
||||
this.getAll();
|
||||
return res;
|
||||
})
|
||||
}
|
||||
}
|
||||
17
src/common/stores/custom_menus.js
Normal file
17
src/common/stores/custom_menus.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { BaseStore } from "./base_store";
|
||||
import {observable, action,computed} from "mobx"
|
||||
|
||||
export class CustomMenus extends BaseStore {
|
||||
@observable formData = {
|
||||
id: '',
|
||||
name : '',
|
||||
url : ''
|
||||
};
|
||||
|
||||
constructor(context) {
|
||||
super(context);
|
||||
|
||||
this.url = 'custom_menu';
|
||||
this.formData = this.formData;
|
||||
}
|
||||
}
|
||||
163
src/common/stores/customer.js
Normal file
163
src/common/stores/customer.js
Normal file
@@ -0,0 +1,163 @@
|
||||
import { observable, action, computed, extendObservable } from 'mobx';
|
||||
|
||||
export default class CustomerStore {
|
||||
|
||||
@observable customers = [];
|
||||
@observable selectedCustomer = {};
|
||||
@observable isLoading = false;
|
||||
@observable CustomerData = {
|
||||
name:'',
|
||||
date_of_birth:'',
|
||||
gender:'',
|
||||
address:'',
|
||||
occupation:'',
|
||||
passport_number:'',
|
||||
email:'',
|
||||
birth_place:'',
|
||||
phone:'',
|
||||
handphone:'',
|
||||
martial_status:'',
|
||||
id_tax_number:'',
|
||||
id_type:'',
|
||||
id_number:'',
|
||||
id_photo:'',
|
||||
passport_photo:'',
|
||||
error_email : '',
|
||||
};
|
||||
@observable orders = [];
|
||||
@observable searchQuery = '';
|
||||
@observable searchResults = [];
|
||||
@observable searchQueryPic = '';
|
||||
@observable searchResultsPic = [];
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
setSearchQuery(searchQuery) {
|
||||
this.searchQuery = searchQuery;
|
||||
return this.http.get(`customers?search=${this.searchQuery}`).then(res => {
|
||||
this.searchResults = res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
search(searchQuery) {
|
||||
return this.http.get(`customers?search=${searchQuery}`).then(res => {
|
||||
this.searchResults = res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
setSearchQueryPic(searchQuery) {
|
||||
this.searchQueryPic = searchQuery;
|
||||
return this.http.get(`customers?search=${this.searchQueryPic}`).then(res => {
|
||||
this.searchResultsPic = res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
reset(){
|
||||
this.CustomerData = {
|
||||
name:'',
|
||||
date_of_birth:'',
|
||||
gender:'',
|
||||
address:'',
|
||||
occupation:'',
|
||||
passport_number:'',
|
||||
email:'',
|
||||
birth_place:'',
|
||||
phone:'',
|
||||
handphone:'',
|
||||
martial_status:'',
|
||||
id_tax_number:'',
|
||||
id_type:'',
|
||||
id_number:'',
|
||||
id_photo:'',
|
||||
passport_photo:'',
|
||||
};
|
||||
}
|
||||
|
||||
// @action
|
||||
// getAll() {
|
||||
// this.isLoading = true;
|
||||
// return this.http.get("customers")
|
||||
// .then(res => {
|
||||
// this.isLoading = false;
|
||||
// this.customers = res;
|
||||
// })
|
||||
// .catch(err => {
|
||||
// this.isLoading = false;
|
||||
// throw err;
|
||||
// })
|
||||
// }
|
||||
|
||||
@action
|
||||
getAll(){
|
||||
this.isLoading = true;
|
||||
return this.http.get(`customers`).then(res => {
|
||||
this.customers = res;
|
||||
this.isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
getDetail(id) {
|
||||
this.isLoading = true;
|
||||
this.CustomerData.id = id;
|
||||
this.http.get(`customers/${id}`)
|
||||
.then(res => {
|
||||
this.CustomerData = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getOrder(id=this.selectedCustomer.id) {
|
||||
this.isLoading = true;
|
||||
return this.http.get(`customers/${id}/orders`)
|
||||
.then(res => {
|
||||
this.orders = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
create() {
|
||||
this.isLoading = true;
|
||||
delete this.CustomerData.error_email;
|
||||
return this.http.post("customers", this.CustomerData)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
update(id) {
|
||||
this.isLoading = true;
|
||||
return this.http.put(`customers/${id}`, this.CustomerData)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
}
|
||||
19
src/common/stores/dashboard.js
Normal file
19
src/common/stores/dashboard.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { action, computed, observable } from 'mobx';
|
||||
|
||||
export default class Dashboard {
|
||||
@observable data = {
|
||||
item_sold: 0,
|
||||
item : 0,
|
||||
order : 0
|
||||
};
|
||||
|
||||
constructor (context) {
|
||||
this.http = context.http;
|
||||
}
|
||||
|
||||
@action
|
||||
async getData(){
|
||||
this.data = await this.http.get(`dashboard`);
|
||||
console.log(this.data, 'data');
|
||||
}
|
||||
}
|
||||
52
src/common/stores/deposit.js
Normal file
52
src/common/stores/deposit.js
Normal file
@@ -0,0 +1,52 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
export default class DepositStore {
|
||||
@observable isLoading = false;
|
||||
@observable depositData = [];
|
||||
@observable bank = {};
|
||||
@observable bankAdmin = {
|
||||
name : '',
|
||||
account_number : '',
|
||||
on_behalf : '',
|
||||
};
|
||||
@observable data = {
|
||||
payment_proof: '',
|
||||
amount: '',
|
||||
bank_account_number: '',
|
||||
bank_name: '',
|
||||
bank_behalf_of: '',
|
||||
bank_to: {
|
||||
name: this.bankAdmin.name,
|
||||
account_number: this.bankAdmin.account_number,
|
||||
on_behalf: this.bankAdmin.on_behalf,
|
||||
},
|
||||
};
|
||||
@observable file = '';
|
||||
|
||||
constructor(context) {
|
||||
this.context = context;
|
||||
this.http = context.http;
|
||||
}
|
||||
|
||||
@action createDeposit() {
|
||||
this.isLoading = true;
|
||||
return this.http.post("deposit/create", this.data)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
checkDeposit(){
|
||||
return this.http.get("deposit").then(res=>{
|
||||
this.depositData = res;
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
42
src/common/stores/employee.js
Normal file
42
src/common/stores/employee.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class EmployeeStore {
|
||||
|
||||
@observable employees = [];
|
||||
@observable selectedEmployee = {};
|
||||
@observable isLoading = false;
|
||||
|
||||
@observable newEmployee = {};
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
getAll() {
|
||||
this.isLoading = true;
|
||||
return this.http.get("employees")
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.employees = res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
create(data) {
|
||||
this.isLoading = true;
|
||||
return this.http.post("employees", data)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
57
src/common/stores/entities.js
Normal file
57
src/common/stores/entities.js
Normal file
@@ -0,0 +1,57 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class EntitiesStore {
|
||||
|
||||
@observable entities = [];
|
||||
@observable isLoading = false;
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
getAll() {
|
||||
this.isLoading = true;
|
||||
return this.http.get("entities")
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.entities = res.data;
|
||||
console.log(res,"tes");
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
create(data) {
|
||||
this.isLoading = true;
|
||||
return this.http.post("entities", data)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getAll();
|
||||
console.log(data);
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
this.getAll();
|
||||
});
|
||||
}
|
||||
|
||||
// @action
|
||||
// post(data) {
|
||||
// this.isLoading = true;
|
||||
// return this.http.post('entities', data)
|
||||
// .then(res => {
|
||||
// this.isLoading = false;
|
||||
// this.getAll()
|
||||
// })
|
||||
// .catch(err => {
|
||||
// this.isLoading = false;
|
||||
// throw err;
|
||||
// })
|
||||
// console.log(data);
|
||||
// }
|
||||
}
|
||||
20
src/common/stores/featured_banner.js
Normal file
20
src/common/stores/featured_banner.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { BaseStore } from "./base_store";
|
||||
import {observable, action,computed} from "mobx"
|
||||
|
||||
export class FeaturedBanner extends BaseStore {
|
||||
@observable formData = {
|
||||
item_id: '',
|
||||
};
|
||||
|
||||
constructor(context) {
|
||||
super(context);
|
||||
|
||||
this.url = 'home_layout/featured_banner';
|
||||
this.formData = this.formData;
|
||||
}
|
||||
|
||||
@action
|
||||
setItem(data){
|
||||
this.formData.item_id = data;
|
||||
}
|
||||
}
|
||||
20
src/common/stores/featured_category.js
Normal file
20
src/common/stores/featured_category.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { BaseStore } from "./base_store";
|
||||
import {observable, action,computed} from "mobx"
|
||||
|
||||
export class FeaturedCategory extends BaseStore {
|
||||
@observable formData = {
|
||||
user_store_id: '',
|
||||
};
|
||||
|
||||
constructor(context) {
|
||||
super(context);
|
||||
|
||||
this.url = 'home_layout/featured_category';
|
||||
this.formData = this.formData;
|
||||
}
|
||||
|
||||
@action
|
||||
setItem(data){
|
||||
this.formData.user_store_id = data;
|
||||
}
|
||||
}
|
||||
20
src/common/stores/featured_item.js
Normal file
20
src/common/stores/featured_item.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { BaseStore } from "./base_store";
|
||||
import {observable, action,computed} from "mobx"
|
||||
|
||||
export class FeaturedItem extends BaseStore {
|
||||
@observable formData = {
|
||||
item_id: '',
|
||||
};
|
||||
|
||||
constructor(context) {
|
||||
super(context);
|
||||
|
||||
this.url = 'home_layout/banners';
|
||||
this.formData = this.formData;
|
||||
}
|
||||
|
||||
@action
|
||||
setItem(data){
|
||||
this.formData.item_id = data;
|
||||
}
|
||||
}
|
||||
20
src/common/stores/featured_store.js
Normal file
20
src/common/stores/featured_store.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { BaseStore } from "./base_store";
|
||||
import {observable, action,computed} from "mobx"
|
||||
|
||||
export class FeaturedStore extends BaseStore {
|
||||
@observable formData = {
|
||||
user_store_id: '',
|
||||
};
|
||||
|
||||
constructor(context) {
|
||||
super(context);
|
||||
|
||||
this.url = 'home_layout/featured_store';
|
||||
this.formData = this.formData;
|
||||
}
|
||||
|
||||
@action
|
||||
setItem(data){
|
||||
this.formData.user_store_id = data;
|
||||
}
|
||||
}
|
||||
62
src/common/stores/firebase.js
Normal file
62
src/common/stores/firebase.js
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Created by 322 on 01/04/2017.
|
||||
*/
|
||||
import * as firebase from "firebase";
|
||||
import {observable, action, computed} from 'mobx';
|
||||
|
||||
export function getMobileOperatingSystem() {
|
||||
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
|
||||
|
||||
// Windows Phone must come first because its UA also contains "Android"
|
||||
if (/windows phone/i.test(userAgent)) {
|
||||
return "Windows Phone";
|
||||
}
|
||||
|
||||
if (/android/i.test(userAgent)) {
|
||||
return "Android";
|
||||
}
|
||||
|
||||
// iOS detection from: http://stackoverflow.com/a/9039885/177710
|
||||
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
|
||||
return "iOS";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
export class Firebase {
|
||||
|
||||
@observable tokenMessage = '';
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
// if(getMobileOperatingSystem() !== 'iOS') {
|
||||
this.init();
|
||||
// }
|
||||
}
|
||||
|
||||
init() {
|
||||
const config = {
|
||||
apiKey: "AIzaSyDhh7woZMxSNXmilAmmxRpOze4YatZbgjA",
|
||||
authDomain: "cerdas-fc4a2.firebaseapp.com",
|
||||
databaseURL: "https://cerdas-fc4a2.firebaseio.com/",
|
||||
projectId: "cerdas-fc4a2",
|
||||
storageBucket: "cerdas-fc4a2.appspot.com",
|
||||
messagingSenderId: "192592024837"
|
||||
};
|
||||
firebase.initializeApp(config);
|
||||
const messaging = firebase.messaging();
|
||||
messaging.requestPermission()
|
||||
.then(function() {
|
||||
console.log('Notification permission granted.');
|
||||
// TODO(developer): Retrieve an Instance ID token for use with FCM.
|
||||
// ...
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.log('Unable to get permission to notify.', err);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
152
src/common/stores/global_ui.js
Normal file
152
src/common/stores/global_ui.js
Normal file
@@ -0,0 +1,152 @@
|
||||
import {action, observable, extendObservable} from 'mobx';
|
||||
import { notification, } from 'antd';
|
||||
|
||||
export const DIALOG = {
|
||||
ORDER: {
|
||||
MAKE_PAYMENT: "dialog_order_make_payment",
|
||||
CANCEL_PAYMENT: "dialog_order_cancel_payment",
|
||||
INPUT_SHIPPING_CODE: 'dialog_order_input_shipping_code',
|
||||
GOJEK_DELIVERY : 'dialog_order_gojek_delivery',
|
||||
PREORDER_ADD_NOTES : 'dialog_preorder_add_notes'
|
||||
},
|
||||
FEATURED_ITEM : {
|
||||
CREATE : 'dialog_featured_item_create'
|
||||
},
|
||||
CUSTOM_MENU : {
|
||||
CREATE : 'dialog_featured_custom_menu'
|
||||
},
|
||||
STORES: {
|
||||
CREATE: "dialog_stores_create",
|
||||
UPDATE: "dialog_stores_update",
|
||||
},
|
||||
ADDRESS :{
|
||||
CREATE : "dialog_address_create"
|
||||
},
|
||||
SETTING : {
|
||||
CATEGORIES : 'dialog_categories',
|
||||
TAGS : 'dialog_tags',
|
||||
},
|
||||
EMPLOYEE: {
|
||||
CREATE: "dialog_employee_create",
|
||||
UPDATE: "dialog_employee_update",
|
||||
},
|
||||
WALLET: {
|
||||
DEPOSIT: "dialog_wallet_deposit",
|
||||
WITHDRAW: "dialog_wallet_withdraw",
|
||||
},
|
||||
UI: {
|
||||
LOADING: "dialog_loading",
|
||||
ALERT: "dialog_alert"
|
||||
},
|
||||
ENTITY: {
|
||||
CREATE: 'entity_create'
|
||||
},
|
||||
STORE_LIST: {
|
||||
CREATE: 'store_list_create'
|
||||
},
|
||||
FEATURED_STORES: {
|
||||
CREATE: 'featured_stores_create'
|
||||
},
|
||||
FEATURED_CATEGORIES: {
|
||||
CREATE: 'featured_categories_create'
|
||||
},
|
||||
};
|
||||
|
||||
export default class GlobalUI {
|
||||
@observable showSideMenu = false;
|
||||
@observable backgroundColor = "#fff";
|
||||
@observable snackbarVisibility = false;
|
||||
@observable loadingVisibility = false;
|
||||
@observable snackbarMessage = "";
|
||||
@observable settingTabSelected = "General";
|
||||
@observable itemsTabSelected = "all";
|
||||
@observable globalAlert = '';
|
||||
@observable dataTabSelected = "";
|
||||
@observable layoutTabSelected = "";
|
||||
@observable contentTabSelected = "";
|
||||
|
||||
constructor() {
|
||||
|
||||
let dialogValue = {};
|
||||
|
||||
Object.keys(DIALOG).map(k => {
|
||||
Object.keys(DIALOG[k]).map(key => dialogValue[DIALOG[k][key]] = false);
|
||||
});
|
||||
|
||||
extendObservable(this, dialogValue);
|
||||
}
|
||||
|
||||
@action
|
||||
showNotification(title, msg){
|
||||
notification.config({
|
||||
placement: 'topRight',
|
||||
duration: 30,
|
||||
top:80,
|
||||
className:'marketplace-notification'
|
||||
});
|
||||
|
||||
notification.error({
|
||||
description: msg,
|
||||
message: title,
|
||||
style: {zIndex: 999999},
|
||||
className:'marketplace-notification'
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
showDialog(name) {
|
||||
this[name] = true;
|
||||
}
|
||||
|
||||
@action
|
||||
hideDialog(name) {
|
||||
this[name] = false;
|
||||
}
|
||||
|
||||
@action
|
||||
changeBackgroundColor(color) {
|
||||
this.backgroundColor = (!color) ? this.backgroundColor : color;
|
||||
}
|
||||
|
||||
@action
|
||||
openSnackbar(message){
|
||||
this.snackbarMessage = message;
|
||||
this.snackbarVisibility = true;
|
||||
setTimeout(() => {
|
||||
this.snackbarVisibility = false;
|
||||
this.snackbarMessage = "";
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
@action
|
||||
openLoading(){
|
||||
this.loadingVisibility = true;
|
||||
}
|
||||
|
||||
@action
|
||||
closeLoading(){
|
||||
this.loadingVisibility = false;
|
||||
}
|
||||
|
||||
@action
|
||||
showDialogLoading() {
|
||||
this[DIALOG.UI.LOADING] = true;
|
||||
}
|
||||
|
||||
@action
|
||||
hideDialogLoading() {
|
||||
this[DIALOG.UI.LOADING] = false;
|
||||
}
|
||||
|
||||
@action
|
||||
showAlert(message) {
|
||||
this.globalAlert = message;
|
||||
this[DIALOG.UI.ALERT] = true;
|
||||
}
|
||||
|
||||
@action
|
||||
hideAlert() {
|
||||
this.globalAlert = '';
|
||||
this[DIALOG.UI.ALERT] = false;
|
||||
}
|
||||
}
|
||||
102
src/common/stores/help.js
Normal file
102
src/common/stores/help.js
Normal file
@@ -0,0 +1,102 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class Help {
|
||||
|
||||
@observable list = [];
|
||||
@observable selected = {};
|
||||
@observable istLoading = false;
|
||||
@observable isSearching = false;
|
||||
@observable filtered = [];
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
getList(){
|
||||
this.isLoading = true;
|
||||
return this.http.get("posts/by_tag/a571f41f-c9d2-4fe1-9638-320c589cffe3")
|
||||
.then(res => {
|
||||
this.list = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getDetail(id){
|
||||
this.isLoading = true;
|
||||
return this.http.get(`posts/${id}`)
|
||||
.then(res => {
|
||||
console.log(res,'ini res store')
|
||||
this.selected = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
post(data){
|
||||
this.isLoading = true;
|
||||
return this.http.post("posts", data)
|
||||
.then(res => {
|
||||
console.log('rest men',res);
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err,'err men')
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
put(id,data){
|
||||
this.isLoading = true;
|
||||
return this.http.put(`posts/${id}`, data)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
delete(id){
|
||||
this.isLoading = true;
|
||||
return this.http.delete(`posts/${id}`)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
filterItems = (query) => {
|
||||
return this.list.filter((el) =>
|
||||
el.title.toLowerCase().indexOf(query.toLowerCase()) > -1
|
||||
);
|
||||
}
|
||||
|
||||
@action
|
||||
search(text){
|
||||
this.filtered = this.filterItems(text);
|
||||
}
|
||||
}
|
||||
15
src/common/stores/item.js
Normal file
15
src/common/stores/item.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import { BaseStore } from "./base_store";
|
||||
import {observable, action} from "mobx/lib/mobx";
|
||||
|
||||
export class ItemStore extends BaseStore {
|
||||
@observable listImages = [];
|
||||
constructor(context) {
|
||||
super(context);
|
||||
this.url = "items";
|
||||
}
|
||||
|
||||
@action
|
||||
addImages(fileList){
|
||||
this.listImages.push(fileList);
|
||||
}
|
||||
}
|
||||
167
src/common/stores/message.js
Normal file
167
src/common/stores/message.js
Normal file
@@ -0,0 +1,167 @@
|
||||
import { BaseStore } from "./base_store";
|
||||
import {
|
||||
action,
|
||||
observable,
|
||||
computed
|
||||
} from 'mobx';
|
||||
import moment from 'moment';
|
||||
import {omit} from 'lodash';
|
||||
export class Messages extends BaseStore {
|
||||
|
||||
@observable chatrooms = [];
|
||||
@observable activerooms = "";
|
||||
@observable selectedTab = "chat";
|
||||
@observable lineMessage = "";
|
||||
|
||||
constructor(context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@action
|
||||
reset(){
|
||||
this.activerooms = "";
|
||||
this.chatrooms = [];
|
||||
}
|
||||
|
||||
@action
|
||||
getRooms(){
|
||||
this.isLoading = true;
|
||||
return this.http.get("message/rooms")
|
||||
.then(res => {
|
||||
this.chatrooms = res.data;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
setRooms(val){
|
||||
this.activerooms = omit(val,['message']);
|
||||
this.isLoading = true;
|
||||
this.getRoomMessages(val.id);
|
||||
if(val.unread_message >0){
|
||||
this.readRoomMessages(val.id);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
readRoomMessages(room_id){
|
||||
return this.http.put(`message/rooms/${room_id}/read`,{})
|
||||
.then(res => {
|
||||
|
||||
}).catch(err => {
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
deliveredMessage(room_id,message_id){
|
||||
return this.http.put(`message/rooms/${room_id}/messages/${message_id}/delivered`,{})
|
||||
.then(res => {
|
||||
|
||||
}).catch(err => {
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
readMessage(room_id,message_id){
|
||||
return this.http.put(`message/rooms/${room_id}/messages/${message_id}/read`,{})
|
||||
.then(res => {
|
||||
|
||||
}).catch(err => {
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getRoomMessages(id){
|
||||
return this.http.get(`message/rooms/${id}/messages`)
|
||||
.then(res => {
|
||||
let chatRoomIndex = this.chatrooms.findIndex(it=>it.id == id);
|
||||
this.chatrooms[chatRoomIndex].message = res;
|
||||
this.chatrooms[chatRoomIndex].unread_message = 0;
|
||||
this.chatrooms = this.chatrooms.map(it => it);
|
||||
this.isLoading = false;
|
||||
|
||||
}).catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@computed
|
||||
get message(){
|
||||
let data = [];
|
||||
if(this.activerooms !== ''){
|
||||
data = this.chatrooms.find(it=>it.id == this.activerooms.id).message;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@action
|
||||
changeTab(val){
|
||||
this.selectedTab= val;
|
||||
}
|
||||
|
||||
@action
|
||||
sendMessage(){
|
||||
this.isLoading = true;
|
||||
if(!this.lineMessage){
|
||||
console.log('message empty');
|
||||
return 0;
|
||||
}
|
||||
return this.http.post(`message/rooms/${this.activerooms.id}/messages`,{
|
||||
message : this.lineMessage
|
||||
})
|
||||
.then(res => {
|
||||
// this.getRooms();
|
||||
this.lineMessage = "";
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.lineMessage = "";
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
writeMessage(val){
|
||||
this.lineMessage = val;
|
||||
}
|
||||
|
||||
@action
|
||||
pushNewMessage(val){
|
||||
|
||||
let chatRoomIndex = this.chatrooms.findIndex(it=>it.id == val.message_room_id);
|
||||
if(chatRoomIndex < 0){
|
||||
this.getRooms();
|
||||
return;
|
||||
}
|
||||
this.deliveredMessage(val.message_room_id,val.message_room_message_id);
|
||||
if(this.activerooms.id == val.message_room_id){
|
||||
this.readMessage(val.message_room_id,val.message_room_message_id);
|
||||
}else{
|
||||
this.chatrooms[chatRoomIndex].unread_message+=1;
|
||||
}
|
||||
val.yours_message = (val.yours_message == 'true');
|
||||
val.created_at = new Date().toISOString();
|
||||
val.user = JSON.parse(val.user);
|
||||
this.chatrooms[chatRoomIndex].message.push(val);
|
||||
|
||||
let chatRoomData = this.chatrooms[chatRoomIndex];
|
||||
|
||||
//move room to top
|
||||
this.chatrooms.splice(chatRoomIndex,1);
|
||||
this.chatrooms.splice(0,0,chatRoomData);
|
||||
//end
|
||||
|
||||
this.chatrooms = this.chatrooms.map(it => it);
|
||||
}
|
||||
|
||||
}
|
||||
28
src/common/stores/my_store.js
Normal file
28
src/common/stores/my_store.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { BaseStore } from "./base_store";
|
||||
import {
|
||||
action,
|
||||
observable,
|
||||
computed
|
||||
} from 'mobx';
|
||||
|
||||
export class MyStoreStore extends BaseStore {
|
||||
|
||||
@observable dataItems = [];
|
||||
@observable data = {
|
||||
name: '',
|
||||
tagline: '',
|
||||
image: null
|
||||
};
|
||||
|
||||
constructor(context) {
|
||||
super(context);
|
||||
|
||||
this.url = "my_store";
|
||||
this.mode = "single";
|
||||
}
|
||||
|
||||
@action
|
||||
getDetail(id) {
|
||||
return Promise.resolve({id});
|
||||
}
|
||||
}
|
||||
9
src/common/stores/my_store_item.js
Normal file
9
src/common/stores/my_store_item.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import { BaseStore } from "./base_store";
|
||||
|
||||
export class MyStoreItemStore extends BaseStore {
|
||||
constructor(context) {
|
||||
super(context);
|
||||
|
||||
this.url = 'my_store/items';
|
||||
}
|
||||
}
|
||||
13
src/common/stores/my_store_shipping_method.js
Normal file
13
src/common/stores/my_store_shipping_method.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { BaseStore } from "./base_store";
|
||||
|
||||
export class MyStoreShippingMethodStore extends BaseStore {
|
||||
constructor(context) {
|
||||
super(context);
|
||||
|
||||
this.url = 'my_store/shipping_methods';
|
||||
}
|
||||
|
||||
isActivated(shippingMethodId) {
|
||||
return this.data.findIndex(d => d.shipping_method_id === shippingMethodId) >= 0;
|
||||
}
|
||||
}
|
||||
108
src/common/stores/notification.js
Normal file
108
src/common/stores/notification.js
Normal file
@@ -0,0 +1,108 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class Notification {
|
||||
|
||||
@observable list = [];
|
||||
@observable selected = {};
|
||||
@observable istLoading = false;
|
||||
@observable isSearching = false;
|
||||
@observable filtered = [];
|
||||
@observable unread_notif = 0;
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
getList(){
|
||||
this.isLoading = true;
|
||||
return this.http.get("notifications")
|
||||
.then(res => {
|
||||
console.log(res.data, 'ini res')
|
||||
this.list = res.data;
|
||||
this.unread_notif = res.unread_notif;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
readAll(){
|
||||
return this.http.put("notifications/read_all",{}).then(res=>{
|
||||
this.unread_notif = 0;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getDetail(id){
|
||||
this.isLoading = true;
|
||||
return this.http.get(`notifications/${id}`)
|
||||
.then(res => {
|
||||
this.selected = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
post(data){
|
||||
this.isLoading = true;
|
||||
return this.http.post("notifications", data)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
put(id,data){
|
||||
this.isLoading = true;
|
||||
return this.http.put(`notifications/${id}`, data)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
delete(id){
|
||||
this.isLoading = true;
|
||||
return this.http.delete(`notifications/${id}`)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
filterItems = (query) => {
|
||||
return this.list.filter((el) =>
|
||||
el.id.toLowerCase().indexOf(query.toLowerCase()) > -1
|
||||
);
|
||||
}
|
||||
|
||||
@action
|
||||
search(text){
|
||||
this.filtered = this.filterItems(text);
|
||||
}
|
||||
}
|
||||
33
src/common/stores/odoo.js
Normal file
33
src/common/stores/odoo.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { action, computed, extendObservable, observable } from 'mobx';
|
||||
|
||||
export default class Odoo {
|
||||
|
||||
@observable isLoading = false;
|
||||
@observable data = null;
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
syncData(){
|
||||
this.isLoading = true;
|
||||
return this.http.get(`odoo/sync/d203f833-356a-45fc-ae99-d65e790e2a88`).then(res => {
|
||||
this.data = res;
|
||||
this.isLoading = false;
|
||||
return res;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
createSales(orderStoreId){
|
||||
this.isLoading = true;
|
||||
return this.http.post(`odoo/sales`,{
|
||||
user_order_store_id : orderStoreId
|
||||
}).then(res => {
|
||||
this.isLoading = false;
|
||||
return res;
|
||||
})
|
||||
}
|
||||
}
|
||||
295
src/common/stores/order.js
Normal file
295
src/common/stores/order.js
Normal file
@@ -0,0 +1,295 @@
|
||||
import {action, observable} from 'mobx';
|
||||
import {BaseStore} from "./base_store";
|
||||
|
||||
export default class OrderStore {
|
||||
|
||||
@observable isLoading = false;
|
||||
@observable isSearching = false;
|
||||
@observable dataFiltered = [];
|
||||
@observable gojekPrice = {};
|
||||
@observable filterBy = 'active';
|
||||
@observable selectedOrder = {
|
||||
"id": "",
|
||||
"user_address_store_id": "",
|
||||
"user_address_buyer_id": "",
|
||||
"weight": "",
|
||||
"shipping_price": "",
|
||||
"created_at": "",
|
||||
"updated_at": "",
|
||||
"deleted_at": null,
|
||||
"subtotal": "",
|
||||
"user_order_id": "",
|
||||
"user_store_id": "",
|
||||
"order_status_id": "",
|
||||
"user_orders_id": "",
|
||||
"user_order_items": [],
|
||||
"shipping_method" : {
|
||||
"id" : "",
|
||||
"name" : ""
|
||||
},
|
||||
"courier_booking_id" : "",
|
||||
"user_address_store": {
|
||||
"id": "",
|
||||
"user_id": "",
|
||||
"name": "",
|
||||
"address": "",
|
||||
"created_at": "",
|
||||
"updated_at": "",
|
||||
"deleted_at": null,
|
||||
"province_id": "",
|
||||
"city_id": "",
|
||||
"is_shipment": "",
|
||||
"is_default": "",
|
||||
"receiver_name": "",
|
||||
"city": {
|
||||
"id": "",
|
||||
"province_id": "",
|
||||
"name": "",
|
||||
"type": "",
|
||||
"raja_ongkir_code": "",
|
||||
"created_at": "",
|
||||
"updated_at": "",
|
||||
"deleted_at": null
|
||||
},
|
||||
"province": {
|
||||
"id": "",
|
||||
"name": "",
|
||||
"raja_ongkir_code": "",
|
||||
"created_at": "",
|
||||
"updated_at": "",
|
||||
"deleted_at": null
|
||||
}
|
||||
},
|
||||
"user_address_buyer": {
|
||||
"id": "",
|
||||
"user_id": "",
|
||||
"name": "",
|
||||
"address": "",
|
||||
"created_at": "",
|
||||
"updated_at": "",
|
||||
"deleted_at": null,
|
||||
"province_id": "",
|
||||
"city_id": "",
|
||||
"is_shipment": false,
|
||||
"is_default": false,
|
||||
"receiver_name": "",
|
||||
"city": {
|
||||
"id": "",
|
||||
"province_id": "",
|
||||
"name": "",
|
||||
"type": "",
|
||||
"raja_ongkir_code": "",
|
||||
"created_at": "",
|
||||
"updated_at": "",
|
||||
"deleted_at": null
|
||||
},
|
||||
"province": {
|
||||
"id": "",
|
||||
"name": "",
|
||||
"raja_ongkir_code": "",
|
||||
"created_at": "",
|
||||
"updated_at": "",
|
||||
"deleted_at": null
|
||||
}
|
||||
},
|
||||
"user_orders": {
|
||||
"id": "",
|
||||
"user_id": "",
|
||||
"order_status_id": "",
|
||||
"created_at": "",
|
||||
"updated_at": "",
|
||||
"deleted_at": null,
|
||||
"firstname": '',
|
||||
"lastname": '',
|
||||
"gender": '',
|
||||
"phone": "",
|
||||
"total": "",
|
||||
"user": {
|
||||
"id": "",
|
||||
"user_type_id": "",
|
||||
"email": "",
|
||||
"username": "",
|
||||
"password": "",
|
||||
"salt": "",
|
||||
"created_at": "",
|
||||
"updated_at": "",
|
||||
"deleted_at": null,
|
||||
"device_unique_id": null,
|
||||
"profile":{
|
||||
"firstname": '',
|
||||
"lastname": '',
|
||||
"gender": '',
|
||||
"phone": "",
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
"tracking" : [],
|
||||
"order_status": {
|
||||
"id": "",
|
||||
"name": "",
|
||||
"visible": true,
|
||||
"order": 0,
|
||||
"created_at": "",
|
||||
"updated_at": "",
|
||||
"deleted_at": ""
|
||||
},
|
||||
histories : []
|
||||
};
|
||||
@observable newOrder = {};
|
||||
@observable orderList = [];
|
||||
@observable orderDetail = {};
|
||||
|
||||
@observable orderAirlineDetail = {
|
||||
'id': '',
|
||||
'agent_id': '',
|
||||
'customer_id': '',
|
||||
'pnrid': '',
|
||||
'created_at': '',
|
||||
'updated_at': '',
|
||||
'deleted_at': '',
|
||||
'status': '',
|
||||
'retrieve': {
|
||||
'bookingcode': '',
|
||||
'status': '',
|
||||
'airlinecode': '',
|
||||
'timelimit': '',
|
||||
'total_fare': '',
|
||||
'pax': [],
|
||||
'paxcontact': {
|
||||
'firstname': '',
|
||||
'lastname': '',
|
||||
'phone1': '',
|
||||
'phone2': '',
|
||||
'email': ''
|
||||
},
|
||||
'flights': [],
|
||||
},
|
||||
}
|
||||
|
||||
constructor(context) {
|
||||
this.context = context;
|
||||
this.http = context.http;
|
||||
}
|
||||
|
||||
filterData = (query) => {
|
||||
return this.orderList.filter((data) => data.id.indexOf(query) > -1);
|
||||
}
|
||||
|
||||
@action
|
||||
changeFilterBy = (val)=>{
|
||||
this.filterBy = val;
|
||||
}
|
||||
|
||||
@action
|
||||
search(text) {
|
||||
console.log(this.orderList);
|
||||
this.dataFiltered = this.filterData(text);
|
||||
}
|
||||
|
||||
@action
|
||||
getAllOrder() {
|
||||
this.isLoading = true;
|
||||
return this.http.get("order_stores")
|
||||
.then(res => {
|
||||
this.orderList = res;
|
||||
this.isLoading = false;
|
||||
console.log(res, 'ini');
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@action
|
||||
getDetail(id) {
|
||||
this.isLoading = true;
|
||||
this.selectedOrder.id = id;
|
||||
|
||||
this.http.get(`order_stores/${id}`)
|
||||
.then(res => {
|
||||
console.log(res)
|
||||
this.selectedOrder = res;
|
||||
this.isLoading = true;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
acceptOrder() {
|
||||
this.http.post(`order_stores/${this.selectedOrder.id}/accept_order`).then(() => {
|
||||
this.context.globalUI.openSnackbar('Order successfully accepted');
|
||||
this.getDetail(this.selectedOrder.id);
|
||||
}).catch(err => {
|
||||
console.log('err', err.message);
|
||||
this.getDetail(this.selectedOrder.id);
|
||||
this.context.globalUI.showAlert(err.message);
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
declineOrder() {
|
||||
this.http.post(`order_stores/${this.selectedOrder.id}/decline_order`).then(() => {
|
||||
this.context.globalUI.openSnackbar('Order successfully declined');
|
||||
this.getDetail(this.selectedOrder.id);
|
||||
}).catch(err => {
|
||||
this.getDetail(this.selectedOrder.id);
|
||||
this.context.globalUI.showAlert(err.message);
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
inputShippingCode(shippingCode) {
|
||||
this.http.post(`order_stores/${this.selectedOrder.id}/input_shipping_code`, {
|
||||
shipping_code: shippingCode
|
||||
}).then(() => {
|
||||
this.context.globalUI.openSnackbar('Shipping code successfully submitted');
|
||||
this.getDetail(this.selectedOrder.id);
|
||||
}).catch(err => {
|
||||
this.getDetail(this.selectedOrder.id);
|
||||
this.context.globalUI.showAlert(err.message);
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
createOrder() {
|
||||
|
||||
}
|
||||
|
||||
@action
|
||||
bookingGojek() {
|
||||
return this.http.post(`order_stores/${this.selectedOrder.id}/booking_gojek`, {}).then(() => {
|
||||
this.context.globalUI.openSnackbar('Booking Courier Gojek Success');
|
||||
this.getDetail(this.selectedOrder.id);
|
||||
}).catch(err => {
|
||||
this.getDetail(this.selectedOrder.id);
|
||||
console.log(err, 'yyohohohoho')
|
||||
this.context.globalUI.showAlert(err.message);
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
calculatePrice() {
|
||||
return this.http.get(`order_stores/${this.selectedOrder.id}/calculate_price_gojek`).then((res) => {
|
||||
this.gojekPrice = res
|
||||
}).catch(err => {
|
||||
console.log(err)
|
||||
throw err
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
addStoreNotes(data) {
|
||||
return this.http.put(`preorder/notes`, data).then((res) => {
|
||||
return res
|
||||
}).catch(err => {
|
||||
console.log(err)
|
||||
throw err
|
||||
});
|
||||
}
|
||||
}
|
||||
86
src/common/stores/package_payment_method.js
Normal file
86
src/common/stores/package_payment_method.js
Normal file
@@ -0,0 +1,86 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class PackagePaymentMethod {
|
||||
@observable packagePaymentMethodList = [];
|
||||
@observable packagePaymentMethodData = {
|
||||
id : '',
|
||||
package_id : '',
|
||||
payment_method_id : '',
|
||||
};
|
||||
@observable packagePaymentMethodId = '';
|
||||
@observable isLoading = false;
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
getPackagePaymentMethodByPackageId(id){
|
||||
this.isLoading = true;
|
||||
this.http.get(`package_payment_methods?package_id=${id}`).then(res => {
|
||||
this.packagePaymentMethodList = res;
|
||||
this.isLoading = false;
|
||||
// console.log(this.contactId);
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
getPackagePaymentMethodById(id){
|
||||
this.isLoading = true;
|
||||
this.packagePaymentMethodId = id;
|
||||
return this.http.get(`package_payment_methods/${id}`).then(res => {
|
||||
this.packagePaymentMethodData = res[0];
|
||||
this.isLoading = false;
|
||||
// console.log(this.contactId);
|
||||
});
|
||||
}
|
||||
|
||||
// @action
|
||||
// getPaymentMethod(){
|
||||
// this.isLoading = true;
|
||||
// this.http.get('payment_methods').then(res => {
|
||||
// this.paymentMethod = res;
|
||||
// this.isLoading = false;
|
||||
// });
|
||||
// }
|
||||
|
||||
@computed
|
||||
get isPackagePaymentMethodEmpty() {
|
||||
if(this.packagePaymentMethodList.length > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@action
|
||||
postPackagePaymentMethod(package_payment_method_id){
|
||||
this.isLoading = true;
|
||||
this.http.post(`package_payment_methods`, this.packagePaymentMethodData).then(res => {
|
||||
this.isLoading = false;
|
||||
this.getPackagePaymentMethodByPackageId(package_payment_method_id);
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
putPackagePaymentMethod(id, package_payment_method_id){
|
||||
this.isLoading = true;
|
||||
this.http.put(`package_payment_methods/${id}`, this.packagePaymentMethodData).then(res => {
|
||||
this.isLoading = false;
|
||||
this.getPackagePaymentMethodByPackageId(package_payment_method_id);
|
||||
console.log(res);
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
delPackagePaymentMethod(id,package_payment_method_id){
|
||||
this.packagePaymentMethodId = id;
|
||||
this.isLoading = true;
|
||||
this.http.delete(`package_payment_methods/${id}`).then(res => {
|
||||
this.isLoading = false;
|
||||
// console.log(detail[0]);
|
||||
this.getPackagePaymentMethodByPackageId(package_payment_method_id);
|
||||
return res;
|
||||
})
|
||||
}
|
||||
}
|
||||
94
src/common/stores/package_schedules.js
Normal file
94
src/common/stores/package_schedules.js
Normal file
@@ -0,0 +1,94 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class PackageSchedules {
|
||||
@observable packageSchedulesList = [];
|
||||
@observable packageSchedulesData = {
|
||||
id : '',
|
||||
package_id : '',
|
||||
depature_date : '',
|
||||
return_date : '',
|
||||
pax : '',
|
||||
price : '',
|
||||
currency : {
|
||||
name : ''
|
||||
}
|
||||
};
|
||||
@observable avaliablePax = [];
|
||||
@observable packageSchedulesId = '';
|
||||
@observable isLoading = false;
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
getPackageSchedulesByPackageId(id){
|
||||
this.isLoading = true;
|
||||
this.http.get(`package_schedules?package_id=${id}`).then(res => {
|
||||
this.packageSchedulesList = res;
|
||||
console.log(res);
|
||||
this.isLoading = false;
|
||||
// console.log(this.contactId);
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
getAvaliable(id){
|
||||
this.isLoading = true;
|
||||
this.http.get(`pax/${id}`).then(res => {
|
||||
this.avaliablePax = res;
|
||||
this.isLoading = false;
|
||||
// console.log(this.contactId);
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
getPackageSchedulesById(id){
|
||||
this.isLoading = true;
|
||||
this.packageSchedulesId = id;
|
||||
return this.http.get(`package_schedules/${id}`).then(res => {
|
||||
this.packageSchedulesData = res[0];
|
||||
this.isLoading = false;
|
||||
// console.log(this.contactId);
|
||||
});
|
||||
}
|
||||
|
||||
@computed
|
||||
get isPackageSchedulesEmpty() {
|
||||
if(this.packageSchedulesList.length > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@action
|
||||
postPackageSchedules(package_schedules_id){
|
||||
this.isLoading = true;
|
||||
this.http.post(`package_schedules`, this.packageSchedulesData).then(res => {
|
||||
this.isLoading = false;
|
||||
this.getPackageSchedulesByPackageId(package_schedules_id);
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
putPackageSchedules(id, package_schedules_id){
|
||||
this.isLoading = true;
|
||||
this.http.put(`package_schedules/${id}`, this.packageSchedulesData).then(res => {
|
||||
this.isLoading = false;
|
||||
this.getPackageSchedulesByPackageId(package_schedules_id);
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
delPackageSchedules(id,package_schedules_id){
|
||||
this.packageSchedulesId = id;
|
||||
this.isLoading = true;
|
||||
this.http.delete(`package_schedules/${id}`).then(res => {
|
||||
this.isLoading = false;
|
||||
// console.log(detail[0]);
|
||||
this.getPackageSchedulesByPackageId(package_schedules_id);
|
||||
return res;
|
||||
})
|
||||
}
|
||||
}
|
||||
28
src/common/stores/package_service.js
Normal file
28
src/common/stores/package_service.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class PackagesService {
|
||||
@observable postData = {
|
||||
agent_id : null,
|
||||
package_schedule_id : '',
|
||||
payment_method_id : '',
|
||||
customer_id : '',
|
||||
agent_reward_id : null,
|
||||
};
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
@action
|
||||
postPackages(data){
|
||||
this.postPackagesLoading = true;
|
||||
return this.http.post(`package_transaction`,data).then(res => {
|
||||
this.postPackagesLoading = false;
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
309
src/common/stores/packages.js
Normal file
309
src/common/stores/packages.js
Normal file
@@ -0,0 +1,309 @@
|
||||
import {observable, action, computed} from 'mobx';
|
||||
|
||||
export default class Packages {
|
||||
|
||||
@observable packagesList = [];
|
||||
@observable packagesListByStatus = [];
|
||||
@observable getAllPackagesLoading = false;
|
||||
@observable temporaryHotels = {
|
||||
name: '',
|
||||
image: []
|
||||
};
|
||||
@observable postData = {
|
||||
package_reward_id: '',
|
||||
name: '',
|
||||
transportation: '',
|
||||
description: '',
|
||||
banner: '',
|
||||
destination: {},
|
||||
duration: {},
|
||||
hotels: {
|
||||
hotels: []
|
||||
},
|
||||
galleries: {
|
||||
image: []
|
||||
},
|
||||
itinerary: {
|
||||
data: []
|
||||
},
|
||||
price: '',
|
||||
status: 'enable',
|
||||
repeat: '',
|
||||
transportation: ''
|
||||
};
|
||||
@observable postPackagesLoading = false;
|
||||
@observable deletePackagesLoading = false;
|
||||
@observable packageData = {
|
||||
package_reward_id: '',
|
||||
name: '',
|
||||
transportation: '',
|
||||
description: '',
|
||||
banner: '',
|
||||
destination: {},
|
||||
duration: {},
|
||||
transport: {
|
||||
name: ''
|
||||
},
|
||||
hotels: {
|
||||
hotels: [
|
||||
{
|
||||
name: '',
|
||||
image: [""]
|
||||
}
|
||||
]
|
||||
},
|
||||
galleries: {
|
||||
image: []
|
||||
},
|
||||
itinerary: {
|
||||
data: []
|
||||
},
|
||||
price: '',
|
||||
status: 'enable',
|
||||
repeat: '',
|
||||
category_id: ''
|
||||
};
|
||||
@observable getPackageByIdLoading = false;
|
||||
@observable editPackagesLoading = false;
|
||||
@observable packageId = '';
|
||||
@observable imageGallerySource = [];
|
||||
@observable editedPackageData = {
|
||||
package_reward_id: '',
|
||||
name: '',
|
||||
transportation: '',
|
||||
description: '',
|
||||
banner: '',
|
||||
destination: {},
|
||||
duration: {},
|
||||
hotels: {
|
||||
hotels: [
|
||||
{
|
||||
name: '',
|
||||
image: [""]
|
||||
}
|
||||
]
|
||||
},
|
||||
galleries: {
|
||||
image: []
|
||||
},
|
||||
transport: {
|
||||
name: ''
|
||||
},
|
||||
itinerary: {
|
||||
data: []
|
||||
},
|
||||
price: '',
|
||||
status: 'enable',
|
||||
repeat: '',
|
||||
category_id: ''
|
||||
};
|
||||
@observable packageReward = "";
|
||||
@observable paymentMethod = "";
|
||||
@observable rewardType = "";
|
||||
@observable queries = {
|
||||
departure_date: "",
|
||||
currency: "",
|
||||
destination: "",
|
||||
price_from: "",
|
||||
price_to: "",
|
||||
pax: ""
|
||||
};
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
setDepartureDate(data) {
|
||||
this.queries.departure_date = data;
|
||||
}
|
||||
|
||||
@action
|
||||
setCurrency(data) {
|
||||
this.queries.currency = data;
|
||||
}
|
||||
|
||||
@action
|
||||
setDestination(data) {
|
||||
this.queries.destination = data;
|
||||
}
|
||||
|
||||
@action
|
||||
setPriceFrom(data) {
|
||||
this.queries.price_from = data;
|
||||
}
|
||||
|
||||
@action
|
||||
setPriceTo(data) {
|
||||
this.queries.price_to = data;
|
||||
}
|
||||
|
||||
@action
|
||||
setPax(data) {
|
||||
this.queries.pax = data;
|
||||
}
|
||||
|
||||
@action
|
||||
getAllPackages() {
|
||||
this.getAllPackagesLoading = true;
|
||||
return this.http.get(`packages`).then(res => {
|
||||
this.packagesList = res;
|
||||
this.getAllPackagesLoading = false;
|
||||
});
|
||||
|
||||
console.log(this.packagesList)
|
||||
}
|
||||
|
||||
@action
|
||||
getAllPackagesByQueries() {
|
||||
let builder = "";
|
||||
this.getAllPackagesLoading = true;
|
||||
if (this.queries.departure_date) {
|
||||
builder = "departure_date=" + this.queries.departure_date
|
||||
}
|
||||
return this.http.get(`packages?` + builder).then(res => {
|
||||
this.packagesListByStatus = res;
|
||||
this.getAllPackagesLoading = false;
|
||||
});
|
||||
|
||||
console.log(this.packagesList)
|
||||
}
|
||||
|
||||
@action
|
||||
getAllPackagesbyStatus() {
|
||||
this.getAllPackagesLoading = true;
|
||||
return this.http.get(`packages?status=enable`).then(res => {
|
||||
this.packagesListByStatus = res;
|
||||
this.getAllPackagesLoading = false;
|
||||
});
|
||||
|
||||
console.log(this.packagesList)
|
||||
}
|
||||
|
||||
@action
|
||||
getPackageById(id) {
|
||||
this.getPackageByIdLoading = true;
|
||||
return this.http.get(`packages/${id}`).then(res => {
|
||||
this.packageData = res[0];
|
||||
this.packageId = id;
|
||||
this.getPackageByIdLoading = false;
|
||||
})
|
||||
}
|
||||
|
||||
@computed
|
||||
get isPackageEmpty() {
|
||||
if (this.packagesList.length > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@computed
|
||||
get isPackageEmptybyStatus() {
|
||||
if (this.packagesListByStatus.length > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@computed
|
||||
get isIteneraryEmpty() {
|
||||
if (this.postData.itinerary.data.length > 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@computed
|
||||
get isHotelEmpty() {
|
||||
if (this.postData.hotels.hotels.length > 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@computed
|
||||
get isHotelsEmpty() {
|
||||
if (this.packageData.hotels.hotels.length > 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
onUpdateGallery(data) {
|
||||
this.postData.galleries.image.push(data);
|
||||
// console.log(data)
|
||||
}
|
||||
|
||||
@action
|
||||
onUpdateHotels(data) {
|
||||
this.temporaryHotels.image.push(data);
|
||||
// console.log(data)
|
||||
}
|
||||
|
||||
@action
|
||||
addHotels(data){
|
||||
// if (typeof this.postData.hotels.hotels !== 'function') {
|
||||
// this.postData.hotels.hotels = [];
|
||||
// }
|
||||
this.postData.hotels.hotels.push(data);
|
||||
}
|
||||
|
||||
@computed
|
||||
get isGalleryEmpty() {
|
||||
if (this.postData.galleries.image.length > 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
postPackages() {
|
||||
this.postPackagesLoading = true;
|
||||
return this.http.post(`packages`, this.postData).then(res => {
|
||||
this.postPackagesLoading = false;
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
deletePackages(id) {
|
||||
this.deletePackagesLoading = true;
|
||||
return this.http.delete(`packages/${id}`).then(res => {
|
||||
this.getAllPackages();
|
||||
this.deletePackagesLoading = false;
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
editPackages() {
|
||||
this.editPackagesLoading = true;
|
||||
return this.http.put(`packages/${this.packageId}`, this.editedPackageData).then(res => {
|
||||
this.getAllPackages();
|
||||
this.editPackagesLoading = false;
|
||||
// this.packageData = {};
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
editPackagesDetail() {
|
||||
this.editPackagesLoading = true;
|
||||
return this.http.put(`packages/${this.packageId}`, this.editedPackageData).then(res => {
|
||||
this.getPackageById(this.packageId);
|
||||
this.editPackagesLoading = false;
|
||||
// this.packageData = {};
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
176
src/common/stores/payment_method.js
Normal file
176
src/common/stores/payment_method.js
Normal file
@@ -0,0 +1,176 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class PaymentMethod {
|
||||
@observable paymentList = [];
|
||||
@observable paymentMethodId = "";
|
||||
@observable paymentMethodDetail = {
|
||||
id : '',
|
||||
type : '',
|
||||
name : '',
|
||||
pinalty_type: '',
|
||||
pinalty_type: '',
|
||||
discount_type: '',
|
||||
downpayment_type: '',
|
||||
discount: '',
|
||||
downpayment: '',
|
||||
downpayment_deadline : '',
|
||||
start_date: '',
|
||||
end_date: null,
|
||||
cancelation_rules: [{
|
||||
period : "",
|
||||
change_date : '',
|
||||
money_return : '',
|
||||
change_package :'',
|
||||
}],
|
||||
};
|
||||
|
||||
// @observable getDriverByIdData = [{
|
||||
// id: "",
|
||||
// contact_id: "",
|
||||
// name: "",
|
||||
// nik: "",
|
||||
// phone_number: "",
|
||||
// date_of_birth: "",
|
||||
// address: "",
|
||||
// photo: "",
|
||||
// created_at: "",
|
||||
// updated_at: "",
|
||||
// deleted_at: null
|
||||
// }];
|
||||
// @observable driverId = '';
|
||||
@observable isLoading = false;
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
reset(){
|
||||
this.paymentMethodDetail = {
|
||||
id : '',
|
||||
type : '',
|
||||
name : '',
|
||||
pinalty_type: '',
|
||||
pinalty_type: '',
|
||||
discount_type: '',
|
||||
downpayment_type: '',
|
||||
discount: '',
|
||||
downpayment: '',
|
||||
downpayment_deadline : '',
|
||||
start_date: '',
|
||||
end_date: null,
|
||||
cancelation_rules: [{
|
||||
period : "",
|
||||
change_date : '',
|
||||
money_return : '',
|
||||
change_package :'',
|
||||
}],
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
getAll(){
|
||||
this.isLoading = true;
|
||||
return this.http.get(`payment_methods`).then(res => {
|
||||
this.paymentList = res;
|
||||
// console.log(this.paymentList);
|
||||
this.isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
// @action
|
||||
// getById(id){
|
||||
// if(id != 0){
|
||||
// this.isLoading = true;
|
||||
// this.http.get(`payment_methods?id=${id}`).then(res => {
|
||||
// this.paymentMethodDetail = res;
|
||||
// this.isLoading = false;
|
||||
// // console.log(this.contactId);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
@action
|
||||
getById(id){
|
||||
this.paymentMethodId = id;
|
||||
this.isLoading = true;
|
||||
return this.http.get(`payment_methods?id=${id}`).then(detail => {
|
||||
this.paymentMethodDetail = detail[0];
|
||||
this.isLoading = false;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
reset(){
|
||||
this.paymentMethodDetail = {
|
||||
id : '',
|
||||
type : '',
|
||||
name : '',
|
||||
pinalty_type: '',
|
||||
pinalty_type: '',
|
||||
discount_type: '',
|
||||
discount: '',
|
||||
downpayment: '',
|
||||
start_date: '',
|
||||
end_date: null,
|
||||
cancelation_rules: [],
|
||||
};
|
||||
}
|
||||
|
||||
@computed
|
||||
get isDetailEmpty(){
|
||||
if(this.paymentMethodDetail.name == ''){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@computed
|
||||
get isEmpty(){
|
||||
if(this.paymentList.length > 0){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@computed
|
||||
get isRulesEmpty(){
|
||||
if(this.paymentMethodDetail.cancelation_rules.length > 0){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@action
|
||||
post(){
|
||||
this.isLoading = true;
|
||||
this.http.post(`payment_methods`, this.paymentMethodDetail).then(res => {
|
||||
this.isLoading = false;
|
||||
this.getAll();
|
||||
return res;
|
||||
});
|
||||
console.log(this.paymentMethodDetail);
|
||||
}
|
||||
|
||||
@action
|
||||
put(id){
|
||||
this.isLoading = true;
|
||||
this.http.put(`payment_methods/${id}`, this.paymentMethodDetail).then(res => {
|
||||
this.isLoading = false;
|
||||
this.getAll();
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
del(id){
|
||||
this.isLoading = true;
|
||||
this.http.delete(`payment_methods/${id}`).then(res => {
|
||||
this.isLoading = false;
|
||||
this.getAll();
|
||||
return res;
|
||||
})
|
||||
}
|
||||
}
|
||||
82
src/common/stores/profile.js
Normal file
82
src/common/stores/profile.js
Normal file
@@ -0,0 +1,82 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class Profile {
|
||||
@observable isLoading = false;
|
||||
@observable profilleId = '';
|
||||
@observable userProfile = {
|
||||
firstname : '',
|
||||
lastname : '',
|
||||
gender: '',
|
||||
place_of_birth: '',
|
||||
date_of_birth:'',
|
||||
phone:'',
|
||||
photo : "",
|
||||
user: {
|
||||
id:'',
|
||||
user_type_id: '',
|
||||
email:'',
|
||||
username: '',
|
||||
password:'',
|
||||
salt: '',
|
||||
full_name:'',
|
||||
}
|
||||
};
|
||||
|
||||
@observable selectedTab = 'general_information'
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@action
|
||||
changeTab(value){
|
||||
this.selectedTab = value;
|
||||
}
|
||||
|
||||
@action
|
||||
getProfile() {
|
||||
this.isLoading = true;
|
||||
return this.http.get('profile')
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.userProfile = res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
updateProfile() {
|
||||
this.isLoading = true;
|
||||
return this.http.put('profile', this.userProfile)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getProfile()
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
updatePhotoProfile() {
|
||||
this.isLoading = true;
|
||||
return this.http.put('profile', {photo : this.userProfile.photo})
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getProfile()
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
console.log(this.userProfile);
|
||||
}
|
||||
|
||||
}
|
||||
118
src/common/stores/recipes.js
Normal file
118
src/common/stores/recipes.js
Normal file
@@ -0,0 +1,118 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class Recipes {
|
||||
|
||||
@observable list = [];
|
||||
@observable listItems = [];
|
||||
@observable selected = {};
|
||||
@observable istLoading = false;
|
||||
@observable isSearching = false;
|
||||
@observable filtered = [];
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
getList(){
|
||||
this.isLoading = true;
|
||||
return this.http.get("posts/by_tag/b0819754-fb35-4e52-be67-eb76ca80c5a4")
|
||||
.then(res => {
|
||||
this.list = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getItems(){
|
||||
this.isLoading = true;
|
||||
return this.http.get("my_store/items")
|
||||
.then(res => {
|
||||
console.log(res.data,'ini res items');
|
||||
this.listItems = res.data;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getDetail(id){
|
||||
this.isLoading = true;
|
||||
return this.http.get(`posts/${id}`)
|
||||
.then(res => {
|
||||
console.log(res,'ini res store')
|
||||
this.selected = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
post(data){
|
||||
this.isLoading = true;
|
||||
return this.http.post("posts", data)
|
||||
.then(res => {
|
||||
console.log('rest men',res);
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err,'err men')
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
put(id,data){
|
||||
this.isLoading = true;
|
||||
return this.http.put(`posts/${id}`, data)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
delete(id){
|
||||
this.isLoading = true;
|
||||
return this.http.delete(`posts/${id}`)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
filterItems = (query) => {
|
||||
return this.list.filter((el) =>
|
||||
el.title.toLowerCase().indexOf(query.toLowerCase()) > -1
|
||||
);
|
||||
}
|
||||
|
||||
@action
|
||||
search(text){
|
||||
this.filtered = this.filterItems(text);
|
||||
}
|
||||
}
|
||||
88
src/common/stores/reward.js
Normal file
88
src/common/stores/reward.js
Normal file
@@ -0,0 +1,88 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class Reward {
|
||||
|
||||
@observable rewardList = [];
|
||||
@observable selectedReward = '';
|
||||
@observable rewardListLoading = false;
|
||||
@observable postRewardLoading = false;
|
||||
@observable detailRewardLoading = false;
|
||||
@observable rewardId = '';
|
||||
@observable delRewardLoading = false;
|
||||
@observable putRewardLoading = false;
|
||||
@observable rewardData = {
|
||||
reward_per : '',
|
||||
reward_type : '',
|
||||
reward_value : '',
|
||||
active_till : '',
|
||||
id: '',
|
||||
name: ''
|
||||
};
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
@action
|
||||
getRewardList(){
|
||||
this.rewardListLoading = true;
|
||||
return this.http.get(`package_rewards`).then(res => {
|
||||
this.rewardList = res;
|
||||
this.rewardListLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@computed
|
||||
get isRewardEmpty() {
|
||||
if(this.rewardList.length > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@action
|
||||
getRewardDetail(id){
|
||||
this.rewardId = id;
|
||||
this.detailRewardLoading = true;
|
||||
return this.http.get(`package_rewards/${id}`).then(detail => {
|
||||
this.rewardData = detail[0];
|
||||
this.detailRewardLoading = false;
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@action
|
||||
postReward(){
|
||||
this.postRewardLoading = true;
|
||||
this.http.post('package_rewards', this.rewardData).then(res => {
|
||||
this.postRewardLoading = false;
|
||||
this.getRewardList();
|
||||
return res;
|
||||
})
|
||||
console.log(this.rewardData)
|
||||
}
|
||||
|
||||
@action
|
||||
putReward(id){
|
||||
this.putRewardLoading = true;
|
||||
this.http.put(`package_rewards/${id}`, this.rewardData).then(res => {
|
||||
this.getRewardList();
|
||||
return res;
|
||||
});
|
||||
console.log(this.rewardData)
|
||||
}
|
||||
|
||||
@action
|
||||
deleteReward(id){
|
||||
this.rewardId = id;
|
||||
this.delRewardLoading = true;
|
||||
this.http.delete(`package_rewards/${id}`).then(res => {
|
||||
this.delRewardLoading = false;
|
||||
// console.log(detail[0]);
|
||||
this.getRewardList();
|
||||
return res;
|
||||
})
|
||||
}
|
||||
}
|
||||
100
src/common/stores/roles.js
Normal file
100
src/common/stores/roles.js
Normal file
@@ -0,0 +1,100 @@
|
||||
import {observable, action, computed} from 'mobx';
|
||||
|
||||
export default class Roles {
|
||||
|
||||
@observable list = [];
|
||||
@observable selected = {};
|
||||
@observable istLoading = false;
|
||||
@observable isSearching = false;
|
||||
@observable filtered = [];
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
getList(){
|
||||
this.isLoading = true;
|
||||
return this.http.get("role")
|
||||
.then(res => {
|
||||
this.list = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getDetail(id){
|
||||
this.isLoading = true;
|
||||
return this.http.get(`role/${id}`)
|
||||
.then(res => {
|
||||
this.selected = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
post(data){
|
||||
this.isLoading = true;
|
||||
return this.http.post("role", data)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
put(id,data){
|
||||
this.isLoading = true;
|
||||
return this.http.put(`role/${id}`, data)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
delete(id){
|
||||
this.isLoading = true;
|
||||
return this.http.delete(`role/${id}`)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
filterItems = (query) => {
|
||||
return this.list.filter((el) =>
|
||||
el.name.toLowerCase().indexOf(query.toLowerCase()) > -1
|
||||
);
|
||||
}
|
||||
|
||||
@action
|
||||
search(text){
|
||||
this.filtered = this.filterItems(text);
|
||||
}
|
||||
|
||||
}
|
||||
34
src/common/stores/setting.js
Normal file
34
src/common/stores/setting.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import {observable, action, computed} from 'mobx';
|
||||
|
||||
export default class Setting {
|
||||
@observable data = {};
|
||||
@observable isLoading = false;
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
getAll() {
|
||||
this.isLoading = true;
|
||||
return this.http.get(`settings`).then(res => {
|
||||
this.data = res.value;
|
||||
this.isLoading = false;
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
put(data) {
|
||||
this.isLoading = true;
|
||||
return this.http.put(`settings`, data).then(res => {
|
||||
this.isLoading = false;
|
||||
this.getAll();
|
||||
return res;
|
||||
}).catch(err=>{
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
8
src/common/stores/shipping_method.js
Normal file
8
src/common/stores/shipping_method.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import { BaseStore } from "./base_store";
|
||||
|
||||
export class ShippingMethodStore extends BaseStore {
|
||||
constructor(context) {
|
||||
super(context);
|
||||
this.url = "shipping_method";
|
||||
}
|
||||
}
|
||||
99
src/common/stores/store_list.js
Normal file
99
src/common/stores/store_list.js
Normal file
@@ -0,0 +1,99 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class StoreList {
|
||||
|
||||
@observable list = [];
|
||||
@observable selected = {};
|
||||
@observable istLoading = false;
|
||||
@observable isSearching = false;
|
||||
@observable filtered = [];
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
getList(){
|
||||
this.isLoading = true;
|
||||
return this.http.get("stores")
|
||||
.then(res => {
|
||||
this.list = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getDetail(id){
|
||||
this.isLoading = true;
|
||||
return this.http.get(`stores/${id}`)
|
||||
.then(res => {
|
||||
this.selected = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
post(data){
|
||||
this.isLoading = true;
|
||||
return this.http.post("stores", data)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
put(id,data){
|
||||
this.isLoading = true;
|
||||
return this.http.put(`stores/${id}`, data)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
delete(id){
|
||||
this.isLoading = true;
|
||||
return this.http.delete(`stores/${id}`)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
filterItems = (query) => {
|
||||
return this.list.filter((el) =>
|
||||
el.name.toLowerCase().indexOf(query.toLowerCase()) > -1
|
||||
);
|
||||
}
|
||||
|
||||
@action
|
||||
search(text){
|
||||
this.filtered = this.filterItems(text);
|
||||
}
|
||||
}
|
||||
10
src/common/stores/stores.js
Normal file
10
src/common/stores/stores.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import {observable, action, computed} from 'mobx';
|
||||
|
||||
export default class Stores {
|
||||
@observable selectedTab = 'profile'
|
||||
|
||||
@action
|
||||
changeTab(value){
|
||||
this.selectedTab = value;
|
||||
}
|
||||
}
|
||||
103
src/common/stores/surf.js
Normal file
103
src/common/stores/surf.js
Normal file
@@ -0,0 +1,103 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class Surf {
|
||||
|
||||
@observable list = [];
|
||||
@observable selected = {};
|
||||
@observable istLoading = false;
|
||||
@observable isSearching = false;
|
||||
@observable filtered = [];
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
this.tagId= '4747ff80-6379-43eb-bf34-a4fbd733a593';
|
||||
}
|
||||
|
||||
@action
|
||||
getList(){
|
||||
this.isLoading = true;
|
||||
return this.http.get("posts/by_tag/"+this.tagId)
|
||||
.then(res => {
|
||||
this.list = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getDetail(id){
|
||||
this.isLoading = true;
|
||||
return this.http.get(`posts/${id}`)
|
||||
.then(res => {
|
||||
console.log(res,'ini res store')
|
||||
this.selected = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
post(data){
|
||||
this.isLoading = true;
|
||||
return this.http.post("posts", data)
|
||||
.then(res => {
|
||||
console.log('rest men',res);
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err,'err men')
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
put(id,data){
|
||||
this.isLoading = true;
|
||||
return this.http.put(`posts/${id}`, data)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
delete(id){
|
||||
this.isLoading = true;
|
||||
return this.http.delete(`posts/${id}`)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
this.getList();
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
filterItems = (query) => {
|
||||
return this.list.filter((el) =>
|
||||
el.title.toLowerCase().indexOf(query.toLowerCase()) > -1
|
||||
);
|
||||
}
|
||||
|
||||
@action
|
||||
search(text){
|
||||
this.filtered = this.filterItems(text);
|
||||
}
|
||||
}
|
||||
16
src/common/stores/tags.js
Normal file
16
src/common/stores/tags.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { BaseStore } from "./base_store";
|
||||
import {
|
||||
action,
|
||||
observable,
|
||||
computed
|
||||
} from 'mobx';
|
||||
export class Tags extends BaseStore {
|
||||
|
||||
|
||||
constructor(context) {
|
||||
super(context);
|
||||
this.url = 'tags';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
56
src/common/stores/task.js
Normal file
56
src/common/stores/task.js
Normal file
@@ -0,0 +1,56 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class Task {
|
||||
@observable data = [];
|
||||
@observable isLoading = false;
|
||||
@observable isSearching = false;
|
||||
@observable taskId = '';
|
||||
@observable filterBy = 'all';
|
||||
@observable selectedData = {};
|
||||
// @observable taskData = {};
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
@action
|
||||
changeFilterBy(v){
|
||||
this.filterBy = v;
|
||||
}
|
||||
@action
|
||||
getAll() {
|
||||
this.isLoading = true;
|
||||
return this.http.get("tasks")
|
||||
.then(res => {
|
||||
this.data = res.data;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getDetail(id) {
|
||||
this.isLoading = true;
|
||||
return this.http.get("tasks/"+id)
|
||||
.then(res => {
|
||||
this.selectedData = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@computed
|
||||
get isEmpty(){
|
||||
if(this.tasks.length > 0){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
152
src/common/stores/transaction.js
Normal file
152
src/common/stores/transaction.js
Normal file
@@ -0,0 +1,152 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
export default class Transaction {
|
||||
@observable isLoading = false;
|
||||
@observable list = [];
|
||||
@observable transactionListFiltered = [];
|
||||
@observable transactionList = [
|
||||
{
|
||||
id : '47efc62f-fb69-427a-9a12-51eac2c45e75',
|
||||
payment_proof : '',
|
||||
amount : '500000',
|
||||
status : 'Waiting Approval',
|
||||
transaction_id: '47efc62f-fb69-427a-9a12-51eac2c45e75',
|
||||
user_id: '47efc62f-fb69-427a-9a12-51eac2c45e75',
|
||||
approver_user_id:'',
|
||||
type: 'Withdraw',
|
||||
bank_account_number : 'T3ST4J4',
|
||||
bank_name : 'BCA',
|
||||
reject_reason : '',
|
||||
bank_behalf_of : 'Sunshine Store',
|
||||
bank_to: 'Admin Martketplace',
|
||||
user : {
|
||||
username : 'sunshine',
|
||||
email : 'store@marketplace.com',
|
||||
}
|
||||
}
|
||||
];
|
||||
@observable detail = {
|
||||
"payment_proof": "",
|
||||
"amount": "",
|
||||
"status": "",
|
||||
account:{
|
||||
id: '',
|
||||
name : '',
|
||||
},
|
||||
"approver_user_id": null,
|
||||
"bank_account_number": "",
|
||||
"bank_name": "",
|
||||
"reject_reason": null,
|
||||
"bank_behalf_of": "",
|
||||
"bank_to": {
|
||||
"name": "",
|
||||
"account_number": "",
|
||||
"on_behalf": ""
|
||||
},
|
||||
"type": "",
|
||||
created_at :'',
|
||||
transaction : {
|
||||
id : '',
|
||||
status : '',
|
||||
amount : '',
|
||||
created_at : '',
|
||||
}
|
||||
};
|
||||
@observable saldo = [
|
||||
{
|
||||
amount : 0
|
||||
},{
|
||||
amount : 0
|
||||
}];
|
||||
@observable wallet ={
|
||||
pending_payment_to_wallet : 0,
|
||||
balance : 0
|
||||
}
|
||||
|
||||
constructor(context) {
|
||||
this.context = context;
|
||||
this.http = context.http;
|
||||
}
|
||||
|
||||
@action
|
||||
reset(){
|
||||
this.detail = {
|
||||
"payment_proof": "",
|
||||
"amount": "",
|
||||
"status": "",
|
||||
account:{
|
||||
id: '',
|
||||
name : '',
|
||||
},
|
||||
"approver_user_id": null,
|
||||
"bank_account_number": "",
|
||||
"bank_name": "",
|
||||
"reject_reason": null,
|
||||
"bank_behalf_of": "",
|
||||
"bank_to": {
|
||||
"name": "",
|
||||
"account_number": "",
|
||||
"on_behalf": ""
|
||||
},
|
||||
"type": "",
|
||||
created_at :'',
|
||||
transaction : {
|
||||
id : '',
|
||||
status : '',
|
||||
amount : '',
|
||||
created_at : '',
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// @action
|
||||
// getAll() {
|
||||
// this.isLoading = true;
|
||||
// return this.http.get("transaction")
|
||||
// .then(res => {
|
||||
// this.isLoading = false;
|
||||
// this.list = res;
|
||||
// })
|
||||
// }
|
||||
|
||||
@action
|
||||
getAll() {
|
||||
this.isLoading = true;
|
||||
return this.http.get("transaction")
|
||||
.then(res => {
|
||||
this.list = res;
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getAmount(){
|
||||
return this.http.get(`wallet`).then(res => {
|
||||
this.wallet = res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
getById(id) {
|
||||
this.isLoading = true;
|
||||
return this.http.get(`transaction/${id}`).then(res => {
|
||||
this.detail = res;
|
||||
this.isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
filterItems = (query) => {
|
||||
return this.transactionList.filter((el) =>
|
||||
el.user.email.toLowerCase().indexOf(query.toLowerCase()) > -1
|
||||
);
|
||||
}
|
||||
|
||||
@action
|
||||
search(text){
|
||||
// var a = _.filter(this.tasks,function(o){return _.includes(o,text)});
|
||||
this.transactionListFiltered = this.filterItems(text);
|
||||
}
|
||||
}
|
||||
40
src/common/stores/transportationStore.js
Normal file
40
src/common/stores/transportationStore.js
Normal file
@@ -0,0 +1,40 @@
|
||||
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;
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
98
src/common/stores/user.js
Normal file
98
src/common/stores/user.js
Normal file
@@ -0,0 +1,98 @@
|
||||
import {observable, action, computed} from 'mobx';
|
||||
|
||||
export default class User {
|
||||
|
||||
@observable userGeolocation = {
|
||||
ip: "",
|
||||
country_code: "",
|
||||
country_name: "",
|
||||
region_code: "",
|
||||
region_name: "",
|
||||
city: "",
|
||||
zip_code: "",
|
||||
time_zone: "",
|
||||
latitude: "",
|
||||
longitude: "",
|
||||
metro_code: "",
|
||||
timezone_city: ""
|
||||
};
|
||||
@observable userList = [];
|
||||
@observable postDataAdmin = {
|
||||
name: '',
|
||||
phone_number: '',
|
||||
email: '',
|
||||
address: '',
|
||||
id: '',
|
||||
created_at: '',
|
||||
user_id: '',
|
||||
};
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
getUserGeolocation() {
|
||||
fetch('https://freegeoip.net/json/', {headers: {}}).then((res) => {
|
||||
return res.json();
|
||||
}).then((data) => {
|
||||
this.userGeolocation = data;
|
||||
this.userGeolocation.timezone_city = (data.time_zone) ? data.time_zone.split('/')[1] : data.time_zone;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
getAllUser() {
|
||||
this.http.get(`agents`).then(res => {
|
||||
res.map(item => {
|
||||
item.role = "Agent";
|
||||
});
|
||||
this.userList = res;
|
||||
});
|
||||
this.http.get(`customers`).then(res => {
|
||||
res.map(item => {
|
||||
item.role = "Customer";
|
||||
this.userList.push(item);
|
||||
});
|
||||
});
|
||||
this.http.get(`admins`).then(res => {
|
||||
res.map(item => {
|
||||
item.role = "Admin";
|
||||
this.userList.push(item);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// @action
|
||||
// postCustomer(){
|
||||
// this.http.post(`customers`, this.postData).then(res => {
|
||||
// return res;
|
||||
// });
|
||||
// this.postData = {};
|
||||
// }
|
||||
|
||||
// @action
|
||||
// postAgent(){
|
||||
// this.http.post(`agents`, this.postData).then(res => {
|
||||
// return res;
|
||||
// });
|
||||
// this.postData = {};
|
||||
// }
|
||||
|
||||
@action
|
||||
postAdmin() {
|
||||
return this.http.post(`admins`, this.postDataAdmin).then(res => {
|
||||
return res;
|
||||
});
|
||||
}
|
||||
|
||||
@computed
|
||||
get isUserEmpty() {
|
||||
if (this.userList.length > 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
152
src/common/stores/user_address.js
Normal file
152
src/common/stores/user_address.js
Normal file
@@ -0,0 +1,152 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
import {
|
||||
MenuItem
|
||||
} from 'material-ui';
|
||||
import React from 'react';
|
||||
export default class UserAddress {
|
||||
|
||||
@observable address = [];
|
||||
@observable provinces = [];
|
||||
@observable cities = [];
|
||||
@observable geoData = {
|
||||
geoaddress : null,
|
||||
lat : null,
|
||||
lng : null
|
||||
};
|
||||
|
||||
@observable searchValue = "";
|
||||
@observable autocompleteData = new Array();
|
||||
autocompleteService = new google.maps.places.AutocompleteService();
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.globalUI = context.globalUI;
|
||||
this.context = context;
|
||||
}
|
||||
@action resetCities(){
|
||||
this.cities = [];
|
||||
}
|
||||
|
||||
@action searchPlaces(value){
|
||||
this.searchValue = value;
|
||||
|
||||
if(!value) {
|
||||
this.searchValue = '';
|
||||
this.autocompleteData = [];
|
||||
return;
|
||||
}
|
||||
|
||||
this.autocompleteService.getPlacePredictions({input: value}, (predictions, status) => {
|
||||
if (status === 'OK' && predictions && predictions.length > 0) {
|
||||
// console.log(predictions);
|
||||
this.autocompleteData = predictions.map(data => ({
|
||||
type: 'google',
|
||||
text: data.description,
|
||||
main_text: data.structured_formatting.main_text,
|
||||
secondary_text: data.structured_formatting.secondary_text,
|
||||
place_id: data.place_id,
|
||||
value: (<MenuItem anchorOrigin={{horizontal: 'left', vertical: 'center'}} innerDivStyle={{fontSize:12}} primaryText={<div className="primaryTextListMap"><span style={{fontWeight:600}}>{data.structured_formatting.main_text}</span>, <span >{data.structured_formatting.secondary_text}</span></div>}/>)
|
||||
}));
|
||||
// this.props.onOpen(predictions);
|
||||
// console.log(predictions);
|
||||
} else {
|
||||
// this.props.onClose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
getProvinces(){
|
||||
return this.http.get(`provinces`).then(res=>{
|
||||
this.provinces = res;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getCities(province_id){
|
||||
return this.http.get(`cities?province_id=${province_id}`).then(res=>{
|
||||
this.cities = res;
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getAllAddress(){
|
||||
this.globalUI.openLoading();
|
||||
return this.http.get(`user_address`).then(res=>{
|
||||
this.address = res;
|
||||
this.globalUI.closeLoading();
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getAllAddressAdmin(id){
|
||||
this.globalUI.openLoading();
|
||||
return this.http.get(`user_address?user_store_id=${id}`).then(res=>{
|
||||
this.address = res;
|
||||
this.globalUI.closeLoading();
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
addAddress(data){
|
||||
this.globalUI.openLoading();
|
||||
return this.http.post(`user_address`,data).then(res=>{
|
||||
this.getAllAddress();
|
||||
this.globalUI.closeLoading();
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
addAddressAdmin(store_id,data){
|
||||
this.globalUI.openLoading();
|
||||
return this.http.post(`user_address?user_store_id=${store_id}`,data).then(res=>{
|
||||
this.getAllAddressAdmin(store_id);
|
||||
this.globalUI.closeLoading();
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
updateAddress(data){
|
||||
|
||||
this.globalUI.openLoading();
|
||||
return this.http.put(`user_address/${data.id}`,data).then(res=>{
|
||||
this.getAllAddress();
|
||||
this.globalUI.closeLoading();
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
updateAddressAdmin(store_id,data){
|
||||
|
||||
this.globalUI.openLoading();
|
||||
return this.http.put(`user_address/${data.id}?user_store_id=${store_id}`,data).then(res=>{
|
||||
this.getAllAddressAdmin(store_id);
|
||||
this.globalUI.closeLoading();
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
deletedAddress(id){
|
||||
this.globalUI.openLoading();
|
||||
return this.http.delete(`user_address/${id}`).then(res=>{
|
||||
this.getAllAddress();
|
||||
this.globalUI.closeLoading();
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
deletedAddressAdmin(store_id,id){
|
||||
this.globalUI.openLoading();
|
||||
return this.http.delete(`user_address/${id}/?user_store_id=${store_id}`).then(res=>{
|
||||
this.getAllAddressAdmin(store_id);
|
||||
this.globalUI.closeLoading();
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
setGeoData(data){
|
||||
this.geoData = data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
71
src/common/stores/user_banks.js
Normal file
71
src/common/stores/user_banks.js
Normal file
@@ -0,0 +1,71 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
|
||||
export default class UserBanks {
|
||||
|
||||
@observable banks = [];
|
||||
@observable isLoading = false;
|
||||
@observable bankId = '';
|
||||
|
||||
constructor(context) {
|
||||
this.http = context.http;
|
||||
this.globalUI = context.globalUI;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@action
|
||||
getAllBanks(){
|
||||
this.globalUI.openLoading();
|
||||
return this.http.get(`user_banks`).then(res=>{
|
||||
this.banks = res;
|
||||
this.globalUI.closeLoading();
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
getAllBanksAdmin(id){
|
||||
this.globalUI.openLoading();
|
||||
return this.http.get(`user_banks?user_store_id=${id}`).then(res=>{
|
||||
this.banks = res;
|
||||
this.globalUI.closeLoading();
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
addBank(data){
|
||||
this.globalUI.openLoading();
|
||||
return this.http.post(`user_banks`,data).then(res=>{
|
||||
this.getAllBanks();
|
||||
this.globalUI.closeLoading();
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
addBankAdmin(id,data){
|
||||
this.globalUI.openLoading();
|
||||
return this.http.post(`user_banks?user_store_id=${id}`,data).then(res=>{
|
||||
this.getAllBanksAdmin(id);
|
||||
this.globalUI.closeLoading();
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
updateBank(data){
|
||||
|
||||
this.globalUI.openLoading();
|
||||
return this.http.put(`user_banks/${data.id}`,data).then(res=>{
|
||||
this.getAllBanks();
|
||||
this.globalUI.closeLoading();
|
||||
})
|
||||
}
|
||||
|
||||
@action
|
||||
updateBankAdmin(store_id,data){
|
||||
this.globalUI.openLoading();
|
||||
return this.http.put(`user_banks/${data.id}?user_store_id=${store_id}`,data).then(res=>{
|
||||
this.getAllBanksAdmin(store_id);
|
||||
this.globalUI.closeLoading();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
33
src/common/stores/withdraw.js
Normal file
33
src/common/stores/withdraw.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import { observable, action, computed } from 'mobx';
|
||||
export default class WithdrawStore {
|
||||
@observable isLoading = false;
|
||||
@observable data = {
|
||||
amount: '',
|
||||
bank_account_number: '',
|
||||
bank_name: '',
|
||||
destination_user_bank_id : ''
|
||||
};
|
||||
@observable bank = {
|
||||
name: '',
|
||||
account_number: ''
|
||||
}
|
||||
|
||||
constructor(context) {
|
||||
this.context = context;
|
||||
this.http = context.http;
|
||||
}
|
||||
|
||||
@action
|
||||
createWithdraw() {
|
||||
this.isLoading = true;
|
||||
return this.http.post("withdraw/create", this.data)
|
||||
.then(res => {
|
||||
this.isLoading = false;
|
||||
return res;
|
||||
})
|
||||
.catch(err => {
|
||||
this.isLoading = false;
|
||||
throw err;
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user