Skip to content

Commit

Permalink
Merge branch '12.0/native-inner/develop' into 12.0/native-inner/main
Browse files Browse the repository at this point in the history
  • Loading branch information
codynguyen committed Nov 11, 2022
2 parents 0f45d28 + d6796b3 commit 088b091
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 106 deletions.
Binary file modified .DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import { useStyle } from '@magento/venia-ui/lib/classify';
const GiftCardSummary = props => {
const classes = useStyle({}, props.classes);
const { data, currencyCode } = props;
const { formatMessage } = useIntl();

if (!data && !data.giftCardUsed && data.giftCardUsed.length == 0) {
if (!data || !data.giftCardUsed || data.giftCardUsed.length == 0) {
return null;
}

Expand Down
18 changes: 10 additions & 8 deletions src/simi/App/nativeInner/Header/header.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,15 @@ header {
.megaMenu {
composes: lg_flex from global;
justify-content: center;
background-color: rgba(255, 255, 255, 0.95);
border-top: solid 1px #f7f7f7;
background-color: #333132;
border-bottom: none;
backdrop-filter: blur(6px);
display: flex;
flex-wrap: wrap;
}
/* megaMenuItem */
.megaMenu > div {
padding: 0 40px;
padding: 0 30px;
}
/* submenu */
.megaMenu > div > div {
Expand All @@ -82,11 +81,14 @@ header {
min-width: unset !important;
}
.megaMenu > div > a {
min-height: 43px;
color: #333132;
min-height: 45px;
color: #ffffff;
font-size: 16px;
line-height: 24px;
font-weight: 600;
line-height: 19px;
}

.megaMenu > div > a > span {
display: none;
}

.megaMenu > div > a polyline {
Expand Down Expand Up @@ -331,7 +333,7 @@ body.fixed-scroll {

@media(min-width: 1200px) {
.right-bar {
width: 65%;
width: 50%;
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/simi/App/nativeInner/Helper/Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ export const isCallForPriceEnable = () => {

export const isGiftCardEnable = () => {
return window.SMCONFIGS && window.SMCONFIGS.plugins && window.SMCONFIGS.plugins.SM_ENABLE_GIFT_CARD && parseInt(window.SMCONFIGS.plugins.SM_ENABLE_GIFT_CARD) === 1;
}

export const isMegaMenuEnable = () => {
return window.SMCONFIGS && window.SMCONFIGS.plugins && window.SMCONFIGS.plugins.ENABLE_MEGA_MENU && parseInt(window.SMCONFIGS.plugins.ENABLE_MEGA_MENU) === 1;
}
21 changes: 13 additions & 8 deletions src/simi/App/nativeInner/Products/Gallery/gallery.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React, {useMemo, useCallback} from 'react';
import {string, shape, array} from 'prop-types';
import {GridItem} from 'src/simi/App/nativeInner/GridItem';
import React, { useMemo, useCallback } from 'react';
import { string, shape, array } from 'prop-types';
import { GridItem } from 'src/simi/App/nativeInner/GridItem';

require('./gallery.scss');

// map Magento 2.3.1 schema changes to Venia 2.0.0 proptype shape to maintain backwards compatibility
const mapGalleryItem = item => {
const {small_image} = item;
const { small_image } = item;
return {
...item,
small_image:
Expand All @@ -15,8 +15,8 @@ const mapGalleryItem = item => {
};

const Gallery = props => {
const {items, history, overRideClasses = {}, styles} = props;
console.log("items",items);
const { items, history, overRideClasses = {}, styles } = props;

const handleLink = useCallback(link => {
history.push(link);
}, []);
Expand All @@ -41,8 +41,13 @@ const Gallery = props => {
);

return (
<div className={`${overRideClasses["gallery-root"] || ""} gallery-root`}>
<div className={`${overRideClasses["gallery-items"] || ""} gallery-items`}>
<div
className={`${overRideClasses['gallery-root'] || ''} gallery-root`}
>
<div
className={`${overRideClasses['gallery-items'] ||
''} gallery-items`}
>
{galleryItems}
</div>
</div>
Expand Down
56 changes: 28 additions & 28 deletions src/simi/App/nativeInner/Products/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ const Products = props => {
}
};
const renderShopByBrand = () => {
if(!brandsList || !brandsList.length) {
return;
}

return (
<div className="brands">
<div className="brand-heading">
Expand All @@ -123,34 +127,30 @@ const Products = props => {
</span>
</span>
</div>
{brandsList ? (
<div className="brands-list">
{brandsList
.filter((item, index) => index < 6)
.map(brand => {
const urlKey =
'/brands/' +
(brand.url_key
? brand.url_key
: brand.default_value.toLowerCase()) +
'.html';
return (
<div key={brand.brand_id}>
<Link to={urlKey}>
<img
width={109}
height={46}
src={brand.image}
alt={brand.value}
/>
</Link>
</div>
);
})}
</div>
) : (
''
)}
<div className="brands-list">
{brandsList
.filter((item, index) => index < 6)
.map(brand => {
const urlKey =
'/brands/' +
(brand.url_key
? brand.url_key
: brand.default_value.toLowerCase()) +
'.html';
return (
<div key={brand.brand_id}>
<Link to={urlKey}>
<img
width={109}
height={46}
src={brand.image}
alt={brand.value}
/>
</Link>
</div>
);
})}
</div>
</div>
);
};
Expand Down
3 changes: 0 additions & 3 deletions src/simi/App/nativeInner/Products/products.scss
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,6 @@
margin-top: 40px;
.list-items {
.config-page {
ul {
display: none !important;
}
.items-per-page {
.items-per-page-select {
font-weight: bold;
Expand Down
15 changes: 7 additions & 8 deletions src/simi/BaseComponents/MegaMenu/components/TopMenu/topMenu.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import React from 'react';
import MenuTree from '../MenuTree';
import { useTopMenu } from '../../talons/useTopMenu';
// import MegaMenu from '@magento/venia-ui/lib/components/MegaMenu/megaMenu';
// import classes from '../../../../App/nativeInner/Header/header.module.css';
import MegaMenu from '@magento/venia-ui/lib/components/MegaMenu/megaMenu';
import classes from '../../../../App/nativeInner/Header/header.module.css';

const TopMenu = props => {
const { menuTree, isEnabled, config } = useTopMenu();
if (!isEnabled) {
// return (
// <div className={classes['header-megamenu-ctn']}>
// <MegaMenu classes={classes} />
// </div>
// );
return null
return (
<div className={classes['header-megamenu-ctn']}>
<MegaMenu classes={classes} />
</div>
);
}

return <MenuTree {...props} config={config} menuTree={menuTree} />;
Expand Down
66 changes: 39 additions & 27 deletions src/simi/talons/Cart/priceSummaryFragments.gql.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,45 @@ const rewardPointEnabled =
window.SMCONFIGS.plugins.SM_ENABLE_REWARD_POINTS &&
parseInt(window.SMCONFIGS.plugins.SM_ENABLE_REWARD_POINTS) === 1;

export const GiftCardSummaryFragment = gql`
fragment GiftCardSummaryFragment on Cart {
mp_giftcard_config {
balance
canShowDetail
creditUsed
css
enableGiftCard
enableGiftCredit
enableMultiple
giftCardUsed {
amount
code
expired_at
status
}
listGiftCard {
balance
code
expired_at
hidden
status
}
maxUsed
}
}
`;
const giftCardEnabled =
window.SMCONFIGS &&
window.SMCONFIGS.plugins &&
window.SMCONFIGS.plugins.SM_ENABLE_GIFT_CARD &&
parseInt(window.SMCONFIGS.plugins.SM_ENABLE_GIFT_CARD) === 1;

export const GiftCardSummaryFragment = giftCardEnabled
? gql`
fragment GiftCardSummaryFragment on Cart {
mp_giftcard_config {
balance
canShowDetail
creditUsed
css
enableGiftCard
enableGiftCredit
enableMultiple
giftCardUsed {
amount
code
expired_at
status
}
listGiftCard {
balance
code
expired_at
hidden
status
}
maxUsed
}
}
`
: gql`
fragment GiftCardSummaryFragment on Cart {
id
}
`;
export const GrandTotalFragment = gql`
fragment GrandTotalFragment on CartPrices {
grand_total {
Expand Down
31 changes: 25 additions & 6 deletions src/simi/talons/Category/useCategoryContentSimiPagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,27 @@ import { GET_BRANDS_LIST } from '../../App/nativeInner/ShopByBrand/talons/Brand.
import {
getCateNoFilter,
getFilterFromCate
} from
// 'src/simi/queries/catalog_gql/category.gql';
'src/simi/queries/catalog_gql/simiCategory.gql';
} from 'src/simi/queries/catalog_gql/category.gql';

import {
getCateNoFilter as getSimiCateNoFilter,
getFilterFromCate as getSimiFilterFromCate
} from 'src/simi/queries/catalog_gql/simiCategory.gql';

import { useQuery } from '@apollo/client';

const shophByBrandEnabled =
window.SMCONFIGS &&
window.SMCONFIGS.plugins &&
window.SMCONFIGS.plugins.SM_ENABLE_SHOP_BY_BRAND &&
parseInt(window.SMCONFIGS.plugins.SM_ENABLE_SHOP_BY_BRAND) === 1;

const connectorEnabled =
window.SMCONFIGS &&
window.SMCONFIGS.plugins &&
window.SMCONFIGS.plugins.SM_ENABLE_CONNECTOR &&
parseInt(window.SMCONFIGS.plugins.SM_ENABLE_CONNECTOR) === 1;

// use pagination follow site magento default ( change both page and pagesize)
export const useCategoryContentSimiPagination = props => {
const {
Expand Down Expand Up @@ -74,13 +90,15 @@ export const useCategoryContentSimiPagination = props => {
}
}

const queryGetProductByCategory = connectorEnabled ? getSimiCateNoFilter : getCateNoFilter
const [
getProductsByCategory,
{ data: oriProductsData, error: error, loading: loading }
] = useLazyQuery(getCateNoFilter);
] = useLazyQuery(queryGetProductByCategory);

const queryGetFilterByCategory = connectorEnabled ? getSimiFilterFromCate : getFilterFromCate
const [getFilterByCategory, { data: oriFilterData }] = useLazyQuery(
getFilterFromCate
queryGetFilterByCategory
);

const variables = {
Expand Down Expand Up @@ -114,7 +132,8 @@ export const useCategoryContentSimiPagination = props => {
pageSize: 199,
currentPage: 1,
},
fetchPolicy:"cache-and-network"
fetchPolicy:"cache-and-network",
skip: !shophByBrandEnabled
});


Expand Down
14 changes: 11 additions & 3 deletions src/simi/talons/RewardPoint/useGetRewardPointData.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import {
import { deriveErrorMessage } from '@magento/peregrine/lib/util/deriveErrorMessage';
import { useAppContext } from '@magento/peregrine/lib/context/app';


const rewardPointEnabled =
window.SMCONFIGS &&
window.SMCONFIGS.plugins &&
window.SMCONFIGS.plugins.SM_ENABLE_REWARD_POINTS &&
parseInt(window.SMCONFIGS.plugins.SM_ENABLE_REWARD_POINTS) === 1;

export const useGetRewardPointData = props => {
const [{ isSignedIn }] = useUserContext();
const [
Expand All @@ -24,7 +31,7 @@ export const useGetRewardPointData = props => {
error: rewardPointError
} = useQuery(GET_CUSTOMER_REWARD_POINTS, {
fetchPolicy: 'no-cache',
skip: !isSignedIn
skip: !rewardPointEnabled || !isSignedIn
});


Expand All @@ -33,14 +40,15 @@ export const useGetRewardPointData = props => {
loading: rewardPointConfigLoading,
error: rewardPointConfigError
} = useQuery(GET_REWARD_POINTS_CONFIG, {
fetchPolicy: 'cache-and-network'
fetchPolicy: 'cache-and-network',
skip: !rewardPointEnabled || !isSignedIn
});


const { data: rewardTransactionData } = useQuery(GET_CUSTOMER_TRANSACTION, {
variables: { pageSize: 100 },
fetchPolicy: 'cache-and-network',
skip: !isSignedIn || (props && props.onCart)
skip: !rewardPointEnabled || !isSignedIn || (props && props.onCart)
});
const [mpRewardPoints,{loading : setSubcribeLoading}] = useMutation(SET_REWARD_SUBSCRIBE_STATUS);
const customerRewardPoint = rewardPointData
Expand Down
Loading

0 comments on commit 088b091

Please sign in to comment.