ProductCard.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import React from "react";
  2. import { SimProduct } from "../services/types";
  3. import { Area } from "../services/product/type";
  4. import { useTranslation } from "react-i18next";
  5. import { formatCurrency, formatNumber } from "../logic/loigicUtils";
  6. const ProductCard: React.FC<{
  7. p: Area;
  8. onClick: (p: Area) => void;
  9. }> = ({ p, onClick }) => {
  10. const { t } = useTranslation();
  11. return (
  12. <div
  13. onClick={() => onClick(p)}
  14. className="bg-white border border-slate-100 rounded-[20px] p-3 md:p-6 shadow-sm hover:shadow-lg transition-all relative flex flex-col md:flex-row items-center md:space-x-4 space-y-2 md:space-y-0 group cursor-pointer text-center md:text-left"
  15. >
  16. {p.promotionPercent !== 0 && (
  17. <div className="absolute top-0 right-0 bg-[#EE0434] text-white text-[10px] font-black px-2 py-1 md:px-3 md:py-1.5 rounded-tr-[19px] rounded-bl-[14px] absolute-right-18">
  18. {p.promotionPercent}%
  19. </div>
  20. )}
  21. <div className="w-10 h-10 md:w-12 md:h-12 rounded-full overflow-hidden shrink-0 border border-slate-50 bg-slate-50">
  22. <img
  23. src={`${p.iconUrl}`}
  24. alt={p.areaName1}
  25. className="w-full h-full object-cover scale-150"
  26. />
  27. </div>
  28. <div className="flex-1 w-full">
  29. <h3 className="text-slate-900 font-black text-sm md:text-lg mb-0.5 group-hover:text-[#EE0434] transition-colors truncate px-1">
  30. {p.areaName1}
  31. </h3>
  32. <p className="text-xs text-slate-400 line-through mb-1">
  33. {formatCurrency(p.minDisplayPrice, p.curency)}
  34. </p>
  35. <p className="text-[#EE0434] font-bold text-xs md:text-lg">
  36. <span className="text-black text-sm md:text-sm lg:text-base">
  37. {t("from")}:{" "}
  38. </span>
  39. <span className="font-black text-lg md:text-xs lg:text-xl">
  40. {formatCurrency(p.minSellPrice, p.curency)}
  41. </span>
  42. </p>
  43. </div>
  44. </div>
  45. );
  46. };
  47. export default ProductCard;