Skip to content

Commit

Permalink
Merge pull request #331 from Simicart/fix/fixbug-regalfabricgallery
Browse files Browse the repository at this point in the history
fix bug
  • Loading branch information
Cody Nguyễn authored Sep 15, 2022
2 parents bc9da42 + 9e03db3 commit fa56423
Show file tree
Hide file tree
Showing 14 changed files with 163 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const PriceAdjustments = (props) => {
return rewardData.code == 'mp_reward_spent';
});
const { customerRewardPoint } = useGetRewardPointData({ onCart: true });
const exchange_rate = customerRewardPoint.current_exchange_rates;
const exchange_rate = customerRewardPoint ? customerRewardPoint.current_exchange_rates : null
const spending_rate = exchange_rate ? exchange_rate.spending_rate : '';
const words = spending_rate ? spending_rate.split(' points') : '';
const money = spending_rate ? spending_rate.split('for $') : '';
Expand All @@ -65,7 +65,7 @@ const PriceAdjustments = (props) => {
const maxPoint = Math.floor(
(pointSpending * subtotalVal) / moneySpending[0]
);
const balance = customerRewardPoint.point_balance;
const balance = customerRewardPoint ? customerRewardPoint.point_balance : 0;
let rewardPointSelected = 0;
if (mpRewardSpent && mpRewardSpent.length > 0)
rewardPointSelected = mpRewardSpent[0].value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const PriceAdjustments = props => {
return rewardData.code == 'mp_reward_spent';
});
const { customerRewardPoint } = useGetRewardPointData({ onCart: true });
const exchange_rate = customerRewardPoint.current_exchange_rates;
const exchange_rate = customerRewardPoint ? customerRewardPoint.current_exchange_rates : null
const spending_rate = exchange_rate ? exchange_rate.spending_rate : '';
const words = spending_rate ? spending_rate.split(' points') : '';
const money = spending_rate ? spending_rate.split('for $') : '';
Expand All @@ -63,7 +63,7 @@ const PriceAdjustments = props => {
const maxPoint = Math.floor(
(pointSpending * subtotalVal) / moneySpending[0]
);
const balance = customerRewardPoint.point_balance;
const balance = customerRewardPoint ? customerRewardPoint.point_balance : 0;
let rewardPointSelected = 0;
if (mpRewardSpent && mpRewardSpent.length > 0)
rewardPointSelected = mpRewardSpent[0].value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Suspense, useState } from 'react';
import LoadingIndicator from '@magento/venia-ui/lib/components/LoadingIndicator';
import {useBottomNotification} from "src/simi/App/nativeInner/Cart/bottomNotificationHook";

const CorePriceAdjustments = React.lazy(() => import('src/simi/App/core/Cart/PriceAdjustments'));
const CorePriceAdjustments = React.lazy(() => import('src/simi/App/nativeInner/CartCore/PriceAdjustments'));

const CartPriceAdjustments = React.lazy(() => import('src/simi/App/nativeInner/Cart/PriceAdjustments'));

Expand Down
13 changes: 11 additions & 2 deletions src/simi/App/nativeInner/GridItem/item.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@ Rate
display: flex;
justify-content: space-between;
box-shadow: 0px 10px 12px -2px rgb(0 0 0 / 30%);


}
}
@media (max-width: 1024px) {
Expand Down Expand Up @@ -312,6 +310,17 @@ Rate
}
}

@media(max-width: 1023px) {
.product-grid-addcartbtn {
min-height: 30px;
font-size: 14px;
}

.product-grid-actions {
min-height: 40px;
}
}

/* @media (max-width : 375px) {
.siminia-product-image img {
max-width: 167px;
Expand Down
41 changes: 26 additions & 15 deletions src/simi/App/nativeInner/ProductFullDetail/productFullDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const ProductFullDetail = props => {
const {
breadcrumbCategoryId,
errorMessage,
userErrorsMessage,
handleAddToCart,
handleBuyNow,
handleSelectionChange,
Expand Down Expand Up @@ -222,6 +223,13 @@ const ProductFullDetail = props => {

// Fill a map with field/section -> error.
const errors = new Map();
if(Array.isArray(userErrorsMessage) && userErrorsMessage.length > 0) {
userErrorsMessage.forEach(userErrorMessage => {
errors.set('form', [
new Error(userErrorMessage)
]);
})
}
if (errorMessage) {
Object.keys(ERROR_MESSAGE_TO_FIELD_MAPPING).forEach(key => {
if (errorMessage.includes(key)) {
Expand Down Expand Up @@ -422,8 +430,6 @@ const ProductFullDetail = props => {
</React.Fragment>
)

console.log('run-')

if(isCallForPriceEnable()) {
if(!(action === 'login_see_price' && isSignedIn) || action === 'redirect_url' ) {
wrapperPrice = null
Expand Down Expand Up @@ -682,20 +688,14 @@ const ProductFullDetail = props => {
{/* <ProductLabel productLabel = {product.mp_label_data.length > 0 ? product.mp_label_data : null} /> */}
</section>

<FormError
classes={{
root: classes.formErrors
}}
errors={errors.get('form') || []}
/>

{(!isMobileSite && product.short_description) ? (
<div className="productDescription">
<div className="productDescription">
{(!isMobileSite && product.short_description) ? (
<RichContent
html={product.short_description.html}
/>
</div>
) : null}
) : null}
</div>


{!isMobileSite ? (
<div className="wrapperOptions">
Expand Down Expand Up @@ -732,6 +732,17 @@ const ProductFullDetail = props => {
: null}

{!isMobileSite ? cartAction : null}

<div className={classes.wrapperError}>
<FormError
classes={{
root: classes.formErrors
}}
errors={errors.get('form') || []}
/>
</div>


<div className={classes.wrapperDes}>
<section className={classes.description}>
<span
Expand Down Expand Up @@ -797,13 +808,13 @@ const ProductFullDetail = props => {
</div>
{!isMobileSite ? (
<section className={classes.details}>
<span className={classes.detailsTitle}>
{/* <span className={classes.detailsTitle}>
<FormattedMessage
id={'SKU'}
defaultMessage={'SKU'}
/>
</span>
<strong>{productDetails.sku}</strong>
<strong>{productDetails.sku}</strong> */}
</section>
) : (
<div className="sku-details">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
grid-auto-flow: row;
grid-template-areas:
'images title'
'images errors'
'images options'
'images quantity'
'images cart'
'images errors'
'images .';
grid-template-columns: 1.5625fr 1fr;
grid-template-rows: repeat(5, min-content) 1fr [fold];
grid-template-rows: repeat(7, min-content) 1fr [fold];
padding: 0;
}
}
Expand Down Expand Up @@ -120,6 +120,7 @@
.formErrors {
composes: section;
grid-area: errors;
border-bottom: none;
}

.quantity {
Expand Down Expand Up @@ -360,6 +361,7 @@
line-height: 3rem;
margin-top: 10px;
position: fixed;
left: 0;
z-index: 7;
width: 100%;
/* padding-right: 15px; */
Expand Down
19 changes: 12 additions & 7 deletions src/simi/App/nativeInner/RootComponents/Product/product.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { Fragment, useEffect, useMemo } from 'react';
import React, { Suspense, useEffect, useMemo } from 'react';
import { FormattedMessage } from 'react-intl';
import { string } from 'prop-types';
import { useProduct } from '@simicart/siminia/src/simi/talons/ProductFullDetail/useProduct.js';

import ErrorView from '@magento/venia-ui/lib/components/ErrorView';
import { StoreTitle, Meta } from '@magento/venia-ui/lib/components/Head';
import { ProductBuilderFullDetailUpperLower } from '@simicart/siminia/src/simi/App/core/ProductFullDetail';
// import ProductBuilderFullDetailUpperLower from '@simicart/siminia/src/simi/App/core/ProductFullDetail';
import ProductFullDetail from '../../ProductFullDetail';
import { prepareProduct } from 'src/simi/Helper/Product';
import mapProduct from '@magento/venia-ui/lib/util/mapProduct';
Expand All @@ -19,6 +19,8 @@ const storeCode = storage.getItem('store_view_code') || STORE_VIEW_CODE;
import Seo from '@simicart/siminia/src/simi/App/core/Seo';

const isMobileSite = window.innerWidth <= 450;

const ProductBuilderFullDetailUpperLower = React.lazy('@simicart/siminia/src/simi/App/core/ProductFullDetail/productbuilderFullDetail.upperlower')
/*
* As of this writing, there is no single Product query type in the M2.3 schema.
* The recommended solution is to use filter criteria on a Products query.
Expand Down Expand Up @@ -166,11 +168,14 @@ const Product = props => {
<StoreTitle>{product.name}</StoreTitle>
<Meta name="description" content={product.meta_description} />
{foudThepage || pageMaskedId ? (
<ProductBuilderFullDetailUpperLower
product={product}
pageData={foudThepage}
maskedId={pageMaskedId}
/>
<Suspense fallback={null}>
<ProductBuilderFullDetailUpperLower
product={product}
pageData={foudThepage}
maskedId={pageMaskedId}
/>
</Suspense>

) : (
<ProductFullDetail product={product} />
)}
Expand Down
11 changes: 6 additions & 5 deletions src/simi/App/nativeInner/WishlistPage/wishlistItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import defaultClasses from './wishlistItem.module.css';
import { Link } from 'react-router-dom';
import { ConfirmPopup } from '../Cart/ConfirmPopup';
import SocialShare from '../../../BaseComponents/SocialShare';
import { CREATE_CART as CREATE_CART_MUTATION } from '@magento/peregrine/lib/talons/CreateAccount/createAccount.gql';

const WishlistItem = props => {
const { item } = props;
Expand All @@ -33,7 +34,7 @@ const WishlistItem = props => {
const { final_price: finalPrice } = maximumPrice;
const { currency, value: unitPrice } = finalPrice;

const talonProps = useWishlistItem(props);
const talonProps = useWishlistItem({...props, operations: { createCartMutaion: CREATE_CART_MUTATION }});
const {
addToCartButtonProps,
handleRemoveProductFromWishlist,
Expand Down Expand Up @@ -222,11 +223,11 @@ const WishlistItem = props => {
className={classes.deleteItem}
aria-label={removeProductAriaLabel}
>
{!isMobileSite ? (
{/* {!isMobileSite ? (
<div className={classes.close} />
) : (
) : ( */}
<ConfirmPopup
trigger={<VscTrash size={25} />}
trigger={isMobileSite ? <VscTrash size={25} /> : <div className={classes.close} />}
content={
<FormattedMessage
id={'Delete Warning'}
Expand All @@ -238,7 +239,7 @@ const WishlistItem = props => {
}
confirmCallback={handleRemoveProductFromWishlist}
/>
)}
{/* )} */}
</button>
<div className={classes.actionWrap}>
<span className={classes.name}>{name}</span>{' '}
Expand Down
8 changes: 4 additions & 4 deletions src/simi/App/nativeInner/WishlistPage/wishlistItem.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
}

.deleteItem {
margin: 0 0.5rem 0 1rem;
/* margin: 0 0.5rem 0 1rem; */
justify-self: right;
position: absolute;
left: 0;
/* //left: 0; */
}

.actionWrap {
Expand All @@ -81,10 +81,10 @@
}

.close {
position: absolute;
/* position: absolute; */
width: 32px;
height: 32px;
left: -15px;
/* left: -15px; */
opacity: 0.7;
background-color: #F4F4F4;
/* padding: 6px; */
Expand Down
Loading

0 comments on commit fa56423

Please sign in to comment.