Pages Product
This commit is contained in:
		
							
								
								
									
										40
									
								
								src/store/categories.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/store/categories.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| import {action, makeAutoObservable} from "mobx"; | ||||
| import {http} from "../utils/http"; | ||||
|  | ||||
| export class Categories { | ||||
|     page = 0; | ||||
|     pageSize = 10 | ||||
|     data = []; | ||||
|     total_data = 0 | ||||
|  | ||||
|     constructor(ctx) { | ||||
|         this.ctx = ctx; | ||||
|         makeAutoObservable(this); | ||||
|     } | ||||
|  | ||||
|     @action | ||||
|     async getData() { | ||||
|         const response = await http.get(`/product/sub-categories?page=${this.page}&pageSize=${this.pageSize}`); | ||||
|         console.log(response,'Data cate') | ||||
|         console.log(JSON.stringify(response.body.data),'Data') | ||||
|          | ||||
|         this.data = response.body.data ?? [] | ||||
|         this.total_data = response.body.total_data ?? 0 | ||||
|     } | ||||
|  | ||||
|     @action | ||||
|     async create(data) { | ||||
|         return await http.post('/user').send(data) | ||||
|     } | ||||
|  | ||||
|     @action | ||||
|     async update(id, data) { | ||||
|         return await http.put('/user/' + id).send(data); | ||||
|     } | ||||
|  | ||||
|     async delete(id) { | ||||
|         return await http.del('/product/' + id); | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -2,12 +2,16 @@ import {UI} from "./ui"; | ||||
| import {Authentication} from "./authentication"; | ||||
| import {User} from "./user"; | ||||
| import {Membership} from "./membership"; | ||||
| import {Product} from "./product"; | ||||
| import {Categories} from "./categories"; | ||||
|  | ||||
| export class Store { | ||||
|     ui = new UI(this); | ||||
|     authentication = new Authentication(this); | ||||
|     user = new User(this); | ||||
|     membership = new Membership(this); | ||||
|     product = new Product(this); | ||||
|     categories = new Categories(this); | ||||
|  | ||||
|     constructor() { | ||||
|     } | ||||
|   | ||||
							
								
								
									
										40
									
								
								src/store/product.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/store/product.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| import {action, makeAutoObservable} from "mobx"; | ||||
| import {http} from "../utils/http"; | ||||
|  | ||||
| export class Product { | ||||
|     page = 0; | ||||
|     pageSize = 10 | ||||
|     data = []; | ||||
|     total_data = 0 | ||||
|  | ||||
|     constructor(ctx) { | ||||
|         this.ctx = ctx; | ||||
|         makeAutoObservable(this); | ||||
|     } | ||||
|  | ||||
|     @action | ||||
|     async getData() { | ||||
|         const response = await http.get(`/product?page=${this.page}&pageSize=${this.pageSize}`); | ||||
|         console.log(response,'Data') | ||||
|         console.log(JSON.stringify(response.body.data),'Data') | ||||
|          | ||||
|         this.data = response.body.data ?? [] | ||||
|         this.total_data = response.body.total_data ?? 0 | ||||
|     } | ||||
|  | ||||
|     @action | ||||
|     async create(data) { | ||||
|         return await http.post('/product').send(data) | ||||
|     } | ||||
|  | ||||
|     @action | ||||
|     async update(id, data) { | ||||
|         return await http.put('/user/' + id).send(data); | ||||
|     } | ||||
|  | ||||
|     async delete(id) { | ||||
|         return await http.del('/product/' + id); | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -6,7 +6,7 @@ export class User { | ||||
|  | ||||
|     @action | ||||
|     async getData() { | ||||
|         this.data = (await http.get('/user')).body.data; | ||||
|         this.data = (await http.get('/product')).body.data; | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user