Replace entire repo content with updated code from /root/shahikitchen-website/
This commit is contained in:
+33
-18
@@ -18,6 +18,11 @@ import { useCart } from "@/components/CartContext";
|
||||
import WishlistButton from "@/components/WishlistButton";
|
||||
import { useLanguage } from "@/lib/language-context";
|
||||
import { getTranslation } from "@/lib/translations";
|
||||
import {
|
||||
getCategoryName,
|
||||
getMenuItemDescription,
|
||||
getMenuItemName,
|
||||
} from "@/application/i18n/menu-localization";
|
||||
import {
|
||||
dishImageUrl,
|
||||
getMenuPosterSrc,
|
||||
@@ -45,7 +50,10 @@ export default function MenuPage() {
|
||||
// Sidebar categories
|
||||
const sidebarCategories = [
|
||||
{ id: "All", name: t.menu.allDishes || "All Dishes" },
|
||||
...menuCategories.map((cat) => ({ id: cat.id, name: cat.name })),
|
||||
...menuCategories.map((cat) => ({
|
||||
id: cat.id,
|
||||
name: getCategoryName(language, cat.id, cat.name),
|
||||
})),
|
||||
];
|
||||
|
||||
// Filtering logic
|
||||
@@ -62,11 +70,15 @@ export default function MenuPage() {
|
||||
// Search
|
||||
if (searchQuery.trim()) {
|
||||
const q = searchQuery.toLowerCase().trim();
|
||||
items = items.filter(
|
||||
(item) =>
|
||||
item.name.toLowerCase().includes(q) ||
|
||||
(item.description && item.description.toLowerCase().includes(q))
|
||||
);
|
||||
items = items.filter((item) => {
|
||||
const localizedName = getMenuItemName(language, item).toLowerCase();
|
||||
const localizedDescription = getMenuItemDescription(language, t, item).toLowerCase();
|
||||
return (
|
||||
localizedName.includes(q) ||
|
||||
localizedDescription.includes(q) ||
|
||||
item.name.toLowerCase().includes(q)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Vegetarian
|
||||
@@ -77,7 +89,7 @@ export default function MenuPage() {
|
||||
return { ...category, items };
|
||||
})
|
||||
.filter((category) => category.items.length > 0);
|
||||
}, [searchQuery, showVegetarianOnly, activeCategory]);
|
||||
}, [searchQuery, showVegetarianOnly, activeCategory, language, t]);
|
||||
|
||||
const handleCategorySelect = (id: string) => {
|
||||
setActiveCategory(id);
|
||||
@@ -85,9 +97,9 @@ export default function MenuPage() {
|
||||
};
|
||||
|
||||
const getItemDescription = (item: MenuItem) =>
|
||||
(t as { menuDescriptions?: Record<string, string> }).menuDescriptions?.[item.id] ||
|
||||
item.description ||
|
||||
"";
|
||||
getMenuItemDescription(language, t, item);
|
||||
|
||||
const getItemName = (item: MenuItem) => getMenuItemName(language, item);
|
||||
|
||||
const openDishDetails = (item: MenuItem) => {
|
||||
setDetailItem(item);
|
||||
@@ -173,7 +185,7 @@ export default function MenuPage() {
|
||||
<div className="sticky top-[116px]">
|
||||
<div className="mb-6">
|
||||
<div className="text-xs tracking-[3px] text-[#c99a2e] mb-2">EXPLORE OUR</div>
|
||||
<h3 className="font-serif text-3xl tracking-tight">Signature Categories</h3>
|
||||
<h3 className="font-serif text-2xl sm:text-3xl tracking-tight">Signature Categories</h3>
|
||||
</div>
|
||||
|
||||
{/* Smooth scroll: horizontal on mobile, vertical on desktop when list exceeds viewport */}
|
||||
@@ -265,7 +277,9 @@ export default function MenuPage() {
|
||||
filteredCategories.map((category) => (
|
||||
<div key={category.id} className="mb-16">
|
||||
<div className="flex items-center gap-4 mb-7">
|
||||
<div className="text-3xl tracking-[-1px] text-[#101724]">{category.name}</div>
|
||||
<div className="text-xl sm:text-2xl md:text-3xl tracking-[-1px] text-[#101724] min-w-0 break-words">
|
||||
{getCategoryName(language, category.id, category.name)}
|
||||
</div>
|
||||
<div className="flex-1 h-px bg-gradient-to-r from-[#e5e1d7] to-transparent" />
|
||||
<div className="text-sm font-medium text-[#68717f] tracking-widest">
|
||||
{category.items.length} {t.menu.dishes}
|
||||
@@ -314,7 +328,7 @@ export default function MenuPage() {
|
||||
>
|
||||
<motion.img
|
||||
src={getCardImageSrc(item, category.id)}
|
||||
alt={item.name}
|
||||
alt={getItemName(item)}
|
||||
className="absolute inset-0 w-full h-full object-cover"
|
||||
loading="lazy"
|
||||
whileHover={!isMobile ? {
|
||||
@@ -337,18 +351,18 @@ export default function MenuPage() {
|
||||
)}
|
||||
<div className="absolute top-3 right-3 z-10">
|
||||
<WishlistButton
|
||||
item={{ id: item.id, name: item.name, price: item.price, image: item.image }}
|
||||
item={{ id: item.id, name: getItemName(item), price: item.price, image: item.image }}
|
||||
size="sm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="p-6 flex flex-col flex-1">
|
||||
<div className="flex justify-between items-start gap-4 mb-4">
|
||||
<h3 className="text-[22px] leading-tight tracking-[-0.4px] text-[#2C2A26]">
|
||||
{item.name}
|
||||
<div className="flex justify-between items-start gap-3 mb-4 min-w-0">
|
||||
<h3 className="min-w-0 flex-1 text-lg sm:text-[22px] leading-tight tracking-[-0.4px] text-[#2C2A26] break-words">
|
||||
{getItemName(item)}
|
||||
</h3>
|
||||
{renderMenuPrice(item)}
|
||||
<div className="shrink-0">{renderMenuPrice(item)}</div>
|
||||
</div>
|
||||
|
||||
{usesDetailModal ? (
|
||||
@@ -404,6 +418,7 @@ export default function MenuPage() {
|
||||
{detailItem && (
|
||||
<DishDetailsModal
|
||||
item={detailItem}
|
||||
displayName={getItemName(detailItem)}
|
||||
description={getItemDescription(detailItem)}
|
||||
isOpen={!!detailItem}
|
||||
onClose={() => setDetailItem(null)}
|
||||
|
||||
Reference in New Issue
Block a user