This commit is contained in:
2021-12-15 18:32:42 +07:00
7 changed files with 227 additions and 136 deletions

View File

@@ -12,11 +12,14 @@ export class Membership {
makeAutoObservable(this);
}
@action
async getData() {
const response = await http.get(`/users?page=${this.page}&pageSize=${this.pageSize}`);
console.log(response)
this.data = response.body.data ?? []
this.data = response.body.data.map((item, idx) => {
item.key = idx;
return item
}) ?? []
this.total_data = response.body.total_data ?? 0
}
// async getData() {
@@ -25,12 +28,10 @@ export class Membership {
// this.total_data = response.body.total_data ?? 0
// }
@action
async create(data) {
return await http.post('/users').send(data)
}
@action
async update(id, data) {
// console.log(data)
// console.log(id)
@@ -44,6 +45,12 @@ export class Membership {
return await http.del('/users/' + id);
}
async changeStatus(id, status) {
const response = await http.get(`/users/${id}/${status}`);
await this.getData();
return response;
}
}

View File

@@ -26,8 +26,12 @@ export class Partner {
async getData() {
const response = await http.get(`/users/partner?page=${this.page}&pageSize=${this.pageSize}`);
this.data = response.body.data ?? []
//console.log(response.body,"ini dari store")
this.data = response.body.data.map((item, idx) => {
item.key = idx;
return item
}) ?? []
this.total_data = response.body.count ?? 0
}
@@ -55,6 +59,11 @@ export class Partner {
return response;
}
async changeStatus(id, status) {
const response = await http.get(`/users/partner/${id}/${status}`);
await this.getData();
return response;
}
}

View File

@@ -37,7 +37,10 @@ export class Product {
async getDataSubCategories() {
const response = await http.get(`/product/sub-categories?page=${this.pageSubCategories}&pageSize=${this.pageSizeSubCategories}`);
this.dataSubCategories = response.body.data ?? []
this.dataSubCategories = response.body.data.map((item, idx) => {
item.key = idx;
return item
}) ?? []
this.total_dataSubCategories = response.body.count ?? 0
}
@@ -46,9 +49,15 @@ export class Product {
this.dataCategories = response.body.data ?? []
this.total_dataCategories = response.body.total_data ?? 0
if (this.dataCategories.length > 0) {
this.filterCategory = this.dataCategories[0].id
}
this.dataCategories = this.dataCategories.map((item, idx) => {
item.key = idx;
return item
}) ?? []
}
async create(data) {