-
-
-
+ <>
+
- {activeCategory?.children &&
}
+ {/* Menu */}
+
+
+
+
+
+ {activeCategory?.children && (
+
+ )}
+
-
- )
+ >
+ );
}
interface CategoryListProps {
- categories: any[]
- isLoading: boolean
- onCategoryHover: (index: number) => void
- onCategoryClick: () => void
+ categories: any[];
+ isLoading: boolean;
+ onCategoryHover: (index: number) => void;
+ onCategoryClick: () => void;
}
-function CategoryList({ categories, isLoading, onCategoryHover, onCategoryClick }: CategoryListProps) {
+function CategoryList({
+ categories,
+ isLoading,
+ onCategoryHover,
+ onCategoryClick,
+}: CategoryListProps) {
return (
{isLoading
- ? [1, 2, 3, 4, 5].map((i) => )
+ ? [1, 2, 3, 4, 5].map((i) => (
+
+ ))
: categories.map((category, index) => (
onCategoryHover(index)}
- className="flex items-center gap-3 px-4 py-3 rounded-xl hover:bg-gray-100 hover:text-primary transition-colors"
+ className="flex items-center gap-3 px-4 py-3 rounded-lg hover:bg-gray-100 hover:text-primary transition-colors"
>
- {category.icon_class && }
+ {category.icon_class && (
+
+ )}
{category.name}
))}
- )
+ );
}
interface SubcategoryListProps {
- category: any
- onSubcategoryClick: () => void
+ category: any;
+ onSubcategoryClick: () => void;
}
-function SubcategoryList({ category, onSubcategoryClick }: SubcategoryListProps) {
+function SubcategoryList({
+ category,
+ onSubcategoryClick,
+}: SubcategoryListProps) {
return (
{category.name}
@@ -91,5 +160,5 @@ function SubcategoryList({ category, onSubcategoryClick }: SubcategoryListProps)
))}
- )
+ );
}
diff --git a/context/AuthWrapper.tsx b/context/AuthWrapper.tsx
index ed07b2e..e92f757 100644
--- a/context/AuthWrapper.tsx
+++ b/context/AuthWrapper.tsx
@@ -3,7 +3,7 @@
"use client";
import { useEffect, type ReactNode } from "react";
-import { useRouter, usePathname } from "next/navigation";
+import { useRouter } from "next/navigation";
import { useAuthStatus, useGetGuestToken } from "@/lib/hooks/useAuth";
import { useUserProfile } from "@/features/profile/hooks/useUserProfile";
import Preloader from "@/components/PageLoader/PreLoader";
@@ -23,14 +23,12 @@ export default function AuthWrapper({
locale,
}: AuthWrapperProps) {
const router = useRouter();
- const pathname = usePathname();
const { isAuthenticated, isLoading } = useAuthStatus();
- const { mutate: getGuestToken, isPending: isGettingGuestToken } = useGetGuestToken();
-
- // Fetch user profile only if authenticated
+ const { mutate: getGuestToken, isPending: isGettingGuestToken } =
+ useGetGuestToken();
+
useUserProfile();
- // Initialize guest token if needed
useEffect(() => {
if (isLoading) return;
@@ -39,26 +37,23 @@ export default function AuthWrapper({
}
}, [isLoading, getGuestToken, isGettingGuestToken]);
- // Handle redirects
useEffect(() => {
if (isLoading || isGettingGuestToken) return;
-
- // Redirect to login if auth required but not authenticated
if (requireAuth && !isAuthenticated) {
- const redirect = redirectTo || `/${locale}/login`;
- const returnUrl = pathname !== redirect ? `?returnUrl=${encodeURIComponent(pathname)}` : "";
- router.push(`${redirect}${returnUrl}`);
+ router.push(`/${locale}`);
return;
}
-
- if (isAuthenticated && (pathname.includes("/login") || pathname.includes("/register"))) {
- router.push(`/${locale}`);
- }
- }, [isAuthenticated, isLoading, requireAuth, pathname, router, locale, redirectTo, isGettingGuestToken]);
-
+ }, [
+ isAuthenticated,
+ isLoading,
+ requireAuth,
+ router,
+ locale,
+ isGettingGuestToken,
+ ]);
if (isLoading || (requireAuth && !isAuthenticated)) {
return
;
}
return <>{children}>;
-}
\ No newline at end of file
+}
diff --git a/features/home/components/Carousel.tsx b/features/home/components/Carousel.tsx
index 6884b71..b154387 100644
--- a/features/home/components/Carousel.tsx
+++ b/features/home/components/Carousel.tsx
@@ -1,38 +1,54 @@
-"use client"
-import Image, { type StaticImageData } from "next/image"
-import { Swiper, SwiperSlide } from "swiper/react"
-import { Autoplay } from "swiper/modules"
-import "swiper/css"
+"use client";
+import Image, { type StaticImageData } from "next/image";
+import Link from "next/link";
+import { Swiper, SwiperSlide } from "swiper/react";
+import { Autoplay } from "swiper/modules";
+import "swiper/css";
type CarouselItem = {
- title: string
- image: StaticImageData | string
- url?: string | null
-}
+ title: string;
+ image: StaticImageData | string;
+ url?: string | null;
+};
export default function HeroCarousel({ items }: { items: CarouselItem[] }) {
return (
-
{items.map((item, i) => (
-
-
-
+ {item.url ? (
+
+
+
+ ) : (
+
+
+
+ )}
))}
- )
-}
\ No newline at end of file
+ );
+}
diff --git a/features/home/components/ProductCard.tsx b/features/home/components/ProductCard.tsx
index 91aad96..f9ab5af 100644
--- a/features/home/components/ProductCard.tsx
+++ b/features/home/components/ProductCard.tsx
@@ -347,7 +347,7 @@ export default function ProductCard({
{isOutOfStock && (
- Out of Stock
+ {t("outOfStock")}
)}
diff --git a/i18n/messages/ru.json b/i18n/messages/ru.json
index 2885b14..1afea82 100644
--- a/i18n/messages/ru.json
+++ b/i18n/messages/ru.json
@@ -171,6 +171,7 @@
"share_experience": "Поделитесь опытом с этим товаром",
"rating": "Рейтинг",
"your_review": "Ваш отзыв",
+ "submit": "Отправить",
"submitting": "Отправляется...",
"submit_review": "Отправить отзыв",
"characters": "символы",
@@ -185,7 +186,11 @@
"collection_not_found": "Коллекция не найдена",
"added_to_favorites": "Товар добавлен в избранное",
"submit_success": "Отзыв отправлен",
- "submit_error": "Произошла ошибка"
-
-
+ "submit_error": "Произошла ошибка",
+ "title": "Открыть магазин",
+ "enter_email": "Введите email",
+ "uploadPatent": "Загрузить патент",
+ "outOfStock": "Нет в наличии"
}
+
+
diff --git a/i18n/messages/tm.json b/i18n/messages/tm.json
index de64c61..a9ecf55 100644
--- a/i18n/messages/tm.json
+++ b/i18n/messages/tm.json
@@ -172,6 +172,7 @@
"share_experience": "Bu haryt barada öz teswiriňizi ýazyň",
"rating": "Reýting",
"your_review": "Teswiriňiz",
+ "sumbit": "Ugratmak",
"submitting": "Ugradylýar...",
"submit_review": "Teswiri ugrat",
"characters": "simbol",
@@ -186,7 +187,9 @@
"collection_not_found": "Kolleksiýa tapylmady",
"added_to_favorites": "Haryt saýlananlara goşuldy",
"submit_success": "Üstünlikli ugradyldy",
- "submit_error": "Ýalňyşlyk ýüze çykdy"
-
-
+ "submit_error": "Ýalňyşlyk ýüze çykdy",
+ "title": "Magazin aç",
+ "enter_email": "Poçtaňyzy ýazyň",
+ "uploadPatent": "Patent goş",
+ "outOfStock": "Ammarda ýok"
}
diff --git a/lib/hooks/useAuth.ts b/lib/hooks/useAuth.ts
index f7488d4..2ec0920 100644
--- a/lib/hooks/useAuth.ts
+++ b/lib/hooks/useAuth.ts
@@ -222,25 +222,16 @@ export function useLogout() {
try {
await apiClient.post("/auth/logout", {}, { timeout: 5000 });
} catch (error) {
- // Logout should succeed even if server call fails
console.warn("[Logout] Server call failed, clearing local state anyway");
}
},
onSuccess: () => {
TokenStorage.clearTokens();
queryClient.clear();
-
- if (typeof window !== "undefined") {
- window.location.href = "/";
- }
},
onError: () => {
TokenStorage.clearTokens();
queryClient.clear();
-
- if (typeof window !== "undefined") {
- window.location.href = "/";
- }
},
});
}
\ No newline at end of file