import { IProduct } from '@/entities/Product' ; import store from '@/store' ; import { AddItem , SetCheckingOut , ClearItems } from '@/store/modules/cart/types' ; import CartRepository from '@/repositories/CartRepository' ; export interface ICartItem extends IProduct { checkoutPrice : number ; } export interface ICart { items : ICartItem [ ] ; } export class CartEntity { constructor ( ) { } addItemToCart ( item ) { const checkoutPrice = item . price * 1.08 ; const cartItem = { ... item , checkoutPrice } ; store . commit ( new AddItem ( cartItem ) ) ; } async checkOut ( ) { store . commit ( new SetCheckingOut ( true ) ) ; setTimeout ( ( ) => { store . commit ( new ClearItems ( ) ) ; store . commit ( new SetCheckingOut ( false ) ) ; } , 2000 ) ; return ; } }