diff --git a/src/store/category.js b/src/store/category.js index 3804881..272bfd9 100644 --- a/src/store/category.js +++ b/src/store/category.js @@ -23,10 +23,10 @@ export class Category { try { const response = await http.get(`/product/categories?page=${this.page}&pageSize=${this.pageSize}`); this.data = response.body.data.map((item, idx) => { - item.key = idx; - return item - }) ?? [] - this.total_data = response.body.total_data ?? 0 + item.key = idx; + return item + }) ?? [] + this.total_data = response?.body?.count ?? 0 } catch (e) { console.log(e); } @@ -55,7 +55,7 @@ export class Category { return item }) ?? [] - this.total_dataCategories = response.body.total_data ?? 0 + this.total_dataCategories = response?.body?.count ?? 0 if (this.dataCategories.length > 0) { this.filterCategory = this.dataCategories[0].id } diff --git a/src/store/commission.js b/src/store/commission.js index a613c2f..41894f8 100644 --- a/src/store/commission.js +++ b/src/store/commission.js @@ -32,7 +32,7 @@ export class Commission { return item }) ?? [] - this.total_data = response.body.total_data ?? 0 + this.total_data = response?.body?.count ?? 0 } catch (e) { console.error(e); } diff --git a/src/store/membership.js b/src/store/membership.js index 80046dd..0afded7 100644 --- a/src/store/membership.js +++ b/src/store/membership.js @@ -23,7 +23,7 @@ export class Membership { return item }) ?? [] - this.total_data = response.body.total_data ?? 0 + this.total_data = response?.body?.count ?? 0 } catch (e) { console.error(e); } @@ -40,7 +40,7 @@ export class Membership { return item }) ?? [] - this.total_data = response.body.total_data ?? 0 + this.total_data = response?.body?.count ?? 0 } catch (e) { console.error(e); } diff --git a/src/store/payback.js b/src/store/payback.js index 1c36900..c616825 100644 --- a/src/store/payback.js +++ b/src/store/payback.js @@ -1,5 +1,5 @@ -import { makeAutoObservable } from "mobx"; -import { http } from "../utils/http"; +import {makeAutoObservable} from "mobx"; +import {http} from "../utils/http"; export class Payback { page = 0; @@ -36,7 +36,7 @@ export class Payback { return item; }) ?? []; - this.total_data = response.body.total_data ?? 0; + this.total_data = response?.body?.count ?? 0; } catch (e) { console.error(e); } @@ -54,7 +54,7 @@ export class Payback { return item; }) ?? []; - this.total_data = response.body.total_data ?? 0; + this.total_data = response?.body?.count ?? 0; } catch (e) { console.error(e); } diff --git a/src/store/product.js b/src/store/product.js index f60eb86..e03b223 100644 --- a/src/store/product.js +++ b/src/store/product.js @@ -36,7 +36,7 @@ export class Product { return item }) ?? [] - this.total_data = response.body.total_data ?? 0 + this.total_data = response?.body?.count ?? 0 } catch (e) { console.error(e); } diff --git a/src/store/role.js b/src/store/role.js index 28b027d..f5607f0 100644 --- a/src/store/role.js +++ b/src/store/role.js @@ -1,5 +1,5 @@ -import { makeAutoObservable } from "mobx"; -import { http } from "../utils/http"; +import {makeAutoObservable} from "mobx"; +import {http} from "../utils/http"; export class Role { page = null; @@ -20,7 +20,7 @@ export class Role { }&pageSize=${this.pageSize}` ); this.data = response.body.data ?? []; - this.total_data = response.body.total_data ?? 0; + this.total_data = response?.body?.count ?? 0; } catch (e) { console.error(e); } diff --git a/src/store/subcategory.js b/src/store/subcategory.js index 8268179..0ffb7c0 100644 --- a/src/store/subcategory.js +++ b/src/store/subcategory.js @@ -33,7 +33,7 @@ export class Subcategory { return item }) ?? [] - this.total_data = response.body.total_data ?? 0 + this.total_data = response?.body?.count ?? 0 } catch (e) { console.error(e); } diff --git a/src/store/transaction.js b/src/store/transaction.js index f2c0dc9..410e049 100644 --- a/src/store/transaction.js +++ b/src/store/transaction.js @@ -35,7 +35,7 @@ export class Transaction { try { const response = await http.get(`/product/by-categories-all?sub-category=${this.filterSubCategory}&page=${this.page}&pageSize=${this.pageSize}`); this.data = response.body.data ?? [] - this.total_data = response.body.total_data ?? 0 + this.total_data = response?.body?.count ?? 0 } catch (e) { console.error(e); } @@ -56,7 +56,7 @@ export class Transaction { const response = await http.get(`/product/categories?page=${this.pageCategories}&pageSize=${this.pageSizeCategories}`); this.dataCategories = response.body.data ?? [] - this.total_dataCategories = response.body.total_data ?? 0 + this.total_dataCategories = response?.body?.count ?? 0 if (this.dataCategories.length > 0) { this.filterCategory = this.dataCategories[0].id } @@ -70,7 +70,7 @@ export class Transaction { const response = await http.get(`/transaction/history?page=${this.pageHistoryTransaction}`); this.dataHistoryTransaction = response.body.data ?? [] - this.total_dataHistoryTransaction = response.body.total_data ?? 0 + this.total_dataHistoryTransaction = response?.body?.count ?? 0 } catch (e) { console.error(e); }