Skip to content

Commit

Permalink
Merge branch 'next' into useui-notification
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszjedrasik authored Jan 11, 2021
2 parents ffade4c + 8cf19c3 commit 66e5e02
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 31 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
4 changes: 2 additions & 2 deletions packages/commercetools/theme/pages/Checkout/Payment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
</ValidationProvider>
<ValidationProvider name="country" rules="required|min:2" v-slot="{ errors }" slim>
<SfSelect
:selectedValue="billingDetails.country"
@selected="country => setBillingDetailsAndUnpickAddress({ country })"
:value="billingDetails.country"
@input="country => setBillingDetailsAndUnpickAddress({ country })"
label="Country"
class="form__element form__element--half form__select sf-select--underlined"
required
Expand Down
4 changes: 2 additions & 2 deletions packages/commercetools/theme/pages/Checkout/Shipping.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
</ValidationProvider>
<ValidationProvider name="country" rules="required|min:2" v-slot="{ errors }" slim>
<SfSelect
:selectedValue="shippingDetails.country"
@selected="country => setShippingDetailsAndUnpickAddress({ country })"
:value="shippingDetails.country"
@input="country => setShippingDetailsAndUnpickAddress({ country })"
label="Country"
name="country"
class="form__element form__element--half form__select sf-select--underlined"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/core/src/factories/useCategoryFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function useCategoryFactory<CATEGORY, CATEGORY_SEARCH_PARAMS>(
const error: Ref<UseCategoryErrors> = sharedRef({}, `useCategory-error-${id}`);

const search = async (searchParams) => {
Logger.debug('useCategory.search', searchParams);
Logger.debug(`useCategory/${id}/search`, searchParams);

try {
loading.value = true;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/core/src/factories/useContentFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function useContentFactory<CONTENT, CONTENT_SEARCH_PARAMS>(
const context = generateContext(factoryParams);

const search = async(params: CONTENT_SEARCH_PARAMS): Promise<void> => {
Logger.debug('useContent.search', params);
Logger.debug(`useContent/${id}/search`, params);

try {
loading.value = true;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/core/src/factories/useFacetFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const useFacetFactory = <SEARCH_DATA>(factoryParams: UseFacetFactoryParams<SEARC
const error: Ref<UseFacetErrors> = sharedRef({}, `useFacet-error-${id}`);

const search = async (params?: AgnosticFacetSearchParams) => {
Logger.debug('useFacet.search', params);
Logger.debug(`useFacet/${ssrKey}/search`, params);

result.value.input = params;
try {
Expand All @@ -25,7 +25,7 @@ const useFacetFactory = <SEARCH_DATA>(factoryParams: UseFacetFactoryParams<SEARC
result.value.data = await factoryParams.search(context, result.value);
} catch (err) {
error.value.search = err;
Logger.error(`useFacet/${id}/search`, err);
Logger.error(`useFacet/${ssrKey}/search`, err);
} finally {
loading.value = false;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/core/src/factories/useProductFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function useProductFactory<PRODUCTS, PRODUCT_SEARCH_PARAMS>(
const error: Ref<UseProductErrors> = sharedRef({}, `useProduct-error-${id}`);

const search = async (searchParams) => {
Logger.debug('useProduct.search', searchParams);
Logger.debug(`useProduct/${id}/search`, searchParams);

try {
loading.value = true;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/core/src/factories/useReviewFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function useReviewFactory<REVIEW, REVIEWS_SEARCH_PARAMS, REVIEW_ADD_PARAM
const context = generateContext(factoryParams);

const search = async (searchParams): Promise<void> => {
Logger.debug('useReview.search', searchParams);
Logger.debug(`useReview/${id}/search`, searchParams);

try {
loading.value = true;
Expand All @@ -32,7 +32,7 @@ export function useReviewFactory<REVIEW, REVIEWS_SEARCH_PARAMS, REVIEW_ADD_PARAM
};

const addReview = async (params): Promise<void> => {
Logger.debug('useReview.addReview', params);
Logger.debug(`useReview/${id}/addReview`, params);

try {
loading.value = true;
Expand Down
2 changes: 2 additions & 0 deletions packages/core/docs/commercetools/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
- removed `formatPrice` from `useUiHelpers`, replaced by vue18n `$n` function ([#5339](https://github.com/vuestorefront/vue-storefront/pull/5339))
- added missing `i18n` tags ([#5337](https://github.com/vuestorefront/vue-storefront/issues/5337))
- use updated factories `useUserBillingFactory`, `useUserShippingFactory` and `useWishlistFactory` ([5350](https://github.com/vuestorefront/vue-storefront/pull/5350))
- use updated factories `useUserBillingFactory`, `useUserShippingFactory` and `useWishlistFactory` ([5350](https://github.com/vuestorefront/vue-storefront/pull/5350))
- fix selecting country on checkout payment and shipping ([5386](https://github.com/vuestorefront/vue-storefront/pull/5386))

## 1.0.1-rc.1
- updated version of core
Expand Down
2 changes: 2 additions & 0 deletions packages/core/docs/contributing/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [BREAKING] refactored names of many factory methods and composable methods, details in linked PR ([#5299](https://github.com/DivanteLtd/vue-storefront/pull/5299))
- [BREAKING] changed signatures of factory methods to always 2 arguments, details in linked PR ([#5299](https://github.com/DivanteLtd/vue-storefront/pull/5299))
- [BREAKING] composables are always returning one field for the response, removed `totalOrders` and `totalProducts`, `useCartFactory` and `useUserFactory` are returning only composables ([#5330](https://github.com/vuestorefront/vue-storefront/pull/5330))
- [BREAKING] update composables in Boilerplate to match new factories signatures ([#5389](https://github.com/DivanteLtd/vue-storefront/pull/5389))
- removed `formatPrice` from `useUiHelpers`, replaced by vue18n `$n` function ([#5339](https://github.com/vuestorefront/vue-storefront/pull/5339))
- updated integration boilerplate to work with refactored names of factories mentioned above ([#5348](https://github.com/DivanteLtd/vue-storefront/pull/5348))
- change `useUserBillingFactory`, `useUserShippingFactory` and `useWishlistFactory` to return composable, move `setWishlist` inside of composable ([5350](https://github.com/vuestorefront/vue-storefront/pull/5350))
Expand All @@ -13,6 +14,7 @@
- fix adding to cart button on product page ([#5375](https://github.com/vuestorefront/vue-storefront/pull/5375))
- typed error ref for each core's factory ([#4956](https://github.com/vuestorefront/vue-storefront/issues/4956))
- added useUiNotification ([#5363](https://github.com/vuestorefront/vue-storefront/issues/5363))
- added ID to Loggers in core factories ([#5351](https://github.com/vuestorefront/vue-storefront/issues/5351))


## 2.1.1-rc.1
Expand Down

0 comments on commit 66e5e02

Please sign in to comment.