back in fixed category

This commit is contained in:
hamid zarghami
2026-01-04 16:38:04 +03:30
parent 6ebefa6a52
commit 86aebd7a9f
4 changed files with 27 additions and 17 deletions
+12 -2
View File
@@ -19,7 +19,7 @@ type Props = object
function FoodPage({ }: Props) {
const { id } = useParams();
const { id, name } = useParams();
const router = useRouter();
const { isSuccess } = useGetProfile();
const { data: food, isLoading } = useGetFood(id as string);
@@ -116,6 +116,16 @@ function FoodPage({ }: Props) {
? foodData.content.join('، ')
: foodData.content || foodData.desc || '';
const handleBackToMenu = () => {
const urlParams = new URLSearchParams(window.location.search);
const categoryParam = urlParams.get('category') || foodData.category?.id;
if (categoryParam) {
router.push(`/${name}?category=${categoryParam}`);
} else {
router.push(`/${name}`);
}
};
return (
<div className='lg:absolute lg:top-1/2 not-lg:max-w-lg not-lg:place-self-center lg:-translate-y-1/2 xl:right-[285px] lg:left-5 lg:right-4 lg:bottom-4 not-lg:w-full not-md:-translate-y-2 pt-6 flex flex-col lg:grid grid-cols-2 bottom-10'>
<div className="relative w-full h-full not-lg:bg-container rounded-2xl overflow-hidden lg:rounded-r-none lg:order-1">
@@ -132,7 +142,7 @@ function FoodPage({ }: Props) {
<div className="bg-container whitespace-nowrap rounded-[34px] py-1.5 px-4 w-min text-xs text-disabled2 dark:text-disabled-text font-bold">
{categoryName || '-'}
</div>
<button onClick={() => router.back()} className='p-2 rounded-full bg-container/40'>
<button onClick={handleBackToMenu} className='p-2 rounded-full bg-container/40'>
<ArrowLeft size={18} className='stroke-primary dark:stroke-foreground' />
</button>
</div>