Skip to content

Commit

Permalink
refactor: composable errors type
Browse files Browse the repository at this point in the history
  • Loading branch information
Fifciuu committed Dec 22, 2020
1 parent 5aa4608 commit 64ad67a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/core/core/src/factories/useCartFactory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CustomQuery, UseCart, Context, FactoryParams } from '../types';
import { CustomQuery, UseCart, Context, FactoryParams, ComposableErrors } from '../types';
import { Ref, computed } from '@vue/composition-api';
import { sharedRef, Logger, generateContext } from '../utils';

Expand Down Expand Up @@ -34,7 +34,7 @@ export const useCartFactory = <CART, CART_ITEM, PRODUCT, COUPON>(
const loading: Ref<boolean> = sharedRef(false, 'useCart-loading');
const cart: Ref<CART> = sharedRef(null, 'useCart-cart');
const context = generateContext(factoryParams);
const error: Ref<Record<string, Error>> = sharedRef({}, 'useCart-error');
const error: Ref<ComposableErrors> = sharedRef({}, 'useCart-error');

const setCart = (newCart: CART) => {
cart.value = newCart;
Expand Down
4 changes: 3 additions & 1 deletion packages/core/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export type CustomQuery<T = any> = (query: any, variables: T) => {
variables?: T;
};

export type ComposableErrors = Record<string, Error>;

export interface ProductsSearchParams {
perPage?: number;
page?: number;
Expand Down Expand Up @@ -167,7 +169,7 @@ export interface UseCart
removeCoupon(params: { coupon: COUPON; customQuery?: CustomQuery }): Promise<void>;
load(): Promise<void>;
load(params: { customQuery?: CustomQuery }): Promise<void>;
error: ComputedProperty<Record<string, Error>>;
error: ComputedProperty<ComposableErrors>;
loading: ComputedProperty<boolean>;
}

Expand Down

0 comments on commit 64ad67a

Please sign in to comment.