1
0

Forgot to check for the stock in the part detils page

This commit is contained in:
Ahmed Al-Taiar
2023-11-22 11:47:38 -05:00
parent 9c0bee1d0b
commit c9946b3d33

View File

@ -55,7 +55,7 @@ const image = (url: string, size: number) => {
} }
export const Success = ({ part }: CellSuccessProps<FindPartDetailsById>) => { export const Success = ({ part }: CellSuccessProps<FindPartDetailsById>) => {
const [toTake, setToTake] = useState(1) const [toTake, setToTake] = useState(part.availableStock > 0 ? 1 : 0)
return ( return (
<div className="grid grid-cols-1 gap-8 sm:grid-cols-2"> <div className="grid grid-cols-1 gap-8 sm:grid-cols-2">
<div className="col-span-2"> <div className="col-span-2">
@ -81,7 +81,9 @@ export const Success = ({ part }: CellSuccessProps<FindPartDetailsById>) => {
<div className="flex space-x-5"> <div className="flex space-x-5">
<div className="join"> <div className="join">
<button <button
className={`btn join-item ${toTake == 1 ? 'btn-disabled' : ''}`} className={`btn join-item ${
toTake == 1 || part.availableStock == 0 ? 'btn-disabled' : ''
}`}
onClick={() => setToTake(toTake - 1)} onClick={() => setToTake(toTake - 1)}
> >
<Icon path={mdiMinus} className="h-6 w-6" /> <Icon path={mdiMinus} className="h-6 w-6" />
@ -99,7 +101,7 @@ export const Success = ({ part }: CellSuccessProps<FindPartDetailsById>) => {
</button> </button>
</div> </div>
<button <button
className="btn btn-primary" className={`btn btn-primary ${toTake == 0 ? 'btn-disabled' : ''}`}
onClick={() => { onClick={() => {
const newBasket = addToBasket(part, toTake) const newBasket = addToBasket(part, toTake)