Update -> check config count

This commit is contained in:
2025-07-26 01:01:06 +03:30
parent 703c16e9ee
commit 2ee6a3b6fa

View File

@@ -71,36 +71,48 @@ const ListAllProduct = ({ activeId }: { activeId: number }) => {
className="w-full h-full border-4 gap-5 border-spacing-1 shadow-lg shadow-white border-solid border-white rounded-lg p-3 grid max-sm:grid-cols-1 max-md:grid-cols-2 max-lg:grid-cols-3 lg:grid-cols-4"
id="listConfig"
>
{data?.data?.result?.map((item: Record<string, string>) => {
const isDisabled = Number(item.max_config) == 0;
return (
<div className="w-full h-full flex flex-col" key={item.id}>
<img src={item.image} alt={item.title} />
<div className="w-full h-full flex justify-center items-center">
{token ? (
<Button
extra="!w-4/5"
onClick={() => {
<img
src={item.image}
alt={item.title}
className={`${isDisabled ? 'grayscale opacity-50' : ''}`}
onClick={() => {
if (isDisabled) {
toast.error("محصول ناموجود است");
}
}}
/>
<div className="w-full h-full flex justify-center items-center mt-2">
<Button
extra={`!w-4/5 ${isDisabled ? '!bg-black !text-white !cursor-not-allowed' : ''}`}
onClick={() => {
if (isDisabled) {
toast.error("محصول ناموجود است");
return;
}
if (token) {
setIsOpen(true);
setConfigId(Number(item.id));
}}
>
خرید
</Button>
) : (
<Button
extra="!w-4/5"
onClick={() => {
} else {
toast.error("برای خرید باید وارد شوید");
navigate("/login");
}}
>
خرید
</Button>
)}
}
}}
>
خرید
</Button>
</div>
</div>
);
})}
</div>
</>
);