Skip to content

Commit

Permalink
Merge d6e53aa into a7fd035
Browse files Browse the repository at this point in the history
  • Loading branch information
filipsobol authored Jan 11, 2021
2 parents a7fd035 + d6e53aa commit 4bf8b31
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
15 changes: 6 additions & 9 deletions packages/boilerplate/composables/src/useCart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,32 @@

import {
Context,
CustomQuery,
useCartFactory,
UseCartFactoryParams
} from '@vue-storefront/core';
import { Cart, CartItem, Coupon, Product } from '../types';

// @todo: implement cart

const params: UseCartFactoryParams<Cart, CartItem, Product, Coupon> = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
load: async (context: Context) => {
load: async (context: Context, { customQuery }) => {
console.log('Mocked: loadCart');
return {};
},

// eslint-disable-next-line @typescript-eslint/no-unused-vars
addItem: async (context: Context, { currentCart, product, quantity }, customQuery?: CustomQuery) => {
addItem: async (context: Context, { currentCart, product, quantity, customQuery }) => {
console.log('Mocked: addToCart');
return {};
},

// eslint-disable-next-line @typescript-eslint/no-unused-vars
removeItem: async (context: Context, { currentCart, product }, customQuery?: CustomQuery) => {
removeItem: async (context: Context, { currentCart, product, customQuery }) => {
console.log('Mocked: removeFromCart');
return {};
},

// eslint-disable-next-line @typescript-eslint/no-unused-vars
updateItemQty: async (context: Context, { currentCart, product, quantity }, customQuery?: CustomQuery) => {
updateItemQty: async (context: Context, { currentCart, product, quantity, customQuery }) => {
console.log('Mocked: updateQuantity');
return {};
},
Expand All @@ -42,13 +39,13 @@ const params: UseCartFactoryParams<Cart, CartItem, Product, Coupon> = {
},

// eslint-disable-next-line @typescript-eslint/no-unused-vars
applyCoupon: async (context: Context, { currentCart, couponCode }, customQuery?: CustomQuery) => {
applyCoupon: async (context: Context, { currentCart, couponCode, customQuery }) => {
console.log('Mocked: applyCoupon');
return {updatedCart: {}, updatedCoupon: {}};
},

// eslint-disable-next-line @typescript-eslint/no-unused-vars
removeCoupon: async (context: Context, { currentCart, coupon }, customQuery?: CustomQuery) => {
removeCoupon: async (context: Context, { currentCart, coupon, customQuery }) => {
console.log('Mocked: removeCoupon');
return {updatedCart: {}};
},
Expand Down
7 changes: 4 additions & 3 deletions packages/boilerplate/composables/src/useCategory/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import {
Context,
CustomQuery,
useCategoryFactory,
UseCategoryFactoryParams
} from '@vue-storefront/core';
import { Category } from '../types';

const params: UseCategoryFactoryParams<Category, any> = {
categorySearch: async (context: Context, params, customQuery?: CustomQuery) => {
return await context.$boilerplate.api.getCategory(params, customQuery);
categorySearch: async (context: Context, params) => {
const { customQuery, ...searchParams } = params;

return await context.$boilerplate.api.getCategory(searchParams, customQuery);
}
};

Expand Down
4 changes: 2 additions & 2 deletions packages/boilerplate/composables/src/useFacet/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Context, useFacetFactory } from '@vue-storefront/core';
import { Context, useFacetFactory, FacetSearchResult } from '@vue-storefront/core';

const factoryParams = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
search: async (context: Context, params) => {
search: async (context: Context, params: FacetSearchResult<any>) => {
console.log('Mocked: searchFacet');
return {};
}
Expand Down
7 changes: 4 additions & 3 deletions packages/boilerplate/composables/src/useProduct/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import {
Context,
CustomQuery,
useProductFactory,
ProductsSearchParams,
UseProductFactoryParams
} from '@vue-storefront/core';
import { ProductsResponse } from '../types';

const params: UseProductFactoryParams<ProductsResponse, any> = {
productsSearch: async (context: Context, params: ProductsSearchParams, customQuery?: CustomQuery): Promise<ProductsResponse> => {
return await context.$boilerplate.api.getProduct(params, customQuery);
productsSearch: async (context: Context, params: ProductsSearchParams): Promise<ProductsResponse> => {
const { customQuery, ...searchParams } = params;

return await context.$boilerplate.api.getProduct(searchParams, customQuery);
}
};

Expand Down
4 changes: 1 addition & 3 deletions packages/boilerplate/composables/src/useUserOrders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import {
} from '@vue-storefront/core';
import { OrdersResponse, OrderSearchParams } from '../types';

// @todo userOrders

const params: UseUserOrdersFactoryParams<OrdersResponse, OrderSearchParams> = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
searchOrders: async (context: Context, params: OrderSearchParams = {}): Promise<OrdersResponse> => {
searchOrders: async (context: Context, params: OrderSearchParams): Promise<OrdersResponse> => {
console.log('Mocked: searchOrders');

return {
Expand Down

0 comments on commit 4bf8b31

Please sign in to comment.