Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Cart Functionality: Added Quantity Modification and Item Removal issue:#50 #148

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/src/assets/empty_cart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 19 additions & 13 deletions client/src/components/Cart-Card/index.jsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,56 @@
const Cartcard = (props) => {
import React from "react";

const Cartcard = ({ productId, productImage, shoename, shoeSize, quantity, price, onIncrease, onDecrease, onRemove }) => {
return (
<>
<div
className="justify-between mb-6 rounded-lg bg-white p-6 shadow-md sm:flex sm:justify-start"

>
<div className="justify-between mb-6 rounded-lg bg-white p-6 shadow-md sm:flex sm:justify-start">
<img
src={props.productImage}
src={productImage}
alt="product-image"
className="w-full rounded-lg sm:w-40"
/>
<div className="sm:ml-4 sm:flex sm:w-full sm:justify-between">
<div className="mt-5 sm:mt-0">
<h2 className="text-lg font-bold text-gray-900">
{props.shoename}
{shoename}
</h2>
<p className="mt-1 text-xs text-gray-700">
{props.shoeSize}
Size: {shoeSize}
</p>
</div>
<div className="mt-4 flex justify-between sm:space-y-6 sm:mt-0 sm:block sm:space-x-6">
<div className="flex items-center border-gray-100">
<span className="cursor-pointer rounded-l bg-gray-100 py-1 px-3.5 duration-100 hover:bg-blue-500 hover:text-blue-50">
<span
className="cursor-pointer rounded-l bg-gray-100 py-1 px-3.5 duration-100 hover:bg-blue-500 hover:text-blue-50"
onClick={() => onDecrease(productId)}
>
{" "}
-{" "}
</span>
<input
className="h-8 w-8 border bg-white text-center text-xs outline-none"
type="number"
defaultValue={props.quantity}
min="1"
value={quantity}
readOnly
/>
<span className="cursor-pointer rounded-r bg-gray-100 py-1 px-3 duration-100 hover:bg-blue-500 hover:text-blue-50">
<span
className="cursor-pointer rounded-r bg-gray-100 py-1 px-3 duration-100 hover:bg-blue-500 hover:text-blue-50"
onClick={() => onIncrease(productId)}
>
{" "}
+{" "}
</span>
</div>
<div className="flex items-center space-x-4">
<p className="text-sm">{props.price}</p>
<p className="text-sm">Price: {price}</p>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth="1.5"
stroke="currentColor"
className="h-5 w-5 cursor-pointer duration-150 hover:text-red-500"
onClick={() => onRemove(productId)}
>
<path
strokeLinecap="round"
Expand Down
Loading
Loading