Skip to content

Commit

Permalink
add star data
Browse files Browse the repository at this point in the history
  • Loading branch information
pourya-asrzad committed Feb 2, 2023
1 parent d79a33d commit b0c7054
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
20 changes: 13 additions & 7 deletions src/components/add-to-cart-sector/AddToCartSector.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { numberWithCommas } from '../../utils/functions.utils';
import Styles from './AddToCartSector.module.scss'
import Hr from '../hr/Hr.component';
import AddToCartBtn from '../buttons/AddToCartBtn.component';
const AddToCartSector = ({ price }) => {
const AddToCartSector = ({ price, quantity }) => {
const priceWithComma = numberWithCommas(price)
return (
<div className={Styles.AddToCartSector}>
Expand Down Expand Up @@ -38,12 +38,18 @@ const AddToCartSector = ({ price }) => {

<div className={Styles.cardpricepart}>
<div style={{ direction: 'rtl' }}>
<span>
{priceWithComma}
</span>
<span>
تومان
</span>
{quantity == 0 ?
<span>ناموجود</span>
:
<>
<span>
{priceWithComma}
</span>
<span>
تومان
</span>
</>
}
</div>
<div>
<span>
Expand Down
5 changes: 3 additions & 2 deletions src/components/main-card/MainCard.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import { AiFillStar } from 'react-icons/ai'
import PriceWithDiscountText from '../price-With-Discount-text/priceWithDiscountText.component';
import { useState } from 'react';
const MainCard = (props) => {
const { colors, image, title, price, discount, quantity } = props
const { colors, image, title, price, discount, quantity, fillStrip } = props
// {colorsArray} is just a test for ui
const colorsArray = [
"blue", "white", "black", "green"
]
const imageHasHttp = image.includes('https')
let priceWithDiscount = price
const numberplit = numberWithCommas(price)
const productStart = parseFloat((((fillStrip.pricevalue + fillStrip.quality + fillStrip.packing) / 3 * 100) * 5 / 100 / 100).toFixed(1))
if (discount) {
const numberplitwithdiscount = numberWithCommas(price - price * discount / 100)
priceWithDiscount = numberplitwithdiscount
Expand All @@ -35,7 +36,7 @@ const MainCard = (props) => {
<div className={Styles.card_footer}>
<h3 className={Styles.card_title}>{title}</h3>
<div className={Styles.score}>
<span>2.5</span>
<span>{productStart ? productStart : ''}</span>
<AiFillStar style={{ color: '#f9bc00' }} />
</div>
{quantity == 0 ? <span>ناموجود</span> : <div style={{ position: 'relative' }}> <div className={Styles.price_discount_coontainer}>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/category/category.page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const Category = () => {
if (filterAsquantity == 1) {
categoryfetchAnswer = products.map((product) => {
return <Link key={product.id} className='link-route' to={INTERNAL_PATHS.SINGLEPRODUCT + "/" + product.id}>
<MainCard quantity={product.quantity} title={product.name}
<MainCard fillStrip={product.fillStrip} quantity={product.quantity} title={product.name}
discount={product.Discount} price={product.price} image={product.image[0]} key={product.id} />
</Link>
})
Expand Down
2 changes: 1 addition & 1 deletion src/pages/single-product/single-product.page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const SingleProduct = () => {
<h1 >{productObj.name}</h1>
<Discription description={productObj.description} />
<div className={Styles.sectors_container}>
<AddToCartSector price={productObj.price} />
<AddToCartSector quantity={productObj.quantity} price={productObj.price} />
<Rate fillStrip={fillStrip} />
</div>
</div>
Expand Down

0 comments on commit b0c7054

Please sign in to comment.