food link to single
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
import { memo, useMemo } from "react";
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { useParams } from "next/navigation";
|
||||
import PlusIcon from "@/components/icons/PlusIcon";
|
||||
import MinusIcon from "@/components/icons/MinusIcon";
|
||||
import { useCart } from "@/app/[name]/(Dialogs)/cart/hook/useCart";
|
||||
@@ -14,6 +16,8 @@ interface MenuItemProps {
|
||||
|
||||
const MenuItem = ({ food }: MenuItemProps) => {
|
||||
const { items, addToCart, removeFromCart } = useCart();
|
||||
const params = useParams<{ name: string }>();
|
||||
const name = params?.name || '';
|
||||
|
||||
const quantity = useMemo(() => {
|
||||
const item = items?.[food.id];
|
||||
@@ -73,26 +77,32 @@ const MenuItem = ({ food }: MenuItemProps) => {
|
||||
removeFromCart(food.id);
|
||||
};
|
||||
|
||||
const foodDetailUrl = `/${name}/${food.id}`;
|
||||
|
||||
return (
|
||||
<div className="flex gap-4 w-full h-full items-center">
|
||||
<Image
|
||||
className="rounded-xl w-28 h-28 object-cover"
|
||||
src={resolvedImage}
|
||||
height={112}
|
||||
width={112}
|
||||
alt={foodName}
|
||||
/>
|
||||
<Link href={foodDetailUrl} className="cursor-pointer">
|
||||
<Image
|
||||
className="rounded-xl min-w-28 w-28 h-28 object-cover"
|
||||
src={resolvedImage}
|
||||
height={112}
|
||||
width={112}
|
||||
alt={foodName}
|
||||
/>
|
||||
</Link>
|
||||
<div className="w-full inline-flex flex-col justify-between">
|
||||
<div>
|
||||
<div className="text-sm2 font-normal text-black dark:text-white">
|
||||
{foodName}
|
||||
</div>
|
||||
{(foodContent || foodDescription) && (
|
||||
<div className="text-[#7F7F7F] line-clamp-2 text-xs leading-5 font-normal mt-2">
|
||||
{foodContent || foodDescription}
|
||||
<Link href={foodDetailUrl} className="cursor-pointer">
|
||||
<div>
|
||||
<div className="text-sm2 font-normal text-black dark:text-white">
|
||||
{foodName}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{(foodContent || foodDescription) && (
|
||||
<div className="text-[#7F7F7F] line-clamp-2 text-xs leading-5 font-normal mt-2">
|
||||
{foodContent || foodDescription}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Link>
|
||||
<div className="inline-flex mt-2 gap-2 justify-between w-full items-center">
|
||||
<span className="w-full text-sm mt-1" dir="ltr">
|
||||
{formattedPrice} T
|
||||
|
||||
Reference in New Issue
Block a user