diff --git a/src/app/[locale]/all-product/page.tsx b/src/app/[locale]/all-product/page.tsx new file mode 100644 index 0000000..e97a568 --- /dev/null +++ b/src/app/[locale]/all-product/page.tsx @@ -0,0 +1,64 @@ +import AllProducts from '@/features/category/ui/AllProduct'; +import { Metadata } from 'next'; + +interface Props { + params: { locale: 'uz' | 'ru' }; +} + +export async function generateMetadata({ params }: Props): Promise { + const { locale } = params; + + const titles = { + uz: 'Barcha mahsulotlar | GASTRO', + ru: 'Все товары | GASTRO', + }; + + const descriptions = { + uz: 'GASTRO onlayn do‘konidagi barcha mahsulotlar ro‘yxati. Sifatli mahsulotlar, qulay narxlar va tez yetkazib berish.', + ru: 'Полный каталог товаров интернет-магазина GASTRO. Качественные товары, выгодные цены и быстрая доставка.', + }; + + const keywords = { + uz: 'barcha mahsulotlar, onlayn do‘kon, gastro, xarid, yetkazib berish', + ru: 'все товары, онлайн-магазин, gastro, покупка, доставка', + }; + + return { + title: titles[locale], + description: descriptions[locale], + keywords: keywords[locale], + openGraph: { + title: titles[locale], + description: descriptions[locale], + siteName: 'GASTRO', + images: [ + { + url: '/logos/logo.png', + width: 1200, + height: 1200, + alt: titles[locale], + }, + ], + locale: locale === 'uz' ? 'uz_UZ' : 'ru_RU', + type: 'website', + }, + twitter: { + card: 'summary_large_image', + title: titles[locale], + description: descriptions[locale], + images: ['/logos/logo.png'], + }, + robots: { + index: true, + follow: true, + }, + }; +} + +export default function AllProductPage() { + return ( +
+ +
+ ); +} diff --git a/src/features/category/ui/AllProduct.tsx b/src/features/category/ui/AllProduct.tsx new file mode 100644 index 0000000..10c704d --- /dev/null +++ b/src/features/category/ui/AllProduct.tsx @@ -0,0 +1,113 @@ +'use client'; + +import { product_api } from '@/shared/config/api/product/api'; +import { usePathname, useRouter } from '@/shared/config/i18n/navigation'; +import { Card } from '@/shared/ui/card'; +import { GlobalPagination } from '@/shared/ui/global-pagination'; +import { Skeleton } from '@/shared/ui/skeleton'; +import { ProductCard } from '@/widgets/categories/ui/product-card'; +import { useQuery } from '@tanstack/react-query'; +import { ArrowLeft } from 'lucide-react'; +import { useTranslations } from 'next-intl'; +import { useSearchParams } from 'next/navigation'; +import { useEffect, useState } from 'react'; + +const PAGE_SIZE = 36; + +const AllProducts = () => { + const router = useRouter(); + const pathname = usePathname(); + const searchParams = useSearchParams(); + const [page, setPage] = useState(1); + const t = useTranslations(); + + useEffect(() => { + const urlPage = Number(searchParams.get('page')) || 1; + setPage(urlPage); + }, [searchParams]); + + const { + data: product, + isLoading, + isError, + } = useQuery({ + queryKey: ['all_product_list', page], + queryFn: () => { + return product_api.list({ + page, + page_size: PAGE_SIZE, + }); + }, + select(data) { + return data.data; + }, + }); + + const handleBack = () => { + router.back(); + }; + + const handlePageChange = (newPage: number) => { + const params = new URLSearchParams(searchParams.toString()); + params.set('page', newPage.toString()); + + router.push(`${pathname}?${params.toString()}`, { + scroll: true, + }); + }; + + return ( +
+
+ {/* Header */} +
+ + +

+ {product?.total} {t('ta mahsulot')} +

+
+ + {/* Products grid */} +
+ {isLoading && + Array.from({ length: 6 }).map((_, index) => ( + + + + + + + ))} + {product && + !isLoading && + product.results + .filter((product) => product.state === 'A') + .map((item) => ( + + ))} +
+
+ + {/* Pagination at the bottom */} + {product && ( +
+ +
+ )} +
+ ); +}; + +export default AllProducts; diff --git a/src/shared/config/i18n/messages/ru.json b/src/shared/config/i18n/messages/ru.json index fa54daf..619f4c1 100644 --- a/src/shared/config/i18n/messages/ru.json +++ b/src/shared/config/i18n/messages/ru.json @@ -202,5 +202,7 @@ "So'rov yuborildi!": "Запрос успешно отправлен!", "Tez-tez So'raladigan Savollar": "Часто задаваемые вопросы", - "Gastro Market haqida eng ko'p so'raladigan savollarga javoblar": "Ответы на самые часто задаваемые вопросы о Gastro Market" + "Gastro Market haqida eng ko'p so'raladigan savollarga javoblar": "Ответы на самые часто задаваемые вопросы о Gastro Market", + + "Barcha mahsulotlar": "Все товары" } diff --git a/src/shared/config/i18n/messages/uz.d.json.ts b/src/shared/config/i18n/messages/uz.d.json.ts index eda7fdd..ac00953 100644 --- a/src/shared/config/i18n/messages/uz.d.json.ts +++ b/src/shared/config/i18n/messages/uz.d.json.ts @@ -202,5 +202,7 @@ declare const messages: { "Tez-tez So'raladigan Savollar": "Tez-tez So'raladigan Savollar"; "Gastro Market haqida eng ko'p so'raladigan savollarga javoblar": "Gastro Market haqida eng ko'p so'raladigan savollarga javoblar"; + + 'Barcha mahsulotlar': 'Barcha mahsulotlar'; }; export default messages; diff --git a/src/shared/config/i18n/messages/uz.json b/src/shared/config/i18n/messages/uz.json index 9bc2dac..7ab4783 100644 --- a/src/shared/config/i18n/messages/uz.json +++ b/src/shared/config/i18n/messages/uz.json @@ -198,5 +198,7 @@ "So'rov yuborildi!": "So'rov yuborildi!", "Tez-tez So'raladigan Savollar": "Tez-tez So'raladigan Savollar", - "Gastro Market haqida eng ko'p so'raladigan savollarga javoblar": "Gastro Market haqida eng ko'p so'raladigan savollarga javoblar" + "Gastro Market haqida eng ko'p so'raladigan savollarga javoblar": "Gastro Market haqida eng ko'p so'raladigan savollarga javoblar", + + "Barcha mahsulotlar": "Barcha mahsulotlar" } diff --git a/src/widgets/welcome/ui/index.tsx b/src/widgets/welcome/ui/index.tsx index 53dfdf4..4e9714e 100644 --- a/src/widgets/welcome/ui/index.tsx +++ b/src/widgets/welcome/ui/index.tsx @@ -4,7 +4,7 @@ import CategoryImage from '@/assets/water-bottle.png'; import { category_api } from '@/shared/config/api/category/api'; import { product_api } from '@/shared/config/api/product/api'; import { BASE_URL } from '@/shared/config/api/URLs'; -import { Link } from '@/shared/config/i18n/navigation'; +import { Link, useRouter } from '@/shared/config/i18n/navigation'; import { cn } from '@/shared/lib/utils'; import { AspectRatio } from '@/shared/ui/aspect-ratio'; import { Button } from '@/shared/ui/button'; @@ -31,6 +31,7 @@ const Welcome = () => { const [canScrollPrev, setCanScrollPrev] = useState(false); const [canScrollNext, setCanScrollNext] = useState(false); const [apiCat, setApiCat] = useState(); + const router = useRouter(); const { data, isLoading, isError } = useQuery({ queryKey: ['banner_list'], @@ -218,12 +219,25 @@ const Welcome = () => {
+
+
router.push(`/all-product/`)} + > +

+ Barcha mahsulotlar +

+
+ +
+
+
- + {productLoading && Array.from({ length: 6 }).map((__, index) => (