Skip to content
This repository was archived by the owner on Jul 3, 2025. It is now read-only.
Merged
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
35 changes: 35 additions & 0 deletions app/pages/cart/QuantityControl.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Minus, Plus } from 'lucide-react'
import type { ReactElement } from 'react'
import { Button } from '~/components/ui/Button'

type QuantityControlProperties = {
quantity: number
handleQuantityChange: (quantity: number) => void
}

export function QuantityControl({ quantity = 1, handleQuantityChange }: QuantityControlProperties): ReactElement {
const handleDecrease = (): void => {
if (quantity > 1) handleQuantityChange(quantity - 1)
}

const handleIncrease = (): void => {
handleQuantityChange(quantity + 1)
}

return (
<div className="flex gap-2">
<Button
variant="gray"
className="w-6 h-6 rounded-sm cursor-pointer"
onClick={handleDecrease}
disabled={quantity === 1}
>
<Minus />
</Button>
<div className="w-6 h-6 flex justify-center items-center">{quantity}</div>
<Button variant="gray" className="w-6 h-6 rounded-sm cursor-pointer" onClick={handleIncrease}>
<Plus />
</Button>
</div>
)
}