feat: register connect to backend
This commit is contained in:
@@ -60,6 +60,7 @@ import Vouchers from './vouchers';
|
||||
import {PurchasedItemStore} from "./purchased_item";
|
||||
import WalletStore from "./wallet";
|
||||
import {PurchasedItemVouchserStore} from "./purchased_item_voucher";
|
||||
import {PlaceStore} from "./place";
|
||||
|
||||
export default class AppState {
|
||||
http = new Http(this.token);
|
||||
@@ -122,6 +123,8 @@ export default class AppState {
|
||||
wallet = new WalletStore(this);
|
||||
purchased_voucher = new PurchasedItemVouchserStore(this);
|
||||
|
||||
places = new PlaceStore(this);
|
||||
|
||||
constructor(initialState) {
|
||||
this.token = initialState.token;
|
||||
this.http.token = this.token;
|
||||
@@ -133,7 +136,7 @@ export default class AppState {
|
||||
this.user.getUserGeolocation();
|
||||
}
|
||||
}
|
||||
if(this.token) {
|
||||
if (this.token) {
|
||||
this.loadDataAfterLogin();
|
||||
}
|
||||
}
|
||||
@@ -178,4 +181,4 @@ export default class AppState {
|
||||
|
||||
return tokenData;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -106,7 +106,7 @@ export class Authentication {
|
||||
@action
|
||||
register(data) {
|
||||
this.isRegistering = true;
|
||||
return this.http.post("register", data)
|
||||
return this.http.post("authentication/register", data)
|
||||
.then(res => {
|
||||
this.isRegistering = false;
|
||||
return res;
|
||||
|
||||
45
src/common/stores/place.js
Normal file
45
src/common/stores/place.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import {observable, action, computed} from 'mobx';
|
||||
|
||||
export class PlaceStore {
|
||||
@observable provinces = [];
|
||||
@observable cities = [];
|
||||
@observable districts = [];
|
||||
@observable subdistricts = [];
|
||||
|
||||
constructor(context) {
|
||||
this.context = context;
|
||||
this.http = context.http;
|
||||
}
|
||||
|
||||
@action
|
||||
getAllProvince() {
|
||||
return this.http.get("places/provinces")
|
||||
.then(res => {
|
||||
this.provinces = res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
getCitiesByProvince(provinceId) {
|
||||
return this.http.get(`places/city?province_id=${provinceId}`)
|
||||
.then(res => {
|
||||
this.cities = res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
getDistrictByCity(cityId) {
|
||||
return this.http.get(`places/district?city_id=${cityId}`)
|
||||
.then(res => {
|
||||
this.districts = res;
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
getSubdistrictByDistrict(districtId) {
|
||||
return this.http.get(`places/subdistrict?district_id=${districtId}`)
|
||||
.then(res => {
|
||||
this.subdistricts = res;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user