This commit is contained in:
shafi54 2026-03-10 13:05:33 +05:30
parent a4218ee1ad
commit c14e32522a
11 changed files with 42 additions and 24 deletions

View file

@ -5,7 +5,7 @@ import { trpc } from '@/src/trpc-client';
import { MyText, MyTouchableOpacity, tw, AppContainer } from 'common-ui';
import { useRouter } from 'expo-router';
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
import { useGetEssentialConsts } from '@/src/api-hooks/essential-consts.api';
import { useGetEssentialConsts } from '@/src/hooks/prominent-api-hooks';
export default function FlashDeliveryBaseLayout() {
const router = useRouter();

View file

@ -28,7 +28,7 @@ import BannerCarousel from "@/components/BannerCarousel";
import { useUserDetails } from "@/src/contexts/AuthContext";
import TabLayoutWrapper from "@/components/TabLayoutWrapper";
import { useNavigationStore } from "@/src/store/navigationStore";
import { useGetEssentialConsts } from "@/src/api-hooks/essential-consts.api";
import { useGetEssentialConsts } from "@/src/hooks/prominent-api-hooks";
import NextOrderGlimpse from "@/components/NextOrderGlimpse";
dayjs.extend(relativeTime);

View file

@ -4,7 +4,7 @@ import { Image } from 'expo-image';
import { MyText, tw, useManualRefresh, MyFlatList, useMarkDataFetchers, theme, MyTouchableOpacity } from 'common-ui';
import { MaterialIcons, Ionicons } from '@expo/vector-icons';
import { trpc } from '@/src/trpc-client';
import { useGetEssentialConsts } from '@/src/api-hooks/essential-consts.api';
import { useGetEssentialConsts } from '@/src/hooks/prominent-api-hooks';
import dayjs from 'dayjs';
import { useRouter } from 'expo-router';

View file

@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
import { View, ActivityIndicator, Platform } from 'react-native';
import { tw, theme, MyText, MyTouchableOpacity , BottomDialog } from 'common-ui';
import { trpc, trpcClient } from '@/src/trpc-client';
import { useGetEssentialConsts } from '@/src/api-hooks/essential-consts.api';
import { useGetEssentialConsts } from '@/src/hooks/prominent-api-hooks';
import Constants from 'expo-constants';
import * as Linking from 'expo-linking';

View file

@ -8,7 +8,7 @@ import dayjs from 'dayjs';
import { trpc } from '@/src/trpc-client';
import { Image } from 'expo-image';
import { orderStatusManipulator } from '@/src/lib/string-manipulators';
import { useGetEssentialConsts } from '@/src/api-hooks/essential-consts.api';
import { useGetEssentialConsts } from '@/src/hooks/prominent-api-hooks';
interface OrderItem {
productName: string;

View file

@ -2,7 +2,7 @@ import React, { useState } from 'react';
import { View, ActivityIndicator } from 'react-native';
import { WebView } from 'react-native-webview';
import { trpc } from '@/src/trpc-client';
import { useGetEssentialConsts } from '@/src/api-hooks/essential-consts.api';
import { useGetEssentialConsts } from '@/src/hooks/prominent-api-hooks';
import { theme, MyText, MyTouchableOpacity } from 'common-ui';
import MaterialIcons from '@expo/vector-icons/MaterialIcons';

View file

@ -26,7 +26,7 @@ import dayjs from "dayjs";
import { trpc } from "@/src/trpc-client";
import { useAllProducts } from "@/src/hooks/prominent-api-hooks";
import { useGetCart, useUpdateCartItem, useRemoveFromCart } from '@/hooks/cart-query-hooks';
import { useGetEssentialConsts } from '@/src/api-hooks/essential-consts.api';
import { useGetEssentialConsts } from '@/src/hooks/prominent-api-hooks';
interface CartPageProps {
isFlashDelivery?: boolean;

View file

@ -10,7 +10,7 @@ import { useAuthenticatedRoute } from '@/hooks/useAuthenticatedRoute';
import { trpc } from '@/src/trpc-client';
import { useAllProducts } from '@/src/hooks/prominent-api-hooks';
import { useGetCart } from '@/hooks/cart-query-hooks';
import { useGetEssentialConsts } from '@/src/api-hooks/essential-consts.api';
import { useGetEssentialConsts } from '@/src/hooks/prominent-api-hooks';
import PaymentAndOrderComponent from '@/components/PaymentAndOrderComponent';
import CheckoutAddressSelector from '@/components/CheckoutAddressSelector';
import { useAddressStore } from '@/src/store/addressStore';

View file

@ -1,8 +0,0 @@
import { trpc } from '@/src/trpc-client';
export const useGetEssentialConsts = () => {
const query = trpc.common.essentialConsts.useQuery(undefined, {
refetchInterval: 60000,
});
return { ...query, refetch: query.refetch };
};

View file

@ -7,7 +7,7 @@ import { useCartStore } from '@/src/store/cartStore';
import { useFlashCartStore } from '@/src/store/flashCartStore';
import { trpc } from '@/src/trpc-client';
import { useAddToCart, useGetCart, useUpdateCartItem, useRemoveFromCart } from '@/hooks/cart-query-hooks';
import { useGetEssentialConsts } from '@/src/api-hooks/essential-consts.api';
import { useGetEssentialConsts } from '@/src/hooks/prominent-api-hooks';
import dayjs from 'dayjs';
import { SafeAreaView } from 'react-native-safe-area-context';

View file

@ -1,10 +1,38 @@
import { useQuery } from '@tanstack/react-query'
import axios from 'axios'
import { useGetEssentialConsts } from '@/src/api-hooks/essential-consts.api'
// import { AllProductsApiType } from '@backend/trpc/router'
import { trpc } from '@/src/trpc-client'
import { AllProductsApiType } from "@backend/trpc/router";
// Local useGetEssentialConsts hook
export const useGetEssentialConsts = () => {
const query = trpc.common.essentialConsts.useQuery(undefined, {
refetchInterval: 60000,
})
return { ...query, refetch: query.refetch }
}
// // Type definitions matching the backend response
// interface ProductSummary {
// id: number
// name: string
// shortDescription: string | null
// price: number
// marketPrice: number | null
// unit: string
// unitNotation: string
// incrementStep: number
// productQuantity: number
// storeId: number | null
// isOutOfStock: boolean
// isFlashAvailable: boolean
// nextDeliveryDate: string | null
// images: string[]
// }
//
// interface ProductsResponse {
// products: ProductSummary[]
// count: number
// }
//
type ProductsResponse = AllProductsApiType;
export function useAllProducts() {
@ -23,8 +51,6 @@ export function useAllProducts() {
if (!cacheUrl) {
throw new Error('Cache URL not available')
}
console.log(cacheUrl)
const response = await axios.get<ProductsResponse>(cacheUrl)
return response.data
},