bug fixed
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { useTheme } from '@/components/ThemeContext';
|
||||
import { products_api } from '@/screens/home/lib/api';
|
||||
import { ProductResponse } from '@/screens/home/lib/types';
|
||||
import { user_api } from '@/screens/profile/lib/api';
|
||||
import { BottomSheetBackdrop, BottomSheetModal, BottomSheetScrollView } from '@gorhom/bottom-sheet';
|
||||
import { useInfiniteQuery } from '@tanstack/react-query';
|
||||
import { useInfiniteQuery, useQuery } from '@tanstack/react-query';
|
||||
import { ResizeMode, Video } from 'expo-av';
|
||||
import { Info, Package, PlayCircle } from 'lucide-react-native';
|
||||
import React, { useCallback, useRef, useState } from 'react';
|
||||
@@ -50,6 +51,17 @@ export default function ProductList({ query }: Props) {
|
||||
|
||||
const allProducts = data?.pages.flatMap((p) => p.results) ?? [];
|
||||
|
||||
const {
|
||||
data: detail,
|
||||
isLoading: loadingDetail,
|
||||
isError: detailError,
|
||||
} = useQuery({
|
||||
queryKey: ['my_ads_id', selectedProduct],
|
||||
queryFn: () => user_api.detail_service(Number(selectedProduct?.id)),
|
||||
select: (res) => res.data.data,
|
||||
enabled: !!selectedProduct,
|
||||
});
|
||||
|
||||
const handlePresentModalPress = useCallback((product: ProductResponse) => {
|
||||
setSelectedProduct(product);
|
||||
setCurrentImageIndex(0);
|
||||
@@ -181,12 +193,29 @@ export default function ProductList({ query }: Props) {
|
||||
style={styles.sheetContent}
|
||||
contentContainerStyle={styles.sheetContentContainer}
|
||||
>
|
||||
{selectedProduct && (
|
||||
{/* Loading holati */}
|
||||
{loadingDetail && (
|
||||
<View style={styles.center}>
|
||||
<ActivityIndicator size="large" color="#3b82f6" />
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* Error holati */}
|
||||
{detailError && (
|
||||
<View style={styles.center}>
|
||||
<Text style={{ color: '#ef4444', fontWeight: '600' }}>
|
||||
{t('Xatolik yuz berdi')}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* Detail mavjud bo‘lsa */}
|
||||
{detail && (
|
||||
<>
|
||||
<View style={styles.carouselWrapper}>
|
||||
<FlatList
|
||||
nestedScrollEnabled={true}
|
||||
data={selectedProduct.files || []}
|
||||
data={detail.files || []}
|
||||
renderItem={renderCarouselItem}
|
||||
keyExtractor={(item) => item.id.toString()}
|
||||
horizontal
|
||||
@@ -197,9 +226,9 @@ export default function ProductList({ query }: Props) {
|
||||
setCurrentImageIndex(index);
|
||||
}}
|
||||
/>
|
||||
{selectedProduct.files.length > 1 && (
|
||||
{detail.files.length > 1 && (
|
||||
<View style={styles.pagination}>
|
||||
{selectedProduct.files.map((_, i) => (
|
||||
{detail.files.map((_, i) => (
|
||||
<View
|
||||
key={i}
|
||||
style={[
|
||||
@@ -214,10 +243,10 @@ export default function ProductList({ query }: Props) {
|
||||
|
||||
<View style={styles.sheetHeader}>
|
||||
<Text style={[styles.sheetTitle, isDark ? styles.darkText : styles.lightText]}>
|
||||
{selectedProduct.title}
|
||||
{detail.title}
|
||||
</Text>
|
||||
<View style={styles.sheetCompanyBadge}>
|
||||
<Text style={styles.sheetCompanyText}>{selectedProduct.company}</Text>
|
||||
<Text style={styles.sheetCompanyText}>{detail.company}</Text>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -230,10 +259,8 @@ export default function ProductList({ query }: Props) {
|
||||
{t("Batafsil ma'lumot")}
|
||||
</Text>
|
||||
</View>
|
||||
<Text
|
||||
style={[styles.sheetDescription, isDark ? styles.darkText : styles.lightText]}
|
||||
>
|
||||
{selectedProduct.description || "Ma'lumot mavjud emas."}
|
||||
<Text style={[styles.sheetDescription, isDark ? styles.darkText : styles.lightText]}>
|
||||
{detail.description || "Ma'lumot mavjud emas."}
|
||||
</Text>
|
||||
</View>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user