enh
This commit is contained in:
parent
7fa44712bf
commit
ed7318f9ee
3 changed files with 434 additions and 521 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -37,6 +37,7 @@ export default function Layout() {
|
||||||
<Tabs
|
<Tabs
|
||||||
// backBehavior="history"
|
// backBehavior="history"
|
||||||
screenOptions={{
|
screenOptions={{
|
||||||
|
lazy: true,
|
||||||
tabBarActiveTintColor: theme.colors.brand500,
|
tabBarActiveTintColor: theme.colors.brand500,
|
||||||
tabBarInactiveTintColor: '#4B5563',
|
tabBarInactiveTintColor: '#4B5563',
|
||||||
tabBarStyle: shouldHideTabs ? { display: 'none' } : {
|
tabBarStyle: shouldHideTabs ? { display: 'none' } : {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import {
|
||||||
BottomDropdown, BottomDialog , Quantifier } from "common-ui";
|
BottomDropdown, BottomDialog , Quantifier } from "common-ui";
|
||||||
import MaterialIcons from "@expo/vector-icons/MaterialIcons";
|
import MaterialIcons from "@expo/vector-icons/MaterialIcons";
|
||||||
import { useHideTabNav } from "@/src/hooks/useHideTabNav";
|
import { useHideTabNav } from "@/src/hooks/useHideTabNav";
|
||||||
|
import { useAuth } from "@/src/contexts/AuthContext";
|
||||||
|
|
||||||
import TestingPhaseNote from "@/components/TestingPhaseNote";
|
import TestingPhaseNote from "@/components/TestingPhaseNote";
|
||||||
|
|
||||||
|
|
@ -34,6 +35,7 @@ export default function CartPage({ isFlashDelivery = false }: CartPageProps) {
|
||||||
// Hide tabs when cart page is active
|
// Hide tabs when cart page is active
|
||||||
useHideTabNav();
|
useHideTabNav();
|
||||||
|
|
||||||
|
const { isAuthenticated } = useAuth();
|
||||||
const cartType: "regular" | "flash" = isFlashDelivery ? "flash" : "regular";
|
const cartType: "regular" | "flash" = isFlashDelivery ? "flash" : "regular";
|
||||||
|
|
||||||
const [quantities, setQuantities] = useState<Record<number, number>>({});
|
const [quantities, setQuantities] = useState<Record<number, number>>({});
|
||||||
|
|
@ -260,6 +262,15 @@ export default function CartPage({ isFlashDelivery = false }: CartPageProps) {
|
||||||
[finalTotal, constsData, isFlashDelivery]
|
[finalTotal, constsData, isFlashDelivery]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const freeDeliveryThreshold = useMemo(
|
||||||
|
() => {
|
||||||
|
return isFlashDelivery
|
||||||
|
? constsData?.flashFreeDeliveryThreshold
|
||||||
|
: constsData?.freeDeliveryThreshold;
|
||||||
|
},
|
||||||
|
[constsData, isFlashDelivery]
|
||||||
|
);
|
||||||
|
|
||||||
const finalTotalWithDelivery = finalTotal + deliveryCharge;
|
const finalTotalWithDelivery = finalTotal + deliveryCharge;
|
||||||
|
|
||||||
const hasAvailableItems = cartItems.some(item => !item.product?.isOutOfStock);
|
const hasAvailableItems = cartItems.some(item => !item.product?.isOutOfStock);
|
||||||
|
|
@ -786,6 +797,18 @@ export default function CartPage({ isFlashDelivery = false }: CartPageProps) {
|
||||||
</MyText>
|
</MyText>
|
||||||
</MyTouchableOpacity>
|
</MyTouchableOpacity>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{!isAuthenticated && (
|
||||||
|
<MyTouchableOpacity
|
||||||
|
style={tw`mt-2 ml-1`}
|
||||||
|
onPress={() => router.push("/(drawer)/(tabs)/me")}
|
||||||
|
>
|
||||||
|
<MyText style={tw`text-xs`}>
|
||||||
|
<MyText style={tw`text-blue-500 underline`}>Log In</MyText>
|
||||||
|
<MyText style={tw`text-gray-400`}> To find offers and coupons</MyText>
|
||||||
|
</MyText>
|
||||||
|
</MyTouchableOpacity>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
@ -842,11 +865,11 @@ export default function CartPage({ isFlashDelivery = false }: CartPageProps) {
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* Free Delivery Nudge */}
|
{/* Free Delivery Nudge */}
|
||||||
{deliveryCharge > 0 && (constsData?.freeDeliveryThreshold || 0) > 0 && finalTotal < (constsData?.freeDeliveryThreshold || 0) && (
|
{deliveryCharge > 0 && (freeDeliveryThreshold || 0) > 0 && finalTotal < (freeDeliveryThreshold || 0) && (
|
||||||
<View style={tw`bg-blue-50 p-2.5 rounded-lg mb-3 flex-row items-center`}>
|
<View style={tw`bg-blue-50 p-2.5 rounded-lg mb-3 flex-row items-center`}>
|
||||||
<MaterialIcons name="shopping-bag" size={16} color="#2563EB" style={tw`mr-2`} />
|
<MaterialIcons name="shopping-bag" size={16} color="#2563EB" style={tw`mr-2`} />
|
||||||
<MyText style={tw`text-blue-700 text-xs font-medium flex-1`}>
|
<MyText style={tw`text-blue-700 text-xs font-medium flex-1`}>
|
||||||
Add products worth ₹{((constsData?.freeDeliveryThreshold || 0) - finalTotal).toFixed(0)} for free delivery
|
Add products worth ₹{((freeDeliveryThreshold || 0) - finalTotal).toFixed(0)} for free delivery
|
||||||
</MyText>
|
</MyText>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
@ -1035,4 +1058,4 @@ export default function CartPage({ isFlashDelivery = false }: CartPageProps) {
|
||||||
</BottomDialog>
|
</BottomDialog>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue