import BaseRepository from '@/repositories/BaseRepository' ; import store from '@/store' ; import { APIClient } from '@/network/APIClient' ; import { ProductAPI } from '@/network/api/Product' ; import { StoreItems , StoreItem , ClearItems , ClearItem } from '@/store/modules/product/types' ; import { IProduct , IProductsCriteria } from '@/entities/Product' ; export default class ProductRepository implements BaseRepository { constructor ( ) { } async fetchItem ( id ) { return await APIClient . shared . request ( new ProductAPI . GetProduct ( id ) ) ; } saveItem ( item ) { store . commit ( new StoreItem ( item ) ) ; } clearItem ( ) { store . commit ( new ClearItem ( ) ) ; } getItem ( ) { return store . state . product . item ; } async fetchItems ( params ) { return await APIClient . shared . request ( new ProductAPI . GetProducts ( params ) ) ; } saveItems ( params ) { store . commit ( new StoreItems ( params ) ) ; } clearItems ( ) { store . commit ( new ClearItems ( ) ) ; } getItems ( ) { return store . state . product . items ; } }