This commit is contained in:
2025-11-18 16:18:43 +07:00
parent f150a84cf0
commit 08b352f686
10 changed files with 2140 additions and 27 deletions

View File

@@ -11,11 +11,12 @@ import {
} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { Ionicons } from '@expo/vector-icons';
import { useFocusEffect } from '@react-navigation/native';
import { useFocusEffect, useRouter } from 'expo-router';
import { useCart } from '../../hooks/useCart';
import CartItemCard from '../../components/CartItemCard';
export default function CartScreen() {
const router = useRouter();
const {
cart,
loading,
@@ -42,7 +43,7 @@ export default function CartScreen() {
{ text: 'Hủy', style: 'cancel' },
{
text: 'Xóa tất cả',
onPress: clearCart,
onPress: () => clearCart(),
style: 'destructive'
},
]
@@ -50,7 +51,13 @@ export default function CartScreen() {
};
const handleCheckout = () => {
Alert.alert('Thông báo', 'Chức năng thanh toán đang được phát triển');
if (!cart || cart.items.length === 0) {
Alert.alert('Thông báo', 'Giỏ hàng của bạn đang trống');
return;
}
// Navigate to checkout screen
router.push('/checkout');
};
const formatPrice = (price: number) => {
@@ -84,6 +91,12 @@ export default function CartScreen() {
<Text style={styles.emptySubtext}>
Hãy thêm sản phẩm vào giỏ hàng đ mua sắm
</Text>
<TouchableOpacity
style={styles.shopButton}
onPress={() => router.push('/')}
>
<Text style={styles.shopButtonText}>Tiếp tục mua sắm</Text>
</TouchableOpacity>
</View>
</SafeAreaView>
);
@@ -202,6 +215,18 @@ const styles = StyleSheet.create({
marginTop: 8,
textAlign: 'center',
},
shopButton: {
backgroundColor: '#ff6b6b',
paddingHorizontal: 32,
paddingVertical: 14,
borderRadius: 12,
marginTop: 24,
},
shopButtonText: {
color: '#fff',
fontSize: 16,
fontWeight: '700',
},
listContent: {
padding: 16,
},