diff --git a/src/app/[locale]/product/[product]/page.tsx b/src/app/[locale]/product/[product]/page.tsx
index 099695e..7f4bfbe 100644
--- a/src/app/[locale]/product/[product]/page.tsx
+++ b/src/app/[locale]/product/[product]/page.tsx
@@ -29,16 +29,13 @@ export async function generateMetadata({
res.data.short_name || `Gastro Market mahsuloti: ${res.data.name}`,
type: 'website',
images: [
- {
- url:
- res.data.images && res.data.images.length > 0
- ? res.data.images[0].image.includes(BASE_URL)
+ res.data.images && res.data.images.length > 0
+ ? {
+ url: res.data.images[0].image?.includes(BASE_URL)
? res.data.images[0].image
- : BASE_URL + res.data.images[0].image
- : '/placeholder.svg',
- width: 800,
- height: 600,
- },
+ : BASE_URL + res.data.images[0].image,
+ }
+ : { url: '/placeholder.svg' },
],
},
twitter: {
@@ -46,14 +43,15 @@ export async function generateMetadata({
title: `${res.data.name} - Gastro Market`,
description:
res.data.short_name || `Gastro Market mahsuloti: ${res.data.name}`,
- images:
+ images: [
res.data.images && res.data.images.length > 0
- ? [
- res.data.images[0].image.includes(BASE_URL)
+ ? {
+ url: res.data.images[0].image?.includes(BASE_URL)
? res.data.images[0].image
: BASE_URL + res.data.images[0].image,
- ]
- : ['/placeholder.svg'],
+ }
+ : { url: '/placeholder.svg' },
+ ],
},
};
} catch {
diff --git a/src/features/cart/ui/OrderPage.tsx b/src/features/cart/ui/OrderPage.tsx
index 1812937..3e0eda9 100644
--- a/src/features/cart/ui/OrderPage.tsx
+++ b/src/features/cart/ui/OrderPage.tsx
@@ -289,11 +289,11 @@ const OrderPage = () => {
{
filial_code: 'dodge',
delivery_date: formatDate.format(deliveryDate, 'DD.MM.YYYY'),
- room_code: '100',
+ room_code: process.env.NEXT_ROOM_CODE!,
deal_time: formatDate.format(deliveryDate, 'DD.MM.YYYY'),
- robot_code: 'r2',
+ robot_code: process.env.NEXT_ROBOT_CODE!,
status: 'B#N',
- sales_manager_code: '1',
+ sales_manager_code: process.env.NEXT_SALES_MANAGER_CODE!,
person_code: user?.username,
currency_code: '860',
owner_person_code: user?.username,
diff --git a/src/features/category/ui/Category.tsx b/src/features/category/ui/Category.tsx
index b9ea9d4..1335bea 100644
--- a/src/features/category/ui/Category.tsx
+++ b/src/features/category/ui/Category.tsx
@@ -1,4 +1,5 @@
'use client';
+import CategoryImage from '@/assets/water-bottle.png';
import { category_api } from '@/shared/config/api/category/api';
import { BASE_URL } from '@/shared/config/api/URLs';
import { Link } from '@/shared/config/i18n/navigation';
@@ -34,7 +35,11 @@ const Category = () => {
>
{
select: (res) => res.data.results,
});
- /* ---------------- PRICE ---------------- */
+ /* ---------------- DERIVED DATA ---------------- */
const price = Number(data?.prices?.[0]?.price || 0);
+ const category = 'Ichimliklar'; // default category
+
/* ---------------- SYNC CART QUANTITY ---------------- */
useEffect(() => {
if (!data || !cartItems) return;
@@ -103,8 +105,8 @@ const ProductDetail = () => {
toast.success(t("Mahsulot savatga qo'shildi"), { richColors: true });
},
onError: (err: AxiosError) => {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const msg = (err.response?.data as any)?.detail || err.message;
+ const msg =
+ (err.response?.data as { detail: string })?.detail || err.message;
toast.error(msg, { richColors: true });
},
});
@@ -124,6 +126,12 @@ const ProductDetail = () => {
queryClient.invalidateQueries({ queryKey: ['product_detail'] });
queryClient.invalidateQueries({ queryKey: ['product_list'] });
},
+ onError: () => {
+ toast.error(t('Tizimga kirilmagan'), {
+ richColors: true,
+ position: 'top-center',
+ });
+ },
});
/* ---------------- HANDLERS ---------------- */
@@ -168,20 +176,20 @@ const ProductDetail = () => {
unoptimized
height={500}
src={
- data && data?.images?.length !== 0
+ data?.images?.length
? BASE_URL + data.images[selectedImage]?.image
- : data?.images[selectedImage]?.image
- ? BASE_URL + data.images[selectedImage]?.image
- : '/placeholder.svg'
+ : '/placeholder.svg'
}
alt={data?.name || 'logo'}
className="w-full h-[400px] object-contain"
/>
-
- {data?.images?.map((img, i) => (
-
+ {(data?.images?.length
+ ? data.images
+ : [{ id: 0, image: '/placeholder.svg' }]
+ ).map((img, i) => (
+
@@ -215,7 +223,13 @@ const ProductDetail = () => {
{data?.short_name}
- {/* QUANTITY */}
+
+
+
Kategoriya:
+
{category}
+
+
+
{/* ACTIONS */}
-
+
@@ -129,14 +129,14 @@ const Profile = () => {
- {user?.username?.slice(0, 1).toUpperCase()}
+ {user?.first_name?.slice(0, 1).toUpperCase()}
{user &&
- user.username.charAt(0).toUpperCase() +
- user.username.slice(1)}
+ user.first_name.charAt(0).toUpperCase() +
+ user.first_name.slice(1)}
diff --git a/src/shared/config/api/category/type.ts b/src/shared/config/api/category/type.ts
index 45b1fa6..3579900 100644
--- a/src/shared/config/api/category/type.ts
+++ b/src/shared/config/api/category/type.ts
@@ -11,5 +11,5 @@ export interface Category {
export interface CategoryResult {
id: string;
name: string;
- image: string;
+ image: string | null;
}
diff --git a/src/shared/config/api/product/type.ts b/src/shared/config/api/product/type.ts
index 56f7c3f..ed87991 100644
--- a/src/shared/config/api/product/type.ts
+++ b/src/shared/config/api/product/type.ts
@@ -42,9 +42,9 @@ export interface ProductListResult {
export interface ProductDetail {
id: number;
- images: { id: number; image: string }[];
+ images: { id: number; image: string | null }[];
liked: boolean;
- meansurement: null | string;
+ meansurement: null | { id: number; name: string };
inventory_id: null | string;
product_id: string;
code: string;
diff --git a/src/widgets/categories/ui/product-card.tsx b/src/widgets/categories/ui/product-card.tsx
index 729c502..91ef810 100644
--- a/src/widgets/categories/ui/product-card.tsx
+++ b/src/widgets/categories/ui/product-card.tsx
@@ -245,6 +245,7 @@ export function ProductCard({
{formatPrice(
Math.max(...product.prices.map((p) => Number(p.price))),
+ true,
)}
)}
diff --git a/src/widgets/navbar/ui/NavbarMobile.tsx b/src/widgets/navbar/ui/NavbarMobile.tsx
index 19bab6a..2fa7720 100644
--- a/src/widgets/navbar/ui/NavbarMobile.tsx
+++ b/src/widgets/navbar/ui/NavbarMobile.tsx
@@ -74,7 +74,7 @@ const NavbarMobile = () => {
isActive && 'text-green-500',
)}
>
-
+
{
)}
/>
{item.href === '/cart' && (
-
+
{cartQuenty === 9 ? cartQuenty + '+' : cartQuenty}
)}
diff --git a/src/widgets/welcome/ui/index.tsx b/src/widgets/welcome/ui/index.tsx
index 4e9714e..d9a2362 100644
--- a/src/widgets/welcome/ui/index.tsx
+++ b/src/widgets/welcome/ui/index.tsx
@@ -20,6 +20,7 @@ import { CategoryCarousel } from '@/widgets/categories/ui/category-carousel';
import { ProductCard } from '@/widgets/categories/ui/product-card';
import { useQuery } from '@tanstack/react-query';
import { AlertCircle, ChevronLeft, ChevronRight } from 'lucide-react';
+import { useTranslations } from 'next-intl';
import Image from 'next/image';
import { useEffect, useState } from 'react';
import 'swiper/css';
@@ -32,6 +33,7 @@ const Welcome = () => {
const [canScrollNext, setCanScrollNext] = useState(false);
const [apiCat, setApiCat] = useState();
const router = useRouter();
+ const t = useTranslations();
const { data, isLoading, isError } = useQuery({
queryKey: ['banner_list'],
@@ -225,7 +227,7 @@ const Welcome = () => {
onClick={() => router.push(`/all-product/`)}
>
- Barcha mahsulotlar
+ {t('Barcha mahsulotlar')}