Skip to content

Commit 4a633ca

Browse files
Updated @moltin/sdk to v4.0.0 (#52)
* Updated to sdk beta.3: built in types with extensions * Updated @moltin/sdk to 4.0.0
1 parent 920e8d7 commit 4a633ca

17 files changed

+119
-270
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.1.0",
44
"private": true,
55
"dependencies": {
6-
"@moltin/sdk": "^3.23.0",
6+
"@moltin/sdk": "^4.0.0",
77
"@types/node": "^12.0.0",
88
"@types/react": "^16.9.0",
99
"@types/react-dom": "^16.9.0",

src/Address.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useState } from 'react';
2+
import * as moltin from '@moltin/sdk';
23
import { useAddressData } from './app-state';
3-
import { Address as IAddress, deleteAddress } from './service';
4+
import { deleteAddress } from './service';
45
import { useTranslation } from './app-state';
56
import { AddressForm } from './AddressForm';
67
import { DeleteAddressDialog } from './DeleteAddressDialog';
@@ -64,7 +65,7 @@ export const Address: React.FC = () => {
6465
<h1 className="address__title">{t("address-book")}</h1>
6566
{addressData && addressData.length > 0 ? (
6667
<div className="address__maincontainer">
67-
{addressData.map((address: IAddress) => (
68+
{addressData.map((address: moltin.Address) => (
6869
<div className="address__container" key={address.id}>
6970
<ul className="address__list">
7071
<li className="">

src/Category.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function useCategoryProducts(categoryId: string | undefined, pageNum: number) {
2424
// during initial loading of categories categoryId might be undefined
2525
if (categoryId) {
2626
const result = await loadCategoryProducts(categoryId, pageNum, selectedLanguage, selectedCurrency);
27-
setTotalPages(result.pagination.totalPages);
27+
setTotalPages(result.meta.page.total);
2828
return result;
2929
}
3030
}, [categoryId, pageNum, selectedLanguage, selectedCurrency]);
@@ -79,7 +79,7 @@ export const Category: React.FC = () => {
7979
{totalPages && (
8080
<Pagination
8181
totalPages={totalPages}
82-
currentPage={products?.pagination?.currentPage ?? pageNum}
82+
currentPage={products?.meta.page.current ?? pageNum}
8383
formatUrl={(page) => createCategoryUrl(categorySlug, page)}
8484
/>
8585
)}

src/CompareCheck.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import React from 'react';
2+
import * as moltin from '@moltin/sdk';
23
import { useCompareProducts } from './app-state';
3-
import { Product } from './service';
44
import { useTranslation } from './app-state';
55

66
import './CompareCheck.scss';
77

88

99
interface CompareCheckProps {
10-
product: Product;
10+
product: moltin.Product;
1111
}
1212

1313
export const CompareCheck: React.FC<CompareCheckProps> = (props) => {

src/CompareOverlay.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
2+
import * as moltin from '@moltin/sdk';
23
import { useHistory, useRouteMatch } from 'react-router-dom';
34
import { useCompareProducts, useTranslation } from './app-state';
45
import { createCompareProductsUrl } from './routes';
56
import { ProductMainImage } from './ProductMainImage';
6-
import { Product } from './service';
77
import { ReactComponent as RemoveIcon } from './images/icons/ic_close.svg';
88

99
import './CompareOverlay.scss';
@@ -22,7 +22,7 @@ export const CompareOverlay: React.FC = (props) => {
2222
history.push(compareUrl);
2323
};
2424

25-
const handleRemoveProduct = (product: Product) => {
25+
const handleRemoveProduct = (product: moltin.Product) => {
2626
removeFromCompare(product.id);
2727
};
2828

src/CompareProducts.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React, { useState } from 'react';
2+
import * as moltin from '@moltin/sdk';
23
import { useCompareProducts, useTranslation } from './app-state';
34
import { ProductMainImage } from './ProductMainImage';
45
import { Availability } from './Availability';
5-
import { Product } from './service';
66
import { isProductAvailable } from './helper';
77
import { config } from './config';
88
import { ReactComponent as RemoveIcon } from './images/icons/ic_close.svg';
@@ -14,7 +14,7 @@ export const CompareProducts: React.FC = () => {
1414
const { compareProducts, removeFromCompare } = useCompareProducts();
1515
const { t } = useTranslation();
1616

17-
const handleRemoveItem = (product: Product) => {
17+
const handleRemoveItem = (product: moltin.Product) => {
1818
removeFromCompare(product.id);
1919
};
2020

src/NavMenu.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { Link } from 'react-router-dom';
33
import { createCategoryUrl } from './routes';
4-
import { Category } from './service';
4+
import * as moltin from '@moltin/sdk';
55
import { useCategories } from './app-state';
66

77
import './NavMenu.scss';
@@ -20,11 +20,11 @@ export const NavMenu: React.FC<NavMenuProps> = (props) => {
2020
handleCloseNavigation();
2121
};
2222

23-
const handleShow = (category: Category) => {
23+
const handleShow = (category: moltin.Category) => {
2424
handleCategoryClick(category.id, category.name);
2525
};
2626

27-
function renderCategories(categories: Category[], level: number = 0, isVisible: boolean = false): React.ReactElement {
27+
function renderCategories(categories: moltin.Category[], level: number = 0, isVisible: boolean = false): React.ReactElement {
2828
return (
2929
<ul className={`navmenu__sub --level-${level} ${isVisible ? '--show' : ''}`}>
3030
{categories?.map(category => (

src/Navigation.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import React, { useState } from 'react';
22
import { Link } from 'react-router-dom';
33
import useOnclickOutside from 'react-cool-onclickoutside';
4+
import * as moltin from '@moltin/sdk';
45
import { useTranslation } from './app-state';
5-
6-
import { Category } from './service';
76
import { useCategories } from './app-state';
87

98
import './Navigation.scss';
@@ -56,7 +55,7 @@ export const Navigation: React.FC = () => {
5655
window.history.back();
5756
};
5857

59-
function renderTopCategories(categories: Category[]): React.ReactElement {
58+
function renderTopCategories(categories: moltin.Category[]): React.ReactElement {
6059
const topCategories = [
6160
{ name: 'home', displayName: t('home'), url: '/' },
6261
{ name: 'products', displayName: t('products'), children: categories },

src/ProductMainImage.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import React from 'react';
2-
import { Product, loadImageHref } from './service';
2+
import * as moltin from '@moltin/sdk';
3+
import { loadImageHref } from './service';
34
import { useResolve } from './hooks';
45
import { ImageContainer } from './ImageContainer';
56

67
interface ProductMainImageProps {
7-
product: Product;
8+
product: moltin.Product;
89
size?: number;
910
}
1011

src/ProductThumbnail.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { Product } from './service';
2+
import * as moltin from '@moltin/sdk';
33
import { createProductUrl } from './routes';
44
import { Link } from 'react-router-dom';
55
import { CompareCheck } from './CompareCheck';
@@ -12,7 +12,7 @@ import './ProductThumbnail.scss';
1212

1313

1414
interface ProductThumbnailProps {
15-
product: Product;
15+
product: moltin.Product;
1616
}
1717

1818
export const ProductThumbnail: React.FC<ProductThumbnailProps> = (props) => {

0 commit comments

Comments
 (0)