enh
This commit is contained in:
parent
a4218ee1ad
commit
c14e32522a
11 changed files with 42 additions and 24 deletions
|
|
@ -5,7 +5,7 @@ import { trpc } from '@/src/trpc-client';
|
||||||
import { MyText, MyTouchableOpacity, tw, AppContainer } from 'common-ui';
|
import { MyText, MyTouchableOpacity, tw, AppContainer } from 'common-ui';
|
||||||
import { useRouter } from 'expo-router';
|
import { useRouter } from 'expo-router';
|
||||||
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
|
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() {
|
export default function FlashDeliveryBaseLayout() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import BannerCarousel from "@/components/BannerCarousel";
|
||||||
import { useUserDetails } from "@/src/contexts/AuthContext";
|
import { useUserDetails } from "@/src/contexts/AuthContext";
|
||||||
import TabLayoutWrapper from "@/components/TabLayoutWrapper";
|
import TabLayoutWrapper from "@/components/TabLayoutWrapper";
|
||||||
import { useNavigationStore } from "@/src/store/navigationStore";
|
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";
|
import NextOrderGlimpse from "@/components/NextOrderGlimpse";
|
||||||
dayjs.extend(relativeTime);
|
dayjs.extend(relativeTime);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { Image } from 'expo-image';
|
||||||
import { MyText, tw, useManualRefresh, MyFlatList, useMarkDataFetchers, theme, MyTouchableOpacity } from 'common-ui';
|
import { MyText, tw, useManualRefresh, MyFlatList, useMarkDataFetchers, theme, MyTouchableOpacity } from 'common-ui';
|
||||||
import { MaterialIcons, Ionicons } from '@expo/vector-icons';
|
import { MaterialIcons, Ionicons } from '@expo/vector-icons';
|
||||||
import { trpc } from '@/src/trpc-client';
|
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 dayjs from 'dayjs';
|
||||||
import { useRouter } from 'expo-router';
|
import { useRouter } from 'expo-router';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
|
||||||
import { View, ActivityIndicator, Platform } from 'react-native';
|
import { View, ActivityIndicator, Platform } from 'react-native';
|
||||||
import { tw, theme, MyText, MyTouchableOpacity , BottomDialog } from 'common-ui';
|
import { tw, theme, MyText, MyTouchableOpacity , BottomDialog } from 'common-ui';
|
||||||
import { trpc, trpcClient } from '@/src/trpc-client';
|
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 Constants from 'expo-constants';
|
||||||
import * as Linking from 'expo-linking';
|
import * as Linking from 'expo-linking';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import dayjs from 'dayjs';
|
||||||
import { trpc } from '@/src/trpc-client';
|
import { trpc } from '@/src/trpc-client';
|
||||||
import { Image } from 'expo-image';
|
import { Image } from 'expo-image';
|
||||||
import { orderStatusManipulator } from '@/src/lib/string-manipulators';
|
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 {
|
interface OrderItem {
|
||||||
productName: string;
|
productName: string;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import React, { useState } from 'react';
|
||||||
import { View, ActivityIndicator } from 'react-native';
|
import { View, ActivityIndicator } from 'react-native';
|
||||||
import { WebView } from 'react-native-webview';
|
import { WebView } from 'react-native-webview';
|
||||||
import { trpc } from '@/src/trpc-client';
|
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 { theme, MyText, MyTouchableOpacity } from 'common-ui';
|
||||||
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
|
import MaterialIcons from '@expo/vector-icons/MaterialIcons';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import dayjs from "dayjs";
|
||||||
import { trpc } from "@/src/trpc-client";
|
import { trpc } from "@/src/trpc-client";
|
||||||
import { useAllProducts } from "@/src/hooks/prominent-api-hooks";
|
import { useAllProducts } from "@/src/hooks/prominent-api-hooks";
|
||||||
import { useGetCart, useUpdateCartItem, useRemoveFromCart } from '@/hooks/cart-query-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 {
|
interface CartPageProps {
|
||||||
isFlashDelivery?: boolean;
|
isFlashDelivery?: boolean;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import { useAuthenticatedRoute } from '@/hooks/useAuthenticatedRoute';
|
||||||
import { trpc } from '@/src/trpc-client';
|
import { trpc } from '@/src/trpc-client';
|
||||||
import { useAllProducts } from '@/src/hooks/prominent-api-hooks';
|
import { useAllProducts } from '@/src/hooks/prominent-api-hooks';
|
||||||
import { useGetCart } from '@/hooks/cart-query-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 PaymentAndOrderComponent from '@/components/PaymentAndOrderComponent';
|
||||||
import CheckoutAddressSelector from '@/components/CheckoutAddressSelector';
|
import CheckoutAddressSelector from '@/components/CheckoutAddressSelector';
|
||||||
import { useAddressStore } from '@/src/store/addressStore';
|
import { useAddressStore } from '@/src/store/addressStore';
|
||||||
|
|
|
||||||
|
|
@ -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 };
|
|
||||||
};
|
|
||||||
|
|
@ -7,7 +7,7 @@ import { useCartStore } from '@/src/store/cartStore';
|
||||||
import { useFlashCartStore } from '@/src/store/flashCartStore';
|
import { useFlashCartStore } from '@/src/store/flashCartStore';
|
||||||
import { trpc } from '@/src/trpc-client';
|
import { trpc } from '@/src/trpc-client';
|
||||||
import { useAddToCart, useGetCart, useUpdateCartItem, useRemoveFromCart } from '@/hooks/cart-query-hooks';
|
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 dayjs from 'dayjs';
|
||||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,38 @@
|
||||||
import { useQuery } from '@tanstack/react-query'
|
import { useQuery } from '@tanstack/react-query'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { useGetEssentialConsts } from '@/src/api-hooks/essential-consts.api'
|
import { trpc } from '@/src/trpc-client'
|
||||||
// import { AllProductsApiType } from '@backend/trpc/router'
|
|
||||||
import { AllProductsApiType } from "@backend/trpc/router";
|
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;
|
type ProductsResponse = AllProductsApiType;
|
||||||
|
|
||||||
export function useAllProducts() {
|
export function useAllProducts() {
|
||||||
|
|
@ -23,8 +51,6 @@ export function useAllProducts() {
|
||||||
if (!cacheUrl) {
|
if (!cacheUrl) {
|
||||||
throw new Error('Cache URL not available')
|
throw new Error('Cache URL not available')
|
||||||
}
|
}
|
||||||
console.log(cacheUrl)
|
|
||||||
|
|
||||||
const response = await axios.get<ProductsResponse>(cacheUrl)
|
const response = await axios.get<ProductsResponse>(cacheUrl)
|
||||||
return response.data
|
return response.data
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue