web/components/Cards/CardCategoriesMobile/page.jsx

94 lines
3.2 KiB
React
Raw Normal View History

2024-02-05 01:40:57 +03:30
"use client";
2024-01-10 11:04:28 +03:30
import Image from "next/image";
import PersianNumber from "plugins/PersianNumber";
2024-02-05 01:40:57 +03:30
import React, { useContext, useState } from "react";
2024-02-11 17:24:30 +03:30
import logo from "../../../public/images/logo.png";
2024-02-05 01:40:57 +03:30
import AppContext from "@ctx/AppContext";
import Link from "next/link";
2024-02-11 17:24:30 +03:30
import AddToCart from "../Components/AddToCart/page";
2024-02-05 01:40:57 +03:30
const CardCategoriesMobile = ({ data }) => {
const CTX = useContext(AppContext);
const cart = CTX.state.cart;
2024-01-10 11:04:28 +03:30
return (
2024-02-05 01:40:57 +03:30
<div className="group border-t-[1px] border-gray-200 w-full hover:bg-white z-40 tr03 flex rtl pt-2 px-3">
2024-01-10 11:04:28 +03:30
<div className=" h-fit ">
2024-02-11 17:24:30 +03:30
{!!data.mainImage ? (
<Image
src={`${process.env.NEXT_PUBLIC_STORAGE_URL}/${data.mainImage}`}
width={100}
height={100}
className="xs:!w-[110px] lg:!w-[130px] mx-auto !object-cover"
/>
) : (
<div className="xs:!w-[85px] lg:!w-[85px] ">
<Image
src={logo}
className="xs:!w-[70px] lg:!w-[70px] mx-auto !object-cover opacity-25 mt-5"
/>
</div>
)}
2024-01-10 11:04:28 +03:30
</div>
2024-02-05 01:40:57 +03:30
<div className="p-3 text-right w-full">
2024-01-10 11:04:28 +03:30
<p className="mb-0 xs:text-[12px] lg:text-[11px] xl:text-[15px] max-h-[50px] tr03 ">
2024-02-05 01:40:57 +03:30
{data?.persianName}
2024-01-10 11:04:28 +03:30
</p>
2024-02-11 17:24:30 +03:30
{data.stock <= 3 && (
2024-02-05 01:40:57 +03:30
<p className="mb-0 xs:text-[11px] lg:text-[12px] xl:text-[13px] text-red-600 font-medium">
{" "}
2024-02-11 17:24:30 +03:30
{data.stock}عدد موجود انبار
2024-02-05 01:40:57 +03:30
</p>
)}
2024-01-10 11:04:28 +03:30
2024-02-05 01:40:57 +03:30
<div className=" rounded-full flex ltr pt-2 mt-2 w-full">
2024-02-11 17:24:30 +03:30
<AddToCart data={data} />{" "}
<div className="w-full text-right rounded-lg">
2024-02-05 01:40:57 +03:30
{data?.hasDiscount ? (
2024-01-10 11:04:28 +03:30
<div className="flex justify-end">
2024-02-11 17:24:30 +03:30
<div className="mb-0 font-bold text-sm absolute mt-[-7px] ml-[20px] text-red-600 flex rtl">
2024-01-10 11:04:28 +03:30
<del>
2024-02-11 17:24:30 +03:30
<PersianNumber
number={(data?.cost / 10).toLocaleString()}
style={"text-[13px] opacity-40 "}
/>
2024-01-10 11:04:28 +03:30
</del>
2024-02-11 17:24:30 +03:30
<span className="bg-red-500 mb-0 px-1 text-[9px] text-white rounded-full mx-2 h-fit ">
<PersianNumber
number={data?.discountPercent}
style={"text-white !text-[10px] mr-1 "}
/>
%
</span>
</div>
2024-01-10 11:04:28 +03:30
<div className="flex rtl mt-[8px]">
{" "}
<p className="mb-0 font-bold">
2024-02-11 17:24:30 +03:30
<PersianNumber
number={(data?.costWithDiscount / 10).toLocaleString()}
/>
2024-01-10 11:04:28 +03:30
</p>
<small className="mr-1 mt-[3px]">تومان</small>
</div>
</div>
) : (
<div className="flex rtl mt-[3px]">
{" "}
<p className="mb-0 font-bold text-lg">
2024-02-11 17:24:30 +03:30
<PersianNumber number={(data?.cost / 10).toLocaleString()} />
2024-01-10 11:04:28 +03:30
</p>
<small className="mr-1 mt-[6px]">تومان</small>
</div>
)}
</div>
</div>
</div>
</div>
);
};
export default CardCategoriesMobile;