Commit 86faa9dd authored by Muhammad Ameen's avatar Muhammad Ameen 💻

Merge branch 'cart_functionality' into 'develop'

Cart functionality

See merge request !1
parents ef3c503e b74f6ee7
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
}
]
}
\ No newline at end of file
......@@ -21,6 +21,7 @@
"react-redux": "^8.0.1",
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.1",
"react-toastify": "^8.1.0",
"redux-thunk": "^2.4.1",
"sass": "^1.51.0",
"web-vitals": "^2.1.4"
......@@ -5445,6 +5446,14 @@
"wrap-ansi": "^7.0.0"
}
},
"node_modules/clsx": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/clsx/-/clsx-1.1.1.tgz",
"integrity": "sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==",
"engines": {
"node": ">=6"
}
},
"node_modules/co": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
......@@ -14589,6 +14598,18 @@
}
}
},
"node_modules/react-toastify": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-8.1.0.tgz",
"integrity": "sha512-M+Q3rTmEw/53Csr7NsV/YnldJe4c7uERcY7Tma9mvLU98QT2VhIkKwjBzzxZkJRk/oBKyUAtkyMjMgO00hx6gQ==",
"dependencies": {
"clsx": "^1.1.1"
},
"peerDependencies": {
"react": ">=16",
"react-dom": ">=16"
}
},
"node_modules/react-transition-group": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.2.tgz",
......@@ -21287,6 +21308,11 @@
"wrap-ansi": "^7.0.0"
}
},
"clsx": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/clsx/-/clsx-1.1.1.tgz",
"integrity": "sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA=="
},
"co": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
......@@ -27748,6 +27774,14 @@
"workbox-webpack-plugin": "^6.4.1"
}
},
"react-toastify": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-8.1.0.tgz",
"integrity": "sha512-M+Q3rTmEw/53Csr7NsV/YnldJe4c7uERcY7Tma9mvLU98QT2VhIkKwjBzzxZkJRk/oBKyUAtkyMjMgO00hx6gQ==",
"requires": {
"clsx": "^1.1.1"
}
},
"react-transition-group": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.2.tgz",
......@@ -16,6 +16,7 @@
"react-redux": "^8.0.1",
"react-router-dom": "^6.3.0",
"react-scripts": "5.0.1",
"react-toastify": "^8.1.0",
"redux-thunk": "^2.4.1",
"sass": "^1.51.0",
"web-vitals": "^2.1.4"
......
......@@ -9,7 +9,7 @@ function App() {
return (
<>
<Routes>
<Route path="/" element={<Home/>} />
<Route path="/" element={<Home />} />
</Routes>
</>
);
......
$black_color: black;
\ No newline at end of file
$black_color: black;
body {
font-family: "Poppin-Regular";
}
@font-face {
font-family: "Poppin-Black";
src: url("./assets/Fonts/Poppins-Black.ttf");
}
@font-face {
font-family: "Poppin-BlackItalic";
src: url("./assets/Fonts/Poppins-BlackItalic.ttf");
}
@font-face {
font-family: "Poppin-Bold";
src: url("./assets/Fonts/Poppins-Bold.ttf");
}
@font-face {
font-family: "Poppin-BoldItalic";
src: url("./assets/Fonts/Poppins-BoldItalic.ttf");
}
@font-face {
font-family: "Poppin-ExtraBold";
src: url("./assets/Fonts/Poppins-ExtraBold.ttf");
}
@font-face {
font-family: "Poppin-ExtraBoldItalic";
src: url("./assets/Fonts/Poppins-ExtraBoldItalic.ttf");
}
@font-face {
font-family: "Poppin-ExtraLight";
src: url("./assets/Fonts/Poppins-ExtraLight.ttf");
}
@font-face {
font-family: "Poppin-ExtraLightItalic";
src: url("./assets/Fonts/Poppins-ExtraLightItalic.ttf");
}
@font-face {
font-family: "Poppin-Italic";
src: url("./assets/Fonts/Poppins-Italic.ttf");
}
@font-face {
font-family: "Poppin-Light";
src: url("./assets/Fonts/Poppins-Light.ttf");
}
@font-face {
font-family: "Poppin-LightItalic";
src: url("./assets/Fonts/Poppins-LightItalic.ttf");
}
@font-face {
font-family: "Poppin-Medium";
src: url("./assets/Fonts/Poppins-Medium.ttf");
}
@font-face {
font-family: "Poppin-MediumItalic";
src: url("./assets/Fonts/Poppins-MediumItalic.ttf");
}
@font-face {
font-family: "Poppin-Regular";
src: url("./assets/Fonts/Poppins-Regular.ttf");
}
@font-face {
font-family: "Poppin-SemiBold";
src: url("./assets/Fonts/Poppins-SemiBold.ttf");
}
@font-face {
font-family: "Poppin-SemiBoldItalic";
src: url("./assets/Fonts/Poppins-SemiBoldItalic.ttf");
}
@font-face {
font-family: "Poppin-Thin";
src: url("./assets/Fonts/Poppins-Thin.ttf");
}
@font-face {
font-family: "Poppin-ThinItalic";
src: url("./assets/Fonts/Poppins-ThinItalic.ttf");
}
import React from "react";
import { Card } from "antd";
import style from "./Card.module.scss";
import { addCart } from "../../store/Reducers/cartReducer";
import { useDispatch } from "react-redux";
const { Meta } = Card;
const MainCard = ({ data, openNotification }) => {
const dispatch = useDispatch();
const firstLatter = data?.title?.charAt(0)?.toUpperCase();
return (
<div>
<Card
cover={<img alt="example" src={data?.image} style={{ height: 280 }} />}
>
<Meta title={firstLatter + data?.title?.substring(1)} />
<div className={style.priceAndButton}>
<p>RS: {data?.price}</p>
<button onClick={() => dispatch(addCart({ data, openNotification }))}>
Add To Cart
</button>
</div>
</Card>
</div>
);
};
export default MainCard;
.priceAndButton {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 25px;
p {
margin: 0px;
font-size: 18px;
font-weight: bold;
}
button {
padding: 8px 25px;
outline: none;
background-color: #e96026;
border: none;
color: white;
font-family: "Poppin-Medium";
border-radius: 50px;
cursor: pointer;
}
}
import React from "react";
import style from "./CategoriesCard.module.scss";
import mobileImg from "../../assets/images/infinix.jpeg";
import { AiOutlineRight } from "react-icons/ai";
const CategoriesCard = ({ data }) => {
return (
<div className={style.mainContainer}>
<div className={style.imageContainer}>
<img src={data?.image} alt="" />
</div>
<div className={style.rightContainer}>
<p>{data?.title}</p>
<button>
<AiOutlineRight />
</button>
</div>
</div>
);
};
export default CategoriesCard;
.mainContainer {
width: 100%;
height: 150px;
background-color: white;
margin-top: 15px;
margin-bottom: 15px;
display: flex;
align-items: center;
.imageContainer {
width: 150px;
height: 80%;
object-fit: contain;
margin-left: 20px;
margin-right: 20px;
img {
width: 100%;
height: 100%;
object-fit: contain;
}
}
.rightContainer {
margin-left: 20px;
margin-right: 20px;
button {
padding: 10px 20px;
border: 1px solid black;
background: transparent;
border-radius: 5px;
}
}
}
import React from "react";
import carouselImg from "../../assets/images/offer.jpg";
import { Carousel } from "react-bootstrap";
import { carouselData } from "../../Helper/dummyData";
import style from "./Carousel.module.scss";
const MainCarousel = () => {
return (
<>
<Carousel
variant="dark"
controls={false}
indicators={false}
className={`${style.carousel}`}
interval={3000}
>
{carouselData?.map((item, index) => {
return (
<Carousel.Item key={index}>
<img
className={`d-block w-100 ${style.image}`}
src={item?.image}
alt="First slide"
/>
</Carousel.Item>
);
})}
</Carousel>
</>
);
};
export default MainCarousel;
.image{
height: 550px;
}
.carousel{
height: 550px;
}
@media only screen and (max-width: 1200px) {
.image{
height: 350px;
}
.carousel{
height: 350px;
}
}
\ No newline at end of file
import { Drawer } from "antd";
import { useDispatch, useSelector } from "react-redux";
import style from "./Drawer.module.scss";
import { AiFillPlusCircle, AiFillMinusCircle } from "react-icons/ai";
import { MdCancel } from "react-icons/md";
import {
removeItem,
increaseQuantity,
decreaseQuantity,
} from "../../store/Reducers/cartReducer";
import { notification } from "antd";
const MainDrawer = ({ visible, setVisible }) => {
const dispatch = useDispatch();
const { cart, total } = useSelector((state) => state.cart);
const openNotification = () => {
notification.success({
message: "HUM MART",
description: " Item Remove from Cart Successfully",
className: "custom-class",
placement: "bottomLeft",
duration: 2.5,
});
};
const onClose = () => {
setVisible(false);
};
// console.log(window.innerWidth);
const removeItemFromCart = (item) => {
dispatch(removeItem({ item, openNotification }));
console.log(item);
};
const productCountingUp = (item) => {
dispatch(increaseQuantity(item));
};
const productCountingDown = (item) => {
dispatch(decreaseQuantity(item));
};
return (
<>
<Drawer
title="Check Out"
placement="right"
width={500}
onClose={onClose}
visible={visible}
>
{Object.values(cart)?.length === 0 ? (
<>
<div className={style.emptyCartText}>
<h3>No Item in your cart</h3>
</div>
</>
) : (
Object.values(cart)?.map((item, index) => {
return (
<>
<div key={index} className={style.mainContainer}>
<div
className={style.crossDiv}
onClick={() => removeItemFromCart(item)}
>
<MdCancel className={style.crossIcon} />
</div>
<div className={style.imageContainer}>
<img src={item?.data?.image} alt="" />
</div>
<div className={style.rightContainer}>
<p>{item?.data?.title}</p>
<p className={style.productPrice}>
Rs: {item?.data?.price}
</p>
<div className={style.countingDiv}>
<span
className={
item?.counting < 2
? style.minusDisable
: style.plusMinus
}
onClick={
item?.counting < 2
? undefined
: () => productCountingDown(item)
}
>
<AiFillMinusCircle />
</span>
<p>{item?.counting}</p>
<span
className={style.plusMinus}
onClick={() => productCountingUp(item)}
>
<AiFillPlusCircle />
</span>
</div>
</div>
</div>
</>
);
})
)}
<div className={style.subTotalContainer}>
<p>Sub Total:</p>
<p>RS: {total}</p>
</div>
<button
className={
Object.values(cart)?.length === 0
? style.submitBtnDisable
: style.submitBtn
}
disabled={Object.values(cart)?.length === 0}
>
Submit
</button>
</Drawer>
</>
);
};
export default MainDrawer;
// .mainContainer {
// width: 100%;
// display: flex;
// justify-content: center;
// background-color: orange;
// .innerMainContainer{
// width: 90%;
// height: 140px;
// background-color: red;
// }
// }
.emptyCartText {
text-align: center;
margin: 20px 0px;
h3 {
font-family: "Poppin-SemiBold";
color: red;
}
}
.mainContainer {
width: 100%;
min-height: 150px;
// height: 100%;
background-color: white;
margin-top: 15px;
margin-bottom: 15px;
display: flex;
align-items: center;
border: 1px solid black;
position: relative;
.crossDiv {
position: absolute;
// top: 0px;
bottom: 134px;
right: -12px;
font-size: 25px;
color: white;
z-index: 1;
background-color: red;
height: 25px;
width: 25px;
border-radius: 50px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
.crossIcon {
}
}
.imageContainer {
width: 30%;
height: 80%;
object-fit: contain;
margin-left: 20px;
margin-right: 20px;
img {
width: 100%;
height: 100%;
object-fit: contain;
}
}
.rightContainer {
margin-left: 0px;
margin-right: 20px;
width: 70%;
p {
margin: 2px;
}
p:nth-child(1) {
font-family: "Poppin-Medium";
}
.productPrice {
font-family: "Poppin-SemiBold";
}
.countingDiv {
display: flex;
justify-content: left;
align-items: center;
.minusDisable {
font-size: 30px;
color: #658845;
padding: 0px 10px;
}
.plusMinus {
font-size: 30px;
color: #56a514;
cursor: pointer;
padding: 0px 10px;
&:hover {
color: #3c750e;
}
}
p {
font-size: 22px;
margin: 0px;
}
}
}
}
.subTotalContainer {
display: flex;
justify-content: space-between;
align-items: center;
p {
margin: 0px;
}
p:nth-child(1) {
font-size: 18px;
font-family: "Poppin-SemiBold";
}
p:nth-child(2) {
font-size: 18px;
font-family: "Poppin-SemiBold";
letter-spacing: 0.2px;
}
}
.submitBtn {
width: 100%;
background-color: #56a514;
outline: none;
border: none;
padding: 8px 0px;
margin-top: 10px;
color: white;
font-size: 16px;
&:hover {
background-color: #3c750e;
}
}
.submitBtnDisable {
width: 100%;
background-color: #79a853;
outline: none;
border: none;
padding: 8px 0px;
margin-top: 10px;
color: white;
font-size: 16px;
}
import React from "react";
import style from "./Footer.module.scss";
import { Container, Row, Col } from "react-bootstrap";
import { AiOutlineCaretRight } from "react-icons/ai";
import { FaArrowRight, FaHome, FaEnvelope,FaPhoneAlt, FaMapMarkerAlt } from "react-icons/fa";
import playStoreImg from "../../assets/images/playstore.png"
import appStoreImg from "../../assets/images/app_store.png"
const Footer = () => {
return (
<>
<div className={style.mainContainer}>
<Container>
<Row>
<Col md={3}>
<div className={style.firstContainer}>
<h2>Hummart</h2>
<div>
<ul>
<li>
<FaHome /> <a href="">Home</a>
</li>
<li>
<FaArrowRight /> <a href="">About Us</a>
</li>
<li>
<FaArrowRight /> <a href="">Careers</a>
</li>
<li>
<FaArrowRight /> <a href="">Sell on Hummart</a>
</li>
<li>
<FaArrowRight /> <a href="">Terms</a>
</li>
</ul>
</div>
</div>
</Col>
<Col md={3}>
<div className={style.secondContainer}>
<h2>Help</h2>
<div>
<ul>
<li>
<AiOutlineCaretRight /> <a href="">FAQ's</a>
</li>
<li>
<AiOutlineCaretRight /> <a href="">How To Order</a>
</li>
<li>
<AiOutlineCaretRight /> <a href="">How To Pay</a>
</li>
<li>
<AiOutlineCaretRight /> <a href="">Return</a>
</li>
<li>
<AiOutlineCaretRight /> <a href="">Delivery Time</a>
</li>
</ul>
</div>
</div>
</Col>
<Col md={3}>
<div className={style.thirdContainer}>
<h2>Contact Us</h2>
<div>
<ul>
<li>
<FaMapMarkerAlt /> <a href="https://goo.gl/maps/vt9gXEHHmUrxfViu9" target="_blank" rel="noreferrer">Dehli, India</a>
</li>
<li>
<FaEnvelope /> <a href="mailto:muhammadameenh1@gmail.com">Hum Mart Mail</a>
</li>
<li>
<FaPhoneAlt /> <a href="tel:790078601">790078601</a>
</li>
</ul>
</div>
</div>
</Col>
<Col md={3}>
<div className={style.fourthContainer}>
<h2>Mobile App</h2>
<div>
<ul>
<li>
<img src={appStoreImg} alt="" />
</li>
<li>
<img src={playStoreImg} alt="" />
</li>
</ul>
</div>
</div>
</Col>
</Row>
</Container>
</div>
</>
);
};
export default Footer;
$main_green: #56a514;
.mainContainer {
width: 100%;
background-color: $main_green;
color: white;
font-family: "Poppin-Regular";
h2 {
color: white;
font-family: "Poppin-Bold";
}
ul {
margin: 0px;
padding: 0px;
}
ul > li {
text-decoration: none;
list-style: none;
font-size: 18px;
padding: 10px 0px;
}
ul > li > a {
color: white;
margin-left: 8px;
&:hover {
color: black;
}
}
.firstContainer,
.secondContainer,
.thirdContainer,
.fourthContainer {
padding-top: 40px;
padding-bottom: 20px;
}
.fourthContainer {
img {
cursor: pointer;
width: 90%;
height: 85px;
}
}
}
import React from "react";
import {
Button,
Col,
Container,
Row,
Navbar,
NavDropdown,
Nav,
} from "react-bootstrap";
import { Container, Navbar, Nav } from "react-bootstrap";
import style from "./Navbar.module.scss";
import logo from "../../assets/logo.png";
import logo from "../../assets/images/logo.png";
import { Input } from "antd";
import { IoMdCart } from "react-icons/io";
import { IoCartOutline } from "react-icons/io5";
import { headerData } from "../../Helper/dummyData";
import { useSelector } from "react-redux";
const { Search } = Input;
const MainNavbar = () => {
const MainNavbar = ({ setVisible }) => {
const { cart } = useSelector((state) => state.cart);
return (
<>
<div className={style.mainCOntainer}>
<section className={style.firstSection}>
<p>Delivering Only In Karachi</p>
</section>
<section className={style.secondSection}>
<p>Customer Care</p>
<p>0900 78601</p>
</section>
<section>
<Navbar collapseOnSelect expand="lg" bg="light" variant="light">
<Navbar
collapseOnSelect
expand="lg"
bg="light"
variant="light"
className={style.navbarMainContainer}
>
<Container>
<Navbar.Brand href="">
<img src={logo} alt="Hum Mart Logo" />
</Navbar.Brand>
<Navbar.Toggle aria-controls="responsive-navbar-nav" />
<Navbar.Collapse id="responsive-navbar-nav">
<Nav className="me-auto">
</Nav>
<Nav className="me-auto" style={{width: "70%"}}>
<Search
placeholder="input search text"
<Nav className="me-auto"></Nav>
<Nav className={`me-auto ${style.searchContainer}`}>
<Search
placeholder="Search Products"
enterButton="Search"
size="large"
/>
......@@ -43,15 +47,42 @@ const MainNavbar = () => {
<Nav.Link href="#pricing">Pricing</Nav.Link> */}
</Nav>
<Nav>
<Nav.Link href="#deets">More deets</Nav.Link>
<Nav.Link eventKey={2} href="#memes">
Dank memes
<Nav.Link>
<div
className={style.cartContianer}
onClick={() => setVisible(true)}
>
<IoCartOutline className={style.cartIcon} />
<p className={style.cartCount}>{Object.values(cart).length}</p>
</div>
</Nav.Link>
</Nav>
</Navbar.Collapse>
</Container>
</Navbar>
</section>
<Container>
<section className={style.thirdContainer}>
<ul>
{headerData?.map((item, index) => {
return (
<li key={index}>
<a
href={item?.link}
className={
headerData?.length - 1 !== index
? style.borderRight
: ""
}
>
{item?.link}
</a>
</li>
);
})}
</ul>
</section>
</Container>
</div>
</>
);
......
$black_color: black;
$white_color: white;
$main_green: #56a514;
.mainCOntainer{
}
.firstSection {
.mainCOntainer {
.firstSection {
width: 100%;
height: 40px;
background-color: $black_color;
display: flex;
justify-content: center;
align-items: center;
}
p {
color: $white_color;
margin: 0px;
padding: 0px;
font-weight: bold;
font-size: 18px;
}
}
.secondSection {
width: 100%;
height: 25px;
background-color: rgb(238, 238, 238);
display: flex;
justify-content: flex-end;
align-items: center;
p {
color: black;
margin: 0px;
padding: 0px;
font-size: 14px;
padding-right: 40px;
}
}
.navbarMainContainer {
// height: 90px;
// min-height: 190px;
}
.searchContainer {
width: 75%;
}
.cartContianer {
position: relative;
.firstSection p{
color: $white_color;
margin: 0px;
padding: 0px;
font-weight: bold;
font-size:18px ;
}
\ No newline at end of file
.cartIcon {
font-size: 35px;
color: $main_green;
}
.cartCount {
position: absolute;
top: -10px;
left: 25px;
background-color: red;
font-size: 12px;
width: 20px;
height: 20px;
border-radius: 50px;
color: $white_color;
display: flex;
justify-content: center;
align-items: center;
}
}
.thirdContainer {
width: 100%;
height: 35px;
background-color: $main_green;
display: flex;
margin-top: 20px;
ul {
text-decoration: none;
list-style: none;
display: flex;
align-items: center;
margin: 0px;
}
li {
padding-left: 10px;
}
ul li a {
text-decoration: none;
color: white;
font-size: 16px;
padding-right: 10px;
}
.borderRight {
border-right: 1px solid black;
}
}
}
import React from "react"
import { Button, notification } from 'antd';
const Context = React.createContext({ name: 'Default' });
const NotificationBox = () => {
const [api, contextHolder] = notification.useNotification();
const openNotification = placement => {
api.info({
message: `Notification ${placement}`,
description: <Context.Consumer>{({ name }) => `Hello, ${name}!`}</Context.Consumer>,
placement,
});
};
return (
<Context.Provider value={{ name: 'Ant Design' }}>
{contextHolder}
<Button type="danger" onClick={() => openNotification('bottomLeft')}>
bottomLeft
</Button>
</Context.Provider>
);
};
export default NotificationBox;
\ No newline at end of file
import fruitAndVegetablesImg from "../assets/images/fruitAndVegetables.jpeg";
import offerImg from "../assets/images/offer.jpg";
import discountImg from "../assets/images/20_discount.jpeg";
import mart_innerImg from "../assets/images/mart_inner.jpeg";
const headerData = [
{
id: 1,
link: "Mobile Tablet and Laptop",
},
];
const carouselData = [
{ id: 1, image: fruitAndVegetablesImg },
{ id: 2, image: offerImg },
{ id: 3, image: discountImg },
{ id: 4, image: mart_innerImg },
];
const cardData = [
{
id: 1,
image: "https://i.ytimg.com/vi/ErN642emCr4/maxresdefault.jpg",
title: "Redmi Hot 8 Pro",
price: 2000,
},
{
id: 2,
image:
"https://www.infinixmobility.com/fileadmin/assets/images/product/list/hot9.jpg",
title: "samsung A2 (2018) Blue | with official warranty",
price: 40000,
},
{
id: 3,
image:
"https://www.infinixmobility.com/fileadmin/assets/images/product/list/hot9.jpg",
title: "samsung A2 (2018) Blue | with official warranty",
price: 34000,
},
{
id: 4,
image:
"https://akm-img-a-in.tosshub.com/indiatoday/images/story/201912/Redmi_Note_8_Pro__10_.jpeg?Bhs5HyEc6QfbqeGsREQZXjSWddZwkixt&size=770:433",
title: "samsung A2 (2018) Blue | with official warranty",
price: 2200,
},
{
id: 5,
image:
"https://www.infinixmobility.com/fileadmin/assets/images/product/list/hot9.jpg",
title: "samsung A2 (2018) Blue | with official warranty",
price: 2200,
},
];
const categoriesCardData = [
{
id: 1,
image:
"https://www.infinixmobility.com/fileadmin/assets/images/product/list/hot9.jpg",
title: "samsung A2 (2018) Blue | with official warranty",
},
{
id: 2,
image:
"https://i.ytimg.com/vi/ErN642emCr4/maxresdefault.jpg",
title: "samsung A2 (2018) Blue | with official warranty",
},
{
id: 3,
image:
"https://akm-img-a-in.tosshub.com/indiatoday/images/story/201912/Redmi_Note_8_Pro__10_.jpeg?Bhs5HyEc6QfbqeGsREQZXjSWddZwkixt&size=770:433",
title: "samsung A2 (2018) Blue | with official warranty",
},
];
export { headerData, carouselData, cardData, categoriesCardData};
import React from "react";
import React, { useState } from "react";
import MainNavbar from "../../Components/Navbar/Navbar";
import MainCarousel from "../../Components/Carousel/Carousel";
import style from "./Home.module.scss";
import { Container, Row, Col } from "react-bootstrap";
import bestPriceImg from "../../assets/images/bestPrice.jpg";
import prayerMatImg from "../../assets/images/prayerMat.jpg";
import MainCard from "../../Components/Card.js/Card";
import CategoriesCard from "../../Components/Card.js/CategoriesCard";
import { cardData, categoriesCardData } from "../../Helper/dummyData";
import Footer from "../../Components/Footer/Footer";
import { useDispatch, useSelector } from "react-redux";
import MainDrawer from "../../Components/Drawer/Drawer";
import { notification } from "antd";
const Home = () => {
const dispatch = useDispatch();
const {cart} = useSelector((state) => state.cart);
const [visible, setVisible] = useState(false);
const openNotification = (item, behaviour) => {
if (behaviour === "success") {
console.log(item);
notification.success({
message: "HUM MART",
description: `${item}`,
className: "custom-class",
placement: "bottomLeft",
duration: 2.5,
});
} else if (behaviour === "warning") {
console.log(item);
notification.warning({
message: "HUM MART",
description: `${item}`,
className: "custom-class",
placement: "bottomLeft",
duration: 2.5,
});
} else if (behaviour === "error") {
console.log(item);
notification.error({
message: "HUM MART",
description: `${item}`,
className: "custom-class",
placement: "bottomLeft",
duration: 2.5,
});
}
};
// console.log(count);
return (
<>
<MainNavbar />
<section>
<Container fluid className="p-0">
<Row>
<div>
<MainNavbar setVisible={setVisible} />
</div>
<div>
<Container className={style.carouselContainer}>
<Row className={style.carouselContainerRow}>
<Col xl={3} md={12} sm={12}>
<div className={style.leftImages}>
<div>
<img src={bestPriceImg} alt="best price" />
</div>
<div>
<img src={prayerMatImg} alt="prayer mat" />
</div>
</div>
</Col>
<Col xl={8} md={12} sm={12}>
<div>
<MainCarousel />
</div>
</Col>
</Row>
</Container>
</div>
<div className={style.thirdContainer}>
<Container>
<div className={style.thirdContainerHeading}>
<h3>Mobile Phone</h3>
</div>
<Row>
{cardData?.map((item, index) => {
return (
<Col
key={index}
xl={3}
md={4}
sm={12}
className={style.cardCol}
>
<MainCard
data={item}
openNotification={openNotification}
/>
</Col>
);
})}
</Row>
</Container>
</div>
<div className={style.fourthContainer}>
<Container>
<div className={style.fourthContainerHeading}>
<h3>Categories</h3>
</div>
<Row className={style.categoriesCardContainer}>
{categoriesCardData?.map((item, index) => {
return (
<Col md={6} key={index}>
<CategoriesCard data={item} />
</Col>
);
})}
</Row>
</Container>
</div>
<div className={style.fifthContainer}>
<Container>
<h3>Online Supermarket, Delivery in Karachi, Pakistan</h3>
<p>
Ever wondered of entering a grocery store and getting an
overview of products sections and get to grab the required
product from there? The alternate is our search bar of HumMart
where you can search from a wide range of categories including
grocery and staples, home furnishing, breakfast and dairy,
instant foods, biscuits and snacks, beverages, household
needs, personal care, home and kitchen, baby products, fruits
and vegetables, ice creams and a lot more. Now with online
phones and accessories purchase and with easy and timely home
delivery all over Pakistan. The online shopping of grocery is
a blessing to get the required products over a few clicks. We
at HumMart provides our customers with the best deals to get
value addition on the purchase of products available online as
a bundle offer. If you are in a mood to mingle with friends
but you got a grocery list in your pocket, just visit HumMart
and order the grocery to get it delivered right at your home
while you get yourself entertained with friends. Want to cook
your favorite dish, no need to worry for the items to prepare
a mouthwatering dish. HumMart offers you ample products to get
the ingredients for the dish. We will provide you the products
through express delivery within 2 hours. You have the
independence to opt out from numerous products as HumMart
focuses to bring utmost facilities through its online grocery
store and adding value in life of our valued customers. You
need to stay at your home, visit hummart.com through your
laptop, smartphone or even from phone application.
</p>
</Container>
</div>
<div className={style.footerDiv}>
<Footer />
</div>
</Row>
</Container>
<MainDrawer visible={visible} setVisible={setVisible} />
</section>
</>
);
};
......
.carouselContainer {
margin-top: 30px;
margin-bottom: 30px;
.leftImages {
display: flex;
align-items: center;
flex-direction: column;
width: 100%;
}
.leftImages div:nth-child(2) {
margin-top: 30px;
}
.carouselContainerRow {
display: flex;
justify-content: center;
}
}
.thirdContainer {
margin-top: 20px;
padding-top: 20px;
background-color: rgb(243, 243, 243);
margin-bottom: 100px;
.thirdContainerHeading {
border-bottom: 1px solid rgb(154, 154, 154);
h2 {
font-family: "Poppin-Medium";
}
}
.cardCol {
margin: 40px 0px;
}
}
.fourthContainer {
padding-top: 20px;
background-color: rgb(243, 243, 243);
.fourthContainerHeading {
border-bottom: 1px solid rgb(154, 154, 154);
h2 {
font-family: "Poppin-Medium";
}
}
.categoriesCardContainer {
margin-top: 20px;
margin-bottom: 20px;
}
}
.fifthContainer {
margin-top: 50px !important;
h3 {
font-family: "Poppin-Medium";
}
p {
font-family: "Poppin-Regular";
text-align: justify;
}
}
.footerDiv {
margin-top: 30px !important;
}
@media only screen and (max-width: 1200px) {
.carouselContainer {
.leftImages {
display: flex;
flex-direction: row;
width: 100%;
overflow: auto;
}
.leftImages div {
padding: 0px 30px 30px 30px;
}
.leftImages div:nth-child(2) {
margin-top: 0px;
}
}
}
Copyright 2020 The Poppins Project Authors (https://github.com/itfoundry/Poppins)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
......@@ -6,7 +6,7 @@ import "bootstrap/dist/css/bootstrap.min.css";
import { Provider } from "react-redux";
import store from "./store/store";
import { BrowserRouter } from "react-router-dom";
import 'antd/dist/antd.css';
import "antd/dist/antd.css";
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
......
import { createSlice } from "@reduxjs/toolkit";
export const cartSlice = createSlice({
name: "cart",
initialState: {
cart: {},
item: [],
total: 0,
},
reducers: {
addCart(state, action) {
const data = action.payload.data;
// const findItem = state.item.find(
// (item) => item.id === action.payload.data.id
// );
// console.log(findItem);
// if (findItem === undefined) {
// state.item.push(action.payload.data);
// action.payload.openNotification(
// "Item Added in to Cart Successfully",
// "success"
// );
// state.total += action.payload.data.price;
// } else {
// action.payload.openNotification("This Item Already Exist", "warning");
// }
if (state.cart[data.id]) {
state.cart[data.id].counting++;
console.log("first Add", state.cart[data.id].counting);
action.payload.openNotification(
"Your Product Quantity Increase",
"warning"
);
state.total += action.payload.data.price;
} else {
state.cart[data.id] = {
counting: 1,
data: data,
};
action.payload.openNotification(
"Item Added in to Cart Successfully",
"success"
);
state.total += action.payload.data.price;
console.log("Not Add");
}
},
removeItem(state, action) {
// console.log(action);
// console.log(state.item);
// const newItem = state.item.filter(
// (item) => item.id !== action.payload.item.id
// );
// state.total = state.total - action.payload.item.price;
// action.payload.openNotification();
// console.log(newItem);
// state.item = newItem;
// const newItem = state.cart.filter(
// (item) => item?.data?.id !== action.payload.item?.data?.id
// );
// state.total = state.total - action.payload.item?.data?.price;
// action.payload.openNotification();
// console.log(newItem);
// state.item = newItem;
// state.cart[action.payload?.item] =
delete state.cart[action.payload.item.data.id];
state.total =
state.total -
action.payload?.item?.data?.price * action.payload?.item?.counting;
action.payload.openNotification(
"Item Remove From Cart Sucessfully",
"success"
);
},
increaseQuantity(state, action) {
state.cart[action.payload?.data?.id].counting++;
state.total += action.payload.data.price;
},
decreaseQuantity(state, action) {
state.cart[action.payload?.data?.id].counting--;
state.total = state.total - action.payload.data.price;
},
},
});
// each case under reducers becomes an action
export const { addCart, removeItem, increaseQuantity, decreaseQuantity } =
cartSlice.actions;
export default cartSlice.reducer;
import { configureStore, applyMiddleware } from '@reduxjs/toolkit'
import thunk from 'redux-thunk'
import counterSlice from './Reducers/counterReducer'
import { configureStore, applyMiddleware } from "@reduxjs/toolkit";
import thunk from "redux-thunk";
import counterSlice from "./Reducers/counterReducer";
import cartSlice from "./Reducers/cartReducer";
const store = configureStore({
reducer: {
counter: counterSlice,
} //add reducers here
})
reducer: {
counter: counterSlice,
cart: cartSlice,
}, //add reducers here
});
export default store;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment