From dc478c57bba97739de6e90e0a47ab67a4d6a2b18 Mon Sep 17 00:00:00 2001 From: Samandar Turgunboyev Date: Tue, 14 Oct 2025 16:11:32 +0500 Subject: [PATCH] bug fix --- src/app/[locale]/boxes/page.tsx | 14 +++++--------- src/app/[locale]/boxes/qr-code/page.tsx | 14 +++++--------- src/app/[locale]/layout.tsx | 14 ++++++-------- src/shared/config/api/httpClient.ts | 3 +-- src/shared/hooks/use-closer.ts | 2 +- src/shared/lib/formatPrice.ts | 8 ++++---- src/widgets/boxes/index.tsx | 21 --------------------- src/widgets/footer/ui/index.tsx | 8 +++++--- src/widgets/navbar/ui/ChangeLang.tsx | 11 +++++------ src/widgets/navbar/ui/index.tsx | 19 +++++++++++++------ src/widgets/welcome/index.tsx | 8 ++------ 11 files changed, 47 insertions(+), 75 deletions(-) diff --git a/src/app/[locale]/boxes/page.tsx b/src/app/[locale]/boxes/page.tsx index fee3451..091bf23 100644 --- a/src/app/[locale]/boxes/page.tsx +++ b/src/app/[locale]/boxes/page.tsx @@ -1,13 +1,9 @@ -import { getPosts } from '@/shared/config/api/testApi'; import Welcome from '@/widgets/welcome'; export default async function BoxesPage() { - const res = await getPosts({ _limit: 1 }); - console.log('SSR res', res.data); - - return ( -
- -
- ); + return ( +
+ +
+ ); } diff --git a/src/app/[locale]/boxes/qr-code/page.tsx b/src/app/[locale]/boxes/qr-code/page.tsx index ee954ed..3056846 100644 --- a/src/app/[locale]/boxes/qr-code/page.tsx +++ b/src/app/[locale]/boxes/qr-code/page.tsx @@ -1,13 +1,9 @@ -import { getPosts } from '@/shared/config/api/testApi'; import Welcome from '@/widgets/welcome'; export default async function QrCode() { - const res = await getPosts({ _limit: 1 }); - console.log('SSR res', res.data); - - return ( -
- -
- ); + return ( +
+ +
+ ); } diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx index 0477c6a..26d8d15 100644 --- a/src/app/[locale]/layout.tsx +++ b/src/app/[locale]/layout.tsx @@ -1,17 +1,15 @@ -import type { Metadata } from 'next'; -import '../globals.css'; import { golosText } from '@/shared/config/fonts'; +import { routing } from '@/shared/config/i18n/routing'; +import QueryProvider from '@/shared/config/react-query/QueryProvider'; import { ThemeProvider } from '@/shared/config/theme-provider'; import { PRODUCT_INFO } from '@/shared/constants/data'; +import type { Metadata } from 'next'; import { hasLocale, Locale, NextIntlClientProvider } from 'next-intl'; -import { routing } from '@/shared/config/i18n/routing'; -import { notFound } from 'next/navigation'; -import Footer from '@/widgets/footer/ui'; -import Navbar from '@/widgets/navbar/ui'; -import { ReactNode } from 'react'; import { setRequestLocale } from 'next-intl/server'; -import QueryProvider from '@/shared/config/react-query/QueryProvider'; +import { notFound } from 'next/navigation'; import Script from 'next/script'; +import { ReactNode } from 'react'; +import '../globals.css'; export const metadata: Metadata = { title: PRODUCT_INFO.name, diff --git a/src/shared/config/api/httpClient.ts b/src/shared/config/api/httpClient.ts index 5329938..f32e25e 100644 --- a/src/shared/config/api/httpClient.ts +++ b/src/shared/config/api/httpClient.ts @@ -15,8 +15,7 @@ httpClient.interceptors.request.use( let language = LanguageRoutes.UZ; try { language = (await getLocale()) as LanguageRoutes; - } catch (e) { - console.log('error', e); + } catch { language = getLocaleCS() || LanguageRoutes.UZ; } diff --git a/src/shared/hooks/use-closer.ts b/src/shared/hooks/use-closer.ts index 4e005d4..1b60884 100644 --- a/src/shared/hooks/use-closer.ts +++ b/src/shared/hooks/use-closer.ts @@ -33,7 +33,7 @@ const useCloser = ( document.removeEventListener('mousedown', handleClickOutside); document.removeEventListener('scroll', handleScroll); }; - }, [ref, closeFunction]); + }, [ref, closeFunction, scrollClose]); }; export default useCloser; diff --git a/src/shared/lib/formatPrice.ts b/src/shared/lib/formatPrice.ts index 2fbfd5d..793eaf4 100644 --- a/src/shared/lib/formatPrice.ts +++ b/src/shared/lib/formatPrice.ts @@ -1,5 +1,5 @@ -import { LanguageRoutes } from '../config/i18n/types'; import { getLocale } from 'next-intl/server'; +import { LanguageRoutes } from '../config/i18n/types'; /** * Format price. With label. @@ -10,9 +10,9 @@ import { getLocale } from 'next-intl/server'; const formatPrice = async (amount: number | string, withLabel?: boolean) => { const locale = (await getLocale()) as LanguageRoutes; const label = withLabel - ? locale == LanguageRoutes.RU + ? locale === LanguageRoutes.RU ? ' сум' - : locale == LanguageRoutes.KI + : locale === LanguageRoutes.KI ? ' сўм' : ' so‘m' : ''; @@ -22,7 +22,7 @@ const formatPrice = async (amount: number | string, withLabel?: boolean) => { const formattedDollars = dollars.replace(/\B(?=(\d{3})+(?!\d))/g, ' '); - if (String(amount).length == 0) { + if (String(amount).length === 0) { return formattedDollars + '.' + cents + label; } else { return formattedDollars + label; diff --git a/src/widgets/boxes/index.tsx b/src/widgets/boxes/index.tsx index 02df4e4..c986bff 100644 --- a/src/widgets/boxes/index.tsx +++ b/src/widgets/boxes/index.tsx @@ -8,25 +8,6 @@ import Image from 'next/image'; import { useParams } from 'next/navigation'; const Boxes = () => { - const products = [ - { - name: 'Quloqchin', - nameRu: 'Наушники', - trackId: 'TRK-001', - quantity: 2, - price: '120 000 UZS', - weight: 0.4, - }, - { - name: 'Zaryadka', - nameRu: 'Зарядка', - trackId: 'TRK-002', - quantity: 1, - price: '60 000 UZS', - weight: 0.2, - }, - ]; - const { id } = useParams(); const { data } = useQuery({ @@ -37,8 +18,6 @@ const Boxes = () => { }, }); - console.log(data); - return (
diff --git a/src/widgets/footer/ui/index.tsx b/src/widgets/footer/ui/index.tsx index 01bf034..0b24253 100644 --- a/src/widgets/footer/ui/index.tsx +++ b/src/widgets/footer/ui/index.tsx @@ -1,7 +1,8 @@ import { PRODUCT_INFO } from '@/shared/constants/data'; -import { InstagramIcon, YoutubeIcon } from 'lucide-react'; -import { sections } from '../lib/data'; import { ModeToggle } from '@/shared/ui/theme-toggle'; +import { InstagramIcon, YoutubeIcon } from 'lucide-react'; +import Image from 'next/image'; +import { sections } from '../lib/data'; const Footer = () => { return ( @@ -12,11 +13,12 @@ const Footer = () => { {/* Logo */}
- {PRODUCT_INFO.name}

{PRODUCT_INFO.name}

diff --git a/src/widgets/navbar/ui/ChangeLang.tsx b/src/widgets/navbar/ui/ChangeLang.tsx index d338cb5..8677fb7 100644 --- a/src/widgets/navbar/ui/ChangeLang.tsx +++ b/src/widgets/navbar/ui/ChangeLang.tsx @@ -1,17 +1,16 @@ 'use client'; -import * as React from 'react'; -import { GlobeIcon } from 'lucide-react'; +import { LanguageRoutes } from '@/shared/config/i18n/types'; +import { Button } from '@/shared/ui/button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/shared/ui/dropdown-menu'; -import { Button } from '@/shared/ui/button'; -import { languages } from '../lib/data'; +import { GlobeIcon } from 'lucide-react'; import { useParams, usePathname, useRouter } from 'next/navigation'; -import { LanguageRoutes } from '@/shared/config/i18n/types'; +import { languages } from '../lib/data'; export function ChangeLang() { const { locale } = useParams(); @@ -30,7 +29,7 @@ export function ChangeLang() { diff --git a/src/widgets/navbar/ui/index.tsx b/src/widgets/navbar/ui/index.tsx index 5189141..9654fb5 100644 --- a/src/widgets/navbar/ui/index.tsx +++ b/src/widgets/navbar/ui/index.tsx @@ -1,3 +1,4 @@ +import { PRODUCT_INFO } from '@/shared/constants/data'; import { Accordion } from '@/shared/ui/accordion'; import { Button } from '@/shared/ui/button'; import { @@ -12,12 +13,12 @@ import { SheetTrigger, } from '@/shared/ui/sheet'; import { Menu } from 'lucide-react'; +import Image from 'next/image'; +import Link from 'next/link'; import { menu } from '../lib/data'; -import { PRODUCT_INFO } from '@/shared/constants/data'; +import { ChangeLang } from './ChangeLang'; import RenderMenuItem from './RenderItem'; import RenderMobileMenuItem from './RenderMobileMenuItem'; -import { ChangeLang } from './ChangeLang'; -import Link from 'next/link'; const Navbar = () => { const auth = { @@ -33,7 +34,9 @@ const Navbar = () => {
{/* Logo */} - {PRODUCT_INFO.name} {
{/* Logo */} - {PRODUCT_INFO.name} { - {PRODUCT_INFO.name} { return (
- logo + logo
); };